9 #ifndef TEMU_OBJSYS_C_H
10 #define TEMU_OBJSYS_C_H
22 # define TEMU_PLUGIN_INIT extern "C" void temu_pluginInit(void)
24 # define TEMU_PLUGIN_INIT void temu_pluginInit(void)
27 #if defined(__has_attribute)
28 # if __has_attribute(annotate)
29 # define TEMU_NO_WRAP __attribute__((annotate("temu-no-wrap")))
33 #if !defined(TEMU_NO_WRAP)
95 #define TEMU_IFACE_REFERENCE_TYPE(N) \
103 N ## IfaceRef *Ifaces; \
104 } N ## IfaceRefArray; \
105 static inline N ## IfaceRefArray \
106 N ## IfaceRefArrayAlloc(unsigned Reserve) \
108 temu_IfaceRefArray Arr = temu_ifaceRefArrayAlloc(Reserve); \
109 N ## IfaceRefArray Res; \
110 Res.Size = Arr.Size; \
111 Res.Reserved = Arr.Reserved; \
112 Res.Ifaces = (N##IfaceRef*)Arr.Ifaces; \
116 N ## IfaceRefArrayDispose(N ## IfaceRefArray *Arr) \
118 temu_ifaceRefArrayDispose((temu_IfaceRefArray*)Arr); \
121 N ## IfaceRefArrayPush2(N ## IfaceRefArray *Arr, void *Obj, void *Iface) \
123 temu_ifaceRefArrayPush2((temu_IfaceRefArray*)Arr, Obj, Iface); \
126 N ## IfaceRefArrayPush(N ## IfaceRefArray *Arr, N ## IfaceRef Iface) \
128 temu_IfaceRef Iface2; \
129 Iface2.Obj = Iface.Obj; \
130 Iface2.Iface = (void*)Iface.Iface; \
132 temu_ifaceRefArrayPush((temu_IfaceRefArray*)Arr, Iface2); \
134 static inline unsigned \
135 N ## IfaceRefArraySize(temu_IfaceRefArray *Arr) \
141 #define TEMU_DYN_ARRAY_TYPE(T, P) \
146 } temu_ ## P ## Array; \
147 static inline temu_ ## P ## Array \
148 temu_ ## P ## ArrayAlloc(unsigned Reserve) \
150 temu_ ## P ## Array Arr; \
152 Arr.Reserved = Reserve; \
153 Arr.Values = (T*)calloc(Reserve, sizeof(T)); \
154 assert(Arr.Values); \
158 temu_ ## P ## ArrayPush(temu_ ## P ## Array *Arr, T Val) \
160 if (Arr->Reserved >= Arr->Size) { \
161 T *NewValues = (T*)realloc(Arr->Values, Arr->Reserved * 2); \
163 Arr->Values = NewValues; \
168 Arr->Values[Arr->Size ++] = Val; \
170 static inline unsigned \
171 temu_ ## P ## ArraySize(temu_ ## P ## Array *Arr) \
267 #ifdef PROP_ASSERTS_ENABLED
268 #define PROP_ASSERT(p, t) assert(p.Typ == t && "invalid property type")
270 #define PROP_ASSERT(p, t)
277 #define PROP_VAL_INITIALIZER(typ, suffix, typetag, valtag) \
278 static inline temu_Propval \
279 temu_makeProp ## suffix (typ val) \
287 temu_propValue ## suffix (temu_Propval pv) \
289 PROP_ASSERT(pv.Typ, typetag); \
290 typ val = pv.valtag; \
378 temu_readValue(
void *Obj, const
char *PropName,
int Idx) TEMU_NO_WRAP;
401 void temu_setValueU8(
void *Obj, const
char *PropName, uint8_t Val,
int Idx);
402 void temu_setValueU16(
void *Obj, const
char *PropName, uint16_t Val,
int Idx);
403 void temu_setValueU32(
void *Obj, const
char *PropName, uint32_t Val,
int Idx);
404 void temu_setValueU64(
void *Obj, const
char *PropName, uint64_t Val,
int Idx);
406 void temu_setValueI8(
void *Obj, const
char *PropName, int8_t Val,
int Idx);
407 void temu_setValueI16(
void *Obj, const
char *PropName, int16_t Val,
int Idx);
408 void temu_setValueI32(
void *Obj, const
char *PropName, int32_t Val,
int Idx);
409 void temu_setValueI64(
void *Obj, const
char *PropName, int64_t Val,
int Idx);
435 int Idx) TEMU_NO_WRAP;
438 int Idx) TEMU_NO_WRAP;
455 #define TEMU_NULL_ARG { NULL, {teTY_Invalid} }
457 typedef void* (*temu_ObjectCreateFunc)(
const char *Name,
515 const char *Doc =
"");
529 const char *IfaceType);
547 const char *IfaceName,
548 const char *IfaceType,
549 void *Iface,
int Count = 0,
550 const char *Doc =
"");
554 const char *IfaceName,
int Idx = 0);
560 const char *IfaceName,
561 const char *IfaceType,
562 void *Iface,
int Count,
567 const char *IfaceName,
int Idx);
600 void*
temu_addObject(
const char *ClsName,
const char *ObjName,
void *Obj);
690 int temu_connect(
void *A,
const char *PropName,
void *B,
const char *IfaceName);
718 int Count,
void *Data);
760 void (*serialise)(
void *Obj,
const char *BaseName,
void *Ctxt);
761 void (*deserialise)(
void *Obj,
const char *BaseName,
void *Ctxt);
769 int (*checkSanity)(
void *Obj,
int Report);
void temu_writeValue(void *Obj, const char *PropName, temu_Propval Val, int Idx) TEMU_NO_WRAP
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)
int temu_isMachine(void *Obj)
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)
int temu_isDiscrete(temu_Propval Pv)
void temu_qualifyAsMachine(void *Cls)
int8_t temu_getValueI8(void *Obj, const char *PropName, int Idx)
void temu_setValueU32(void *Obj, const char *PropName, uint32_t Val, int Idx)
int temu_isReal(temu_Propval Pv)
void temu_setValueU8(void *Obj, const char *PropName, uint8_t Val, int Idx)
const char * temu_nameForClass(temu_Class *Cls)
int temu_generateObjectGraph(const char *Path, int Display)
void temu_setValueU16(void *Obj, const char *PropName, uint16_t Val, int Idx)
int temu_connect(void *A, const char *PropName, void *B, const char *IfaceName)
#define TEMU_DYN_ARRAY_TYPE(T, P)
temu_Class * temu_classForObjectName(const char *Obj)
uint16_t temu_getValueU16(void *Obj, const char *PropName, int Idx)
int temu_isString(temu_Propval Pv)
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)
struct temu_IfaceRef temu_IfaceRef
int temu_getPropDynLength(const void *Obj, const char *PropName)
int8_t temu_readValueI8(void *Obj, const char *PropName, int Idx)
int64_t temu_asInteger(temu_Propval Pv)
struct temu_IfaceRefArray temu_IfaceRefArray
void temu_writeNamedObjectProp(const char *Obj, const char *PropName, temu_Propval Val, int Idx) TEMU_NO_WRAP
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)
temu_Propval temu_getValue(void *Obj, const char *PropName, int Idx) TEMU_NO_WRAP
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) TEMU_NO_WRAP
temu_Propval temu_readNamedObjectProp(const char *Obj, const char *PropName, int Idx) TEMU_NO_WRAP
void * temu_getVTableForClass(temu_Class *Cls)
int temu_isNumber(temu_Propval Pv)
uint64_t temu_asUnsigned(temu_Propval Pv)
temu_IfaceRefArray temu_ifaceRefArrayAlloc(unsigned Reserve)
temu_Propval temu_getNamedObjectProp(const char *Obj, const char *PropName, int Idx) TEMU_NO_WRAP
int temu_checkpointGetLength(void *Ctxt, const char *Name)
int temu_isCpu(void *Obj)
#define TEMU_IFACE_REFERENCE_TYPE(N)
void * temu_addObject(const char *ClsName, const char *ObjName, void *Obj)
void * temu_createObject(const char *ClsName, const char *ObjName, const temu_CreateArg *Args)
void temu_setValueI64(void *Obj, const char *PropName, int64_t Val, int Idx)
void temu_requireInterface(temu_Class *Cls, const char *PropName, const char *IfaceType)
void temu_writeValueI64(void *Obj, const char *PropName, int64_t Val, int Idx)
void temu_ifaceRefArrayDispose(temu_IfaceRefArray *Arr)
void temu_writeValueI8(void *Obj, const char *PropName, int8_t Val, int Idx)
void temu_setValue(void *Obj, const char *PropName, temu_Propval Val, int Idx) TEMU_NO_WRAP
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)
temu_Propval temu_readValue(void *Obj, const char *PropName, int Idx) TEMU_NO_WRAP
int32_t temu_getValueI32(void *Obj, const char *PropName, int Idx)
void temu_objsysClear(void)
void * temu_getVTable(void *Obj)
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)
double temu_asDouble(temu_Propval Pv)
void temu_ifaceRefArrayPush(temu_IfaceRefArray *Arr, temu_IfaceRef Iface)
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)
void temu_setValueI16(void *Obj, const char *PropName, int16_t Val, int Idx)
int temu_checkSanity(int Report)
void temu_ifaceRefArrayPush2(temu_IfaceRefArray *Arr, void *Obj, void *Iface)
int64_t temu_getValueI64(void *Obj, const char *PropName, int Idx)
int temu_setVTable(temu_Class *Cls, void *VTable)
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)
uint16_t temu_readValueU16(void *Obj, const char *PropName, int Idx)
temu_Propref temu_getPropref(const void *Obj, const char *PropName)
int temu_deserialiseJSON(const char *FileName)
int temu_isExternal(void *Obj)
void temu_setValueU64(void *Obj, const char *PropName, uint64_t Val, int Idx)
void temu_qualifyAsCpu(void *Cls)
int64_t temu_readValueI64(void *Obj, const char *PropName, int Idx)
void temu_writeValueI16(void *Obj, const char *PropName, int16_t Val, int Idx)
temu_IfaceRefArray IfaceRefArray
unsigned temu_ifaceRefArraySize(temu_IfaceRefArray *Arr)
void * temu_getInterface(void *Obj, const char *IfaceName, int Idx)
void temu_writeValueU8(void *Obj, const char *PropName, uint8_t Val, int Idx)
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)