TEMU  2
The Terma Emulator
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Objsys.h
Go to the documentation of this file.
1 //===-- temu-c/Objsys.h - T-EMU Object System -------------------*- C++ -*-===//
2 //
3 // T-EMU: The Terma Emulator
4 // (c) Terma 2015, 2016
5 // Authors: Mattias Holm <maho (at) terma.com>
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef TEMU_OBJSYS_C_H
10 #define TEMU_OBJSYS_C_H
11 
13 #include <assert.h>
14 #include <stddef.h>
15 #include <stdint.h>
16 #include <stdlib.h>
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
22 #ifdef __cplusplus
23 #define TEMU_PLUGIN_INIT extern "C" void temu_pluginInit(void)
24 #else
25 #define TEMU_PLUGIN_INIT void temu_pluginInit(void)
26 #endif
27 
28 #if defined(__has_attribute)
29 #if __has_attribute(annotate)
30 #define TEMU_NO_WRAP __attribute__((annotate("temu-no-wrap")))
31 #endif
32 #endif
33 
34 #ifdef __cplusplus
35 #if (__cplusplus < 201103L) && !defined(nullptr)
36 #define nullptr 0
37 #endif
38 #endif
39 
40 #if !defined(TEMU_NO_WRAP)
41 #define TEMU_NO_WRAP
42 #endif
43 
44 #ifndef TEMU_BUFF_DEFINED
45 #define TEMU_BUFF_DEFINED
46 typedef struct {
47  uintptr_t data0;
48  uint32_t data1;
49  uint32_t data2;
50 } temu_Buff;
51 #endif // !TEMU_BUFF_DEFINED
52 
53 #ifndef TEMU_COMPONENT_DEFINED
54 #define TEMU_COMPONENT_DEFINED
56 #endif // !TEMU_COMPONENT_DEFINED
57 
58 typedef void temu_Class;
59 typedef void temu_MetaIface;
60 
61 typedef struct {
62  temu_Class *Class;
63  void *TimeSource;
65  uint64_t LoggingFlags;
66 
68  int64_t DisposedNotification;
70 } temu_Object;
72 
73 #define temu_Object_ void // For forward compatibility with TEMU3
74 // Generic interface
75 typedef struct temu_IfaceRef {
76  void *Obj;
77  void *Iface;
79 
80 // In some cases, the number of objects we know about is unknown, so
81 // we need a dynamic array (e.g. std::vector in C++), but we cannot
82 // expose std::vector in a known format to LLVM, so we do this simple
83 // system with a dynamic interface array.
84 typedef struct temu_IfaceRefArray {
85  uint32_t Size;
86  uint32_t Reserved;
89 
97 
105  void *Obj TEMU_NONNULL,
106  void *Iface TEMU_NONNULL);
107 
115  temu_IfaceRef Iface);
116 
122 TEMU_API unsigned
123 temu_ifaceRefArraySize(temu_IfaceRefArray *Arr); // Return size
124 
126 
127 // Used to declare typed interfaces, also declares an array of such
128 // and inline wrappers for the iface array functions
129 #define TEMU_IFACE_REFERENCE_TYPE(N) \
130  typedef struct { \
131  void *Obj; \
132  N##Iface *Iface; \
133  } N##IfaceRef; \
134  typedef struct { \
135  uint32_t Size; \
136  uint32_t Reserved; \
137  N##IfaceRef *Ifaces; \
138  } N##IfaceRefArray; \
139  static inline N##IfaceRefArray N##IfaceRefArrayAlloc(unsigned Reserve) \
140  { \
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; \
146  return Res; \
147  } \
148  static inline void N##IfaceRefArrayDispose(N##IfaceRefArray *Arr) \
149  { \
150  temu_ifaceRefArrayDispose((temu_IfaceRefArray *)Arr); \
151  } \
152  static inline void N##IfaceRefArrayPush2(N##IfaceRefArray *Arr, void *Obj, \
153  void *Iface) \
154  { \
155  temu_ifaceRefArrayPush2((temu_IfaceRefArray *)Arr, Obj, Iface); \
156  } \
157  static inline void N##IfaceRefArrayPush(N##IfaceRefArray *Arr, \
158  N##IfaceRef Iface) \
159  { \
160  temu_IfaceRef Iface2; \
161  Iface2.Obj = Iface.Obj; \
162  Iface2.Iface = (void *)Iface.Iface; \
163  \
164  temu_ifaceRefArrayPush((temu_IfaceRefArray *)Arr, Iface2); \
165  } \
166  static inline unsigned N##IfaceRefArraySize(N##IfaceRefArray *Arr) \
167  { \
168  return Arr->Size; \
169  } \
170  static inline void N##IfaceRefArrayPop(N##IfaceRefArray *Arr) { Arr->Size--; }
171 
172 #define TEMU_DYN_ARRAY_TYPE(T, P) \
173  typedef struct { \
174  uint32_t Size; \
175  uint32_t Reserved; \
176  T *Values; \
177  } temu_##P##Array; \
178  static inline temu_##P##Array temu_##P##ArrayAlloc(unsigned Reserve) \
179  { \
180  assert(Reserve > 0); \
181  temu_##P##Array Arr; \
182  Arr.Size = 0; \
183  Arr.Reserved = Reserve; \
184  Arr.Values = (T *)calloc(Reserve, sizeof(T)); \
185  assert(Arr.Values); \
186  return Arr; \
187  } \
188  static inline void temu_##P##ArrayPush(temu_##P##Array *Arr, T Val) \
189  { \
190  if (Arr->Reserved >= Arr->Size) { \
191  T *NewValues = (T *)realloc(Arr->Values, Arr->Reserved * 2); \
192  if (NewValues) { \
193  Arr->Values = NewValues; \
194  } else { \
195  abort(); \
196  } \
197  } \
198  Arr->Values[Arr->Size++] = Val; \
199  } \
200  static inline unsigned temu_##P##ArraySize(temu_##P##Array *Arr) \
201  { \
202  return Arr->Size; \
203  } \
204  static inline void temu_##P##ArrayPop(temu_##P##Array *Arr) \
205  { \
206  if (Arr->Size > 0) \
207  Arr->Size--; \
208  }
209 
210 TEMU_DYN_ARRAY_TYPE(int8_t, i8)
211 TEMU_DYN_ARRAY_TYPE(int16_t, i16)
212 TEMU_DYN_ARRAY_TYPE(int32_t, i32)
213 TEMU_DYN_ARRAY_TYPE(int64_t, i64)
214 
215 TEMU_DYN_ARRAY_TYPE(uint8_t, u8)
216 TEMU_DYN_ARRAY_TYPE(uint16_t, u16)
217 TEMU_DYN_ARRAY_TYPE(uint32_t, u32)
218 TEMU_DYN_ARRAY_TYPE(uint64_t, u64)
219 TEMU_DYN_ARRAY_TYPE(void *, object)
220 
221 typedef enum temu_Type {
222  teTY_Invalid, // Invalid value 0
223 
224  // C pointer sized integers
227 
228  // Standard C floating point types
231 
232  // Standard C fixed width integer types
233  teTY_U8, // 5
234  teTY_U16, // 6
235  teTY_U32, // 7
236  teTY_U64, // 8
241 
242  // Object pointer, must be saved as an object reference
244 
245  // Internal pointer, points somewhere in the object itself
246  // (e.g. bank resolution arrays) This can be saved as an offset...
248 
249  // Interface references (object and interface pointer pair)
251  teTY_IfaceRefArray, // Dynamic object/interface array
252 
253  teTY_String, // C-string, useful for serialisation
254  teTY_Buffer, // Buffer (see Buffer.h)
255  teTY_Dict, // Dictionary
256  teTY_Vector, // Vector (i.e. dynamic array)
257  teTY_List, // List
258 } temu_Type;
259 
266 typedef struct temu_Propref {
268  void *Ptr;
269 } temu_Propref;
270 
271 typedef struct {
272  void *Obj;
273  const char *Name;
274 } temu_PropName;
275 
276 typedef void temu_Dict;
277 
278 typedef struct {
280  void *VecData; // Managed pointer, do not use directly
281 } temu_Vector;
282 
283 typedef void temu_ListNode;
284 
285 typedef struct {
287  temu_ListNode *Head; // Managed pointer, do not use directly
288  temu_ListNode *Tail; // Managed pointer, do not use directly
289 } temu_List;
290 
298 typedef struct temu_Propval {
300  union {
301  intptr_t IntPtr;
302  uintptr_t UIntPtr;
303 
304  float f;
305  double d;
306 
307  uint8_t u8;
308  uint16_t u16;
309  uint32_t u32;
310  uint64_t u64;
311 
312  int8_t i8;
313  int16_t i16;
314  int32_t i32;
315  int64_t i64;
316 
317  void *Obj;
320  const char *String;
322  temu_Dict *Dict;
325  };
326 } temu_Propval;
327 
328 // Dictionary support. Dictionaries are data structure that contain
329 // named prop values. They are not ment for high performing code, but
330 // are useful for advanced configuration capabilities. In practice
331 // dictionaries work for any type, but checkpointing will not yet work
332 // for entries containing complex types (temu_Buff, temu_Vector and
333 // other dictionaries). This will be addressed in the future.
334 
339 TEMU_API temu_Dict *temu_dictCreate(void);
340 
345 TEMU_API void temu_dictDispose(temu_Dict *Dict);
346 
355 TEMU_API int temu_dictInsertValue(temu_Dict *Dict, const char *Name,
356  temu_Propval Val);
357 
364 TEMU_API temu_Propval temu_dictGetValue(temu_Dict *Dict, const char *Name);
365 
373 TEMU_API int temu_dictRemoveValue(temu_Dict *Dict, const char *Name);
374 
381 TEMU_API const char *temu_dictGetNextKey(temu_Dict *Dict, const char *Key);
382 
383 // Typed vector support. The typed vectors can be described as a C++
384 // std::vector, however, they are expressed as a C-API here and
385 // supports checkpointing.
392 
398 
405 
412 
419 
426 
432 
439 
446 
453 
460 
466 TEMU_API temu_ListNode *temu_listGetHead(temu_List *List);
467 
473 TEMU_API temu_ListNode *temu_listGetTail(temu_List *List);
474 
480 TEMU_API temu_ListNode *temu_listGetNext(temu_ListNode *Node);
481 
487 TEMU_API temu_ListNode *temu_listGetPrev(temu_ListNode *Node);
488 
494 TEMU_API temu_Propval temu_listNodeGetVal(temu_ListNode *Node);
495 
496 #ifdef PROP_ASSERTS_ENABLED
497 #define PROP_ASSERT(p, t) assert(p.Typ == t && "invalid property type")
498 #else
499 #define PROP_ASSERT(p, t)
500 #endif
501 
502 // Ugly, but we want to be compatible with C++ and C99, meaning:
503 // cannot use designated initializers (C99, not C++)
504 // cannot use constructors (C++, not C99)
505 
506 #define PROP_VAL_INITIALIZER(typ, suffix, typetag, valtag) \
507  static inline temu_Propval temu_makeProp##suffix(typ val) \
508  { \
509  temu_Propval pv; \
510  pv.Typ = typetag; \
511  pv.valtag = val; \
512  return pv; \
513  } \
514  static inline typ temu_propValue##suffix(temu_Propval pv) \
515  { \
516  PROP_ASSERT(pv.Typ, typetag); \
517  typ val = pv.valtag; \
518  return val; \
519  }
520 
521 PROP_VAL_INITIALIZER(intptr_t, IntPtr, teTY_Intptr, IntPtr)
522 PROP_VAL_INITIALIZER(uintptr_t, UIntPtr, teTY_Uintptr, UIntPtr)
523 
524 PROP_VAL_INITIALIZER(float, Float, teTY_Float, f)
525 PROP_VAL_INITIALIZER(double, Double, teTY_Double, d)
526 
527 PROP_VAL_INITIALIZER(uint8_t, U8, teTY_U8, u8)
528 PROP_VAL_INITIALIZER(uint16_t, U16, teTY_U16, u16)
529 PROP_VAL_INITIALIZER(uint32_t, U32, teTY_U32, u32)
530 PROP_VAL_INITIALIZER(uint64_t, U64, teTY_U64, u64)
531 
532 PROP_VAL_INITIALIZER(int8_t, I8, teTY_I8, i8)
533 PROP_VAL_INITIALIZER(int16_t, I16, teTY_I16, i16)
534 PROP_VAL_INITIALIZER(int32_t, I32, teTY_I32, i32)
535 PROP_VAL_INITIALIZER(int64_t, I64, teTY_I64, i64)
536 
537 PROP_VAL_INITIALIZER(void *, Obj, teTY_Obj, Obj)
539 PROP_VAL_INITIALIZER(const char *, String, teTY_String, String)
540 
547 typedef void (*temu_PropWriter)(void *Obj, temu_Propval Pv, int Idx);
548 
555 typedef temu_Propval (*temu_PropReader)(void *Obj, int Idx);
556 
565 TEMU_API temu_Propref temu_getPropref(const void *Obj, const char *PropName);
566 
576 TEMU_API temu_PropName temu_getPropName(const void *Obj, const char *PropName);
577 
584 TEMU_API int temu_getPropLength(const void *Obj, const char *PropName);
585 
592 TEMU_API int temu_getPropDynLength(const void *Obj, const char *PropName);
593 
600 TEMU_API temu_Type temu_getPropType(const void *Obj, const char *PropName);
601 
609 TEMU_API int temu_objectHasProp(const void *Obj, const char *PropName);
610 
619 TEMU_API int temu_objectHasIface(const void *Obj, const char *IfaceName);
620 
627 
634 
641 
644 
651 
658 
665 
672 
680 TEMU_API temu_Propval temu_getValue(void *Obj, const char *PropName,
681  int Idx) TEMU_NO_WRAP;
682 
683 // Python CTYPES does not like the anonymous union in propval.
691 TEMU_API uint8_t temu_getValueU8(void *Obj, const char *PropName, int Idx);
692 
699 TEMU_API uint16_t temu_getValueU16(void *Obj, const char *PropName, int Idx);
700 
707 TEMU_API uint32_t temu_getValueU32(void *Obj, const char *PropName, int Idx);
708 
715 TEMU_API uint64_t temu_getValueU64(void *Obj, const char *PropName, int Idx);
716 
724 TEMU_API int8_t temu_getValueI8(void *Obj, const char *PropName, int Idx);
725 
733 TEMU_API int16_t temu_getValueI16(void *Obj, const char *PropName, int Idx);
734 
742 TEMU_API int32_t temu_getValueI32(void *Obj, const char *PropName, int Idx);
743 
751 TEMU_API int64_t temu_getValueI64(void *Obj, const char *PropName, int Idx);
752 
763 TEMU_API temu_Propval temu_readValue(void *Obj, const char *PropName,
764  int Idx) TEMU_NO_WRAP;
765 
779 TEMU_API uint8_t temu_readValueU8(void *Obj, const char *PropName, int Idx);
780 
794 TEMU_API uint16_t temu_readValueU16(void *Obj, const char *PropName, int Idx);
795 
809 TEMU_API uint32_t temu_readValueU32(void *Obj, const char *PropName, int Idx);
810 
824 TEMU_API uint64_t temu_readValueU64(void *Obj, const char *PropName, int Idx);
825 
839 TEMU_API int8_t temu_readValueI8(void *Obj, const char *PropName, int Idx);
840 
854 TEMU_API int16_t temu_readValueI16(void *Obj, const char *PropName, int Idx);
855 
869 TEMU_API int32_t temu_readValueI32(void *Obj, const char *PropName, int Idx);
870 
884 TEMU_API int64_t temu_readValueI64(void *Obj, const char *PropName, int Idx);
885 
894 TEMU_API void temu_setValue(void *Obj, const char *PropName, temu_Propval Val,
895  int Idx) TEMU_NO_WRAP;
896 
905 TEMU_API void temu_setValueU8(void *Obj, const char *PropName, uint8_t Val,
906  int Idx);
907 
916 TEMU_API void temu_setValueU16(void *Obj, const char *PropName, uint16_t Val,
917  int Idx);
918 
927 TEMU_API void temu_setValueU32(void *Obj, const char *PropName, uint32_t Val,
928  int Idx);
929 
938 TEMU_API void temu_setValueU64(void *Obj, const char *PropName, uint64_t Val,
939  int Idx);
940 
949 TEMU_API void temu_setValueI8(void *Obj, const char *PropName, int8_t Val,
950  int Idx);
951 
960 TEMU_API void temu_setValueI16(void *Obj, const char *PropName, int16_t Val,
961  int Idx);
962 
971 TEMU_API void temu_setValueI32(void *Obj, const char *PropName, int32_t Val,
972  int Idx);
973 
982 TEMU_API void temu_setValueI64(void *Obj, const char *PropName, int64_t Val,
983  int Idx);
984 
993 TEMU_API void temu_writeValue(void *Obj, const char *PropName, temu_Propval Val,
994  int Idx) TEMU_NO_WRAP;
995 
1004 TEMU_API void temu_writeValueU8(void *Obj, const char *PropName, uint8_t Val,
1005  int Idx);
1006 
1015 TEMU_API void temu_writeValueU16(void *Obj, const char *PropName, uint16_t Val,
1016  int Idx);
1017 
1026 TEMU_API void temu_writeValueU32(void *Obj, const char *PropName, uint32_t Val,
1027  int Idx);
1028 
1037 TEMU_API void temu_writeValueU64(void *Obj, const char *PropName, uint64_t Val,
1038  int Idx);
1039 
1048 TEMU_API void temu_writeValueI8(void *Obj, const char *PropName, int8_t Val,
1049  int Idx);
1050 
1059 TEMU_API void temu_writeValueI16(void *Obj, const char *PropName, int16_t Val,
1060  int Idx);
1061 
1070 TEMU_API void temu_writeValueI32(void *Obj, const char *PropName, int32_t Val,
1071  int Idx);
1072 
1081 TEMU_API void temu_writeValueI64(void *Obj, const char *PropName, int64_t Val,
1082  int Idx);
1083 
1092  const char *PropName, int Idx)
1093  TEMU_NO_WRAP TEMU_DEPRECATED;
1094 
1105  const char *PropName, int Idx)
1106  TEMU_NO_WRAP TEMU_DEPRECATED;
1107 
1114 TEMU_API void temu_setNamedObjectProp(const char *Obj, const char *PropName,
1115  temu_Propval Val,
1116  int Idx) TEMU_NO_WRAP TEMU_DEPRECATED;
1117 
1124 TEMU_API void temu_writeNamedObjectProp(const char *Obj, const char *PropName,
1125  temu_Propval Val,
1126  int Idx) TEMU_NO_WRAP TEMU_DEPRECATED;
1127 
1128 typedef struct temu_CreateArg {
1129  const char *Key;
1131 } temu_CreateArg;
1132 
1133 #define TEMU_NULL_ARG \
1134  { \
1135  NULL, { teTY_Invalid } \
1136  }
1137 
1138 typedef void *(*temu_ObjectCreateFunc)(const char *Name, int Argc,
1139  const temu_CreateArg *Argv);
1140 typedef void (*temu_ObjectDisposeFunc)(void *);
1141 
1154 TEMU_API temu_Class *temu_registerClass(const char *ClsName,
1155  temu_ObjectCreateFunc Create,
1156  temu_ObjectDisposeFunc Dispose);
1157 
1171 TEMU_API temu_Class *
1172 temu_registerExternalClass(const char *ClsName) TEMU_DEPRECATED;
1173 
1174 #ifdef __cplusplus
1175 
1194 TEMU_API void temu_addProperty(temu_Class *Cls, const char *PropName,
1195  int Offset, temu_Type Typ, int Count,
1196  temu_PropWriter Wr = nullptr,
1197  temu_PropReader Rd = nullptr,
1198  const char *Doc = "");
1199 #else
1200 
1219 TEMU_API void temu_addProperty(temu_Class *Cls, const char *PropName,
1220  int Offset, temu_Type Typ, int Count,
1222  const char *Doc);
1223 
1224 #endif
1225 
1253 TEMU_API void temu_addPseudoProperty(temu_Class *Cls, const char *PropName,
1254  temu_Type Typ, int Count,
1257  const char *Doc);
1258 
1266 TEMU_API int temu_addLoggingCategory(temu_Class *Cls, unsigned CategoryId,
1267  const char *Category);
1268 
1275 TEMU_API const char *temu_getLoggingCategory(temu_Class *Cls,
1276  unsigned CategoryId);
1277 
1284 TEMU_API int temu_isPseudoProperty(void *Obj, const char *PropName);
1285 
1291 TEMU_API int temu_isNormalProperty(void *Obj, const char *PropName);
1292 
1303 TEMU_API void temu_requireInterface(temu_Class *Cls, const char *PropName,
1304  const char *IfaceType);
1305 
1324 TEMU_API int temu_addPort(temu_Class *C, const char *IfaceRefName,
1325  const char *IfaceName, const char *Doc);
1326 
1335 #ifdef __cplusplus
1336 
1348 TEMU_API void temu_addInterface(temu_Class *Cls, const char *IfaceName,
1349  const char *IfaceType, void *Iface,
1350  int DeprecatedParam = 0, const char *Doc = "");
1351 
1360 TEMU_API void *temu_getInterface(void *Obj, const char *IfaceName, int Idx = 0);
1361 
1362 #else
1363 TEMU_API void temu_addInterface(temu_Class *Cls,
1364 
1365  const char *IfaceName, const char *IfaceType,
1366  void *Iface, int DeprecatedParam,
1367  const char *Doc);
1368 
1369 TEMU_API void *temu_getInterface(void *Obj, const char *IfaceName, int Idx);
1370 
1371 #endif
1372 
1379 TEMU_API temu_IfaceRef temu_getInterfaceRef(void *Obj, const char *IfaceName,
1380  int Idx);
1381 
1400 TEMU_API void temu_addInterfaceArray(temu_Class *Cls, const char *IfaceName,
1401  const char *IfaceType, void *Iface,
1402  size_t Count, size_t Size,
1403  const char *Doc);
1404 
1418 TEMU_API int temu_setVTable(temu_Class *Cls, void *VTable);
1419 
1425 TEMU_API void *temu_getVTableForClass(temu_Class *Cls);
1426 
1434 TEMU_API void *temu_getVTable(const void *Obj);
1435 
1443 TEMU_API void temu_setTimeSource(void *Obj, void *TS);
1444 
1454 TEMU_API int temu_isExternal(const void *Obj) TEMU_DEPRECATED;
1455 
1456 /*
1457  * Qualification support
1458  *
1459  * Qualifiers can set a tag per class, which can then be used for
1460  * quick identification of an object's class properties. For example
1461  * all objects qualified as CPUs, machines and memories must have the
1462  * vtable set appropriatelly.
1463  */
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
1471 
1472 // Users can set their own class qualifiers, but should use an offset
1473 // from the TEMU_QUAL_USER.
1474 #define TEMU_QUAL_USER 65536
1475 
1482 TEMU_API int temu_isQualifiedAs(const void *Obj, unsigned Qualifier);
1483 
1492 TEMU_API int temu_isCpu(const void *Obj);
1493 
1502 TEMU_API int temu_isMachine(const void *Obj);
1503 
1509 TEMU_API int temu_isMemory(const void *Obj);
1510 
1516 TEMU_API int temu_isComponent(const void *Obj);
1517 
1525 TEMU_API void temu_qualifyAsCpu(void *Cls);
1526 
1534 TEMU_API void temu_qualifyAsMachine(void *Cls);
1535 
1541 TEMU_API void temu_qualifyAsMemory(void *Cls);
1542 
1549 TEMU_API void temu_qualifyAs(void *Cls, unsigned Qualifier);
1550 
1556 TEMU_API void temu_objsysClear(void);
1557 
1561 
1572 TEMU_API void *temu_addObject(const char *ClsName, const char *ObjName,
1573  void *Obj) TEMU_DEPRECATED;
1574 
1588 TEMU_API void *temu_createObject(const char *ClsName, const char *ObjName,
1589  const temu_CreateArg *Args);
1590 
1596 TEMU_API void temu_disposeObject(void *Obj);
1597 
1604 TEMU_API temu_Class *temu_classForName(const char *ClsName);
1605 
1611 TEMU_API const char *temu_nameForClass(temu_Class *Cls);
1612 
1618 TEMU_API temu_Class *temu_classForObject(const void *Obj);
1619 
1625 TEMU_API temu_Class *temu_classForObjectName(const char *Obj) TEMU_DEPRECATED;
1626 
1627 typedef struct {
1628  const char *Name;
1630  size_t Count;
1631  uintptr_t Offset;
1632 } temu_PropInfo;
1633 
1661 TEMU_API int temu_propInfoForClass(temu_Class *Cls, unsigned PIIndex,
1662  unsigned PICount, temu_PropInfo *PI);
1663 
1669 TEMU_API void *temu_objectForName(const char *Name);
1670 
1677 TEMU_API const char *temu_nameForObject(const void *Obj);
1678 
1685 TEMU_API const char *temu_nameForInterface(const void *Obj, const void *Iface);
1686 
1693 TEMU_API const char *temu_typenameForInterface(const void *Obj,
1694  const void *Iface);
1695 
1716 TEMU_API int temu_loadPlugin(const char *PluginName);
1717 
1722 TEMU_API void temu_pluginPathAppend(const char *Path);
1723 
1728 TEMU_API void temu_pluginPathRemove(const char *Path);
1729 
1734 TEMU_API void temu_pluginPathPrint(void);
1735 
1741 TEMU_API const char *temu_typeToName(temu_Type Typ);
1742 
1743 /* NOTE: The getProcessors, getProcsessorCount, getComponents and
1744  getComponentCount functions are experimental and unstable. Do not
1745  rely on these for the moment.
1746 */
1752 TEMU_API void **temu_getProcessors(void);
1753 
1758 TEMU_API size_t temu_getProcessorCount(void);
1759 
1765 TEMU_API void **temu_getComponents(void);
1766 
1771 TEMU_API size_t temu_getComponentCount(void);
1772 
1787 TEMU_API int temu_connect(void *A, const char *PropName, void *B,
1788  const char *IfaceName);
1789 
1804 TEMU_API int temu_serialiseJSON(const char *FileName);
1805 
1818 TEMU_API int temu_deserialiseJSON(const char *FileName);
1819 
1834 TEMU_API void temu_serialiseProp(void *Ctxt, const char *Name, temu_Type Typ,
1835  int Count, void *Data);
1836 
1846 TEMU_API void temu_deserialiseProp(void *Ctxt, void *Obj, const char *Name);
1847 
1854 TEMU_API int temu_checkpointGetLength(void *Ctxt, const char *Name);
1855 
1863 TEMU_API temu_Propval temu_checkpointGetValue(void *Ctxt, const char *Name,
1864  int Idx);
1865 
1878 TEMU_API int temu_checkSanity(int Report);
1879 
1893 TEMU_API int temu_generateObjectGraph(const char *Path, int Display);
1894 
1895 TEMU_API int temu_isValidObjectName(const char *Name);
1896 TEMU_API int temu_isValidClassName(const char *Name);
1897 TEMU_API int temu_isValidInterfaceName(const char *Name);
1898 TEMU_API int temu_isValidPropertyName(const char *Name);
1899 
1904 typedef struct {
1913  void (*serialise)(void *Obj, const char *BaseName, void *Ctxt);
1914 
1924  void (*deserialise)(void *Obj, const char *BaseName, void *Ctxt);
1925 
1932  int (*checkSanity)(void *Obj, int Report); // Optional
1933 
1940  void (*timeSourceSet)(void *Obj);
1941 
1948  void (*printObject)(void *Obj);
1950 #define TEMU_OBJECT_IFACE_TYPE "ObjectIface"
1952 
1953 
1960 TEMU_API void temu_foreachObject(void (*Func)(void *, void *), void *Arg);
1961 
1970 TEMU_API void temu_foreachClass(void (*Func)(temu_Class *, void *), void *Arg);
1971 
1980 TEMU_API void temu_foreachProcessor(void (*Func)(temu_Object *, void *),
1981  void *Arg);
1982 
1994  temu_Class *C, void (*Func)(temu_Class *, const char *, void *), void *Arg);
1995 
2007  temu_Class *C, void (*Func)(temu_Class *, const char *, void *), void *Arg);
2008 
2009 #ifdef __cplusplus
2010 }
2011 #endif
2012 
2013 #endif
TEMU_API temu_Class * temu_classForName(const char *ClsName)
#define TEMU_DEPRECATED
Definition: Attributes.h:21
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)
uintptr_t UIntPtr
Definition: Objsys.h:302
int16_t i16
Definition: Objsys.h:313
temu_Type
Definition: Objsys.h:221
void temu_Dict
Definition: Objsys.h:276
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)
Definition: Objsys.h:547
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)
double d
Definition: Objsys.h:305
TEMU_API void temu_qualifyAsCpu(void *Cls)
TEMU_API const char * temu_getLoggingCategory(temu_Class *Cls, unsigned CategoryId)
int64_t WillDisposeNotification
Definition: Objsys.h:67
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.
Definition: Objsys.h:63
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)
uint16_t u16
Definition: Objsys.h:308
uint32_t Size
Definition: Objsys.h:85
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)
int8_t i8
Definition: Objsys.h:312
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)
Definition: Objsys.h:172
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)
intptr_t IntPtr
Definition: Objsys.h:301
void * VecData
Definition: Objsys.h:280
TEMU_API void temu_pluginPathAppend(const char *Path)
int32_t i32
Definition: Objsys.h:314
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_Buff Buffer
Definition: Objsys.h:321
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_List List
Definition: Objsys.h:324
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)
void * Ptr
Definition: Objsys.h:268
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
void temu_ListNode
Definition: Objsys.h:283
TEMU_API void temu_writeValueI16(void *Obj, const char *PropName, int16_t Val, int Idx)
temu_IfaceRef * Ifaces
Definition: Objsys.h:87
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)
#define TEMU_NONNULL
Definition: Attributes.h:48
const char * Key
Definition: Objsys.h:1129
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
uint32_t u32
Definition: Objsys.h:309
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.
Definition: Objsys.h:1631
TEMU_API int temu_generateObjectGraph(const char *Path, int Display)
void temu_Class
Definition: Objsys.h:58
TEMU_API void temu_writeNamedObjectProp(const char *Obj, const char *PropName, temu_Propval Val, int Idx) TEMU_NO_WRAP TEMU_DEPRECATED
uint8_t u8
Definition: Objsys.h:307
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_Dict * Dict
Definition: Objsys.h:322
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)
void temu_MetaIface
Definition: Objsys.h:59
temu_ListNode * Head
Definition: Objsys.h:287
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)
temu_Type Typ
Definition: Objsys.h:299
#define TEMU_IFACE_REFERENCE_TYPE(N)
Definition: Objsys.h:129
size_t Count
Number of elements in property.
Definition: Objsys.h:1630
TEMU_API void temu_setValueU8(void *Obj, const char *PropName, uint8_t Val, int Idx)
TEMU_API void * temu_objectForName(const char *Name)
uint32_t Reserved
Definition: Objsys.h:86
const char * Name
Name of property.
Definition: Objsys.h:1628
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 * Obj
Definition: Objsys.h:317
temu_Propval Val
Definition: Objsys.h:1130
void *(* temu_ObjectCreateFunc)(const char *Name, int Argc, const temu_CreateArg *Argv)
Definition: Objsys.h:1138
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 *)
Definition: Objsys.h:1140
struct temu_Propref temu_Propref
TEMU_API void ** temu_getComponents(void)
temu_Type Typ
Definition: Objsys.h:286
TEMU_API void temu_writeValueI64(void *Obj, const char *PropName, int64_t Val, int Idx)
temu_IfaceRef IfaceRef
Definition: Objsys.h:318
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)
const char * String
Definition: Objsys.h:320
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)
Definition: Objsys.h:555
uint64_t LoggingFlags
Log category enabled/disabled.
Definition: Objsys.h:65
temu_Component * Component
Parent component (null for root comp)
Definition: Objsys.h:64
TEMU_API int8_t temu_readValueI8(void *Obj, const char *PropName, int Idx)
TEMU_API temu_Class * temu_classForObjectName(const char *Obj) TEMU_DEPRECATED
const char * Name
Definition: Objsys.h:273
TEMU_API int temu_serialiseJSON(const char *FileName)
TEMU_API void temu_foreachProcessor(void(*Func)(temu_Object *, void *), void *Arg)
void * Obj
Definition: Objsys.h:76
TEMU_API int temu_isMachine(const void *Obj)
TEMU_API temu_PropName temu_getPropName(const void *Obj, const char *PropName)
void * Obj
Definition: Objsys.h:272
TEMU_API int temu_isQualifiedAs(const void *Obj, unsigned Qualifier)
TEMU_API int temu_dictInsertValue(temu_Dict *Dict, const char *Name, temu_Propval Val)
int64_t i64
Definition: Objsys.h:315
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)
Definition: Objsys.h:506
TEMU_API void * temu_getVTable(const void *Obj)
#define TEMU_NO_WRAP
Definition: Objsys.h:41
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)
void * Iface
Definition: Objsys.h:77
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)
uint64_t u64
Definition: Objsys.h:310
struct temu_Component temu_Component
Definition: Component.h:27
TEMU_API void temu_setTimeSource(void *Obj, void *TS)
TEMU_API temu_Vector temu_vecCreate(temu_Type Typ)
temu_Vector Vector
Definition: Objsys.h:323
TEMU_API void temu_qualifyAs(void *Cls, unsigned Qualifier)
float f
Definition: Objsys.h:304
temu_ListNode * Tail
Definition: Objsys.h:288
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
Definition: Objsys.h:319
TEMU_API void temu_setValueU64(void *Obj, const char *PropName, uint64_t Val, int Idx)
temu_Class * Class
Class pointer.
Definition: Objsys.h:62
TEMU_API void temu_qualifyAsMachine(void *Cls)
TEMU_API temu_Class * temu_classForObject(const void *Obj)
temu_Type Typ
Definition: Objsys.h:279
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_Type Typ
Type tag.
Definition: Objsys.h:1629
#define TEMU_API
Definition: Attributes.h:53
temu_Type Typ
Definition: Objsys.h:267
TEMU_API void * temu_vecGetData(temu_Vector *Vec)