5#include <cx/container/stype_hashtable.h>
6#include <cx/container/stype_sarray.h>
9#include "stype_struct.h"
26typedef struct StructSet StructSet;
28typedef struct StructMemberDesc {
39typedef struct StructInfo {
46 void (*init)(
void* _struct);
47 void (*destroy)(
void* _struct);
49 const StructMemberDesc members[];
53typedef struct StructSet {
55 const StructInfo* entries[];
63_Ret_maybenull_
const StructInfo*
structSetFind(_In_
const StructSet* ss, _In_opt_ strref name);
65typedef struct StructBase {
67 const StructInfo* structinfo;
74#define structInfoName(sname) sname##_structinfo
75#define structDefaultsName(sname) sname##_structdefaults
77#define STRUCTBASE(s) (unused_noeval(&((s)->_is_struct)), (StructBase*)(s))
78#define STRUCTHANDLE(sp) (unused_noeval(&((*sp)->_is_struct)), (StructBase**)(sp))
80void _structInitMany(_Out_ StructBase* base, _In_
const StructInfo* info,
int number);
99#define structInitMany(structname, s, n) \
100 _structInitMany(STRUCTBASE(s), &structInfoName(structname), n)
118#define structInit(structname, s) _structInitMany(STRUCTBASE(s), &structInfoName(structname), 1)
120_Ret_notnull_ StructBase* _structAlloc(_In_
const StructInfo* info);
139#define structCreate(structname) ((structname*)_structAlloc(&structInfoName(structname)))
143void _structDestroyMember(_In_
const StructMemberDesc* member, _Inout_ StructBase* s);
145void _structDestroyMembersMany(_Pre_notnull_ _Post_invalid_ StructBase* base,
int number);
165#define structDestroyMembersMany(s, n) _structDestroyMembersMany(STRUCTBASE(s), n)
185#define structDestroyMembers(s) _structDestroyMembersMany(STRUCTBASE(s), 1)
187_At_(*pbase, _Pre_maybenull_ _Post_null_)
void _structDestroy(StructBase** pbase);
205#define structDestroy(ps) _structDestroy(STRUCTHANDLE(ps))
const StructInfo * structSetFind(const StructSet *ss, strref name)
@ STRUCT_NoCopy
Member should be skipped during copy operations.
@ STRUCT_NoSerialize
Member should not be serialized (e.g. by JSON, etc.)
@ STRUCT_NoDestroy
Member should not be automatically destroyed.
Hash table container with type-safe generic key-value storage.
Dynamic arrays with type-safe generic programming.
Copy-on-write strings with automatic memory management and rope optimization.
Runtime type system and type descriptor infrastructure.