libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
Loading...
Searching...
No Matches
GblBox Struct Reference

#include <gimbal_box.h>

Inheritance diagram for GblBox:
GblInstance GblClosure GblEvent GblObject GblProperty GblCClosure GblClassClosure GblSignalClosure GblApp GblArenaAllocator GblCmdParser GblContext GblException GblLogger GblMainLoop GblOptionGroup GblScanner GblSettings GblTask GblTestSuite GblThread

Data Fields

union { 
 
   GblBoxClass *   pClass 
 
   GblInstance   base 
 
};  
 
struct { 
 
   GblArrayMap *   pFields 
 
   volatile uint16_t   refCounter 
 
   uint16_t   contextType: 1 
 
   uint16_t   constructedInPlace: 1 
 
   uint16_t   derivedFlags: 14 
 
private_ 
 
- Data Fields inherited from GblInstance
GblClasspClass
 

Related Symbols

(Note that these are not member symbols.)

Reference Counting

Methods for managing shared reference lifetime

GblBoxGblBox_ref (GblBox *pSelf)
 
GblRefCount GblBox_unref (GblBox *pSelf)
 
GblRefCount GblBox_refCount (const GblBox *pSelf)
 
Userdata

Methods for managing and destroying userdata

void * GblBox_userdata (const GblBox *pSelf)
 
GBL_RESULT GblBox_setUserdata (GblBox *pSelf, void *pUserdata)
 
GBL_RESULT GblBox_setUserDestructor (GblBox *pSelf, GblArrayMapDtorFn pFnUdDtor)
 
Fields

Methods for managing extended userdata fields

uintptr_t GblBox_field (const GblBox *pSelf, GblQuark key)
 
uintptr_t GblBox_takeField (GblBox *pSelf, GblQuark key)
 
GblBool GblBox_clearField (GblBox *pSelf, GblQuark key)
 
GblBool GblBox_hasField (const GblBox *pSelf, GblQuark key)
 
GBL_RESULT GblBox_setField (GblBox *pSelf, GblQuark key, uintptr_t ud, GblArrayMapDtorFn pFnDtor)
 

Detailed Description

Minimally bindable GblInstance with reference semantics and opaque userdata.

A GblBox is a GblInstance-derived type which simply adds the bare minimal set of functionality that is typically required for language bindings and interop. This includes:

  • destructors
  • reference counting semantics
  • a dictionary for storing arbitrary associated userdata
  • interop with GblVariant types
  • arbitrary flag bits
Note
A GblBox is 12 or 20 bytes total (32 or 64 bit respectively).
See also
GblBoxClass

Definition at line 83 of file gimbal_box.h.

Friends And Related Symbol Documentation

◆ GblBox_ref()

GblBox * GblBox_ref ( GblBox pSelf)
related

Increments the given GblBox's reference count by 1, returning a pointer to it.

◆ GblBox_unref()

GblRefCount GblBox_unref ( GblBox pSelf)
related

Decrements the given GblBox's reference count by 1, destructing it when it hits 0.

◆ GblBox_refCount()

GblRefCount GblBox_refCount ( const GblBox pSelf)
related

Returns the number of active references held to the given GblBox.

◆ GblBox_userdata()

void * GblBox_userdata ( const GblBox pSelf)
related

Returns the userdata pointer stored within the given GblBox.

◆ GblBox_setUserdata()

GBL_RESULT GblBox_setUserdata ( GblBox pSelf,
void *  pUserdata 
)
related

Stores the untyped userdata pointer within the GblBox.

◆ GblBox_setUserDestructor()

GBL_RESULT GblBox_setUserDestructor ( GblBox pSelf,
GblArrayMapDtorFn  pFnUdDtor 
)
related

Sets an additional user destructor to be invoked with the GblBox passed back to it when its being destructed.

◆ GblBox_field()

uintptr_t GblBox_field ( const GblBox pSelf,
GblQuark  key 
)
related

Returns the generic userdata field value for the given GblBox associated with the key.

◆ GblBox_takeField()

uintptr_t GblBox_takeField ( GblBox pSelf,
GblQuark  key 
)
related

Extracts the generic userdata field value for the given key, without destroying it.

◆ GblBox_clearField()

GblBool GblBox_clearField ( GblBox pSelf,
GblQuark  key 
)
related

Clears the field value for the given key, if it exists, calling its destructor (if it has one) and returning GBL_TRUE.

◆ GblBox_hasField()

GblBool GblBox_hasField ( const GblBox pSelf,
GblQuark  key 
)
related

Returns GBL_TRUE if there is a field value on the given GblBox corresponding to the key.

◆ GblBox_setField()

GBL_RESULT GblBox_setField ( GblBox pSelf,
GblQuark  key,
uintptr_t  ud,
GblArrayMapDtorFn  pFnDtor 
)
related

Inserts ud into the the GblBox with the given key and optional destructor, destroying any overwritten value.

Field Documentation

◆ pClass

GblBoxClass* GblBox::pClass

Pointer to class/vtable structure.

Definition at line 83 of file gimbal_box.h.

◆ base

GblInstance GblBox::base

Inherited base GblBox structure.

Definition at line 83 of file gimbal_box.h.

◆ pFields

GblArrayMap* GblBox::pFields

PRIVATE: Storage for extended userdata fields.

Definition at line 85 of file gimbal_box.h.

◆ refCounter

volatile uint16_t GblBox::refCounter

PRIVATE: Atomic reference counter.

Definition at line 86 of file gimbal_box.h.

◆ contextType

uint16_t GblBox::contextType

PRIVATE: GblContext type flag.

Deprecated:

Definition at line 87 of file gimbal_box.h.

◆ constructedInPlace

uint16_t GblBox::constructedInPlace

PRIVATE: Flag for whether memory is deallocated upon destruction.

Definition at line 88 of file gimbal_box.h.

◆ derivedFlags

uint16_t GblBox::derivedFlags

PRIVATE: Extra flags for use in derived classes.

Definition at line 89 of file gimbal_box.h.


The documentation for this struct was generated from the following file: