9 #ifndef TEMU_OBJSYS_C_H
10 #define TEMU_OBJSYS_C_H
23 #define TEMU_PLUGIN_INIT extern "C" void temu_pluginInit(void)
25 #define TEMU_PLUGIN_INIT void temu_pluginInit(void)
28 #if defined(__has_attribute)
29 #if __has_attribute(annotate)
30 #define TEMU_NO_WRAP __attribute__((annotate("temu-no-wrap")))
35 #if (__cplusplus < 201103L) && !defined(nullptr)
40 #if !defined(TEMU_NO_WRAP)
44 #ifndef TEMU_BUFF_DEFINED
45 #define TEMU_BUFF_DEFINED
51 #endif // !TEMU_BUFF_DEFINED
53 #ifndef TEMU_COMPONENT_DEFINED
54 #define TEMU_COMPONENT_DEFINED
56 #endif // !TEMU_COMPONENT_DEFINED
68 int64_t DisposedNotification;
73 #define temu_Object_ void // For forward compatibility with TEMU3
105 void *Obj TEMU_NONNULL,
106 void *Iface TEMU_NONNULL);
129 #define TEMU_IFACE_REFERENCE_TYPE(N) \
137 N##IfaceRef *Ifaces; \
138 } N##IfaceRefArray; \
139 static inline N##IfaceRefArray N##IfaceRefArrayAlloc(unsigned Reserve) \
141 temu_IfaceRefArray Arr = temu_ifaceRefArrayAlloc(Reserve); \
142 N##IfaceRefArray Res; \
143 Res.Size = Arr.Size; \
144 Res.Reserved = Arr.Reserved; \
145 Res.Ifaces = (N##IfaceRef *)Arr.Ifaces; \
148 static inline void N##IfaceRefArrayDispose(N##IfaceRefArray *Arr) \
150 temu_ifaceRefArrayDispose((temu_IfaceRefArray *)Arr); \
152 static inline void N##IfaceRefArrayPush2(N##IfaceRefArray *Arr, void *Obj, \
155 temu_ifaceRefArrayPush2((temu_IfaceRefArray *)Arr, Obj, Iface); \
157 static inline void N##IfaceRefArrayPush(N##IfaceRefArray *Arr, \
160 temu_IfaceRef Iface2; \
161 Iface2.Obj = Iface.Obj; \
162 Iface2.Iface = (void *)Iface.Iface; \
164 temu_ifaceRefArrayPush((temu_IfaceRefArray *)Arr, Iface2); \
166 static inline unsigned N##IfaceRefArraySize(N##IfaceRefArray *Arr) \
170 static inline void N##IfaceRefArrayPop(N##IfaceRefArray *Arr) { Arr->Size--; }
172 #define TEMU_DYN_ARRAY_TYPE(T, P) \
178 static inline temu_##P##Array temu_##P##ArrayAlloc(unsigned Reserve) \
180 assert(Reserve > 0); \
181 temu_##P##Array Arr; \
183 Arr.Reserved = Reserve; \
184 Arr.Values = (T *)calloc(Reserve, sizeof(T)); \
185 assert(Arr.Values); \
188 static inline void temu_##P##ArrayPush(temu_##P##Array *Arr, T Val) \
190 if (Arr->Reserved >= Arr->Size) { \
191 T *NewValues = (T *)realloc(Arr->Values, Arr->Reserved * 2); \
193 Arr->Values = NewValues; \
198 Arr->Values[Arr->Size++] = Val; \
200 static inline unsigned temu_##P##ArraySize(temu_##P##Array *Arr) \
204 static inline void temu_##P##ArrayPop(temu_##P##Array *Arr) \
496 #ifdef PROP_ASSERTS_ENABLED
497 #define PROP_ASSERT(p, t) assert(p.Typ == t && "invalid property type")
499 #define PROP_ASSERT(p, t)
506 #define PROP_VAL_INITIALIZER(typ, suffix, typetag, valtag) \
507 static inline temu_Propval temu_makeProp##suffix(typ val) \
514 static inline typ temu_propValue##suffix(temu_Propval pv) \
516 PROP_ASSERT(pv.Typ, typetag); \
517 typ val = pv.valtag; \
764 int Idx) TEMU_NO_WRAP;
895 int Idx) TEMU_NO_WRAP;
994 int Idx) TEMU_NO_WRAP;
1092 const
char *PropName,
int Idx)
1105 const
char *PropName,
int Idx)
1106 TEMU_NO_WRAP TEMU_DEPRECATED;
1116 int Idx) TEMU_NO_WRAP TEMU_DEPRECATED;
1126 int Idx) TEMU_NO_WRAP TEMU_DEPRECATED;
1133 #define TEMU_NULL_ARG \
1135 NULL, { teTY_Invalid } \
1138 typedef void *(*temu_ObjectCreateFunc)(
const char *Name,
int Argc,
1198 const char *Doc =
"");
1267 const char *Category);
1276 unsigned CategoryId);
1304 const char *IfaceType);
1325 const char *IfaceName,
const char *Doc);
1349 const char *IfaceType,
void *Iface,
1350 int DeprecatedParam = 0,
const char *Doc =
"");
1365 const char *IfaceName,
const char *IfaceType,
1366 void *Iface,
int DeprecatedParam,
1401 const char *IfaceType,
void *Iface,
1402 size_t Count,
size_t Size,
1464 #define TEMU_QUAL_NONE 0
1465 #define TEMU_QUAL_CPU 1
1466 #define TEMU_QUAL_MACHINE 2
1467 #define TEMU_QUAL_EXTERNAL 3 // Deprecated
1468 #define TEMU_QUAL_MEMORY 4
1469 #define TEMU_QUAL_COMPONENT 5
1470 #define TEMU_QUAL_CLOCK 6
1474 #define TEMU_QUAL_USER 65536
1788 const char *IfaceName);
1835 int Count,
void *Data);
1913 void (*serialise)(
void *Obj,
const char *BaseName,
void *Ctxt);
1924 void (*deserialise)(
void *Obj,
const char *BaseName,
void *Ctxt);
1932 int (*checkSanity)(
void *Obj,
int Report);
1940 void (*timeSourceSet)(
void *Obj);
1948 void (*printObject)(
void *Obj);
1950 #define TEMU_OBJECT_IFACE_TYPE "ObjectIface"
1994 temu_Class *C,
void (*Func)(temu_Class *, const
char *,
void *),
void *Arg);
2007 temu_Class *C,
void (*Func)(temu_Class *, const
char *,
void *),
void *Arg);
TEMU_API temu_Class * temu_classForName(const char *ClsName)
TEMU_API int temu_objectHasProp(const void *Obj, const char *PropName)
TEMU_API void temu_setValueI64(void *Obj, const char *PropName, int64_t Val, int Idx)
TEMU_API void temu_listDispose(temu_List *List)
TEMU_API void temu_addPseudoProperty(temu_Class *Cls, const char *PropName, temu_Type Typ, int Count, temu_PropWriter Wr, temu_PropReader Rd, temu_PropWriter Set, temu_PropReader Get, const char *Doc)
void(* temu_PropWriter)(void *Obj, temu_Propval Pv, int Idx)
TEMU_API void temu_writeValueI32(void *Obj, const char *PropName, int32_t Val, int Idx)
TEMU_API temu_Dict * temu_dictCreate(void)
TEMU_API void temu_setValueU16(void *Obj, const char *PropName, uint16_t Val, int Idx)
TEMU_API void temu_qualifyAsCpu(void *Cls)
TEMU_API const char * temu_getLoggingCategory(temu_Class *Cls, unsigned CategoryId)
int64_t WillDisposeNotification
TEMU_API void * temu_addObject(const char *ClsName, const char *ObjName, void *Obj) TEMU_DEPRECATED
TEMU_API int temu_checkpointGetLength(void *Ctxt, const char *Name)
TEMU_API size_t temu_getComponentCount(void)
TEMU_API int temu_dictRemoveValue(temu_Dict *Dict, const char *Name)
TEMU_API int8_t temu_getValueI8(void *Obj, const char *PropName, int Idx)
void * TimeSource
Timesource object.
TEMU_API temu_Propval temu_listRemoveTail(temu_List *List)
TEMU_API temu_Type temu_getPropType(const void *Obj, const char *PropName)
TEMU_API uint16_t temu_getValueU16(void *Obj, const char *PropName, int Idx)
TEMU_API void temu_addInterfaceArray(temu_Class *Cls, const char *IfaceName, const char *IfaceType, void *Iface, size_t Count, size_t Size, const char *Doc)
TEMU_API void temu_deserialiseProp(void *Ctxt, void *Obj, const char *Name)
TEMU_API int temu_getPropDynLength(const void *Obj, const char *PropName)
TEMU_API int temu_setVTable(temu_Class *Cls, void *VTable)
TEMU_API int32_t temu_getValueI32(void *Obj, const char *PropName, int Idx)
TEMU_API uint64_t temu_getValueU64(void *Obj, const char *PropName, int Idx)
TEMU_API int temu_isComponent(const void *Obj)
#define TEMU_DYN_ARRAY_TYPE(T, P)
TEMU_API int temu_getPropLength(const void *Obj, const char *PropName)
TEMU_API temu_Propval temu_listRemoveHead(temu_List *List)
TEMU_API const char * temu_nameForInterface(const void *Obj, const void *Iface)
TEMU_API int16_t temu_getValueI16(void *Obj, const char *PropName, int Idx)
TEMU_API void temu_writeValueU16(void *Obj, const char *PropName, uint16_t Val, int Idx)
TEMU_API void temu_pluginPathAppend(const char *Path)
TEMU_API int64_t temu_asInteger(temu_Propval Pv)
TEMU_API temu_Propval temu_readValue(void *Obj, const char *PropName, int Idx) TEMU_NO_WRAP
TEMU_API int temu_isValidInterfaceName(const char *Name)
TEMU_API int temu_isNumber(temu_Propval Pv)
TEMU_API void ** temu_getProcessors(void)
TEMU_API temu_Class * temu_registerClass(const char *ClsName, temu_ObjectCreateFunc Create, temu_ObjectDisposeFunc Dispose)
TEMU_API int temu_isValidObjectName(const char *Name)
TEMU_API void temu_writeValueI8(void *Obj, const char *PropName, int8_t Val, int Idx)
TEMU_API const char * temu_dictGetNextKey(temu_Dict *Dict, const char *Key)
TEMU_API const char * temu_nameForObject(const void *Obj)
TEMU_API temu_ListNode * temu_listGetNext(temu_ListNode *Node)
TEMU_API temu_Propval temu_getValue(void *Obj, const char *PropName, int Idx) TEMU_NO_WRAP
TEMU_API uint32_t temu_readValueU32(void *Obj, const char *PropName, int Idx)
struct temu_IfaceRef temu_IfaceRef
TEMU_API void temu_writeValueI16(void *Obj, const char *PropName, int16_t Val, int Idx)
TEMU_API int temu_checkSanity(int Report)
TEMU_API void temu_dictDispose(temu_Dict *Dict)
TEMU_API temu_ListNode * temu_listGetHead(temu_List *List)
TEMU_API void temu_listAppend(temu_List *List, temu_Propval Val)
TEMU_API double temu_asDouble(temu_Propval Pv)
TEMU_API int temu_isString(temu_Propval Pv)
TEMU_API void temu_foreachObject(void(*Func)(void *, void *), void *Arg)
TEMU_API void temu_setValueI8(void *Obj, const char *PropName, int8_t Val, int Idx)
TEMU_API void temu_foreachInterface(temu_Class *C, void(*Func)(temu_Class *, const char *, void *), void *Arg)
TEMU_API void * temu_getInterface(void *Obj, const char *IfaceName, int Idx)
TEMU_API temu_Propval temu_checkpointGetValue(void *Ctxt, const char *Name, int Idx)
TEMU_API int temu_addLoggingCategory(temu_Class *Cls, unsigned CategoryId, const char *Category)
TEMU_API int temu_isDiscrete(temu_Propval Pv)
TEMU_API void temu_foreachProperty(temu_Class *C, void(*Func)(temu_Class *, const char *, void *), void *Arg)
struct temu_IfaceRefArray temu_IfaceRefArray
TEMU_API int temu_connect(void *A, const char *PropName, void *B, const char *IfaceName)
TEMU_API void * temu_createObject(const char *ClsName, const char *ObjName, const temu_CreateArg *Args)
TEMU_API int temu_isCpu(const void *Obj)
TEMU_API void temu_setValueI16(void *Obj, const char *PropName, int16_t Val, int Idx)
TEMU_API void temu_ifaceRefArrayDispose(temu_IfaceRefArray *Arr)
TEMU_API void temu_writeValueU64(void *Obj, const char *PropName, uint64_t Val, int Idx)
TEMU_API void temu_ifaceRefArrayPush2(temu_IfaceRefArray *Arr TEMU_NONNULL, void *Obj TEMU_NONNULL, void *Iface TEMU_NONNULL)
uintptr_t Offset
Offset from struct start.
TEMU_API int temu_generateObjectGraph(const char *Path, int Display)
TEMU_API void temu_writeNamedObjectProp(const char *Obj, const char *PropName, temu_Propval Val, int Idx) TEMU_NO_WRAP TEMU_DEPRECATED
TEMU_API int temu_propInfoForClass(temu_Class *Cls, unsigned PIIndex, unsigned PICount, temu_PropInfo *PI)
TEMU_API uint16_t temu_readValueU16(void *Obj, const char *PropName, int Idx)
TEMU_API int16_t temu_readValueI16(void *Obj, const char *PropName, int Idx)
TEMU_API int temu_deserialiseJSON(const char *FileName)
TEMU_API temu_Propval temu_getNamedObjectProp(const char *Obj, const char *PropName, int Idx) TEMU_NO_WRAP TEMU_DEPRECATED
TEMU_API void temu_writeValueU32(void *Obj, const char *PropName, uint32_t Val, int Idx)
TEMU_API size_t temu_getProcessorCount(void)
TEMU_API void temu_setValue(void *Obj, const char *PropName, temu_Propval Val, int Idx) TEMU_NO_WRAP
TEMU_API size_t temu_vecGetSize(temu_Vector *Vec)
TEMU_API void temu_ifaceRefArrayPush(temu_IfaceRefArray *Arr TEMU_NONNULL, temu_IfaceRef Iface)
TEMU_API const char * temu_typenameForInterface(const void *Obj, const void *Iface)
TEMU_API temu_List temu_listCreate(temu_Type Typ)
TEMU_API void temu_pluginPathPrint(void)
#define TEMU_IFACE_REFERENCE_TYPE(N)
size_t Count
Number of elements in property.
TEMU_API void temu_setValueU8(void *Obj, const char *PropName, uint8_t Val, int Idx)
TEMU_API void * temu_objectForName(const char *Name)
const char * Name
Name of property.
TEMU_API int temu_isSigned(temu_Propval Pv)
TEMU_API void temu_foreachClass(void(*Func)(temu_Class *, void *), void *Arg)
TEMU_API temu_IfaceRefArray temu_ifaceRefArrayAlloc(unsigned Reserve)
TEMU_API const char * temu_nameForClass(temu_Class *Cls)
TEMU_API void temu_serialiseProp(void *Ctxt, const char *Name, temu_Type Typ, int Count, void *Data)
TEMU_API int64_t temu_readValueI64(void *Obj, const char *PropName, int Idx)
TEMU_API void temu_qualifyAsMemory(void *Cls)
TEMU_API void temu_setValueI32(void *Obj, const char *PropName, int32_t Val, int Idx)
TEMU_API void temu_disposeObject(void *Obj)
void *(* temu_ObjectCreateFunc)(const char *Name, int Argc, const temu_CreateArg *Argv)
TEMU_API void temu_writeValue(void *Obj, const char *PropName, temu_Propval Val, int Idx) TEMU_NO_WRAP
TEMU_API int temu_isMemory(const void *Obj)
TEMU_API int temu_objectHasIface(const void *Obj, const char *IfaceName)
TEMU_API int64_t temu_getValueI64(void *Obj, const char *PropName, int Idx)
TEMU_API int32_t temu_readValueI32(void *Obj, const char *PropName, int Idx)
void(* temu_ObjectDisposeFunc)(void *)
struct temu_Propref temu_Propref
TEMU_API void ** temu_getComponents(void)
TEMU_API void temu_writeValueI64(void *Obj, const char *PropName, int64_t Val, int Idx)
TEMU_API void temu_vecPush(temu_Vector *Vec, temu_Propval Val)
TEMU_API int temu_isNormalProperty(void *Obj, const char *PropName)
TEMU_API int temu_isValidPropertyName(const char *Name)
TEMU_API temu_Propval temu_dictGetValue(temu_Dict *Dict, const char *Name)
TEMU_API int temu_isReal(temu_Propval Pv)
TEMU_API void temu_addInterface(temu_Class *Cls, const char *IfaceName, const char *IfaceType, void *Iface, int DeprecatedParam, const char *Doc)
TEMU_API temu_Propval temu_readNamedObjectProp(const char *Obj, const char *PropName, int Idx) TEMU_NO_WRAP TEMU_DEPRECATED
temu_Propval(* temu_PropReader)(void *Obj, int Idx)
uint64_t LoggingFlags
Log category enabled/disabled.
temu_Component * Component
Parent component (null for root comp)
TEMU_API int8_t temu_readValueI8(void *Obj, const char *PropName, int Idx)
TEMU_API temu_Class * temu_classForObjectName(const char *Obj) TEMU_DEPRECATED
TEMU_API int temu_serialiseJSON(const char *FileName)
TEMU_API void temu_foreachProcessor(void(*Func)(temu_Object *, void *), void *Arg)
TEMU_API int temu_isMachine(const void *Obj)
TEMU_API temu_PropName temu_getPropName(const void *Obj, const char *PropName)
TEMU_API int temu_isQualifiedAs(const void *Obj, unsigned Qualifier)
TEMU_API int temu_dictInsertValue(temu_Dict *Dict, const char *Name, temu_Propval Val)
TEMU_API void temu_vecDispose(temu_Vector *Vec)
TEMU_API int temu_isUnsigned(temu_Propval Pv)
TEMU_API void temu_objsysClearObjects(void)
TEMU_API void temu_writeValueU8(void *Obj, const char *PropName, uint8_t Val, int Idx)
TEMU_API int temu_addPort(temu_Class *C, const char *IfaceRefName, const char *IfaceName, const char *Doc)
TEMU_API uint32_t temu_getValueU32(void *Obj, const char *PropName, int Idx)
TEMU_API void temu_setNamedObjectProp(const char *Obj, const char *PropName, temu_Propval Val, int Idx) TEMU_NO_WRAP TEMU_DEPRECATED
TEMU_API int temu_isExternal(const void *Obj) TEMU_DEPRECATED
TEMU_API temu_IfaceRef temu_getInterfaceRef(void *Obj, const char *IfaceName, int Idx)
#define PROP_VAL_INITIALIZER(typ, suffix, typetag, valtag)
TEMU_API void * temu_getVTable(const void *Obj)
TEMU_API int temu_loadPlugin(const char *PluginName)
TEMU_API void temu_setValueU32(void *Obj, const char *PropName, uint32_t Val, int Idx)
TEMU_API temu_Propval temu_listNodeGetVal(temu_ListNode *Node)
TEMU_API uint64_t temu_readValueU64(void *Obj, const char *PropName, int Idx)
TEMU_API temu_ListNode * temu_listGetPrev(temu_ListNode *Node)
TEMU_API void temu_requireInterface(temu_Class *Cls, const char *PropName, const char *IfaceType)
TEMU_API temu_ListNode * temu_listGetTail(temu_List *List)
TEMU_API void * temu_getVTableForClass(temu_Class *Cls)
TEMU_API uint8_t temu_getValueU8(void *Obj, const char *PropName, int Idx)
TEMU_API void temu_listPrepend(temu_List *List, temu_Propval Val)
TEMU_API 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)
TEMU_API void temu_objsysClear(void)
TEMU_API int temu_isPseudoProperty(void *Obj, const char *PropName)
TEMU_API void temu_pluginPathRemove(const char *Path)
struct temu_Component temu_Component
TEMU_API void temu_setTimeSource(void *Obj, void *TS)
TEMU_API temu_Vector temu_vecCreate(temu_Type Typ)
TEMU_API void temu_qualifyAs(void *Cls, unsigned Qualifier)
TEMU_API temu_Class * temu_registerExternalClass(const char *ClsName) TEMU_DEPRECATED
TEMU_API uint64_t temu_asUnsigned(temu_Propval Pv)
TEMU_API int temu_isValidClassName(const char *Name)
temu_IfaceRefArray IfaceRefArray
TEMU_API void temu_setValueU64(void *Obj, const char *PropName, uint64_t Val, int Idx)
temu_Class * Class
Class pointer.
TEMU_API void temu_qualifyAsMachine(void *Cls)
TEMU_API temu_Class * temu_classForObject(const void *Obj)
TEMU_API unsigned temu_ifaceRefArraySize(temu_IfaceRefArray *Arr)
TEMU_API const char * temu_typeToName(temu_Type Typ)
TEMU_API temu_Propref temu_getPropref(const void *Obj, const char *PropName)
TEMU_API uint8_t temu_readValueU8(void *Obj, const char *PropName, int Idx)
struct temu_CreateArg temu_CreateArg
struct temu_Propval temu_Propval
TEMU_API void * temu_vecGetData(temu_Vector *Vec)