1 #ifndef TEMU_OBJSYS_C_H
2 #define TEMU_OBJSYS_C_H
14 #define TEMU_PLUGIN_INIT \
15 extern "C" void temu_pluginInit(void)
17 #define TEMU_PLUGIN_INIT \
18 void temu_pluginInit(void)
74 #define OBJSYS_OBJ_TYPE(N) \
84 static inline N ## ObjArray \
85 N ## ObjArrayAlloc(unsigned Reserve) \
87 temu_IfaceArray Arr = temu_ifaceArrayAlloc(Reserve); \
89 Res.Size = Arr.Size; \
90 Res.Reserved = Arr.Reserved; \
91 Res.Ifaces = (N##Obj*)Arr.Ifaces; \
95 N ## ObjArrayDispose(N ## ObjArray *Arr) \
99 temu_ifaceArrayDispose((temu_IfaceArray*)&Arr->Ifaces); \
102 N ## ObjArrayPush2(N ## ObjArray *Arr, void *Obj, void *Iface) \
104 temu_ifaceArrayPush2((temu_IfaceArray*)Arr, Obj, Iface); \
107 N ## ObjArrayPush(N ## ObjArray *Arr, N ## Obj Iface) \
110 Iface2.Obj = Iface.Obj; \
111 Iface2.Iface = (void*)Iface.Iface; \
113 temu_ifaceArrayPush((temu_IfaceArray*)Arr, Iface2); \
115 static inline unsigned \
116 N ## ObjArraySize(temu_IfaceArray *Arr) \
122 #define DYN_ARRAY_TYPE(T, P) \
127 } temu_ ## P ## Array; \
128 static inline temu_ ## P ## Array \
129 temu_ ## P ## ArrayAlloc(unsigned Reserve) \
131 temu_ ## P ## Array Arr; \
133 Arr.Reserved = Reserve; \
134 Arr.Values = (T*)calloc(Reserve, sizeof(T)); \
135 assert(Arr.Values); \
139 temu_ ## P ## ArrayPush(temu_ ## P ## Array *Arr, T Val) \
141 if (Arr->Reserved >= Arr->Size) { \
142 T *NewValues = (T*)realloc(Arr->Values, Arr->Reserved * 2); \
144 Arr->Values = NewValues; \
149 Arr->Values[Arr->Size ++] = Val; \
151 static inline unsigned \
152 temu_ ## P ## ArraySize(temu_ ## P ## Array *Arr) \
247 #ifdef PROP_ASSERTS_ENABLED
248 #define PROP_ASSERT(p, t) assert(p.Typ == t && "invalid property type")
250 #define PROP_ASSERT(p, t)
257 #define PROP_VAL_INITIALIZER(typ, suffix, typetag, valtag) \
258 static inline temu_Propval \
259 temu_makeProp ## suffix (typ val) \
267 temu_propValue ## suffix (temu_Propval pv) \
269 PROP_ASSERT(pv.Typ, typetag); \
270 typ val = pv.valtag; \
370 void temu_setValueU8(
void *Obj, const
char *PropName, uint8_t Val,
int Idx);
371 void temu_setValueU16(
void *Obj, const
char *PropName, uint16_t Val,
int Idx);
372 void temu_setValueU32(
void *Obj, const
char *PropName, uint32_t Val,
int Idx);
373 void temu_setValueU64(
void *Obj, const
char *PropName, uint64_t Val,
int Idx);
375 void temu_setValueI8(
void *Obj, const
char *PropName, int8_t Val,
int Idx);
376 void temu_setValueI16(
void *Obj, const
char *PropName, int16_t Val,
int Idx);
377 void temu_setValueI32(
void *Obj, const
char *PropName, int32_t Val,
int Idx);
378 void temu_setValueI64(
void *Obj, const
char *PropName, int64_t Val,
int Idx);
423 typedef void* (*temu_ObjectCreateFunc)(
const char *Name,
481 const char *Doc =
"");
508 const char *IfaceName,
509 const char *IfaceType,
510 void *Iface,
int Count = 0,
511 const char *Doc =
"");
515 const char *IfaceName,
int Idx = 0);
521 const char *IfaceName,
522 const char *IfaceType,
523 void *Iface,
int Count,
528 const char *IfaceName,
int Idx);
550 void*
temu_addObject(
const char *ClsName,
const char *ObjName,
void *Obj);
631 int temu_connect(
void *A,
const char *PropName,
void *B,
const char *IfaceName);
659 int Count,
void *Data);
684 void (*serialise)(
void *Obj,
const char *BaseName,
void *Ctxt);
685 void (*deserialise)(
void *Obj,
const char *BaseName,
void *Ctxt);
693 int (*checkSanity)(
void *Obj,
int Report);
void * temu_objectForName(const char *Name)
void temu_objsysClearObjects(void)
void temu_serialiseProp(void *Ctxt, const char *Name, temu_Type Typ, int Count, void *Data)
void(* temu_PropWriter)(void *Obj, temu_Propval Pv, int Idx)
void temu_deserialiseProp(void *Ctxt, void *Obj, const char *Name)
temu_Class * temu_registerExternalClass(const char *ClsName)
int temu_getPropLength(const void *Obj, const char *PropName)
void temu_writeValueI32(void *Obj, const char *PropName, int32_t Val, int Idx)
uint64_t temu_getValueU64(void *Obj, const char *PropName, int Idx)
void temu_writeNamedObjectProp(const char *Obj, const char *PropName, temu_Propval Val, int Idx)
int8_t temu_getValueI8(void *Obj, const char *PropName, int Idx)
void temu_setValueU32(void *Obj, const char *PropName, uint32_t Val, int Idx)
void temu_setValueU8(void *Obj, const char *PropName, uint8_t Val, int Idx)
struct temu_IfaceArray temu_IfaceArray
void temu_setValueU16(void *Obj, const char *PropName, uint16_t Val, int Idx)
temu_IfaceArray temu_ifaceArrayAlloc(unsigned Reserve)
int temu_connect(void *A, const char *PropName, void *B, const char *IfaceName)
temu_Class * temu_classForObjectName(const char *Obj)
uint16_t temu_getValueU16(void *Obj, const char *PropName, int Idx)
#define OBJSYS_OBJ_TYPE(N)
temu_Class * temu_classForObject(void *Obj)
void temu_writeValueU64(void *Obj, const char *PropName, uint64_t Val, int Idx)
int16_t temu_readValueI16(void *Obj, const char *PropName, int Idx)
uint8_t temu_readValueU8(void *Obj, const char *PropName, int Idx)
void temu_addProperty(temu_Class *Cls, const char *PropName, int Offset, temu_Type Typ, int Count, temu_PropWriter Wr, temu_PropReader Rd, const char *Doc)
int8_t temu_readValueI8(void *Obj, const char *PropName, int Idx)
#define DYN_ARRAY_TYPE(T, P)
temu_Propval temu_getValue(void *Obj, const char *PropName, int Idx)
void temu_addInterface(temu_Class *Cls, const char *IfaceName, const char *IfaceType, void *Iface, int Count, const char *Doc)
void temu_setValueI8(void *Obj, const char *PropName, int8_t Val, int Idx)
uint8_t temu_getValueU8(void *Obj, const char *PropName, int Idx)
void temu_writeValueU16(void *Obj, const char *PropName, uint16_t Val, int Idx)
void temu_setNamedObjectProp(const char *Obj, const char *PropName, temu_Propval Val, int Idx)
void temu_ifaceArrayDispose(temu_IfaceArray *Arr)
temu_Propval temu_readValue(void *Obj, const char *PropName, int Idx)
int temu_checkpointGetLength(void *Ctxt, const char *Name)
void temu_ifaceArrayPush2(temu_IfaceArray *Arr, void *Obj, void *Iface)
void * temu_addObject(const char *ClsName, const char *ObjName, void *Obj)
temu_IfaceArray IfaceArray
void temu_setValueI64(void *Obj, const char *PropName, int64_t Val, int Idx)
void temu_writeValueI64(void *Obj, const char *PropName, int64_t Val, int Idx)
void temu_writeValueI8(void *Obj, const char *PropName, int8_t Val, int Idx)
unsigned temu_ifaceArraySize(temu_IfaceArray *Arr)
const char * temu_typeToName(temu_Type Typ)
void *(* temu_ObjectCreateFunc)(const char *Name, int Argc, const temu_CreateArg *Argv)
int16_t temu_getValueI16(void *Obj, const char *PropName, int Idx)
struct temu_Iface temu_Iface
int32_t temu_getValueI32(void *Obj, const char *PropName, int Idx)
void temu_objsysClear(void)
void(* temu_ObjectDisposeFunc)(void *)
struct temu_Propref temu_Propref
int temu_loadPlugin(const char *Path)
uint32_t temu_readValueU32(void *Obj, const char *PropName, int Idx)
uint64_t temu_readValueU64(void *Obj, const char *PropName, int Idx)
const char * temu_nameForObject(const void *Obj)
temu_Propval(* temu_PropReader)(void *Obj, int Idx)
void temu_disposeObject(void *Obj)
temu_Propval temu_readNamedObjectProp(const char *Obj, const char *PropName, int Idx)
void temu_setValueI16(void *Obj, const char *PropName, int16_t Val, int Idx)
int temu_checkSanity(int Report)
int64_t temu_getValueI64(void *Obj, const char *PropName, int Idx)
temu_Class * temu_classForName(const char *ClsName)
int32_t temu_readValueI32(void *Obj, const char *PropName, int Idx)
void temu_setValueI32(void *Obj, const char *PropName, int32_t Val, int Idx)
#define PROP_VAL_INITIALIZER(typ, suffix, typetag, valtag)
void temu_writeValueU32(void *Obj, const char *PropName, uint32_t Val, int Idx)
temu_Class * temu_registerClass(const char *ClsName, temu_ObjectCreateFunc Create, temu_ObjectDisposeFunc Dispose)
temu_Propval temu_getNamedObjectProp(const char *Obj, const char *PropName, int Idx)
uint16_t temu_readValueU16(void *Obj, const char *PropName, int Idx)
temu_Propref temu_getPropref(const void *Obj, const char *PropName)
void * temu_createObject(const char *ClsName, const char *ObjName)
int temu_deserialiseJSON(const char *FileName)
void temu_setValueU64(void *Obj, const char *PropName, uint64_t Val, int Idx)
void temu_setValue(void *Obj, const char *PropName, temu_Propval Val, int Idx)
int64_t temu_readValueI64(void *Obj, const char *PropName, int Idx)
void temu_writeValue(void *Obj, const char *PropName, temu_Propval Val, int Idx)
void temu_writeValueI16(void *Obj, const char *PropName, int16_t Val, int Idx)
void * temu_getInterface(void *Obj, const char *IfaceName, int Idx)
void temu_writeValueU8(void *Obj, const char *PropName, uint8_t Val, int Idx)
void temu_ifaceArrayPush(temu_IfaceArray *Arr, temu_Iface Iface)
struct temu_CreateArg temu_CreateArg
struct temu_Propval temu_Propval
int temu_serialiseJSON(const char *FileName)
uint32_t temu_getValueU32(void *Obj, const char *PropName, int Idx)
temu_Propval temu_checkpointGetValue(void *Ctxt, const char *Name, int Idx)