Go to the source code of this file.
◆ DC_TRAIT_REFERENCABLE
| #define DC_TRAIT_REFERENCABLE |
( |
| SELF | ) |
|
Value:
DC_STATIC_ASSERT(
sizeof(
NS(
SELF, ref)) <=
sizeof(
SELF*), \
"Reference type must be at most pointer sized"); \
#define DC_REQUIRE_TYPE(obj, name)
The reference trait. For some objects references do not need to be the size of pointers.
- For singletons an empty struct is sufficient
- For a small (global) pool of objects, a smaller index can be used.
These are convertable to pointers for ease of use, but use less storage when stored.
Definition at line 13 of file ref.h.
13#define DC_TRAIT_REFERENCABLE(SELF) \
14 DC_REQUIRE_TYPE(SELF, ref); \
15 DC_STATIC_ASSERT(sizeof(NS(SELF, ref)) <= sizeof(SELF*), \
16 "Reference type must be at most pointer sized"); \
17 DC_REQUIRE_METHOD(SELF*, NS(SELF, ref), deref, (NS(SELF, ref)))
◆ DC_TRAIT_REFERENCABLE_BY_PTR
| #define DC_TRAIT_REFERENCABLE_BY_PTR |
( |
| SELF | ) |
|
Value:
DC_TRAIT_REFERENCABLE(
SELF)
Definition at line 19 of file ref.h.
19#define DC_TRAIT_REFERENCABLE_BY_PTR(SELF) \
20 typedef SELF* NS(SELF, ref); \
21 DC_PUBLIC static SELF* NS(NS(SELF, ref), deref)(NS(SELF, ref) ref) { return ref; } \
22 DC_TRAIT_REFERENCABLE(SELF)
◆ DC_TRAIT_REFERENCABLE_SINGLETON
| #define DC_TRAIT_REFERENCABLE_SINGLETON |
( |
| SELF, |
|
|
| INSTANCE ) |
Value:
DC_TRAIT_REFERENCABLE(
SELF)
#define DC_ZERO_SIZED(TYPE)
Zero sized types are useful as markers (e.g. for gdb printing, or to replace debug info structs.
Definition at line 24 of file ref.h.
24#define DC_TRAIT_REFERENCABLE_SINGLETON(SELF, INSTANCE) \
25 DC_ZERO_SIZED(NS(SELF, ref)); \
26 DC_PUBLIC static NS(SELF, ref) NS(SELF, get_ref)() { return (NS(SELF, ref)){}; } \
27 DC_PUBLIC static SELF* NS(NS(SELF, ref), deref)(NS(SELF, ref) ) { return &INSTANCE; } \
28 DC_TRAIT_REFERENCABLE(SELF)