CX Framework
Cross-platform C utility framework
Loading...
Searching...
No Matches
stype.h File Reference

Runtime type system and type descriptor infrastructure. More...

#include <cx/debug/assert.h>
#include <cx/platform/base.h>
#include <cx/platform/cpp.h>
#include <cx/string/strliteral.h>
#include <cx/utils/macros/optarg.h>
#include <cx/utils/macros/salieri.h>
#include <cx/utils/macros/unused.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>

Go to the source code of this file.

Data Structures

struct  STypeInfo
 
struct  STypeInfoExt
 

Macros

#define stTypeCast(name, v)   ((SType_##name)(v))
 
#define stPtrCast(name, v)   ((SType_##name*)(v))
 
#define stvarTypeId(v)   (stvarType(v)->id)
 
#define stTypeId(name)   STypeId_##name
 
#define stTypeSize(name)   STypeSize_##name
 
#define stHasFlag(st, fname)   (((st)->flags & stFlag(fname)) != 0)
 
#define stGetSize(st)   ((st)->size)
 
#define stCheck(type, val)   STypeCheck_##type(type, val)
 
#define stCheckPtr(type, ptr)   STypeCheckPtr_##type(type, ptr)
 
#define stRvalAddr(type, rval)   ((stStorageType(type)[1]) { rval })
 
#define stType(name)   (&stTypeInfo(name))
 
#define stArg(type, val)   STypeArg_##type(type, val)
 
#define stArgPtr(type, val)   STypeArgPtr_##type(type, val)
 
#define stCheckedArg(type, val)   STypeCheckedArg_##type(type, val)
 
#define stCheckedPtrArg(type, val)   STypeCheckedPtrArg_##type(type, val)
 
#define stExt(name)   (&_stie_##name)
 
#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))
 
#define stDestroy(type, pobj, ...)    _stDestroy(stType(type), stArgPtr(type, pobj), opt_flags(__VA_ARGS__))
 
#define stCmp(type, obj1, obj2, ...)    _stCmp(stType(type), stArg(type, obj1), stArg(type, obj2), opt_flags(__VA_ARGS__))
 
#define stCopy(type, pdest, src, ...)    _stCopy(stType(type), stArgPtr(type, pdest), stArg(type, src), opt_flags(__VA_ARGS__))
 
#define stHash(type, obj, ...)   _stHash(stType(type), stArg(type, obj), opt_flags(__VA_ARGS__))
 
#define stConvert(desttype, pdest, srctype, src, ...)
 
#define stDeclare(name)   extern const STypeInfo _sti_##name
 
#define stDefine(name)   const STypeInfo _sti_##name =
 

Typedefs

typedef struct STypeInfo STypeInfo
 
typedef struct STypeInfoExt STypeInfoExt
 
typedef void(* stDtorFunc) (stype st, stgeneric *gen, flags_t flags)
 
typedef intptr(* stCmpFunc) (stype st, stgeneric gen1, stgeneric gen2, flags_t flags)
 
typedef uint32(* stHashFunc) (stype st, stgeneric gen, flags_t flags)
 
typedef void(* stCopyFunc) (stype st, _stCopyDest_Anno_(st) stgeneric *dest, stgeneric src, flags_t flags)
 
typedef bool(* stConvertFunc) (stype destst, _stCopyDest_Anno_(destst) stgeneric *dest, stype srcst, stgeneric src, flags_t flags)
 
typedef bool(* stSerializeFunc) (stype st, stgeneric val, SerWriter *w)
 
typedef bool(* stDeserializeFunc) (stype st, stgeneric *val, SerReader *r)
 

Enumerations

enum  STYPE_OPS_FLAGS { ST_CaseInsensitive = 0x00000001 , ST_Equality = 0x00000002 , ST_Overflow = 0x00000004 , ST_Lossless = 0x00000008 }
 
enum  STypeInfoExtFlagsEnum { STIE_TypeSet = (1 << 0) }
 Flags for STypeInfoExt::flags. More...
 

Functions

stype stvarType (const stvar *v)
 
const char * stvarKey (const stvar *v)
 
stype stCanonical (stype st)
 
bool stEq (stype s1, stype s2)
 

Variables

const STypeInfoExt _stie_none
 
const STypeInfoExt _stie_bool
 
const STypeInfoExt _stie_int8
 
const STypeInfoExt _stie_int16
 
const STypeInfoExt _stie_int32
 
const STypeInfoExt _stie_int64
 
const STypeInfoExt _stie_uint8
 
const STypeInfoExt _stie_uint16
 
const STypeInfoExt _stie_uint32
 
const STypeInfoExt _stie_uint64
 
const STypeInfoExt _stie_float32
 
const STypeInfoExt _stie_float64
 
const STypeInfoExt _stie_string
 
const STypeInfoExt _stie_suid
 
const STypeInfoExt _stie_object
 
const STypeInfoExt _stie_buffer
 
const STypeInfoExt _stie_stvar
 
const STypeInfoExt _stie_sarray
 
const STypeInfoExt _stie_hashtable
 

Detailed Description

Runtime type system and type descriptor infrastructure.

Definition in file stype.h.