TEMU  4.4
The Terma Emulator
Objsys.h
Go to the documentation of this file.
1 //===-- temu-c/Objsys.h - TEMU Object System -------------------*- C++ -*-===//
2 //
3 // TEMU: The Terma Emulator
4 // (c) Terma 2015, 2016, 2021
5 // Authors: Mattias Holm <maho (at) terma.com>
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef TEMU_OBJSYS_C_H
10 #define TEMU_OBJSYS_C_H
11 
12 #include "temu-c/Support/Attributes.h"
13 #include "temu-c/Support/Temu2Compat.h"
14 #include "temu-c/Support/Temu3Compat.h"
15 #include <assert.h>
16 #include <stddef.h>
17 #include <stdint.h>
18 #include <stdlib.h>
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 #ifdef __cplusplus
25 #define TEMU_PLUGIN_INIT extern "C" TEMU_API void temu_pluginInit(void)
26 #else
27 #define TEMU_PLUGIN_INIT TEMU_API void temu_pluginInit(void)
28 #endif
29 
30 #if defined(__has_attribute)
31 #if __has_attribute(annotate)
32 #define TEMU_NO_WRAP __attribute__((annotate("temu-no-wrap")))
33 #endif
34 #endif
35 
36 #ifdef __cplusplus
37 #if (__cplusplus < 201103L) && !defined(nullptr)
38 #define nullptr 0
39 #endif
40 #endif
41 
42 #if !defined(TEMU_NO_WRAP)
43 #define TEMU_NO_WRAP
44 #endif
45 
46 #ifndef TEMU_BUFF_DEFINED
47 #define TEMU_BUFF_DEFINED
48 typedef struct {
49  uintptr_t data0;
50  uint32_t data1;
51  uint32_t data2;
52 } temu_Buff;
53 #endif // !TEMU_BUFF_DEFINED
54 
55 #ifndef TEMU_COMPONENT_DEFINED
56 #define TEMU_COMPONENT_DEFINED
57 typedef struct temu_Component temu_Component;
58 #endif // !TEMU_COMPONENT_DEFINED
59 
60 typedef struct temu_Class temu_Class;
61 typedef void temu_MetaIface;
62 
63 typedef struct temu_TimeSource temu_TimeSource;
64 
65 /*!
66  Root object type for all TEMU objects.
67 
68  The TEMU object system is used for defining models in TEMU.
69  All models must derive from `temu_Object`.
70 
71  Inheritance in C is done by placing a `temu_Object` field
72  as the first field in the derived struct.
73 
74  TEMU by convention use the name `Super` for the parent field name.
75 
76  The type contains a `UserData` void pointer that can be used by for example
77  simulator integrators.
78  The `UserData` field can be written by the user.
79  The field is guaranteed to not be modified by the TEMU runtime.
80 
81  \note While the convention in C is safe,
82  in {cpp} it is the responsibility of the user to ensure
83  that the derived type is a _standard layout type_.
84  */
85 typedef struct temu_Object {
86  temu_Class *Class; //!< Class pointer
87  char *Name; //!< Object name
88  temu_TimeSource *TimeSource; //!< Timesource object
89  temu_Component *Component; //!< Parent component (null for root comp)
90  uint64_t LoggingFlags; //!< Log category enabled/disabled
91  int64_t WillDisposeNotification; //!< Notification emitted before object is
92  //!< deleted
93  int64_t DisposedNotification; //!< Notification emitted after object has been
94  //!< deleted
95 
96  void *UserData; //!< User data pointer. This is not saved in snapshots.
97 
98  uint64_t IsClassObject : 1; //!< The object is a class object
99  uint64_t IsCheckpointable : 1; //!< The object is snapshottable
100  uint64_t IsTimeSource : 1; //!< The object is a time source (can be safely
101  //!< casted to temu_TimeSource)
102  uint64_t TraceMemoryReads : 1; //!< Memory read accesses to this object will
103  //!< be traced by memory space
104  uint64_t TraceMemoryWrites : 1; //!< Memory write accesses to this object will
105  //!< be traced by memory space
106  uint64_t BreakOnMemoryRead : 1; //!< Memory read accesses to this object will
107  //!< trigger break
108  uint64_t BreakOnMemoryWrite : 1; //!< Memory write accesses to this object
109  //!< will trigger break
110 } temu_Object;
111 
112 /*!
113  Generic interface
114 
115  In TEMU interfaces are referred to using an object / interface pointer pair.
116  The object is in general passed as the first parameter to functions in the
117  interface. This type provides a generic interface reference where the
118  interface pointer itself is type erased.
119 
120  While the type is rarely used by itself, it is commonly returned by the TEMU
121  API. To convert to / from this type from / to typed interface references, it
122  is possible to either memcopy or cast field by field.
123  */
124 typedef struct temu_IfaceRef {
125  temu_Object_ *Obj; //!< Object pointer (first field of interface reference)
126  void *Iface; //!< Type erased interface pointer
127 } temu_IfaceRef;
128 
129 /*!
130  Dynamic interface reference array
131 
132  In some cases, the number of objects we know about is unknown.
133  To solve that TEMU provides a vector like type.
134 
135  \note It is not the intention that the fields in the array are manipulated
136  directly. Instead, use the `temu_ifaceRefArray*` functions.
137 */
138 typedef struct temu_IfaceRefArray {
139  uint32_t Size; //!< Number of used items in array
140  uint32_t Reserved; //!< Number of slots allocated for array
141  temu_IfaceRef *Ifaces; //!< Interface references
142 } temu_IfaceRefArray;
143 
144 /*!
145  Allocate interface array.
146 
147  \param Reserve Number of entries to reserve initially.
148  \result The allocated interface array.
149  */
150 TEMU_API temu_IfaceRefArray temu_ifaceRefArrayAlloc(unsigned Reserve);
151 
152 /*!
153  Push an object and raw interface pointer to an interface array.
154  \param Arr The interface reference array.
155  \param Obj The object implementing the relevant interface
156  \param Iface Pointer to the interface struct.
157  */
160  void *Iface TEMU_NONNULL);
161 
162 /*!
163  Push an interface reference to the interface array.
164  \param Arr The interface reference array
165  \param Iface The interface reference (object-interface pointer pair)
166  */
167 
170 
171 /*!
172  Get the length of a dynamically allocated interface array.
173  \param Arr The interface array to get the size from.
174  \result The length in number of entries.
175  */
176 TEMU_API unsigned
178 
179 /*!
180  Get the index of the interface reference array.
181  \param Arr The interface reference array
182  \param idx is the index of the array
183  \result The interface array with in bounds.
184  */
185 TEMU_API temu_IfaceRef temu_ifaceRefArrayGet(temu_IfaceRefArray *Arr,
186  unsigned idx);
187 
189 
190 /*!
191  Easy way of declaring typed interface references and interface reference
192  arrays.
193  */
194 #define TEMU_IFACE_REFERENCE_TYPE(N)
195  typedef struct {
196  temu_Object_ *Obj; /*!< Object pointer */
197  N##Iface *Iface; /*!< Typed interface pointer */
198  } N##IfaceRef;
199  typedef struct {
200  uint32_t Size;
201  uint32_t Reserved;
202  N##IfaceRef *Ifaces;
203  } N##IfaceRefArray;
204  static inline N##IfaceRefArray N##IfaceRefArrayAlloc(unsigned Reserve)
205  {
206  temu_IfaceRefArray Arr = temu_ifaceRefArrayAlloc(Reserve);
207  N##IfaceRefArray Res;
208  Res.Size = Arr.Size;
209  Res.Reserved = Arr.Reserved;
210  Res.Ifaces = (N##IfaceRef *)Arr.Ifaces;
211  return Res;
212  }
213  static inline void N##IfaceRefArrayDispose(N##IfaceRefArray *Arr)
214  {
215  temu_ifaceRefArrayDispose((temu_IfaceRefArray *)Arr);
216  }
217  static inline void N##IfaceRefArrayPush2(N##IfaceRefArray *Arr,
218  temu_Object_ *Obj, void *Iface)
219  {
220  temu_ifaceRefArrayPush2((temu_IfaceRefArray *)Arr, Obj, Iface);
221  }
222  static inline void N##IfaceRefArrayPush(N##IfaceRefArray *Arr,
223  N##IfaceRef Iface)
224  {
225  temu_IfaceRef Iface2;
226  Iface2.Obj = Iface.Obj;
227  Iface2.Iface = (void *)Iface.Iface;
228 
229  temu_ifaceRefArrayPush((temu_IfaceRefArray *)Arr, Iface2);
230  }
231  static inline unsigned N##IfaceRefArraySize(N##IfaceRefArray *Arr)
232  {
233  return Arr->Size;
234  }
235  static inline void N##IfaceRefArrayPop(N##IfaceRefArray *Arr)
236  {
237  Arr->Size--;
238  }
239 
240 #define TEMU_DYN_ARRAY_TYPE(T, P)
241  typedef struct {
242  uint32_t Size;
243  uint32_t Reserved;
244  T *Values;
245  } temu_##P##Array;
246  static inline temu_##P##Array TEMU_MAYBE_UNUSED temu_##P##ArrayAlloc(
247  unsigned Reserve)
248  {
249  assert(Reserve > 0);
250  temu_##P##Array Arr;
251  Arr.Size = 0;
252  Arr.Reserved = Reserve;
253  Arr.Values = (T *)calloc(Reserve, sizeof(T));
254  assert(Arr.Values);
255  return Arr;
256  }
257  static inline void TEMU_MAYBE_UNUSED temu_##P##ArrayPush(
258  temu_##P##Array *Arr, T Val)
259  {
260  if (Arr->Reserved >= Arr->Size) {
261  T *NewValues = (T *)realloc(Arr->Values, Arr->Reserved * 2);
262  if (NewValues) {
263  Arr->Values = NewValues;
264  } else {
265  abort();
266  }
267  }
268  Arr->Values[Arr->Size++] = Val;
269  }
270  static inline unsigned TEMU_MAYBE_UNUSED temu_##P##ArraySize(
271  temu_##P##Array *Arr)
272  {
273  return Arr->Size;
274  }
275  static inline void TEMU_MAYBE_UNUSED temu_##P##ArrayPop(
276  temu_##P##Array *Arr)
277  {
278  if (Arr->Size > 0)
279  Arr->Size--;
280  }
281 
282 TEMU_DYN_ARRAY_TYPE(int8_t, i8)
283 TEMU_DYN_ARRAY_TYPE(int16_t, i16)
284 TEMU_DYN_ARRAY_TYPE(int32_t, i32)
285 TEMU_DYN_ARRAY_TYPE(int64_t, i64)
286 
287 TEMU_DYN_ARRAY_TYPE(uint8_t, u8)
288 TEMU_DYN_ARRAY_TYPE(uint16_t, u16)
289 TEMU_DYN_ARRAY_TYPE(uint32_t, u32)
290 TEMU_DYN_ARRAY_TYPE(uint64_t, u64)
291 TEMU_DYN_ARRAY_TYPE(temu_Object_ *, object)
292 
293 /*!
294  Type tag
295 
296  The TEMU object system uses type tags to track which type is registered and
297  in use at runtime. Type tags are used in for example the property
298  registration functions.
299  */
300 typedef enum temu_Type {
301  teTY_Invalid, //!< Invalid value 0
302 
303  // C pointer sized integers
304  teTY_Intptr, //!< Pointer sized signed integer (intptr_t)
305  teTY_Uintptr, //!< Pointer sized unsigned integer (uintptr_t)
306 
307  // Standard C floating point types
308  teTY_Float, //!< Single precision floating point value
309  teTY_Double, //!< Double precision floating point value
310 
311  // Standard C fixed width integer types
312  teTY_U8, //!< 8-bit fixed width unsigned integer
313  teTY_U16, //!< 16-bit fixed width unsigned integer
314  teTY_U32, //!< 32-bit fixed width unsigned integer
315  teTY_U64, //!< 64-bit fixed width unsigned integer
316  teTY_I8, //!< 8-bit fixed width signed integer
317  teTY_I16, //!< 16-bit fixed width signed integer
318  teTY_I32, //!< 32-bit fixed width signed integer
319  teTY_I64, //!< 64-bit fixed width signed integer
320 
321  // Object pointer, must be saved as an object reference
322  teTY_Obj, //!< Pointer to temu_Object
323 
324  // Internal pointer, points somewhere in the object itself
325  // (e.g. bank resolution arrays) This can be saved as an offset...
326  teTY_InternalPtr, //!< Internal pointer
327 
328  // Interface references (object and interface pointer pair)
329  teTY_IfaceRef, //!< Interface reference
330  teTY_IfaceRefArray, //!< Dynamic object/interface array
331 
332  teTY_String, //!< C-string, useful for serialization
333  teTY_Buffer, //!< Buffer (see Buffer.h)
334  teTY_Dict, //!< Dictionary
335  teTY_Vector, //!< Vector (i.e. dynamic array)
336  teTY_List, //!< List
337 } temu_Type;
338 
339 /*!
340  Typed property reference.
341 
342  The property reference contains a type tag and a raw pointer to the
343  property.
344  */
345 typedef struct temu_Propref {
346  temu_Type Typ; //!< Type of property
347  void *Ptr; //!< Pointer to property
348 } temu_Propref;
349 
350 /*!
351  * Named property reference
352  */
353 typedef struct {
354  temu_Object_ *Obj; //!< Object pointer
355  const char *Name; //!< Property name
356 } temu_PropName;
357 
358 typedef void temu_Dict;
359 
360 /*!
361  * Dynamically sized array
362  */
363 typedef struct {
364  temu_Type Typ; //!< Type of vector data
365  void *VecData; //!< Managed pointer, do not use directly
366  uint32_t Size; //!< Managed do not use directly
367  uint32_t Capacity; //!< Managed do not use directly
368 } temu_Vector;
369 
370 typedef void temu_ListNode;
371 
372 /*!
373  * Linked list type
374  */
375 typedef struct {
376  temu_Type Typ; //!< Element type in list
377  temu_ListNode *Head; //!< Managed pointer, do not use directly
378  temu_ListNode *Tail; //!< Managed pointer, do not use directly
379 } temu_List;
380 
381 /*!
382  Generic property value.
383 
384  As properties can be of any normal type, the propval struct provides
385  a sum type/tagged union which contain both the type tag and the
386  property value.
387  */
388 typedef struct temu_Propval {
389  temu_Type Typ; //!< Value type
390  union {
391  intptr_t IntPtr;
392  uintptr_t UIntPtr;
393 
394  float f;
395  double d;
396 
397  uint8_t u8;
398  uint16_t u16;
399  uint32_t u32;
400  uint64_t u64;
401 
402  int8_t i8;
403  int16_t i16;
404  int32_t i32;
405  int64_t i64;
406 
407  temu_Object_ *Obj;
408  temu_IfaceRef IfaceRef;
409  temu_IfaceRefArray IfaceRefArray;
410  const char *String;
411  temu_Buff Buffer;
412  temu_Dict *Dict;
413  temu_Vector Vector;
414  temu_List List;
415  };
416 } temu_Propval;
417 
418 /*!
419  Generic constructor argument
420 
421  The object constructors takes an array of key/value pairs as parameters.
422  The values are passed using either:
423 
424  - Registered argument in the `Class.new` command method.
425  - Explicitly to `temu_createObject()`.
426  - Args parameter to `object-create` global command.
427 
428  The object create function would typically scan through the array,
429  finding relevant matching keys.
430  */
431 typedef struct temu_CreateArg {
432  const char *Key; //!< Name of argument
433  temu_Propval Val; //!< Value of argument
434 } temu_CreateArg;
435 
436 #define TEMU_NULL_ARG
437  {
438  NULL,
439  {
440  teTY_Invalid
441  }
442  }
443 
444 typedef void *(*temu_ObjectCreateFunc)(const char *Name, int Argc,
445  const temu_CreateArg *Argv);
446 typedef void (*temu_ObjectDisposeFunc)(void *);
447 
448 /*!
449  Class object
450 
451  The TEMU object system is a dynamic object system.
452  Classes are themselves represented as objects (instanciated by meta-classes).
453 
454  The TEMU class contains among other things the constructor/destructor.
455  Internally, the hidden implementation provides more capabilities than is
456  exposed by the `temu_Class` type.
457  */
458 struct temu_Class {
459  temu_Object Super; //!< Super class of the class instance.
460  void *Impl; //!< Internal pointer, do not touch.
461  void *VTable; //!< Internal pointer, do not touch.
462  temu_ObjectCreateFunc Create; //!< Constructor / create function for creating
463  //!< instances of the class.
464  temu_ObjectDisposeFunc Dispose; //!< Destructor / dispose function for
465  //!< disposing instances of the class.
466  const char *LoggingCategories[32]; // Named logging categories.
467 };
468 
469 // Dictionary support. Dictionaries are data structure that contain
470 // named prop values. They are not meant for high performing code, but
471 // are useful for advanced configuration capabilities. In practice
472 // dictionaries work for any type, but snapshots will not yet work
473 // for entries containing complex types (temu_Buff, temu_Vector and
474 // other dictionaries). This will be addressed in the future.
475 
476 /*!
477  * Creates a dictionary object
478  * \result A pointer to the dictionary object
479  */
480 TEMU_API temu_Dict *temu_dictCreate(void);
481 
482 /*!
483  * Delete a dictionary object
484  *
485  * \param Dict Pointer to the dictionary object to be deleted
486  */
488 
489 /*!
490  * Inserts a name/value pair to a dictionary
491  *
492  * \param Dict Pointer to the dictionary object
493  * \param Name The name to be inserted
494  * \param Val The value to be inserted
495  * \result 0 on success. Other values indicate failures (e.g. the key is already
496  * used)
497  */
499  temu_Propval Val);
500 
501 /*!
502  * Retrieve a dictionary value by name
503  *
504  * \param Dict Pointer to the dictionary object
505  * \param Name The name associated with the value to be retrieved
506  * \result The value
507  */
508 TEMU_API temu_Propval temu_dictGetValue(temu_Dict *Dict, const char *Name);
509 
510 /*!
511  * Erase a name/value pair from a dictionary by name
512  *
513  * \param Dict Pointer to the dictionary object
514  * \param Name The name of the pair to be removed
515  * \result 0 on success. Other values indicate errors (e.g. key was unavailable
516  * in the dictionary)
517  */
518 TEMU_API int temu_dictRemoveValue(temu_Dict *Dict, const char *Name);
519 
520 /*!
521  * Given a specific key of a dictionary, the next key is
522  * provided by this function
523  *
524  * \param Dict The dictionary that contains the keys
525  * \param Key The key, whose next value in the dict to be provided
526  * \result The key that comes after Key, or nullptr on failure
527  */
528 TEMU_API const char *temu_dictGetNextKey(temu_Dict *Dict, const char *Key);
529 
530 // Typed vector support. The typed vectors can be described as a C++
531 // std::vector, however, they are expressed as a C-API here and
532 // supports snapshots.
533 
534 /*!
535  * Create a vector object
536  *
537  * \param Typ The type of the elements
538  * \result the vector object created
539  */
540 TEMU_API temu_Vector temu_vecCreate(temu_Type Typ);
541 
542 /*!
543  * Delete a vector object
544  *
545  * \param Vec The vector object to be deleted
546  */
548 
549 /*!
550  * Add an element to a vector object
551  *
552  * \param Vec The vector, to which the element to be added
553  * \param Val The element to be added
554  */
556 
557 /*!
558  * Retrieve the array of elements of a vector
559  *
560  * \param Vec The vector, whose elements are requested
561  * \result Returns a pointer to the first element of the vector
562  */
564 
565 /*!
566  * Get the number of elements of a vector
567  *
568  * \param Vec The vector, whose size to be retrieved
569  * \result The number of elements in Vec
570  */
571 TEMU_API size_t temu_vecGetSize(temu_Vector *Vec);
572 
573 /*!
574  * Create a linked-list object
575  *
576  * \param Typ The type to be stored in the elements of the linked list
577  * \result A newly created list.
578  */
579 TEMU_API temu_List temu_listCreate(temu_Type Typ);
580 
581 /*!
582  * Delete a linked-list object
583  *
584  * \param List The list to be deleted
585  */
587 
588 /*!
589  * Add an element to the end of a linked-list
590  *
591  * \param List The list, to which the element to be added
592  * \param Val The element to be added
593  */
595 
596 /*!
597  * Add an element to the beginning of a linked-list
598  *
599  * \param List The list, to which the element to be added
600  * \param Val The element to be added
601  */
603 
604 /*!
605  * Removes the first element of a linked-list
606  *
607  * \param List The list, from which the first element to be removed
608  * \result The element that was removed from the list
609  */
610 TEMU_API temu_Propval temu_listRemoveHead(temu_List *List);
611 
612 /*!
613  * Removes the last element of a linked-list
614  *
615  * \param List The list, from which the last element to be removed
616  * \result The element that was removed from the list
617  */
618 TEMU_API temu_Propval temu_listRemoveTail(temu_List *List);
619 
620 /*!
621  * Get the first element of a linked-list
622  *
623  * \param List The list, whose first element is requested
624  * \result Pointer to the first element of the linked-list
625  */
626 TEMU_API temu_ListNode *temu_listGetHead(temu_List *List);
627 
628 /*!
629  * Get the last element of a linked-list
630  *
631  * \param List The list, whose last element is requested
632  * \result Pointer to the last element of the linked-list
633  */
634 TEMU_API temu_ListNode *temu_listGetTail(temu_List *List);
635 
636 /*!
637  * Get the next element of a linked list
638  *
639  * \param Node The node, whose next element is requested
640  * \result The next element if available, otherwise nullptr
641  */
642 TEMU_API temu_ListNode *temu_listGetNext(temu_ListNode *Node);
643 
644 /*!
645  * Get the previous element of a linked list
646  *
647  * \param Node The node, whose next element is requested
648  * \result The previous element if available, otherwise nullptr
649  */
650 TEMU_API temu_ListNode *temu_listGetPrev(temu_ListNode *Node);
651 
652 /*!
653  * Get value of a linked-list node
654  *
655  * \param Node The node, from which the value to be extracted
656  * \result The value extracted from the node
657  */
658 TEMU_API temu_Propval temu_listNodeGetVal(temu_ListNode *Node);
659 
660 #ifdef PROP_ASSERTS_ENABLED
661 #define PROP_ASSERT(p, t) assert(p.Typ == t && "invalid property type")
662 #else
663 #define PROP_ASSERT(p, t)
664 #endif
665 
666 // This is not the nicest solution,
667 // but we want to be compatible with C++ and C99, meaning:
668 // - cannot use designated initializers (C99, not C++)
669 // - cannot use constructors (C++, not C99)
670 
671 #define PROP_VAL_INITIALIZER(typ, suffix, typetag, valtag)
672  static inline temu_Propval temu_makeProp##suffix(typ val)
673  {
674  temu_Propval pv;
675  pv.Typ = typetag;
676  pv.valtag = val;
677  return pv;
678  }
679  static inline typ temu_propValue##suffix(temu_Propval pv)
680  {
681  PROP_ASSERT(pv.Typ, typetag);
682  typ val = pv.valtag;
683  return val;
684  }
685 
686 PROP_VAL_INITIALIZER(intptr_t, IntPtr, teTY_Intptr, IntPtr)
687 PROP_VAL_INITIALIZER(uintptr_t, UIntPtr, teTY_Uintptr, UIntPtr)
688 
689 PROP_VAL_INITIALIZER(float, Float, teTY_Float, f)
690 PROP_VAL_INITIALIZER(double, Double, teTY_Double, d)
691 
692 PROP_VAL_INITIALIZER(uint8_t, U8, teTY_U8, u8)
693 PROP_VAL_INITIALIZER(uint16_t, U16, teTY_U16, u16)
694 PROP_VAL_INITIALIZER(uint32_t, U32, teTY_U32, u32)
695 PROP_VAL_INITIALIZER(uint64_t, U64, teTY_U64, u64)
696 
697 PROP_VAL_INITIALIZER(int8_t, I8, teTY_I8, i8)
698 PROP_VAL_INITIALIZER(int16_t, I16, teTY_I16, i16)
699 PROP_VAL_INITIALIZER(int32_t, I32, teTY_I32, i32)
700 PROP_VAL_INITIALIZER(int64_t, I64, teTY_I64, i64)
701 
702 PROP_VAL_INITIALIZER(temu_Object_ *, Obj, teTY_Obj, Obj)
703 PROP_VAL_INITIALIZER(temu_IfaceRef, IfaceRef, teTY_IfaceRef, IfaceRef)
704 PROP_VAL_INITIALIZER(const char *, String, teTY_String, String)
705 
706 /*! A prop writer function is provided when properties are
707  * registered, it is responsible for writing the property when
708  * temu_writeValue is called. The function can be used to introduce
709  * side-effects on writes unlike the setValue which will never have
710  * side-effects and only sets the raw value.
711  */
712 typedef void (*temu_PropWriter)(void *Obj, temu_Propval Pv, int Idx);
713 
714 /*! A prop reader function is provided when properties are
715  * registered, it is responsible for reading the property when
716  * temu_readValue is called. The function can be used to introduce
717  * side-effects on reads unlike the getValue which will never have
718  * side-effects and only returns the raw value.
719  */
720 typedef temu_Propval (*temu_PropReader)(void *Obj, int Idx);
721 
722 /*!
723  Get a reference to the named property.
724  The propref is a typetag and a pointer to the raw value, as such it does
725  not work with delegated properties in components, nor with pseudo properties.
726 
727  \param Obj An object of a class with the relevant property registered.
728  \param PropName The name of the property to be queried.
729  \result Object of the property reference
730  */
731 TEMU_API temu_Propref temu_getPropref(const temu_Object_ *Obj,
732  const char *PropName);
733 
734 /**!
735  * Generic property accessor
736  *
737  * This struct serves as a generic accessor for properties.
738  * The intention for this is to be able to cache property accessors,
739  * without having to disambiguate between properties and pseudo properties.
740  *
741  * The accessor is queried by the temu_getPropAccessor function,
742  * and is then used by calling the functions:
743  *
744  * - `readProp`
745  * - `writeProp`
746  * - `getProp`
747  * - `setProp`
748  *
749  * Depending on whether read, write, get or set semantics is needed.
750  */
751 typedef struct temu_PropAccessor {
752  temu_Type Typ; //!< Type of property
753  temu_Object *Obj; //!< Pointer to object containing property
754  int Index; //!< Index used in access, can be modified by user
755 
756  void *Data; //!< Pointer to value if applicable
757  temu_PropWriter Writer; //!< Writer function if applicable
758  temu_PropReader Reader; //!< Reader function if applicable
759  temu_PropWriter Setter; //!< Setter function if applicable
760  temu_PropReader Getter; //!< Getter function if applicable
761 
762  temu_Propval (*readProp)(
763  struct temu_PropAccessor *accessor); //!< Read property via accessor
764  void (*writeProp)(struct temu_PropAccessor *accessor,
765  temu_Propval pv); //!< Write property via accessor
766  temu_Propval (*getProp)(
767  struct temu_PropAccessor *accessor); //!< Get property via accessor
768  void (*setProp)(struct temu_PropAccessor *accessor,
769  temu_Propval pv); //!< Set property via accessor
770 } temu_PropAccessor;
771 
772 /*!
773  Get a reference to the named property
774 
775  This is useful as a replacement of temu_getPropref and temu_getPropName.
776  The resulting data structure lets you automatically disambiguate between
777  properties and pseudo properties.
778 
779  The index used will be PropIdx,
780  or K if the PropName string has an array suffix `[K]`.
781 
782  \param Obj An object of a class with the relevant property registered.
783  \param PropName The name of the property to be queried.
784  \param PropIdx Index in property array.
785  \result A struct containing prop accessor data.
786  */
787 
788 TEMU_API temu_PropAccessor temu_getPropAccessor(temu_Object *Obj,
789  const char *PropName,
790  int PropIdx);
791 
792 /*!
793  Get a reference to a named property.
794 
795  \param Obj An object of a class with the relevant property registered.
796  \param PropName The name of the property to be queried.
797 
798  \result Prop name object, note that the returned name string is not
799  the same as the passed string. The returned string has a lifetime
800  bound to the class, hence it can be returned without any problems.
801  */
802 TEMU_API temu_PropName temu_getPropName(const temu_Object_ *Obj,
803  const char *PropName);
804 
805 /*!
806  * Returns property length/size if a property is an array
807  *
808  * \param Obj Pointer to the object of the property
809  * \param PropName Name of the property
810  * \result The length of the property
811  */
812 TEMU_API int temu_getPropLength(const temu_Object_ *Obj, const char *PropName);
813 
814 /*!
815  * Get the dynamic length of the property
816  *
817  * Normally, the `temu_getPropLength()` would return 1 for a dynamic array.
818  * This means that there is one dynamic array.
819  * In case the length of the dynamic array is needed, this function can be used.
820  *
821  * \param Obj Pointer to the object of the property
822  * \param PropName Name of the property
823  * \result Dynamic length of property
824  */
826  const char *PropName);
827 
828 /*!
829  * Get the type of a property
830  *
831  * \param Obj Pointer to the object of the property
832  * \param PropName Name of the property
833  * \result Property type
834  */
835 TEMU_API temu_Type temu_getPropType(const temu_Object_ *Obj,
836  const char *PropName);
837 
838 /*!
839  * Check if the object has a named property
840  *
841  * \param Obj Pointer to the object of the property
842  * \param PropName Name of the property
843  * \result 0 if the property does not exist, otherwise the property is valid
844  */
845 TEMU_API int temu_objectHasProp(const temu_Object_ *Obj, const char *PropName);
846 
847 /*!
848  * Check if the object has a named interface
849  *
850  * \param Obj Pointer to the object to query
851  * \param IfaceName Interface name to look for
852  * \result 0 if the interface does not exist, otherwise the interface exists
853  */
854 
856  const char *IfaceName);
857 
858 /*!
859  * Checks whether a property is a number
860  *
861  * \param Pv The property to be checked
862  * \result 0 for false, non-zero for true
863  */
865 
866 /*!
867  * Checks whether a property is a real number
868  *
869  * \param Pv The property to be checked
870  * \result 0 for false, non-zero for true
871  */
873 
874 /*!
875  * Checks whether the numeric property is an integer-like
876  *
877  * \param Pv The property to be checked
878  * \result 0 for false, non-zero for true
879  */
881 
884 
885 /*!
886  * Checks whether a property is a string
887  *
888  * \param Pv The property to be checked
889  * \result 0 for false, non-zero for true
890  */
892 
893 /*!
894  * Converts the given propery to integer
895  *
896  * \param Pv The property to be converted
897  * \result Returns the property as integer
898  */
899 TEMU_API int64_t temu_asInteger(temu_Propval Pv);
900 
901 /*!
902  * Converts the given property to unsigned integer
903  *
904  * \param Pv The property to be converted
905  * \result Returns the property as an unsigned integer
906  */
907 TEMU_API uint64_t temu_asUnsigned(temu_Propval Pv);
908 
909 /*!
910  * Converts the given property to double
911  *
912  * \param Pv The property to be converted
913  * \result Returns the property as an unsigned integer
914  */
916 
917 /*!
918  * Get the value of a property from an object
919  *
920  * \param Obj The object that contains the property
921  * \param PropName Property name
922  * \param Idx Index of the property. Set to 0 if the property is not an array
923  * \result The value of the property
924  */
925 TEMU_API temu_Propval temu_getValue(temu_Object_ *Obj, const char *PropName,
926  int Idx) TEMU_NO_WRAP;
927 
928 /*!
929  * Get the value of a property from an object if it is an uint8
930  *
931  * \param Obj The object that contains the property
932  * \param PropName Property name
933  * \param Idx Index of the property. Set to 0 if the property is not an array
934  * \result The value of the property
935  */
936 TEMU_API uint8_t temu_getValueU8(temu_Object_ *Obj, const char *PropName,
937  int Idx);
938 
939 /*!
940  * Get the value of a property from an object if it is an uint16
941  *
942  * \param Obj The object that contains the property
943  * \param PropName Property name
944  * \param Idx Index of the property. Set to 0 if the property is not an array
945  * \result The value of the property
946  */
947 TEMU_API uint16_t temu_getValueU16(temu_Object_ *Obj, const char *PropName,
948  int Idx);
949 
950 /*!
951  * Get the value of a property from an object if it is an uint32
952  *
953  * \param Obj The object that contains the property
954  * \param PropName Property name
955  * \param Idx Index of the property. Set to 0 if the property is not an array
956  * \result The value of the property
957  */
958 TEMU_API uint32_t temu_getValueU32(temu_Object_ *Obj, const char *PropName,
959  int Idx);
960 
961 /*!
962  * Get the value of a property from an object if it is an uint64
963  *
964  * \param Obj The object that contains the property
965  * \param PropName Property name
966  * \param Idx Index of the property. Set to 0 if the property is not an array
967  * \result The value of the property
968  */
969 TEMU_API uint64_t temu_getValueU64(temu_Object_ *Obj, const char *PropName,
970  int Idx);
971 
972 /*!
973  * Get the value of a property from an object if it is an int8
974  *
975  * \param Obj The object that contains the property
976  * \param PropName Property name
977  * \param Idx Index of the property. Set to 0 if the property is not an array
978  * \result The value of the property
979  */
980 TEMU_API int8_t temu_getValueI8(temu_Object_ *Obj, const char *PropName,
981  int Idx);
982 
983 /*!
984  * Get the value of a property from an object if it is an int16
985  *
986  * \param Obj The object that contains the property
987  * \param PropName Property name
988  * \param Idx Index of the property. Set to 0 if the property is not an array
989  * \result The value of the property
990  */
991 TEMU_API int16_t temu_getValueI16(temu_Object_ *Obj, const char *PropName,
992  int Idx);
993 
994 /*!
995  * Get the value of a property from an object if it is an int32
996  *
997  * \param Obj The object that contains the property
998  * \param PropName Property name
999  * \param Idx Index of the property. Set to 0 if the property is not an array
1000  * \result The value of the property
1001  */
1002 TEMU_API int32_t temu_getValueI32(temu_Object_ *Obj, const char *PropName,
1003  int Idx);
1004 
1005 /*!
1006  * Get the value of a property from an object if it is an int64
1007  *
1008  * \param Obj The object that contains the property
1009  * \param PropName Property name
1010  * \param Idx Index of the property. Set to 0 if the property is not an array
1011  * \result The value of the property
1012  */
1013 TEMU_API int64_t temu_getValueI64(temu_Object_ *Obj, const char *PropName,
1014  int Idx);
1015 
1016 /*!
1017  * Read a property value with side-effects
1018  *
1019  * \param Obj Object pointer
1020  * \param PropName Name of property to read.
1021  * \param Idx Index of property, set to 0 if it is not an array.
1022  * \result The property value corresponding to the name. In case of
1023  * the property not being found, the Typ field of the returned
1024  * property will be teTY_Invalid.
1025  */
1026 TEMU_API temu_Propval temu_readValue(temu_Object_ *Obj, const char *PropName,
1027  int Idx) TEMU_NO_WRAP;
1028 
1029 /*!
1030  * Read typed properties.
1031  *
1032  * The readValue[U|I][8|16|32|64] function reads a typed property. The
1033  * accessor will fail with a fatal error if the read type is not the
1034  * same as the property type. If the property type is unknown, use the
1035  * temu_readValue function instead.
1036  *
1037  * \param Obj Object pointer
1038  * \param PropName Name of property to read
1039  * \param Idx Index in property array, set to 0 if the property is not an array
1040  * \result The read out property value.
1041  */
1042 TEMU_API uint8_t temu_readValueU8(temu_Object_ *Obj, const char *PropName,
1043  int Idx);
1044 
1045 /*!
1046  * Read typed properties.
1047  *
1048  * The readValue[U|I][8|16|32|64] function reads a typed property. The
1049  * accessor will fail with a fatal error if the read type is not the
1050  * same as the property type. If the property type is unknown, use the
1051  * temu_readValue function instead.
1052  *
1053  * \param Obj Object pointer
1054  * \param PropName Name of property to read
1055  * \param Idx Index in property array, set to 0 if the property is not an array
1056  * \result The read out property value.
1057  */
1058 TEMU_API uint16_t temu_readValueU16(temu_Object_ *Obj, const char *PropName,
1059  int Idx);
1060 
1061 /*!
1062  * Read typed properties.
1063  *
1064  * The readValue[U|I][8|16|32|64] function reads a typed property. The
1065  * accessor will fail with a fatal error if the read type is not the
1066  * same as the property type. If the property type is unknown, use the
1067  * temu_readValue function instead.
1068  *
1069  * \param Obj Object pointer
1070  * \param PropName Name of property to read
1071  * \param Idx Index in property array, set to 0 if the property is not an array
1072  * \result The read out property value.
1073  */
1074 TEMU_API uint32_t temu_readValueU32(temu_Object_ *Obj, const char *PropName,
1075  int Idx);
1076 
1077 /*!
1078  * Read typed properties.
1079  *
1080  * The readValue[U|I][8|16|32|64] function reads a typed property. The
1081  * accessor will fail with a fatal error if the read type is not the
1082  * same as the property type. If the property type is unknown, use the
1083  * temu_readValue function instead.
1084  *
1085  * \param Obj Object pointer
1086  * \param PropName Name of property to read
1087  * \param Idx Index in property array, set to 0 if the property is not an array
1088  * \result The read out property value.
1089  */
1090 TEMU_API uint64_t temu_readValueU64(temu_Object_ *Obj, const char *PropName,
1091  int Idx);
1092 
1093 /*!
1094  * Read typed properties.
1095  *
1096  * The readValue[U|I][8|16|32|64] function reads a typed property. The
1097  * accessor will fail with a fatal error if the read type is not the
1098  * same as the property type. If the property type is unknown, use the
1099  * temu_readValue function instead.
1100  *
1101  * \param Obj Object pointer
1102  * \param PropName Name of property to read
1103  * \param Idx Index in property array, set to 0 if the property is not an array
1104  * \result The read out property value.
1105  */
1106 TEMU_API int8_t temu_readValueI8(temu_Object_ *Obj, const char *PropName,
1107  int Idx);
1108 
1109 /*!
1110  * Read typed properties.
1111  *
1112  * The readValue[U|I][8|16|32|64] function reads a typed property. The
1113  * accessor will fail with a fatal error if the read type is not the
1114  * same as the property type. If the property type is unknown, use the
1115  * temu_readValue function instead.
1116  *
1117  * \param Obj Object pointer
1118  * \param PropName Name of property to read
1119  * \param Idx Index in property array, set to 0 if the property is not an array
1120  * \result The read out property value.
1121  */
1122 TEMU_API int16_t temu_readValueI16(temu_Object_ *Obj, const char *PropName,
1123  int Idx);
1124 
1125 /*!
1126  * Read typed properties.
1127  *
1128  * The readValue[U|I][8|16|32|64] function reads a typed property. The
1129  * accessor will fail with a fatal error if the read type is not the
1130  * same as the property type. If the property type is unknown, use the
1131  * temu_readValue function instead.
1132  *
1133  * \param Obj Object pointer
1134  * \param PropName Name of property to read
1135  * \param Idx Index in property array, set to 0 if the property is not an array
1136  * \result The read out property value.
1137  */
1138 TEMU_API int32_t temu_readValueI32(temu_Object_ *Obj, const char *PropName,
1139  int Idx);
1140 
1141 /*!
1142  * Read typed properties.
1143  *
1144  * The readValue[U|I][8|16|32|64] function reads a typed property. The
1145  * accessor will fail with a fatal error if the read type is not the
1146  * same as the property type. If the property type is unknown, use the
1147  * temu_readValue function instead.
1148  *
1149  * \param Obj Object pointer
1150  * \param PropName Name of property to read
1151  * \param Idx Index in property array, set to 0 if the property is not an array
1152  * \result The read out property value.
1153  */
1154 TEMU_API int64_t temu_readValueI64(temu_Object_ *Obj, const char *PropName,
1155  int Idx);
1156 
1157 /*!
1158  * Set a raw property value without side-effects
1159  *
1160  * \param Obj Object pointer
1161  * \param PropName Name of property to read.
1162  * \param Val The value to set. It must be of the correct type.
1163  * \param Idx Index of property, set to 0 if it is not an array.
1164  */
1165 TEMU_API void temu_setValue(temu_Object_ *Obj, const char *PropName,
1167 
1168 /*!
1169  * Set a raw property value without side-effects
1170  *
1171  * \param Obj Object pointer
1172  * \param PropName Name of property to read.
1173  * \param Val The value to set. It must be of the correct type.
1174  * \param Idx Index of property, set to 0 if it is not an array.
1175  */
1176 TEMU_API void temu_setValueU8(temu_Object_ *Obj, const char *PropName,
1177  uint8_t Val, int Idx);
1178 
1179 /*!
1180  * Set a raw property value without side-effects
1181  *
1182  * \param Obj Object pointer
1183  * \param PropName Name of property to read.
1184  * \param Val The value to set. It must be of the correct type.
1185  * \param Idx Index of property, set to 0 if it is not an array.
1186  */
1188  uint16_t Val, int Idx);
1189 
1190 /*!
1191  * Set a raw property value without side-effects
1192  *
1193  * \param Obj Object pointer
1194  * \param PropName Name of property to read.
1195  * \param Val The value to set. It must be of the correct type.
1196  * \param Idx Index of property, set to 0 if it is not an array.
1197  */
1199  uint32_t Val, int Idx);
1200 
1201 /*!
1202  * Set a raw property value without side-effects
1203  *
1204  * \param Obj Object pointer
1205  * \param PropName Name of property to read.
1206  * \param Val The value to set. It must be of the correct type.
1207  * \param Idx Index of property, set to 0 if it is not an array.
1208  */
1210  uint64_t Val, int Idx);
1211 
1212 /*!
1213  * Set a raw property value without side-effects
1214  *
1215  * \param Obj Object pointer
1216  * \param PropName Name of property to read.
1217  * \param Val The value to set. It must be of the correct type.
1218  * \param Idx Index of property, set to 0 if it is not an array.
1219  */
1220 TEMU_API void temu_setValueI8(temu_Object_ *Obj, const char *PropName,
1221  int8_t Val, int Idx);
1222 
1223 /*!
1224  * Set a raw property value without side-effects
1225  *
1226  * \param Obj Object pointer
1227  * \param PropName Name of property to read.
1228  * \param Val The value to set. It must be of the correct type.
1229  * \param Idx Index of property, set to 0 if it is not an array.
1230  */
1232  int16_t Val, int Idx);
1233 
1234 /*!
1235  * Set a raw property value without side-effects
1236  *
1237  * \param Obj Object pointer
1238  * \param PropName Name of property to read.
1239  * \param Val The value to set. It must be of the correct type.
1240  * \param Idx Index of property, set to 0 if it is not an array.
1241  */
1243  int32_t Val, int Idx);
1244 
1245 /*!
1246  * Set a raw property value without side-effects
1247  *
1248  * \param Obj Object pointer
1249  * \param PropName Name of property to read.
1250  * \param Val The value to set. It must be of the correct type.
1251  * \param Idx Index of property, set to 0 if it is not an array.
1252  */
1254  int64_t Val, int Idx);
1255 
1256 /*!
1257  * Write a property value with side-effects
1258  *
1259  * \param Obj Object pointer
1260  * \param PropName Name of property to read.
1261  * \param Val The value to set. It must be of the correct type.
1262  * \param Idx Index of property, set to 0 if it is not an array.
1263  */
1264 TEMU_API void temu_writeValue(temu_Object_ *Obj, const char *PropName,
1266 
1267 /*!
1268  * Write a property value with side-effects
1269  *
1270  * \param Obj Object pointer
1271  * \param PropName Name of property to read.
1272  * \param Val The value to set. It must be of the correct type.
1273  * \param Idx Index of property, set to 0 if it is not an array.
1274  */
1276  uint8_t Val, int Idx);
1277 
1278 /*!
1279  * Write a property value with side-effects
1280  *
1281  * \param Obj Object pointer
1282  * \param PropName Name of property to read.
1283  * \param Val The value to set. It must be of the correct type.
1284  * \param Idx Index of property, set to 0 if it is not an array.
1285  */
1287  uint16_t Val, int Idx);
1288 
1289 /*!
1290  * Write a property value with side-effects
1291  *
1292  * \param Obj Object pointer
1293  * \param PropName Name of property to read.
1294  * \param Val The value to set. It must be of the correct type.
1295  * \param Idx Index of property, set to 0 if it is not an array.
1296  */
1298  uint32_t Val, int Idx);
1299 
1300 /*!
1301  * Write a property value with side-effects
1302  *
1303  * \param Obj Object pointer
1304  * \param PropName Name of property to read.
1305  * \param Val The value to set. It must be of the correct type.
1306  * \param Idx Index of property, set to 0 if it is not an array.
1307  */
1309  uint64_t Val, int Idx);
1310 
1311 /*!
1312  * Write a property value with side-effects
1313  *
1314  * \param Obj Object pointer
1315  * \param PropName Name of property to read.
1316  * \param Val The value to set. It must be of the correct type.
1317  * \param Idx Index of property, set to 0 if it is not an array.
1318  */
1320  int8_t Val, int Idx);
1321 
1322 /*!
1323  * Write a property value with side-effects
1324  *
1325  * \param Obj Object pointer
1326  * \param PropName Name of property to read.
1327  * \param Val The value to set. It must be of the correct type.
1328  * \param Idx Index of property, set to 0 if it is not an array.
1329  */
1331  int16_t Val, int Idx);
1332 
1333 /*!
1334  * Write a property value with side-effects
1335  *
1336  * \param Obj Object pointer
1337  * \param PropName Name of property to read.
1338  * \param Val The value to set. It must be of the correct type.
1339  * \param Idx Index of property, set to 0 if it is not an array.
1340  */
1342  int32_t Val, int Idx);
1343 
1344 /*!
1345  * Write a property value with side-effects
1346  *
1347  * \param Obj Object pointer
1348  * \param PropName Name of property to read.
1349  * \param Val The value to set. It must be of the correct type.
1350  * \param Idx Index of property, set to 0 if it is not an array.
1351  */
1353  int64_t Val, int Idx);
1354 
1355 /*!
1356  * Write a property value with side-effects
1357  *
1358  * \param Obj Object pointer
1359  * \param PropName Name of property to read.
1360  * \param Val The value to set. It must be of the correct type.
1361  * \param Idx Index of property, set to 0 if it is not an array.
1362  */
1364  temu_Object *Val, int Idx);
1365 
1366 /*!
1367  * Register a class in the TEMU object system. With these classes, the TEMU
1368  * object system is responsible for allocation and de-allocation.
1369  *
1370  * \param ClsName The name of the class that is to be created.
1371  * \param Create A constructor, the constructor is responsible for
1372  * allocation and initialisation of the object.
1373  * \param Dispose A destructor, this function is responsible for deleting
1374  * the objects of the class.
1375  * \result A pointer to the class object that can be further used to register
1376  * properties and interfaces.
1377  */
1378 TEMU_API temu_Class *temu_registerClass(const char *ClsName,
1379  temu_ObjectCreateFunc Create,
1380  temu_ObjectDisposeFunc Dispose);
1381 
1382 #ifdef __cplusplus
1383 
1384 /*!
1385  * Add a property to a class.
1386  *
1387  * \param Cls The class object
1388  * \param PropName Name of the property to add.
1389  *
1390  * \param Offset Offset in bytes from the start of the class to the
1391  * value the property refers to.
1392  *
1393  * \param Typ Type of the property.
1394  *
1395  * \param Count Set to > 1 to indicate that the property is an array,
1396  * the value is the length of the array.
1397  *
1398  * \param Wr Property write function. This function can have side-effects.
1399  * \param Rd Property read function. This function can have side-effects.
1400  * \param Doc Documentation string
1401  */
1402 TEMU_API void temu_addProperty(temu_Class *Cls, const char *PropName,
1403  int Offset, temu_Type Typ, int Count,
1404  temu_PropWriter Wr = nullptr,
1405  temu_PropReader Rd = nullptr,
1406  const char *Doc = "");
1407 #else
1408 
1409 /*!
1410  * Add a property to a class.
1411  *
1412  * \param Cls The class object
1413  * \param PropName Name of the property to add.
1414  *
1415  * \param Offset Offset in bytes from the start of the class to the
1416  * value the property refers to.
1417  *
1418  * \param Typ Type of the property.
1419  *
1420  * \param Count Set to > 1 to indicate that the property is an array,
1421  * the value is the length of the array.
1422  *
1423  * \param Wr Property write function. This function can have side-effects.
1424  * \param Rd Property read function. This function can have side-effects.
1425  * \param Doc Documentation string
1426  */
1427 TEMU_API void temu_addProperty(temu_Class *Cls, const char *PropName,
1428  int Offset, temu_Type Typ, int Count,
1429  temu_PropWriter Wr, temu_PropReader Rd,
1430  const char *Doc);
1431 
1432 #endif
1433 
1434 /*!
1435  * Add property without storage
1436  *
1437  * A pseudo property does not have backing storage (and therefore no
1438  * offset). They exist to provide access to computed properties.
1439  *
1440  * Pseudo properties also work fine with C++ types with non-standard
1441  * layout.
1442  *
1443  * Pseudo properties are snapshotted if the set and get functions are
1444  * implemented. The set and get should implement read and write
1445  * without semantic effect. That is, if the property is a register,
1446  * then the read and write should have the effect of an actual
1447  * register access (including event rescheduling etc), while for a
1448  * get/set, only the value of the register is modified, event
1449  * restoration is done differently.
1450  *
1451  * \param Cls class to add pseudo property to
1452  * \param PropName name of pseudo property
1453  * \param Typ Type of property
1454  * \param Count number of elements, 1 for a scalar.
1455  * \param Wr Property write function (semantic effect)
1456  * \param Rd Property read function (semantic effect)
1457  * \param Set Property set function (non-semantic)
1458  * \param Get Property get function (non-semantic)
1459  * \param Doc Documentation string
1460  */
1462  temu_Type Typ, int Count,
1465  const char *Doc);
1466 
1467 /*!
1468  * temu_addLogginCategory adds a logging category to the class
1469  *
1470  * \param Cls the class
1471  * \param CategoryId The category id. Valid range is [8,16)
1472  * \param Category The category name
1473  * \result 0 for success, 1 indicates failure.
1474  */
1476  const char *Category);
1477 
1478 /*!
1479  * temu_getLogginCategory adds a logging category to the class
1480  *
1481  * \param Cls the class
1482  * \param CategoryId The category id. Valid range is [8,16)
1483  * \result Pointer to the category string, NULL for failure.
1484  */
1486  unsigned CategoryId);
1487 
1488 /*!
1489  * temu_isPseudoProperty Checks whether a property is a pseudo-property
1490  *
1491  * \param Obj The object that contains the property
1492  * \param PropName The property name
1493  * \result 0 for false, non-zero for true
1494  */
1496 
1497 /*!
1498  * temu_isNormalProperty Checks whether a property is a normal property (not a
1499  * pseudo-property)
1500  *
1501  * \param Obj The object that contains the property
1502  * \param PropName The property name
1503  * \result 0 for false, non-zero for true
1504  */
1506 
1507 /*!
1508  * Associate the interface reference property with an interface type.
1509  *
1510  * Setting the type, prevents the connect command / function to assign
1511  * the connection if the target interface type is not the same as the
1512  * property interface reference type.
1513  *
1514  * \param Cls Class pointer
1515  * \param PropName Name of interface reference property
1516  * \param IfaceType Type required to connect the property
1517  */
1519  const char *IfaceType);
1520 
1521 /*!
1522  * Add a interface reference property.
1523  *
1524  * \param Cls The class object
1525  * \param PropName Name of the property to add.
1526  *
1527  * \param Offset Offset in bytes from the start of the class to the
1528  * value the property refers to.
1529  *
1530  * \param TypeName Interface type name.
1531  *
1532  * \param Count Set to > 1 to indicate that the property is an array,
1533  * the value is the length of the array.
1534  * \param Flags Flags for property, 1 implies property is mandatory to set.
1535  * \param Wr Property write function. This function can have side-effects.
1536  * \param Rd Property read function. This function can have side-effects.
1537  * \param Doc Documentation string
1538  */
1540  int Offset, const char *TypeName,
1541  int Count, unsigned Flags,
1543  const char *Doc);
1544 
1545 /*!
1546  * Add a interface reference property.
1547  *
1548  * \param Cls The class object
1549  * \param PropName Name of the property to add.
1550  *
1551  * \param TypeName Interface type name.
1552  *
1553  * \param Count Set to > 1 to indicate that the property is an array,
1554  * the value is the length of the array.
1555  * \param Flags Flags for property, 1 implies property is mandatory to set.
1556  * \param Wr Property write function. This function can have side-effects.
1557  * \param Rd Property read function. This function can have side-effects.
1558  * \param Set Property set function. Non-semantic.
1559  * \param Get Property get function. Non-semantic.
1560  * \param Doc Documentation string
1561  */
1563  temu_Class *Cls, const char *PropName, const char *TypeName, int Count,
1565  temu_PropReader Get, const char *Doc);
1566 
1567 /*!
1568  * Make interface reference property and an interface inverses
1569  *
1570  * A port is a bidirectional interface. Thus, if an interface
1571  * reference is connected to another objects interface, the remote
1572  * object will be told to issue a reverse connection. This is
1573  * convenient as it simplifies device connection during system
1574  * configuration and construction. That is, instead of calling the
1575  * connect two times with the inverse connections explicitly, only one
1576  * call is needed.
1577  *
1578  * \param C The class object
1579  * \param IfaceRefName the name of the interface reference property
1580  * \param IfaceName Name of interface that is the inverse of the
1581  * interface ref property.
1582  * \param Doc Documentation string
1583  * \result 0 on success, non-zero otherwise.
1584  */
1585 TEMU_API int temu_addPort(temu_Class *C, const char *IfaceRefName,
1586  const char *IfaceName, const char *Doc);
1587 
1588 /*!
1589  * Register interface with the named class.
1590  *
1591  * \param Cls_name Name of class to add interface to
1592  * \param Ifacename Interface name
1593  * \param IfaceType Interface type
1594  * \param Iface Pointer to the interface structure.
1595  */
1596 #ifdef __cplusplus
1597 
1598 /*!
1599  * Add an interface to a class
1600  *
1601  * \param Cls Class pointer, returned from registerClass or similar
1602  * \param IfaceName Name of the interface
1603  * \param IfaceType Name of the interface type, note that the type
1604  * names are typically defined together with the
1605  * interface C-type.
1606  * \param Iface Pointer to interface struct
1607  * \param DeprecatedParam Not used, set to zero
1608  * \param Doc Description of interface
1609  */
1610 TEMU_API void temu_addInterface(temu_Class *Cls, const char *IfaceName,
1611  const char *IfaceType, void *Iface,
1612  int DeprecatedParam = 0, const char *Doc = "");
1613 
1614 /*!
1615  * temu_getInterface Get an interface from an object by name
1616  *
1617  * \param Obj Pointer to the object containing the interface
1618  * \param IfaceName Name of the interface
1619  * \param Idx Index in case the interface name refers to an
1620  * interface array
1621  * \result Pointer to the interface
1622  */
1623 TEMU_API void *temu_getInterface(temu_Object_ *Obj, const char *IfaceName,
1624  int Idx = 0);
1625 
1626 #else
1627 TEMU_API void temu_addInterface(temu_Class *Cls,
1628 
1629  const char *IfaceName, const char *IfaceType,
1630  void *Iface, int DeprecatedParam,
1631  const char *Doc);
1632 
1633 TEMU_API void *temu_getInterface(temu_Object_ *Obj, const char *IfaceName,
1634  int Idx);
1635 
1636 #endif
1637 
1638 /*!
1639  * Retrieve a reference to an interface identified by its name and index
1640  *
1641  * \param Obj Pointer to the object containing the interface
1642  * \param IfaceName Name of the interface
1643  * \param Idx Interface index
1644  * \result The interface reference as a temu_IfaceRef object
1645  */
1646 TEMU_API temu_IfaceRef temu_getInterfaceRef(temu_Object_ *Obj,
1647  const char *IfaceName, int Idx);
1648 
1649 /*!
1650  * temu_getInterfaceName Get Interface Name of the Obj
1651  *
1652  * \param Obj Pointer to the object containing the interface
1653  * \param Iface Interface to be find w.r.t. Object
1654  * \result The name of the interface
1655  */
1656 TEMU_API const char *temu_getInterfaceName(temu_Object *Obj, void *Iface);
1657 
1658 /*!
1659  * Add an array of interfaces to a class
1660  *
1661  * Interface arrays are especially useful when e.g. multiple "network
1662  * ports" are available, although they can be added manually with
1663  * distinct names (e.g. uartaiface, uartbiface, etc), the interface
1664  * array registration allows for the addition of several interfaces at
1665  * once. Individual interfaces are then referred to with normal index
1666  * syntax, e.g. obj:uartiface[0].
1667  *
1668  * \param Cls Class pointer
1669  * \param IfaceName name of interface
1670  * \param IfaceType name of interface type
1671  * \param Iface Pointer to array of interfaces
1672  * \param Count Number of interfaces in array
1673  * \param Size Size of one interface (e.g. sizeof(uartiface[0]))
1674  * \param Doc Documentation comment for interface
1675  */
1677  const char *IfaceType, void *Iface,
1679  const char *Doc);
1680 
1681 /*!
1682  * Set the VTable pointer.
1683  *
1684  * Temu classes, provides the ability to, for internal objects query
1685  * for a VTable manually in O(1) time. In practice this can be any
1686  * pointer, but it is typically used to register performance sensitive
1687  * interfaces. E.g. the CPU and machine classes have their own VTable
1688  * types that refer to a number of interfaces they implement.
1689  *
1690  * \param Cls The class, for which the vtable to be set
1691  * \param VTable Pointer to the vtable to be used
1692  * \result 0 on success, non-zero otherwise.
1693  */
1695 
1696 /*!
1697  * Get the VTable pointer for a class
1698  *
1699  * \param Cls The class, for which the vtable is to be retrieved
1700  * \result Pointer to the vtable in question
1701  */
1703 
1704 /*!
1705  * Get the VTable pointer for an object. This only works for internal
1706  * objects that inherits from temu_Object.
1707  *
1708  * \param Obj The object in question
1709  * \result Pointer to the vtable in question
1710  */
1711 TEMU_API void *temu_getVTable(const temu_Object_ *Obj);
1712 
1713 /*!
1714  * Set time source object for models. Typically TS is a CPU. You can
1715  * only set the time source for an internal class.
1716  *
1717  * \param Obj Object to set time source in.
1718  * \param TS Time source object (CPU or clock model)
1719  */
1721 
1722 /*
1723  * Qualification support
1724  *
1725  * Qualifiers can set a tag per class, which can then be used for
1726  * quick identification of an object's class properties. For example
1727  * all objects qualified as CPUs, machines and memories must have the
1728  * vtable set appropriatelly.
1729  */
1730 #define TEMU_QUAL_NONE 0
1731 #define TEMU_QUAL_CPU 1
1732 #define TEMU_QUAL_MACHINE 2
1733 #define TEMU_QUAL_MEMORY 4
1734 #define TEMU_QUAL_COMPONENT 5
1735 #define TEMU_QUAL_CLOCK 6
1736 
1737 // Users can set their own class qualifiers, but should use an offset
1738 // from the TEMU_QUAL_USER.
1739 #define TEMU_QUAL_USER 65536
1740 
1741 /*!
1742  * temu_isQualifiedAs Check if an object is qualified as Qualifier
1743  *
1744  * \param Obj The object to be checked
1745  * \param Qualifier The qualification to be checked
1746  * \result 0 for false, non-zero for true
1747  */
1748 TEMU_API int temu_isQualifiedAs(const temu_Object_ *Obj, unsigned Qualifier);
1749 
1750 /*!
1751  * Predicate for identifying CPU classes. In release without assert
1752  * builds this runs in O(1) time.
1753  *
1754  * \param Obj The object to test
1755  * \result 0 for false, non-zero for true
1756  */
1757 TEMU_API int temu_isCpu(const temu_Object_ *Obj);
1758 
1759 /*!
1760  * Predicate for identifying CPU classes. In release without assert
1761  * builds this runs in O(1) time..
1762  *
1763  * \param Obj The object to test
1764  * \result 0 for false, non-zero for true
1765  */
1767 
1768 /*!
1769  * temu_isMemory Checks whether an object is a memory object
1770  *
1771  * \param Obj The object to test
1772  * \result 0 for false, non-zero for true
1773  */
1775 
1776 /*!
1777  * temu_isComponent Checks if an object is a component
1778  *
1779  * \param Obj The object to test
1780  * \result 0 for false, non-zero for true
1781  */
1783 
1784 /*!
1785  * Bless the class so that the isCpu predicate returns 1. There are
1786  * certain assumptions that CPU classes must meet. These assumptions
1787  * are not stable yet, so do not use this in user code.
1788  *
1789  * \param Cls The class to be blessed
1790  */
1792 
1793 /*!
1794  * Bless the class so that the isMachine predicate returns 1. There
1795  * are certain assumptions that machine classes must meet. These
1796  * assumptions are not stable yet, so do not use this in user code.
1797  *
1798  * \param Cls The class to be blessed
1799  */
1801 
1802 /*!
1803  * Bless the class so that the isMemory predicate returns 1
1804  *
1805  * \param Cls The class to be blessed
1806  */
1808 
1809 /*!
1810  * Bless the class so that the isQualified predicate returns 1.
1811  * Qualifiers with the MSb cleared are reserved for TEMU internals.
1812  *
1813  * \param Cls The class to be blessed
1814  */
1816 
1817 /*! Erase all classes, interfaces, properties and objects registered
1818  * in the object system.
1819  */
1820 TEMU_API void temu_objsysClear(void);
1821 
1822 /*! Erase all objects, but do not delete classes.
1823  */
1825 
1826 /*! Create object with class and name.
1827  *
1828  * \param ClsName Name of class used for instantiation
1829  * \param ObjName Name of object in object system
1830  *
1831  * \param Args Named argument pairs to pass into constructor. The list
1832  * of args should be terminated by a
1833  * TEMU_NULL_ARG. In case no arguments are passed,
1834  * pass in NULL.
1835  *
1836  * \result Allocated object. Result is NULL in case of: class does not exist,
1837  * object already allocated with the given name, out of memory.
1838  */
1839 TEMU_API temu_Object_ *temu_createObject(const char *ClsName,
1840  const char *ObjName,
1841  const temu_CreateArg *Args);
1842 
1843 /*! Dispose object. The function will call the Objects dispose
1844  * function.
1845  *
1846  * \param Obj The object to delete.
1847  */
1848 TEMU_API void temu_disposeObject(temu_Object_ *Obj);
1849 
1850 /*!
1851  * Get the class pointer for the named class
1852  *
1853  * \param ClsName The name of the class
1854  * \result Pointer to the class if found, otherwise NULL
1855  */
1856 TEMU_API temu_Class *temu_classForName(const char *ClsName);
1857 
1858 /*!
1859  * temu_nameForClass Get the class name from its object
1860  *
1861  * \param Cls Pointer to the object of the class in question
1862  * \result The name of the class as a C-string
1863  */
1865 
1866 /*!
1867  * Get the class for the given object.
1868  *
1869  * \param Obj Pointer to the object
1870  * \result Pointer to the class type object
1871  */
1872 TEMU_API temu_Class *temu_classForObject(const temu_Object_ *Obj);
1873 
1874 /*!
1875  * Query whether the class has a specific command implemented
1876  *
1877  * \param Cls class to query for a command.
1878  * \param CmdName Command name class is expected to implement.
1879  * \result 0 if command is not implemented by class, 1 if implemented.
1880  */
1881 TEMU_API int temu_classHasCommand(const temu_Class *Cls, const char *CmdName);
1882 
1883 typedef void temu_TypeObject;
1884 
1885 typedef struct {
1886  const char *Name; //!< Name of property
1887  temu_Type Typ; //!< Type tag
1888  size_t Count; //!< Number of elements in property
1889  uintptr_t Offset; //!< Offset from struct start
1891 } temu_PropInfo;
1892 
1893 /*!
1894  * Get property info for class
1895  *
1896  * It is possible to extract low level property info data using this
1897  * function. This can be useful if integrating in another simulator or
1898  * if integrating the system in e.g. a GUI in which you need to
1899  * provide object introspection.
1900  *
1901  * The function can be called with the PI array set to NULL to return
1902  * the number of properties in the class.
1903  *
1904  * You can read out all property fields using the following sequence:
1905  * \code{.c}
1906  * temu_PropInfo PI; unsigned i = 0; int r;
1907  * while ((r = temu_propInfoForClass(C, i, 1, &PI)) == 1) {
1908  * // ...
1909  * i += r;
1910  * }
1911  * \endcode
1912  *
1913  * \param Cls The class to inspect
1914  * \param PIIndex The property index to read from.
1915  * \param PICount Size of PI array in number of entries.
1916  * \Param PI Pointer to an array of prop info objects to fill in.
1917  * \result Number of read PI entries. In case PI is NULL, the total
1918  * number of PIs for the class.
1919  */
1921  unsigned PICount, temu_PropInfo *PI);
1922 
1923 /*!
1924  * Get object for name
1925  *
1926  * \param Name The name of the object
1927  * \result Pointer to the object
1928  */
1929 TEMU_API temu_Object_ *temu_objectForName(const char *Name);
1930 
1931 /*!
1932  * Get the name of an object
1933  *
1934  * \param Obj Pointer to the object
1935  * \result Name of the object as C-string
1936  */
1937 TEMU_API const char *temu_nameForObject(const temu_Object_ *Obj);
1938 
1939 /*!
1940  * Get name for interface
1941  *
1942  * \param Obj Pointer to the object that contains the interface
1943  * \param Iface Pointer to the interface
1944  * \result The name of the interface as C-string
1945  */
1946 TEMU_API const char *temu_nameForInterface(const temu_Object_ *Obj,
1947  const void *Iface);
1948 
1949 /*!
1950  * Get index for interface
1951  *
1952  * \param Obj Pointer to the object that contains the interface
1953  * \param Iface Pointer to the interface
1954  * \result Index of interface if it is in an iface array.
1955  * Otherwise it returns -1. Consequently the function only have valid
1956  * result for interface arrays.
1957  */
1958 TEMU_API int temu_indexForInterface(const temu_Object_ *Obj, const void *Iface);
1959 
1960 /*!
1961  * Get type name for interface
1962  *
1963  * \param Obj Pointer to the object that contains the interface
1964  * \param Iface Pointer to the interface
1965  * \result The name of the type as C-string
1966  */
1968  const void *Iface);
1969 
1970 /*!
1971  * Load a plugin. When a plugin is loaded the temu_pluginInit function
1972  * will be called. This function should create and define any classes
1973  * that the plugin provides.
1974  *
1975  * The function loads plugins following the operating system's loading
1976  * rules. This means in particular that first, the plugin will be
1977  * found in the RPATH location of libTEMUSupport (which refers to the
1978  * TEMU lib directory). Secondly, it will look in the LD_LIBRARY_PATH
1979  * and other standard load directories.
1980  *
1981  * In practice, it will look for lib<Plugin>.so in the TEMU plugin
1982  * paths, or libTEMU<Plugin>.so in the same paths. It will then
1983  * fallback on attempting to load libTEMU<Plugin>.so from the system
1984  * load paths. If the plugin name contains a slash '/' it will be
1985  * treated as a path and not a plugin name.
1986  *
1987  * \param PluginName A path or plugin name
1988  * \result 0 on success, non-zero otherwise.
1989  */
1990 TEMU_API int temu_loadPlugin(const char *PluginName);
1991 
1992 /*!
1993  * Load a plugin. When a plugin is loaded the temu_pluginInit function
1994  * will be called. This function should create and define any classes
1995  * that the plugin provides.
1996  *
1997  * The plugin will be made available globally for the linker
1998  * (e.g. using RTLD_GLOBAL).
1999  *
2000  * This is not recommended for normal TEMU plugins.
2001  *
2002  * The function loads plugins following the operating system's loading
2003  * rules. This means in particular that first, the plugin will be
2004  * found in the RPATH location of libTEMUSupport (which refers to the
2005  * TEMU lib directory). Secondly, it will look in the LD_LIBRARY_PATH
2006  * and other standard load directories.
2007  *
2008  * In practice, it will look for lib<Plugin>.so in the TEMU plugin
2009  * paths, or libTEMU<Plugin>.so in the same paths. It will then
2010  * fallback on attempting to load libTEMU<Plugin>.so from the system
2011  * load paths. If the plugin name contains a slash '/' it will be
2012  * treated as a path and not a plugin name.
2013  *
2014  * \param PluginName A path or plugin name
2015  * \result 0 on success, non-zero otherwise.
2016  */
2017 TEMU_API int temu_loadPluginGlobal(const char *PluginName);
2018 
2019 /*!
2020  * temu_pluginPathAppend Add a path to the list of paths, where T-emu searches
2021  * for plugins
2022  *
2023  * \param Path The path to append
2024  */
2025 TEMU_API void temu_pluginPathAppend(const char *Path);
2026 
2027 /*!
2028  * temu_pluginPathRemove Remove a path from the list of paths, where T-emu
2029  * searches for plugins
2030  *
2031  * \param Path to remove
2032  */
2033 TEMU_API void temu_pluginPathRemove(const char *Path);
2034 
2035 /*!
2036  * temu_pluginPathPrint Print the list of paths, where T-emu searches for
2037  * plugins
2038  */
2039 TEMU_API void temu_pluginPathPrint(void);
2040 
2041 /*!
2042  * Get a string representing the type tag.
2043  *
2044  * \param Typ The type, whose name is required
2045  * \result The name as a C-string
2046  */
2047 TEMU_API const char *temu_typeToName(temu_Type Typ);
2048 
2049 /* NOTE: The getProcessors, getProcsessorCount, getComponents and
2050  getComponentCount functions are experimental and unstable. Do not
2051  rely on these for the moment.
2052 */
2053 /*!
2054  * temu_getProcessors Get the list of processors in the current simulation
2055  *
2056  * \result An array of processor pointers, the length can be obtained from
2057  * temu_getProcessorCount()
2058  */
2059 TEMU_API temu_Object_ **temu_getProcessors(void);
2060 
2061 /*!
2062  * temu_getProcessorCount Get the number of processors in the current simulation
2063  *
2064  * \result The number of processors in the current simulation
2065  */
2066 TEMU_API size_t temu_getProcessorCount(void);
2067 
2068 /*!
2069  * temu_getComponents Get the number of components in the current simulation
2070  *
2071  * \result An array of the pointers to the components in the current simulation,
2072  * the length of the array can be obtained from temu_getComponentCount()
2073  */
2074 TEMU_API temu_Component **temu_getComponents(void);
2075 
2076 /*!
2077  * temu_getComponentCount Get the number of components in the current simulation
2078  *
2079  * \result The number of components in the current simulation
2080  */
2081 TEMU_API size_t temu_getComponentCount(void);
2082 
2083 /*!
2084 
2085  Connect an interface property in object A to the interface in object
2086  B. If A.PropName is an interface array, B,B:IfaceName will be
2087  appended to it. For dynamic arrays, it is pushed to the end, for
2088  static arrays, it is placed in the first null slot (unless, the
2089  indexing syntax is used in the property name).
2090 
2091  \param A The object to connect.
2092  \param PropName The name of the property in object A
2093  \param B The object to connect to.
2094  \param IfaceName The name of the interface in object B
2095  \result 0 on success, otherwise non-zero
2096  */
2097 TEMU_API int temu_connect(temu_Object_ *A, const char *PropName,
2098  temu_Object_ *B, const char *IfaceName);
2099 
2100 /*!
2101  Serialise the simulation state to the given file name.
2102 
2103  The serialisation writes a JSON formatted file and calls the
2104  serialise procedure in the (optional) ObjectIface if it is
2105  implemented.
2106 
2107  The serialisation interface can for example be used to write out
2108  memory buffers to separate files as such data should not be written
2109  to a JSON file.
2110 
2111  \param FileName The filename, to which the JSON data is to be stored
2112  \result 0 on success, otherwise non-zero
2113  */
2114 TEMU_API int temu_serialiseJSON(const char *FileName);
2115 
2116 /*!
2117  De-serialise the simulation state.
2118 
2119  The function clears the whole internal object system, reads the JSON
2120  file FileName and creates all the objects.
2121 
2122  If a class implements the ObjectIface, the (optional) deserialise
2123  procedure will be called.
2124 
2125  \param FileName The filename that contains the JSON data
2126  \result 0 on success, otherwise non-zero
2127  */
2128 TEMU_API int temu_deserialiseJSON(const char *FileName);
2129 
2130 /*!
2131  De-serialise the simulation state.
2132 
2133  This function directly restores properties on already created objects.
2134  It does not clear the objects system.
2135  Thus pointers to objects remains stable after a snapshot restore.
2136 
2137  If a class implements the ObjectIface, the (optional) deserialise
2138  procedure will be called.
2139 
2140  \param FileName The filename that contains the JSON data
2141  \result 0 on success, otherwise non-zero
2142  */
2144 
2145 /*!
2146  * Serialise an explicit property, this can be called from the
2147  * serialisiation interface. Note that the availability of pseudo
2148  * properties makes this function and the serialise interface more or
2149  * less obsolete.
2150  *
2151  * \param Ctxt The context object that has the property (same as
2152  * passed to serialise function in the interface)
2153  * \param Name The name of the property
2154  * \param Typ The type of the property
2155  * \param Count 0 if the property is not an array, otherwise the
2156  * element number in the property
2157  * \param Data Serialized data
2158  */
2159 TEMU_API void temu_serialiseProp(void *Ctxt, const char *Name, temu_Type Typ,
2160  int Count, void *Data);
2161 
2162 /*!
2163  * temu_deserialiseProp Deserialize a serialized property
2164  *
2165  * \param Ctxt An opaque context, this is the same context as is
2166  * passed to the deserialise interface function.
2167  *
2168  * \param Obj Object being deserialised
2169  * \param Name The name of the property
2170  */
2172  const char *Name);
2173 
2174 /*!
2175  * Get number of entries for the serialized property
2176  *
2177  * \param Ctxt Context passed to deserialise function
2178  * \param Name Name of property / key in the serialized file
2179  * \result Length of the property in elements. Negative on error.
2180  */
2181 TEMU_API int temu_snapshotGetLength(void *Ctxt, const char *Name);
2182 /*!
2183  * Get number of entries for the serialized property
2184  *
2185  * \param Ctxt Context passed to deserialise function
2186  * \param Name Name of property / key in the serialized file
2187  * \result Length of the property in elements. Negative on error.
2188  */
2189 TEMU_API int temu_checkpointGetLength(void *Ctxt, const char *Name);
2190 
2191 /*!
2192  * Get value for named snapshot value
2193  *
2194  * \param Ctxt Context is passed to deserialise interface function
2195  * \param Name Name of the saved value
2196  * \param Idx Index of the saved value (if array)
2197  * \result Property value with the contents saved to the snapshot
2198  */
2199 TEMU_API temu_Propval temu_snapshotGetValue(void *Ctxt, const char *Name,
2200  int Idx);
2201 
2202 /*!
2203  * Get value for named snapshot value
2204  *
2205  * \param Ctxt Context is passed to deserialise interface function
2206  * \param Name Name of the saved value
2207  * \param Idx Index of the saved value (if array)
2208  * \result Property value with the contents saved to the snapshot
2209  */
2210 TEMU_API temu_Propval temu_checkpointGetValue(void *Ctxt, const char *Name,
2211  int Idx);
2212 
2213 /*! Check object system sanity.
2214  *
2215  * The function traverses all objects and their properties and ensures that
2216  * all (scalar) interface properties are connected.
2217  * An object can override the default check by implementing the checkSanity
2218  * function in the ObjectIface.
2219  *
2220  * \param Report set to 1 to have the function report connectivity issues on
2221  * stdout, 2 to report on stderr, and 0 to not report at all.
2222  * \result Returns 0 if the object system is connected.
2223  * Returns non-zero if the object system is not properly connected.
2224  */
2226 
2227 //! Print the current object graph as a dot file
2228 //!
2229 //! Pass NULL (or nullptr) to generate to stdout. And set Display to
2230 //! non-zero to automatically display the generated dot-file.
2231 //!
2232 //! \param Path Destination file to write the graph to. NULL indicates
2233 //! stdout.
2234 //!
2235 //! \param Display If non-zero, the function will attempt to display
2236 //! the graph by running it through dot and .
2237 //!
2238 //! \result 0 if the generation was successful. Non-zero in case of
2239 //! failure.
2240 TEMU_API int temu_generateObjectGraph(const char *Path, int Display);
2241 
2242 TEMU_API int temu_isValidObjectName(const char *Name);
2243 TEMU_API int temu_isValidClassName(const char *Name);
2244 TEMU_API int temu_isValidInterfaceName(const char *Name);
2245 TEMU_API int temu_isValidPropertyName(const char *Name);
2246 
2247 /*!
2248  * Generic object interface The object interface provides generic
2249  * functionality such as serialisation and sanity checking support.
2250  */
2251 typedef struct {
2252  /*! Optional function
2253  * Called after an object has been written to the snapshot, this
2254  * function can write out additional properties to the snapshot
2255  * and take other actions.
2256  *
2257  * Note that with the pseudoproperties supporting snapshotting,
2258  * this function is very rarely needed.
2259  */
2260  void (*serialise)(void *Obj, const char *BaseName, void *Ctxt);
2261 
2262  /*! Optional function
2263  * Called after an object has been restored from a snapshot, this
2264  * function can read additional properties to the snapshot
2265  * and take other actions.
2266  *
2267  * Note that with the pseudoproperties supporting snapshotting,
2268  * this function is very rarely needed.
2269  */
2270 
2271  void (*deserialise)(void *Obj, const char *BaseName, void *Ctxt);
2272 
2273  /*!
2274  * Return zero if the object is connected as expected, return
2275  * non-zero if the object is not fully connected the default check
2276  * will ensure that all the Interface references are connected, but
2277  * does not care about optional interfaces or
2278  */
2279  int (*checkSanity)(void *Obj, int Report); // Optional
2280 
2281  /*!
2282  * Optional function
2283  *
2284  * Called when the time source has been set on the object
2285  * The function can for example post initial events.
2286  */
2287  void (*timeSourceSet)(void *Obj);
2288 
2289  /*!
2290  * Optional function
2291  *
2292  * Pretty prints the object to stdout, called by the object-print
2293  * command.
2294  */
2295  void (*printObject)(void *Obj);
2296 } temu_ObjectIface;
2297 #define TEMU_OBJECT_IFACE_TYPE "ObjectIface"
2298 TEMU_IFACE_REFERENCE_TYPE(temu_Object)
2299 
2300 /*!
2301  * Call function on every object in the object system
2302  * The function is called with the object pointer and the argument.
2303  * NOTE: This function is experimental.
2304  *
2305  * \param Func Function to call
2306  * \param Arg Argument passed as the last parameter to Func
2307  */
2308 TEMU_API void temu_foreachObject(void (*Func)(temu_Object_ *, void *),
2309  void *Arg);
2310 
2311 /*!
2312  * Call function on every class in the object system
2313  * The function is called with the metaclass pointer and the argument.
2314  * NOTE: This function is experimental.
2315  *
2316  * \param Func Function to call
2317  * \param Arg Argument passed as the last parameter to Func
2318  */
2319 TEMU_API void temu_foreachClass(void (*Func)(temu_Class *, void *), void *Arg);
2320 
2321 /*!
2322  * Call function on every processor in the object system
2323  * The function is called with the CPU pointer and the argument.
2324  * NOTE: This function is experimental.
2325  *
2326  * \param Func Function to call
2327  * \param Arg Argument passed as the last parameter to Func
2328  */
2329 TEMU_API void temu_foreachProcessor(void (*Func)(temu_Object_ *, void *),
2330  void *Arg);
2331 
2332 /*!
2333  * Call function on every property in a class.
2334  * The function is called with the class pointer, property name and the
2335  * argument. NOTE: This function is experimental.
2336  *
2337  * \param C Class to iterate properties
2338  * \param Func Function to call
2339  * \param Arg Argument passed as the last parameter to Func
2340  */
2341 
2343  temu_Class *C, void (*Func)(temu_Class *, const char *, void *), void *Arg);
2344 
2345 /*!
2346  * Call function on every interface in a class.
2347  * The function is called with the class pointer, interface name and the
2348  * argument. NOTE: This function is experimental.
2349  *
2350  * \param C Class to iterate properties
2351  * \param Func Function to call
2352  * \param Arg Argument passed as the last parameter to Func
2353  */
2354 
2356  temu_Class *C, void (*Func)(temu_Class *, const char *, void *), void *Arg);
2357 
2358 TEMU_API void *temu_registerInterfaceType(const char *Name);
2359 TEMU_API void *temu_getInterfaceType(const char *Name);
2360 
2361 //! Add a scalar (one element) property without setters / getters
2362 //! \param Cls Class pointer
2363 //! \param Name Name of property
2364 //! \param offset Offset from object pointer
2365 //! \param T Property type
2366 //! \param Doc Documentation string
2367 //! \result 0 if the property was added
2369  int offset, temu_Type T, const char *Doc);
2370 //! Add a fixed length array property without setters / getters
2371 //! \param Cls Class pointer
2372 //! \param Name Name of property
2373 //! \param offset Offset from object pointer
2374 //! \param T Property type
2375 //! \param NumElems Array length
2376 //! \param Doc Documentation string
2377 //! \result 0 if the property was added
2379  int offset, temu_Type T, int NumElems,
2380  const char *Doc);
2381 
2382 //! Add a scalar (one element) pseudo-property
2383 //! \param Cls Class pointer
2384 //! \param Name Name of property
2385 //! \param T Property type
2386 //! \param Doc Documentation string
2387 //! \result 0 if the property was added
2389  temu_Type T, const char *Doc);
2390 
2391 //! Add an array pseudo-property
2392 //! \param Cls Class pointer
2393 //! \param Name Name of property
2394 //! \param T Property type
2395 //! \param NumElems Array length
2396 //! \param Doc Documentation string
2397 //! \result 0 if the property was added
2399  temu_Type T, int NumElems,
2400  const char *Doc);
2401 
2402 //! Write property (with side effects)
2403 //! \param Obj Object pointer
2404 //! \param Name Name of property
2405 //! \param idx Index in property array (set to 0 if scalar)
2406 //! \param PV Pointer to propval
2407 //! \result 0 if the property was written
2408 TEMU_API int temu_writeProp(temu_Object_ *Obj, const char *Name, int idx,
2409  temu_Propval *PV);
2410 
2411 //! Read property (with side effects)
2412 //! \param Obj Object pointer
2413 //! \param Name Name of property
2414 //! \param idx Index in property array (set to 0 if scalar)
2415 //! \result The read value, set to teTY_Invalid for failures
2416 TEMU_API temu_Propval temu_readProp(temu_Object_ *Obj, const char *Name,
2417  int idx);
2418 
2419 //! Get property (without side effects)
2420 //! \param Obj Object pointer
2421 //! \param PropName Name of property
2422 //! \param Idx Index in property array (set to 0 if scalar)
2423 //! \result The property value converted to unsigned
2424 TEMU_API uint64_t temu_getValueUnsigned(temu_Object_ *Obj, const char *PropName,
2425  int Idx);
2426 //! Get property (without side effects)
2427 //! \param Obj Object pointer
2428 //! \param PropName Name of property
2429 //! \param Idx Index in property array (set to 0 if scalar)
2430 //! \result The property value converted to signed
2431 TEMU_API int64_t temu_getValueSigned(temu_Object_ *Obj, const char *PropName,
2432  int Idx);
2433 
2434 //! Get property (without side effects)
2435 //! \param Obj Object pointer
2436 //! \param PropName Name of property
2437 //! \param Idx Index in property array (set to 0 if scalar)
2438 //! \result The property value converted to double
2439 TEMU_API double temu_getValueDouble(temu_Object_ *Obj, const char *PropName,
2440  int Idx);
2441 //! Read property (with side effects)
2442 //! \param Obj Object pointer
2443 //! \param PropName Name of property
2444 //! \param Idx Index in property array (set to 0 if scalar)
2445 //! \result The property value converted to unsigned
2446 TEMU_API uint64_t temu_readValueUnsigned(temu_Object_ *Obj,
2447  const char *PropName, int Idx);
2448 //! Read property (with side effects)
2449 //! \param Obj Object pointer
2450 //! \param PropName Name of property
2451 //! \param Idx Index in property array (set to 0 if scalar)
2452 //! \result The property value converted to signed
2453 TEMU_API int64_t temu_readValueSigned(temu_Object_ *Obj, const char *PropName,
2454  int Idx);
2455 //! Read property (with side effects)
2456 //! \param Obj Object pointer
2457 //! \param PropName Name of property
2458 //! \param Idx Index in property array (set to 0 if scalar)
2459 //! \result The property value converted to double
2460 TEMU_API double temu_readValueDouble(temu_Object_ *Obj, const char *PropName,
2461  int Idx);
2462 
2463 //! Set unsigned property (without side effects)
2464 //! \param Obj Object pointer
2465 //! \param PropName Name of property
2466 //! \param Val The new property value
2467 //! \param Idx Index in property array (set to 0 if scalar)
2468 TEMU_API void temu_setValueUnsigned(temu_Object_ *Obj, const char *PropName,
2469  uint64_t Val, int Idx);
2470 //! Set signed property (without side effects)
2471 //! \param Obj Object pointer
2472 //! \param PropName Name of property
2473 //! \param Val The new property value
2474 //! \param Idx Index in property array (set to 0 if scalar)
2475 TEMU_API void temu_setValueSigned(temu_Object_ *Obj, const char *PropName,
2476  int64_t Val, int Idx);
2477 //! Set floating point property (without side effects)
2478 //! \param Obj Object pointer
2479 //! \param PropName Name of property
2480 //! \param Val The new property value
2481 //! \param Idx Index in property array (set to 0 if scalar)
2482 TEMU_API void temu_setValueDouble(temu_Object_ *Obj, const char *PropName,
2483  double Val, int Idx);
2484 //! Write unsigned property (with side effects)
2485 //! \param Obj Object pointer
2486 //! \param PropName Name of property
2487 //! \param Val The new property value
2488 //! \param Idx Index in property array (set to 0 if scalar)
2489 TEMU_API void temu_writeValueUnsigned(temu_Object_ *Obj, const char *PropName,
2490  uint64_t Val, int Idx);
2491 //! Write signed property (with side effects)
2492 //! \param Obj Object pointer
2493 //! \param PropName Name of property
2494 //! \param Val The new property value
2495 //! \param Idx Index in property array (set to 0 if scalar)
2496 TEMU_API void temu_writeValueSigned(temu_Object_ *Obj, const char *PropName,
2497  int64_t Val, int Idx);
2498 //! Write floating point property (with side effects)
2499 //! \param Obj Object pointer
2500 //! \param PropName Name of property
2501 //! \param Val The new property value
2502 //! \param Idx Index in property array (set to 0 if scalar)
2503 TEMU_API void temu_writeValueDouble(temu_Object_ *Obj, const char *PropName,
2504  double Val, int Idx);
2505 
2506 /*!
2507  * Create a signed propval of the given type
2508  * \param T Type ID, must be a signed integer type tag
2509  * \param I Integer value
2510  * \result Property value with the given type and value.
2511  */
2512 TEMU_API temu_Propval temu_signedPropval(temu_Type T, int64_t I);
2513 /*!
2514  * Create an unsigned propval of the given type
2515  * \param T Type ID, must be an unsigned integer type tag
2516  * \param U Integer value
2517  * \result Property value with the given type and value.
2518  */
2519 TEMU_API temu_Propval temu_unsignedPropval(temu_Type T, uint64_t U);
2520 /*!
2521  * Create a floating point propval of the given type
2522  * \param T Type ID, must be a teTY_Float or teTY_Double
2523  * \param V Value
2524  * \result Property value with the given type and value.
2525  */
2526 TEMU_API temu_Propval temu_floatingPointPropval(temu_Type T, double V);
2527 
2528 /*!
2529  * Check if object has a command
2530  * \param Obj Object pointer
2531  * \param CmdName Name of command
2532  * \result 0 in case command does not exist. Otherwise 1.
2533  */
2534 TEMU_API int temu_objectHasCmd(const temu_Object_ *Obj, const char *CmdName);
2535 
2536 #ifdef __cplusplus
2537 }
2538 #endif
2539 
2540 #endif /*! TEMU_OBJSYS_C_H */
temu_Class::Impl
void * Impl
Internal pointer, do not touch.
Definition: Objsys.h:460
temu_isNormalProperty
TEMU_API int temu_isNormalProperty(temu_Object_ *Obj, const char *PropName)
temu_Object::BreakOnMemoryWrite
uint64_t BreakOnMemoryWrite
Definition: Objsys.h:108
temu_listDispose
TEMU_API void temu_listDispose(temu_List *List)
temu_setValueI32
TEMU_API void temu_setValueI32(temu_Object_ *Obj, const char *PropName, int32_t Val, int Idx)
temu_Component
struct temu_Component temu_Component
Definition: Objsys.h:57
temu_Dict
void temu_Dict
Definition: Objsys.h:358
temu_addScalarProperty
TEMU_API int temu_addScalarProperty(temu_Class *Cls, const char *Name, int offset, temu_Type T, const char *Doc)
temu_List::Typ
temu_Type Typ
Element type in list.
Definition: Objsys.h:376
temu_Propref
Definition: Objsys.h:345
temu_writeValueDouble
TEMU_API void temu_writeValueDouble(temu_Object_ *Obj, const char *PropName, double Val, int Idx)
temu_addPseudoProperty
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)
temu_Vector::Typ
temu_Type Typ
Type of vector data.
Definition: Objsys.h:364
temu_getLoggingCategory
const TEMU_API char * temu_getLoggingCategory(temu_Class *Cls, unsigned CategoryId)
temu_ObjectIface::deserialise
void(* deserialise)(void *Obj, const char *BaseName, void *Ctxt)
Definition: Objsys.h:2271
temu_checkpointGetLength
TEMU_API int temu_checkpointGetLength(void *Ctxt, const char *Name)
temu_dictRemoveValue
TEMU_API int temu_dictRemoveValue(temu_Dict *Dict, const char *Name)
temu_CreateArg::Key
const char * Key
Name of argument.
Definition: Objsys.h:432
temu_Object::TraceMemoryReads
uint64_t TraceMemoryReads
Definition: Objsys.h:102
temu_Vector::Capacity
uint32_t Capacity
Managed do not use directly.
Definition: Objsys.h:367
temu_addInterfaceArray
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_writeValueObj
TEMU_API void temu_writeValueObj(temu_Object *Obj, const char *PropName, temu_Object *Val, int Idx)
temu_PropInfo::Count
size_t Count
Number of elements in property.
Definition: Objsys.h:1888
temu_Object::LoggingFlags
uint64_t LoggingFlags
Log category enabled/disabled.
Definition: Objsys.h:90
temu_List::Head
temu_ListNode * Head
Managed pointer, do not use directly.
Definition: Objsys.h:377
temu_setVTable
TEMU_API int temu_setVTable(temu_Class *Cls, void *VTable)
TEMU_DYN_ARRAY_TYPE
#define TEMU_DYN_ARRAY_TYPE(T, P)
Definition: Objsys.h:240
temu_PropAccessor::Data
void * Data
Pointer to value if applicable.
Definition: Objsys.h:756
temu_setValueU8
TEMU_API void temu_setValueU8(temu_Object_ *Obj, const char *PropName, uint8_t Val, int Idx)
temu_PropAccessor
Definition: Objsys.h:751
temu_qualifyAs
TEMU_API void temu_qualifyAs(temu_Class *Cls, unsigned Qualifier)
temu_pluginPathAppend
TEMU_API void temu_pluginPathAppend(const char *Path)
temu_ObjectIface::checkSanity
int(* checkSanity)(void *Obj, int Report)
Definition: Objsys.h:2279
temu_writeValueI16
TEMU_API void temu_writeValueI16(temu_Object_ *Obj, const char *PropName, int16_t Val, int Idx)
temu_isValidInterfaceName
TEMU_API int temu_isValidInterfaceName(const char *Name)
temu_isMachine
TEMU_API int temu_isMachine(const temu_Object_ *Obj)
temu_writeValueU16
TEMU_API void temu_writeValueU16(temu_Object_ *Obj, const char *PropName, uint16_t Val, int Idx)
temu_isNumber
TEMU_API int temu_isNumber(temu_Propval Pv)
temu_nameForObject
const TEMU_API char * temu_nameForObject(const temu_Object_ *Obj)
temu_dictGetNextKey
const TEMU_API char * temu_dictGetNextKey(temu_Dict *Dict, const char *Key)
temu_setValueU32
TEMU_API void temu_setValueU32(temu_Object_ *Obj, const char *PropName, uint32_t Val, int Idx)
temu_isValidObjectName
TEMU_API int temu_isValidObjectName(const char *Name)
temu_objectHasIface
TEMU_API int temu_objectHasIface(const temu_Object_ *Obj, const char *IfaceName)
temu_PropInfo::Offset
uintptr_t Offset
Offset from struct start.
Definition: Objsys.h:1889
temu_Buff::data0
uintptr_t data0
Definition: Buffer.h:84
temu_IfaceRefArray::Ifaces
temu_IfaceRef * Ifaces
Interface references.
Definition: Objsys.h:141
temu_PropAccessor::Obj
temu_Object * Obj
Pointer to object containing property.
Definition: Objsys.h:753
temu_setValueI8
TEMU_API void temu_setValueI8(temu_Object_ *Obj, const char *PropName, int8_t Val, int Idx)
temu_ListNode
void temu_ListNode
Definition: Objsys.h:370
temu_isQualifiedAs
TEMU_API int temu_isQualifiedAs(const temu_Object_ *Obj, unsigned Qualifier)
temu_getVTable
TEMU_API void * temu_getVTable(const temu_Object_ *Obj)
temu_IfaceRefArray
Definition: Objsys.h:138
temu_nameForClass
const TEMU_API char * temu_nameForClass(temu_Class *Cls)
temu_checkSanity
TEMU_API int temu_checkSanity(int Report)
temu_dictDispose
TEMU_API void temu_dictDispose(temu_Dict *Dict)
temu_registerInterfaceType
TEMU_API void * temu_registerInterfaceType(const char *Name)
temu_PropName::Name
const char * Name
Property name.
Definition: Objsys.h:355
temu_listAppend
TEMU_API void temu_listAppend(temu_List *List, temu_Propval Val)
temu_asDouble
TEMU_API double temu_asDouble(temu_Propval Pv)
temu_Object::UserData
void * UserData
User data pointer. This is not saved in snapshots.
Definition: Objsys.h:96
temu_isString
TEMU_API int temu_isString(temu_Propval Pv)
temu_isPseudoProperty
TEMU_API int temu_isPseudoProperty(temu_Object_ *Obj, const char *PropName)
temu_PropInfo::Name
const char * Name
Name of property.
Definition: Objsys.h:1886
temu_Object::DisposedNotification
int64_t DisposedNotification
Definition: Objsys.h:93
temu_readValueDouble
TEMU_API double temu_readValueDouble(temu_Object_ *Obj, const char *PropName, int Idx)
temu_ifaceRefArrayPush2
TEMU_API void temu_ifaceRefArrayPush2(temu_IfaceRefArray *Arr TEMU_NONNULL, temu_Object_ *Obj TEMU_NONNULL, void *Iface TEMU_NONNULL)
temu_Propval
Definition: Objsys.h:388
temu_foreachInterface
TEMU_API void temu_foreachInterface(temu_Class *C, void(*Func)(temu_Class *, const char *, void *), void *Arg)
temu_foreachProcessor
TEMU_API void temu_foreachProcessor(void(*Func)(temu_Object_ *, void *), void *Arg)
temu_addLoggingCategory
TEMU_API int temu_addLoggingCategory(temu_Class *Cls, unsigned CategoryId, const char *Category)
temu_isDiscrete
TEMU_API int temu_isDiscrete(temu_Propval Pv)
temu_foreachProperty
TEMU_API void temu_foreachProperty(temu_Class *C, void(*Func)(temu_Class *, const char *, void *), void *Arg)
temu_PropAccessor::Index
int Index
Index used in access, can be modified by user.
Definition: Objsys.h:754
temu_qualifyAsCpu
TEMU_API void temu_qualifyAsCpu(temu_Class *Cls)
temu_getPropLength
TEMU_API int temu_getPropLength(const temu_Object_ *Obj, const char *PropName)
temu_Buff::data1
uint32_t data1
Definition: Buffer.h:85
temu_ObjectDisposeFunc
void(* temu_ObjectDisposeFunc)(void *)
Definition: Objsys.h:446
temu_writeValueSigned
TEMU_API void temu_writeValueSigned(temu_Object_ *Obj, const char *PropName, int64_t Val, int Idx)
temu_addArrayPseudoProperty
TEMU_API int temu_addArrayPseudoProperty(temu_Class *Cls, const char *Name, temu_Type T, int NumElems, const char *Doc)
temu_ifaceRefArrayDispose
TEMU_API void temu_ifaceRefArrayDispose(temu_IfaceRefArray *Arr)
temu_setValueU16
TEMU_API void temu_setValueU16(temu_Object_ *Obj, const char *PropName, uint16_t Val, int Idx)
temu_generateObjectGraph
TEMU_API int temu_generateObjectGraph(const char *Path, int Display)
temu_CreateArg
Definition: Objsys.h:431
temu_addScalarPseudoProperty
TEMU_API int temu_addScalarPseudoProperty(temu_Class *Cls, const char *Name, temu_Type T, const char *Doc)
temu_propInfoForClass
TEMU_API int temu_propInfoForClass(temu_Class *Cls, unsigned PIIndex, unsigned PICount, temu_PropInfo *PI)
temu_IfaceRef::Obj
temu_Object_ * Obj
Object pointer (first field of interface reference)
Definition: Objsys.h:125
temu_deserialiseJSON
TEMU_API int temu_deserialiseJSON(const char *FileName)
temu_objectHasCmd
TEMU_API int temu_objectHasCmd(const temu_Object_ *Obj, const char *CmdName)
temu_MetaIface
void temu_MetaIface
Definition: Objsys.h:61
temu_ifaceRefArrayPush
TEMU_API void temu_ifaceRefArrayPush(temu_IfaceRefArray *Arr TEMU_NONNULL, temu_IfaceRef Iface)
temu_PropWriter
void(* temu_PropWriter)(void *Obj, temu_Propval Pv, int Idx)
Definition: Objsys.h:712
temu_pluginPathPrint
TEMU_API void temu_pluginPathPrint(void)
temu_PropAccessor::setProp
void(* setProp)(struct temu_PropAccessor *accessor, temu_Propval pv)
Set property via accessor.
Definition: Objsys.h:768
TEMU_IFACE_REFERENCE_TYPE
#define TEMU_IFACE_REFERENCE_TYPE(N)
Definition: Objsys.h:194
temu_writeValueU32
TEMU_API void temu_writeValueU32(temu_Object_ *Obj, const char *PropName, uint32_t Val, int Idx)
temu_writeProp
TEMU_API int temu_writeProp(temu_Object_ *Obj, const char *Name, int idx, temu_Propval *PV)
temu_isComponent
TEMU_API int temu_isComponent(const temu_Object_ *Obj)
temu_isSigned
TEMU_API int temu_isSigned(temu_Propval Pv)
temu_writeValueUnsigned
TEMU_API void temu_writeValueUnsigned(temu_Object_ *Obj, const char *PropName, uint64_t Val, int Idx)
temu_foreachClass
TEMU_API void temu_foreachClass(void(*Func)(temu_Class *, void *), void *Arg)
temu_Object::Component
temu_Component * Component
Parent component (null for root comp)
Definition: Objsys.h:89
temu_writeValueI64
TEMU_API void temu_writeValueI64(temu_Object_ *Obj, const char *PropName, int64_t Val, int Idx)
temu_setValueU64
TEMU_API void temu_setValueU64(temu_Object_ *Obj, const char *PropName, uint64_t Val, int Idx)
temu_writeValueI8
TEMU_API void temu_writeValueI8(temu_Object_ *Obj, const char *PropName, int8_t Val, int Idx)
temu_serialiseProp
TEMU_API void temu_serialiseProp(void *Ctxt, const char *Name, temu_Type Typ, int Count, void *Data)
temu_addInterfaceReference
TEMU_API void temu_addInterfaceReference(temu_Class *Cls, const char *PropName, int Offset, const char *TypeName, int Count, unsigned Flags, temu_PropWriter Wr, temu_PropReader Rd, const char *Doc)
temu_TypeObject
void temu_TypeObject
Definition: Objsys.h:1883
temu_PropInfo::Typ
temu_Type Typ
Type tag.
Definition: Objsys.h:1887
temu_PropAccessor::Typ
temu_Type Typ
Type of property.
Definition: Objsys.h:752
temu_Object::Name
char * Name
Object name.
Definition: Objsys.h:87
temu_Propref::Typ
temu_Type Typ
Type of property.
Definition: Objsys.h:346
temu_addArrayProperty
TEMU_API int temu_addArrayProperty(temu_Class *Cls, const char *Name, int offset, temu_Type T, int NumElems, const char *Doc)
temu_Propref::Ptr
void * Ptr
Pointer to property.
Definition: Objsys.h:347
temu_inlineDeserialiseJSON
TEMU_API int temu_inlineDeserialiseJSON(const char *FileName)
temu_loadPluginGlobal
TEMU_API int temu_loadPluginGlobal(const char *PluginName)
temu_setValueI16
TEMU_API void temu_setValueI16(temu_Object_ *Obj, const char *PropName, int16_t Val, int Idx)
temu_Object::IsCheckpointable
uint64_t IsCheckpointable
The object is snapshottable.
Definition: Objsys.h:99
temu_PropAccessor::Setter
temu_PropWriter Setter
Setter function if applicable.
Definition: Objsys.h:759
temu_addPseudoInterfaceReference
TEMU_API void temu_addPseudoInterfaceReference(temu_Class *Cls, const char *PropName, const char *TypeName, int Count, unsigned Flags, temu_PropWriter Wr, temu_PropReader Rd, temu_PropWriter Set, temu_PropReader Get, const char *Doc)
temu_setValue
TEMU_API void temu_setValue(temu_Object_ *Obj, const char *PropName, temu_Propval Val, int Idx) TEMU_NO_WRAP
temu_objectHasProp
TEMU_API int temu_objectHasProp(const temu_Object_ *Obj, const char *PropName)
temu_connect
TEMU_API int temu_connect(temu_Object_ *A, const char *PropName, temu_Object_ *B, const char *IfaceName)
temu_Object::Class
temu_Class * Class
Class pointer.
Definition: Objsys.h:86
temu_Object::TraceMemoryWrites
uint64_t TraceMemoryWrites
Definition: Objsys.h:104
temu_writeValue
TEMU_API void temu_writeValue(temu_Object_ *Obj, const char *PropName, temu_Propval Val, int Idx) TEMU_NO_WRAP
temu_CreateArg::Val
temu_Propval Val
Value of argument.
Definition: Objsys.h:433
temu_isCpu
TEMU_API int temu_isCpu(const temu_Object_ *Obj)
PROP_ASSERT
#define PROP_ASSERT(p, t)
Definition: Objsys.h:663
temu_qualifyAsMemory
TEMU_API void temu_qualifyAsMemory(temu_Class *Cls)
temu_vecPush
TEMU_API void temu_vecPush(temu_Vector *Vec, temu_Propval Val)
temu_isValidPropertyName
TEMU_API int temu_isValidPropertyName(const char *Name)
temu_isReal
TEMU_API int temu_isReal(temu_Propval Pv)
temu_Class::LoggingCategories
const char * LoggingCategories[32]
Definition: Objsys.h:466
temu_typenameForInterface
const TEMU_API char * temu_typenameForInterface(const temu_Object_ *Obj, const void *Iface)
temu_snapshotGetLength
TEMU_API int temu_snapshotGetLength(void *Ctxt, const char *Name)
temu_Buff::data2
uint32_t data2
Definition: Buffer.h:86
temu_List::Tail
temu_ListNode * Tail
Managed pointer, do not use directly.
Definition: Objsys.h:378
temu_writeValueU64
TEMU_API void temu_writeValueU64(temu_Object_ *Obj, const char *PropName, uint64_t Val, int Idx)
temu_getPropDynLength
TEMU_API int temu_getPropDynLength(const temu_Object_ *Obj, const char *PropName)
temu_ObjectIface::timeSourceSet
void(* timeSourceSet)(void *Obj)
Definition: Objsys.h:2287
temu_ObjectIface::printObject
void(* printObject)(void *Obj)
Definition: Objsys.h:2295
temu_serialiseJSON
TEMU_API int temu_serialiseJSON(const char *FileName)
temu_Object
struct temu_Object temu_Object
Definition: Scheduler.h:18
temu_qualifyAsMachine
TEMU_API void temu_qualifyAsMachine(temu_Class *Cls)
temu_Class::Super
temu_Object Super
Super class of the class instance.
Definition: Objsys.h:459
temu_dictInsertValue
TEMU_API int temu_dictInsertValue(temu_Dict *Dict, const char *Name, temu_Propval Val)
temu_vecDispose
TEMU_API void temu_vecDispose(temu_Vector *Vec)
temu_TimeSource
struct temu_TimeSource temu_TimeSource
Definition: Scheduler.h:17
temu_writeValueU8
TEMU_API void temu_writeValueU8(temu_Object_ *Obj, const char *PropName, uint8_t Val, int Idx)
temu_getValueDouble
TEMU_API double temu_getValueDouble(temu_Object_ *Obj, const char *PropName, int Idx)
temu_isUnsigned
TEMU_API int temu_isUnsigned(temu_Propval Pv)
temu_PropAccessor::writeProp
void(* writeProp)(struct temu_PropAccessor *accessor, temu_Propval pv)
Write property via accessor.
Definition: Objsys.h:764
temu_setTimeSource
TEMU_API void temu_setTimeSource(temu_Object_ *Obj, temu_TimeSource_ *TS)
temu_classHasCommand
TEMU_API int temu_classHasCommand(const temu_Class *Cls, const char *CmdName)
temu_objsysClearObjects
TEMU_API void temu_objsysClearObjects(void)
temu_PropName::Obj
temu_Object_ * Obj
Object pointer.
Definition: Objsys.h:354
temu_addPort
TEMU_API int temu_addPort(temu_Class *C, const char *IfaceRefName, const char *IfaceName, const char *Doc)
temu_PropAccessor::Reader
temu_PropReader Reader
Reader function if applicable.
Definition: Objsys.h:758
temu_PropAccessor::Getter
temu_PropReader Getter
Getter function if applicable.
Definition: Objsys.h:760
temu_IfaceRefArray::Reserved
uint32_t Reserved
Number of slots allocated for array.
Definition: Objsys.h:140
temu_Object::IsTimeSource
uint64_t IsTimeSource
Definition: Objsys.h:100
temu_Class::Dispose
temu_ObjectDisposeFunc Dispose
Definition: Objsys.h:464
temu_ObjectIface::serialise
void(* serialise)(void *Obj, const char *BaseName, void *Ctxt)
Definition: Objsys.h:2260
temu_IfaceRefArray::Size
uint32_t Size
Number of used items in array.
Definition: Objsys.h:139
temu_typeToName
const TEMU_API char * temu_typeToName(temu_Type Typ)
temu_writeValueI32
TEMU_API void temu_writeValueI32(temu_Object_ *Obj, const char *PropName, int32_t Val, int Idx)
PROP_VAL_INITIALIZER
#define PROP_VAL_INITIALIZER(typ, suffix, typetag, valtag)
Definition: Objsys.h:671
temu_indexForInterface
TEMU_API int temu_indexForInterface(const temu_Object_ *Obj, const void *Iface)
temu_setValueSigned
TEMU_API void temu_setValueSigned(temu_Object_ *Obj, const char *PropName, int64_t Val, int Idx)
temu_deserialiseProp
TEMU_API void temu_deserialiseProp(void *Ctxt, temu_Object_ *Obj, const char *Name)
TEMU_NO_WRAP
#define TEMU_NO_WRAP
Definition: Objsys.h:43
temu_Class::Create
temu_ObjectCreateFunc Create
Definition: Objsys.h:462
temu_loadPlugin
TEMU_API int temu_loadPlugin(const char *PluginName)
temu_Propval::Typ
temu_Type Typ
Value type.
Definition: Objsys.h:389
temu_requireInterface
TEMU_API void temu_requireInterface(temu_Class *Cls, const char *PropName, const char *IfaceType)
temu_Object::WillDisposeNotification
int64_t WillDisposeNotification
Definition: Objsys.h:91
temu_IfaceRef
Definition: Objsys.h:124
temu_getVTableForClass
TEMU_API void * temu_getVTableForClass(temu_Class *Cls)
temu_disposeObject
TEMU_API void temu_disposeObject(temu_Object_ *Obj)
temu_PropInfo::TypeObj
temu_TypeObject * TypeObj
Definition: Objsys.h:1890
temu_listPrepend
TEMU_API void temu_listPrepend(temu_List *List, temu_Propval Val)
temu_objsysClear
TEMU_API void temu_objsysClear(void)
temu_Vector::VecData
void * VecData
Managed pointer, do not use directly.
Definition: Objsys.h:365
temu_setValueDouble
TEMU_API void temu_setValueDouble(temu_Object_ *Obj, const char *PropName, double Val, int Idx)
temu_setValueI64
TEMU_API void temu_setValueI64(temu_Object_ *Obj, const char *PropName, int64_t Val, int Idx)
temu_pluginPathRemove
TEMU_API void temu_pluginPathRemove(const char *Path)
temu_PropAccessor::Writer
temu_PropWriter Writer
Writer function if applicable.
Definition: Objsys.h:757
temu_isMemory
TEMU_API int temu_isMemory(const temu_Object_ *Obj)
temu_Object::IsClassObject
uint64_t IsClassObject
The object is a class object.
Definition: Objsys.h:98
temu_getInterfaceType
TEMU_API void * temu_getInterfaceType(const char *Name)
temu_Vector::Size
uint32_t Size
Managed do not use directly.
Definition: Objsys.h:366
temu_nameForInterface
const TEMU_API char * temu_nameForInterface(const temu_Object_ *Obj, const void *Iface)
temu_Object::TimeSource
temu_TimeSource * TimeSource
Timesource object.
Definition: Objsys.h:88
temu_isValidClassName
TEMU_API int temu_isValidClassName(const char *Name)
temu_Object::BreakOnMemoryRead
uint64_t BreakOnMemoryRead
Definition: Objsys.h:106
temu_getInterfaceName
const TEMU_API char * temu_getInterfaceName(temu_Object *Obj, void *Iface)
temu_foreachObject
TEMU_API void temu_foreachObject(void(*Func)(temu_Object_ *, void *), void *Arg)
temu_Class::VTable
void * VTable
Internal pointer, do not touch.
Definition: Objsys.h:461
temu_ifaceRefArraySize
TEMU_API unsigned temu_ifaceRefArraySize(temu_IfaceRefArray *Arr)
temu_setValueUnsigned
TEMU_API void temu_setValueUnsigned(temu_Object_ *Obj, const char *PropName, uint64_t Val, int Idx)
temu_IfaceRef::Iface
void * Iface
Type erased interface pointer.
Definition: Objsys.h:126
temu_ObjectCreateFunc
void *(* temu_ObjectCreateFunc)(const char *Name, int Argc, const temu_CreateArg *Argv)
Definition: Objsys.h:444
temu_vecGetData
TEMU_API void * temu_vecGetData(temu_Vector *Vec)
temu_Class
struct temu_Class temu_Class
Definition: Objsys.h:60