00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef CUDYN_CTOR_H
00019 #define CUDYN_CTOR_H
00020
00021 #include <cudyn/fwd.h>
00022 #include <cuoo/type.h>
00023 #include <cu/ptr.h>
00024
00025 CU_BEGIN_DECLARATIONS
00026
00027 struct cudyn_ctortype
00028 {
00029 cu_inherit (cuoo_type);
00030 cudyn_duntype_t fulltype;
00031 cudyn_tuptype_t parttype;
00032 };
00033
00034 extern cuoo_type_t cudynP_ctortype_type;
00035
00036
00037 CU_SINLINE cuoo_type_t cudyn_ctortype_type()
00038 { return cudynP_ctortype_type; }
00039
00040
00041 CU_SINLINE cu_bool_t cudyn_meta_is_ctortype(cuex_meta_t meta)
00042 { return cuoo_type_to_meta(cudyn_ctortype_type()) == meta; }
00043
00044
00045 CU_SINLINE cu_bool_t cuoo_type_is_ctortype(cuoo_type_t t)
00046 { return cuoo_type_shape(t) == CUOO_SHAPE_CTORTYPE; }
00047
00048 #define cudyn_ctortype_to_type(t) cu_to(cuoo_type, t)
00049 #define cudyn_ctortype_from_type(t) cu_from(cudyn_ctortype, cuoo_type, t)
00050
00051
00052
00053
00054 cudyn_ctortype_t
00055 cudyn_ctortype(cudyn_tuptype_t parttype, cudyn_duntype_t restype);
00056
00057
00058 CU_SINLINE cudyn_duntype_t
00059 cudyn_ctortype_union_type(cudyn_ctortype_t t) { return t->fulltype; }
00060
00061
00062 CU_SINLINE cudyn_tuptype_t
00063 cudyn_ctortype_partition_type(cudyn_ctortype_t t) { return t->parttype; }
00064
00065
00066
00067 cuex_t cudyn_ctor(cudyn_ctortype_t type, unsigned int ctor_num);
00068
00069
00070 CU_SINLINE cu_bool_t cudyn_is_ctor(cuex_t ex)
00071 {
00072 cuex_meta_t meta = cuex_meta(ex);
00073 return cuex_meta_is_type(meta)
00074 && cuoo_type_is_ctortype(cuoo_type_from_meta(meta));
00075 }
00076
00077
00078 CU_SINLINE unsigned int cudyn_ctor_num(cuex_t ctor)
00079 { return *((unsigned int *)(cu_ptr_add(ctor, CUOO_HCOBJ_SHIFT))); }
00080
00081 CU_END_DECLARATIONS
00082
00083 #endif