libGimbal 0.2.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
Loading...
Searching...
No Matches
gimbal_object.h File Reference

Go to the source code of this file.

Data Structures

struct  GblObjectClass
 
class  GblObject
 

Macros

#define GblObject_foreachChild(...)
 
#define GblObject_foreachChildReverse(...)
 
Type System

Type UUID and Cast operators

#define GBL_OBJECT_TYPE
 
#define GBL_OBJECT(self)
 
#define GBL_OBJECT_CLASS(klass)
 
#define GBL_OBJECT_CLASSOF(self)
 
Construction Macros

Helper macros for creating new GblObject instances.

#define GBL_NEW(...)
 
#define GBL_NEW_AT(...)
 

Typedefs

typedef GblBool(* GblObjectCmpFn) (const GblObject *pObj, void *pClosure)
 
User-Operator Callbacks

Typedefs for applying various user-supplied functions over a GblObject.

typedef GblBool(* GblObjectIterFn) (GblObject *pChild, void *pClosure)
 

Functions

GblType GblObject_type (void)
 
GblContext * GblObject_findContext (GblObject *pSelf)
 
Constructors

Methods for constructing GblObject-derived types.

Each constructor takes a list of property names and values. Values for CONSTRUCT properties are set before GblObjectClass::pFnConstructed is called, and the remaining values are then set as regular writes, as though by GblObject_setProperties().

Construction fails, and the object is torn down, when:

  • A value for a CONSTRUCT property which is not also WRITE is rejected
  • A CONSTRUCT property which is not also WRITE is not given a value
  • GblObjectClass::pFnConstructed fails
  • An unknown property name is given in a NULL-terminated K,V pair list, as none of the remaining arguments can then be read

Upon failure, the create functions return NULL, and the construct functions return the error with the given memory left destructed. The error remains available from the thread's last call record.

Any other value which is rejected, either because its property is WRITE or because setting it fails, is skipped. The object is still constructed, the result is #GBL_RESULT_INCOMPLETE, and the object must be released as usual. Since #GBL_RESULT_INCOMPLETE is not a success code, callers of the construct functions should check for failure with GBL_RESULT_ERROR(), not GBL_RESULT_SUCCESS(). Unknown property names given as variants are skipped with a warning.

Values passed to ACQUIRE properties are moved, and are consumed even when rejected or when construction fails.

GblObject * GblObject_create (GblType type,...)
 
GblObject * GblObject_createExt (GblType type, size_t size,...)
 
GBL_RESULT GblObject_construct (GblObject *pSelf, GblType type,...)
 
GblObject * GblObject_createWithClass (GblObjectClass *pClass,...)
 
GblObject * GblObject_createExtWithClass (GblObjectClass *pClass, size_t size,...)
 
GBL_RESULT GblObject_constructWithClass (GblObject *pSelf, GblObjectClass *pClass,...)
 
GblObject * GblObject_createVa (GblType type, va_list *pList)
 
GblObject * GblObject_createExtVa (GblType type, size_t size, va_list *pList)
 
GBL_RESULT GblObject_constructVa (GblObject *pSelf, GblType type, va_list *pList)
 
GblObject * GblObject_createVaWithClass (GblObjectClass *pClass, va_list *pList)
 
GblObject * GblObject_createExtVaWithClass (GblObjectClass *pClass, size_t size, va_list *pList)
 
GBL_RESULT GblObject_constructVaWithClass (GblObject *pSelf, GblObjectClass *pClass, va_list *pList)
 
GblObject * GblObject_createVariants (GblType type, size_t propertyCount, const char *pNames[], GblVariant *pValues)
 
GblObject * GblObject_createVariantsExt (GblType type, size_t size, size_t propertyCount, const char *pNames[], GblVariant *pValues)
 
GBL_RESULT GblObject_constructVariants (GblObject *pSelf, GblType type, size_t propertyCount, const char *pNames[], GblVariant *pValues)
 
GblObject * GblObject_createVariantsWithClass (GblObjectClass *pClass, size_t propertyCount, const char *pNames[], GblVariant *pValues)
 
GblObject * GblObject_createVariantsExtWithClass (GblObjectClass *pClass, size_t size, size_t propertyCount, const char *pNames[], GblVariant *pValues)
 
GBL_RESULT GblObject_constructVariantsWithClass (GblObject *pSelf, GblObjectClass *pClass, size_t propertyCount, const char *pNames[], GblVariant *pValues)
 

Detailed Description

GblObject structure and related functions.

This file contains the type definitions and API for GblObject and GblObjectClass. This is the instantiable type which provides the OO meat of the instantiable types– such as properties, hierarchical relationships, event management, generic construction, named instances, etc.

Author
2023, 2024, 2025, 2026 Falco Girgis
2025, 2026 Agustín Bellagamba
Todo
Test

Definition in file gimbal_object.h.

Macro Definition Documentation

◆ GBL_OBJECT_TYPE

#define GBL_OBJECT_TYPE

GblType UUID for GblObject.

Definition at line 38 of file gimbal_object.h.

◆ GBL_OBJECT

#define GBL_OBJECT ( self)

Casts a GblInstance to a GblObject.

Definition at line 39 of file gimbal_object.h.

◆ GBL_OBJECT_CLASS

#define GBL_OBJECT_CLASS ( klass)

Casts a GblClass to a GblObjectClass.

Definition at line 40 of file gimbal_object.h.

◆ GBL_OBJECT_CLASSOF

#define GBL_OBJECT_CLASSOF ( self)

Gets a GblObjectClass from a GblInstance.

Definition at line 41 of file gimbal_object.h.

◆ GBL_NEW

#define GBL_NEW ( ...)

DSL macro used to heap-construct a GblObject-derived type.

It takes the struct name followed by an optional list of property KV pairs.

Definition at line 52 of file gimbal_object.h.

◆ GBL_NEW_AT

#define GBL_NEW_AT ( ...)

DSL macro used to placement-construct a GblObject-derived type It takes the struct name followed by an optional list of property KV pairs.

Definition at line 57 of file gimbal_object.h.

◆ GblObject_foreachChild

#define GblObject_foreachChild ( ...)

For-loop style iteration over the children of a GblObject.

Iterates over every child within the given object, setting the item variable to the current child. Optionally takes in a type parameter to specify the type of the children to iterate over.

Definition at line 66 of file gimbal_object.h.

◆ GblObject_foreachChildReverse

#define GblObject_foreachChildReverse ( ...)

For-loop style iteration over the children of a GblObject, in reverse order.

Iterates over every child within the given object, setting the item variable to the current child. Optionally takes in a type parameter to specify the type of the children to iterate over.

Definition at line 73 of file gimbal_object.h.

Typedef Documentation

◆ GblObjectCmpFn

typedef GblBool(* GblObjectCmpFn) (const GblObject *pObj, void *pClosure)

Comparator callback function which gets called with a GblObject and an arbitrary closure, returning true if the object matches the desired criteria.

Definition at line 78 of file gimbal_object.h.

◆ GblObjectIterFn

typedef GblBool(* GblObjectIterFn) (GblObject *pChild, void *pClosure)

Iterator callback function which gets called over every child of a GblObject, being passed back a GblObject and an arbitrary closure, returning true should iteration cease early.

Definition at line 111 of file gimbal_object.h.

Function Documentation

◆ GblObject_type()

GblType GblObject_type ( void )

Returns the GblType UUID associated with GblObject.

◆ GblObject_create()

GblObject * GblObject_create ( GblType type,
... )

Creates an object-derived type on the heap, initializing it with a NULL-terminated K,V pair listing of properties.

◆ GblObject_createExt()

GblObject * GblObject_createExt ( GblType type,
size_t size,
... )

Variant of GblObject_create(), where the object is created with an extended size.

◆ GblObject_construct()

GBL_RESULT GblObject_construct ( GblObject * pSelf,
GblType type,
... )

Constructs an object-derived type in-place, initializing it with a NULL-terminated K,V pair listing of properties.

◆ GblObject_createWithClass()

GblObject * GblObject_createWithClass ( GblObjectClass * pClass,
... )

Creates an object-derived type on the heap, with the given class, initializing it with a NULL-terminated K,V pair property list.

◆ GblObject_createExtWithClass()

GblObject * GblObject_createExtWithClass ( GblObjectClass * pClass,
size_t size,
... )

Variant of GblObject_createWithClass(), where the object is created with an extended size.

◆ GblObject_constructWithClass()

GBL_RESULT GblObject_constructWithClass ( GblObject * pSelf,
GblObjectClass * pClass,
... )

Constructs an object-derived type in-place, with the given class, initializing it with a NULL-terminated K,V pair property list.

◆ GblObject_createVa()

GblObject * GblObject_createVa ( GblType type,
va_list * pList )

Variant of GblObject_create(), where the property list is provided as a va_list pointer.

◆ GblObject_createExtVa()

GblObject * GblObject_createExtVa ( GblType type,
size_t size,
va_list * pList )

Variant of GblObject_createVaList(), where the object is created with an extended size.

◆ GblObject_constructVa()

GBL_RESULT GblObject_constructVa ( GblObject * pSelf,
GblType type,
va_list * pList )

Variant of GblObject_construct(), where the property list is provided as a va_list pointer.

◆ GblObject_createVaWithClass()

GblObject * GblObject_createVaWithClass ( GblObjectClass * pClass,
va_list * pList )

Variant of GblObject_createWithClass(), where the property list is provided as a va_list pointer.

◆ GblObject_createExtVaWithClass()

GblObject * GblObject_createExtVaWithClass ( GblObjectClass * pClass,
size_t size,
va_list * pList )

Variant of GblObject_createVaListWithClass(), where the object is allocated with an extended size.

◆ GblObject_constructVaWithClass()

GBL_RESULT GblObject_constructVaWithClass ( GblObject * pSelf,
GblObjectClass * pClass,
va_list * pList )

Variant of GblObject_constructWithClass(), where the property list is provided as a va_list pointer.

◆ GblObject_createVariants()

GblObject * GblObject_createVariants ( GblType type,
size_t propertyCount,
const char * pNames[],
GblVariant * pValues )

Creates an object-derived type on the heap, initializing it with an array of property values and a corresponding array of names.

◆ GblObject_createVariantsExt()

GblObject * GblObject_createVariantsExt ( GblType type,
size_t size,
size_t propertyCount,
const char * pNames[],
GblVariant * pValues )

Variant of GblObject_createVariants(), where the object is allocated with an extended size.

◆ GblObject_constructVariants()

GBL_RESULT GblObject_constructVariants ( GblObject * pSelf,
GblType type,
size_t propertyCount,
const char * pNames[],
GblVariant * pValues )

Creates an object-derived type in-place, initializing it with an array of property values and a corresponding array of names.

◆ GblObject_createVariantsWithClass()

GblObject * GblObject_createVariantsWithClass ( GblObjectClass * pClass,
size_t propertyCount,
const char * pNames[],
GblVariant * pValues )

Variant of GblObject_createVariants(), where the object is constructed with a weak reference to the given class.

◆ GblObject_createVariantsExtWithClass()

GblObject * GblObject_createVariantsExtWithClass ( GblObjectClass * pClass,
size_t size,
size_t propertyCount,
const char * pNames[],
GblVariant * pValues )

Variant of GblObject_createVariantsWithClass(), where the object is allocated with an extended size.

◆ GblObject_constructVariantsWithClass()

GBL_RESULT GblObject_constructVariantsWithClass ( GblObject * pSelf,
GblObjectClass * pClass,
size_t propertyCount,
const char * pNames[],
GblVariant * pValues )

Variant of GblObject_constructVariants(), where the object is constructed with a weak reference to the given class.

◆ GblObject_findContext()

GblContext * GblObject_findContext ( GblObject * pSelf)