|
CX Framework
Cross-platform C utility framework
|
Macros | |
| #define | stStored(st, storage) (stHasFlag(st, PassPtr) ? stgeneric(ptr, (void*)(storage)) : _stStoredVal(st, storage)) |
| #define | stStoredPtr(st, storage) (stHasFlag(st, PassPtr) ? &stgeneric(ptr, ((void*)(storage))) : (stgeneric*)((void*)(storage))) |
| #define | stGenPtr(st, gen) (stHasFlag(st, PassPtr) ? (gen).st_ptr : &(gen)) |
Macros for loading and storing typed values from raw memory. These handle the distinction between pass-by-value types (stored inline) and pass-by-pointer types (stored as pointers).
| #define stGenPtr | ( | st, | |
| gen | |||
| ) | (stHasFlag(st, PassPtr) ? (gen).st_ptr : &(gen)) |
void* stGenPtr(stype st, stgeneric gen)
Get a pointer to the actual data from a generic container.
For pass-by-pointer types, extracts the pointer stored in the container. For pass-by-value types, returns the address of the container itself.
| st | Type descriptor |
| gen | Generic container with value |
| #define stStored | ( | st, | |
| storage | |||
| ) | (stHasFlag(st, PassPtr) ? stgeneric(ptr, (void*)(storage)) : _stStoredVal(st, storage)) |
stgeneric stStored(stype st, void* storage)
Load a typed value from raw storage into a generic container.
Handles both inline storage (primitives) and pointer-based storage (objects, opaque). For pass-by-value types, reads the value directly from memory. For pass-by-pointer types, treats storage as containing a pointer to the actual value.
| st | Type descriptor |
| storage | Pointer to the stored value |
Example:
| #define stStoredPtr | ( | st, | |
| storage | |||
| ) | (stHasFlag(st, PassPtr) ? &stgeneric(ptr, ((void*)(storage))) : (stgeneric*)((void*)(storage))) |
stgeneric* stStoredPtr(stype st, void* storage)
Get a pointer to a stored value suitable for modification.
For pass-by-value types, returns a pointer directly to the storage location. For pass-by-pointer types, wraps the pointer in a generic container.
| st | Type descriptor |
| storage | Pointer to storage location |