2
3
4
5
6
7
8
9
10
11
12
13
14
15#ifndef GIMBAL_PROPERTY_H
16#define GIMBAL_PROPERTY_H
18#include "../instances/gimbal_box.h"
21
22
23
25#define GBL_PROPERTY(self) (GBL_CAST
(GblProperty, self))
26#define GBL_PROPERTY_CLASS(klass) (GBL_CLASS_CAST
(GblProperty, klass))
27#define GBL_PROPERTY_GET_CLASS(self) (GBL_CLASSOF
(GblProperty, self))
34
35
36
38#define GBL_PROPERTIES(object, ...) GBL_PROPERTIES_
(object, __VA_ARGS__)
40#define GBL_PROPERTIES_REGISTER( ...) GBL_PROPERTIES_REGISTER_
(__VA_ARGS__)
43#define GBL_SELF_TYPE GblProperty
50typedef GblBool (*GblPropertyIterFn)(
const GblProperty* pProp,
void* pClosure);
53
54
71
72
73
74
75
76
77
78
79
80
81
82
83
84
87 GBL_RESULT (*pFnInitOptionalArgs)(
GBL_SELF, size_t argCount, va_list* pVaList);
89 GBL_RESULT (*pFnDefaultValue) (
GBL_CSELF, GblVariant* pValue);
91 GBL_RESULT (*pFnCheckValue) (
GBL_CSELF,
const GblVariant* pValue);
93 GBL_RESULT (*pFnValidateValue) (
GBL_CSELF, GblVariant* pValue);
95 GBL_RESULT (*pFnCompareValues) (
GBL_CSELF,
const GblVariant* pV1,
const GblVariant* pV2,
int* pResult);
99
100
101
102
103
104
105
106
107
108
124
125
126
138
139
140
150
151
152
160
161
162
165 const GblProperty* pPrev,
170 GblPropertyIterFn pFnIt,
175
176
177
183 size_t optionalArgCount,
190 size_t optionalArgCount,
198 size_t optionalArgCount,
206 size_t optionalArgCount,
214 size_t optionalArgCount,
219
220
221
229
230
231
240 const GblVariant* pV1,
247#define GBL_PROPERTIES_(object, ...)
248 GBL_PROPERTIES_IDS_
(object, __VA_ARGS__)
249 GBL_PROPERTIES_REGISTER_DEFINE_
(object, __VA_ARGS__)
251#define GBL_PROPERTIES_REGISTER_(...)
254#define GBL_PROPERTIES_REGISTER_1(object)
255 GBL_PROPERTIES_REGISTER_2
(object, NULL
)
257#define GBL_PROPERTIES_REGISTER_2(object, list)
259 for(size_t p = 0
; p < object##_Property_Id_count; ++p) {
260 object##_registerProperty_(p,
265#define GBL_PROPERTIES_IDS_(object, ...)
266 typedef enum object##_Property_Id_ {
268 object##_Property_Id_count
269 } object##_Property_Id_;
271#define GBL_PROPERTY_ID_(object, property)
272 GBL_PROPERTY_ID__
(object, GBL_EVAL property)
274#define GBL_PROPERTY_ID__(...)
275 GBL_PROPERTY_ID___
(__VA_ARGS__)
277#define GBL_PROPERTY_ID___(object, name, type, flags, ...)
278 object##_Property_Id_##name,
280#define GBL_PROPERTIES_REGISTER_DEFINE_(object, ...)
282 GBL_INLINE GBL_RESULT object##_registerProperty_(GblEnum id,
286 GblProperty* pProp = ppProp? *ppProp : GBL_NULL;
292 GBL_CTX_CALL(GblProperty_install(object##_type(), pProp));
293 if(ppProp) *ppProp = pProp;
298#define GBL_PROPERTY_REGISTER_(object, property)
299 GBL_PROPERTY_REGISTER__
(object, GBL_EVAL property)
301#define GBL_PROPERTY_REGISTER__(...)
302 GBL_PROPERTY_REGISTER___
(__VA_ARGS__)
304#define GBL_PROPERTY_REGISTER___(object, name, type, ...)
305 case object##_Property_Id_##name:
307 type##_PROPERTY_TYPE,
311 GBL_PROPERTY_VARARGS_
((__VA_ARGS__))));
314#define GBL_PROPERTY_VARARGS_(...)
317#define GBL_PROPERTY_VARARGS__1(flags)
320#define GBL_PROPERTY_VARARGS__N(...)
323#define GBL_PROPERTY_FLAGS_MASK_(...)
324 GBL_MAP(GBL_PROPERTY_FLAGS_MASK__
, __VA_ARGS__)0
326#define GBL_PROPERTY_FLAGS_MASK__(suffix)
327 GBL_PROPERTY_FLAG_##suffix |
#define GBL_CTX_VERIFY_CALL(...)
#define GBL_CTX_CALL(...)
#define GBL_CTX_BEGIN(...)
#define GBL_CTX_VERIFY(...)
#define GBL_FORWARD_DECLARE_STRUCT(S)
#define GBL_TYPEID(instanceStruct)
#define GBL_INSTANCE_DERIVE(derivedInstance, baseInstance)
#define GBL_PRIVATE_BEGIN
#define GBL_DECLARE_ENUM(E)
#define GBL_CLASS_DERIVE(...)
#define GBL_PRIVATE_END
Private data structure.
#define GBL_VA_OVERLOAD_CALL(BASE, SUFFIXER,...)
#define GBL_TUPLE_REST(X,...)
#define GBL_TUPLE_FIRST(...)
#define GBL_TUPLE_FOREACH(MACRO_, DATA_, TUPLE_)
#define GBL_VA_OVERLOAD_SUFFIXER_1_N(...)
#define GBL_VA_OVERLOAD_SUFFIXER_ARGC(...)
#define GBL_MAP(f,...)
Applies the function macro f to each of the remaining parameters.
GBL_PROPERTY_FLAG
Flags used to denote property attributes.
@ GBL_PROPERTY_FLAG_READ
Property value can be read.
@ GBL_PROPERTY_FLAG_SAVE_LOAD
Property is both savable and loadable.
@ GBL_PROPERTY_FLAG_ABSTRACT
Property must be implemented by deriving type.
@ GBL_PROPERTY_FLAG_OUT
Property releases ownership of data when reading.
@ GBL_PROPERTY_FLAG_WRITE
Property value can be modified.
@ GBL_PROPERTY_FLAG_LOAD
Property is deserialized when loading.
@ GBL_PROPERTY_FLAG_IN
Property assumes ownership of data when writing.
@ GBL_PROPERTY_FLAG_SAVE
Property is serialized when saving.
@ GBL_PROPERTY_FLAG_CONSTRUCT
Property must be given to the constructor.
@ GBL_PROPERTY_FLAG_OVERRIDE
Property overrides an existing property.
@ GBL_PROPERTY_FLAG_READ_WRITE
Property is both readable and writable.
@ GBL_PROPERTY_FLAG_ALL
Mask for all property flags combined.
GblProperty * GblProperty_create(GblType derivedType, const char *pName, size_t id, GblFlags flags, size_t optionalArgCount,...)
Creates a new property on the heap with the given type, name, id, flags, and any optional arguments h...
#define GBL_PROPERTY_TYPE
Type UUID for GblProperty.
const GblProperty * GblProperty_find(GblType objectType, const char *pName)
Looks up the given property by string name which was previously installed onto the given GblObject ty...
GblFlags GblProperty_combinedFlags(GblType objectType)
Returns the combined, bitwise OR'd flags from all properties registered onto the given type.
GblBool GblProperty_uninstall(GblType objType, const char *pName)
Uninstalls the property with the given name from the given object type.
GblBool GblProperty_uninstallQuark(GblType objType, GblQuark name)
Uninstalls the property with the given name quark from the given object type.
GBL_RESULT GblProperty_defaultValue(const GblProperty *pSelf, GblVariant *pValue)
Sets the given variant to contain the default value of the given property, calling GblPropertyClass::...
GblType GblProperty_objectType(const GblProperty *pSelf)
Returns the UUID of the type associated with the given property.
const GblProperty * GblProperty_next(GblType objectType, const GblProperty *pPrev, GblFlags mask)
Returns the next property installed onto the given type, given the current property (or NULL for the ...
GblBool GblProperty_foreach(GblType objectType, GBL_PROPERTY_FLAG flags, GblPropertyIterFn pFnIt, void *pClosure)
Iterates over the properties installed onto the given type containing any of the given flags,...
GblBool GblProperty_checkValue(const GblProperty *pSelf, const GblVariant *pValue)
Checks whether the value contained by the given variant is valid for the given property,...
int GblProperty_compareValues(const GblProperty *pSelf, const GblVariant *pV1, const GblVariant *pV2)
Compares the values contained by the given variants, based on the rules of the given property,...
GBL_RESULT GblProperty_validateValue(const GblProperty *pSelf, GblVariant *pValue)
Modifies the value contained within the given variant to be a valid value, if possible,...
GblType GblProperty_type(void)
Returns the UUID associated with the GblProperty type, registering it if it hasn't been already.
size_t GblProperty_totalCount(void)
Returns the total number of properties which have been registered onto any GblType.
GBL_RESULT GblProperty_createOrConstruct(GblProperty **ppSelf, GblType derivedType, const char *pName, size_t id, GblFlags flags, size_t optionalArgCount,...)
Either calls GblProperty_create() or GblProperty_construct() based on whether ppSelf points to an exi...
GBL_RESULT GblProperty_constructVaList(GblProperty *pSelf, GblType derivedType, const char *pName, size_t id, GblFlags flags, size_t optionalArgCount, va_list *pList)
Equivalent to GblProperty_construct(), except taking a va_list rather than variadic argument list.
const GblProperty * GblProperty_findQuark(GblType objectType, GblQuark name)
Looks up the given property by GblQuark name which was previously installed onto the given GblObject ...
GBL_RESULT GblProperty_install(GblType objType, GblProperty *pProp)
Installs the given property onto the given type (which must be GblObject compatible).
const char * GblProperty_name(const GblProperty *pSelf)
Returns the string name of the given property.
size_t GblProperty_count(GblType objectType)
Returns the number of properties which were explicitly registered to the given type (not including in...
#define GBL_PROPERTIES_REGISTER(...)
Registers the list of properties which were declared with GBL_PROPERTIES()
GblBool GblProperty_uninstallAll(GblType objType)
Uninstalls all properties which were previously installed onto the given object type.
GblProperty * GblProperty_createVaList(GblType derivedType, const char *pName, size_t id, GblFlags flags, size_t optionalArgCount, va_list *pList)
Equivalent to GblProperty_create(), except taking a va_list rather than variadic argument list.
GBL_RESULT GblProperty_construct(GblProperty *pSelf, GblType derivedType, const char *pName, size_t id, GblFlags flags, size_t optionalArgCount,...)
Constructs a preallocated property with the given type, name, id, flags, and any optional arguments h...
uint32_t GblFlags
Standard-sized flags type, 32-bits across platforms.
uint8_t GblBool
Basic boolean type, standardized to sizeof(char)
uintptr_t GblQuark
Uniquely identifiable interned string type.
Represents a string-indexed member of a GblObject.
GblFlags flags
Combined flags of property.
GblProperty * pNext
Pointer to next property contained by the same type.
GblQuark name
Interned string name of property.
GblType objectType
UUID of the owning type.
GblType valueType
Type of the value represented by the property.
size_t id
Integer ID of property.