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

#include <gimbal_closure.h>

Inheritance diagram for GblClosure:
Collaboration diagram for GblClosure:

Data Fields

union { 
 
   GblClosureClass *   pClass 
 
   GblBox   base 
 
};  
 
struct { 
 
   GblMarshalFn   pFnMarshal 
 
private_ 
 
- Data Fields inherited from GblInstance
GblClasspClass
 

Related Symbols

(Note that these are not member symbols.)

Accessor Methods

Methods for reading/writing GblClosure fields

void GblClosure_setMarshal (GblClosure *pSelf, GblMarshalFn pFnMarshal)
 
GBL_RESULT GblClosure_setMetaMarshal (GblClosure *pSelf, GblMarshalFn pFnMeta)
 
GblBool GblClosure_hasMarshal (const GblClosure *pSelf)
 
GblBool GblClosure_hasMetaMarshal (const GblClosure *pSelf)
 
Invocation Method(s)

Methods used to invoke the closure

GBL_RESULT GblClosure_invoke (GblClosure *pSelf, GblVariant *pRetValue, size_t argCount, GblVariant *pArgValues)
 

Detailed Description

Base instance for all closure types.

A GblClosure represents an abstract generic callback object. It is analogous to a stateful C++ function object, or functor, in that it can contain both a callback method as well as stateful data to operate upon.

All closures have a single entry-point for having their callback logic called, which is GblClosure_invoke(). This calls the closure's "marshal" function, which is responsible for

  • validating arguments and return type
  • converting arguments into expected format for callback
  • calling actual callback or logic
  • converting return value back into a GblVariant

As the abstract base closure, there is no underlying language-specific callback state within this class. For calling back into C function pointers, see GblCClosure.

Note
As GblClosure inherits GblBox, it can contain arbitrary language-specific or binding-specific userdata and has reference count semantics.
See also
GblCClosure, GblMarshalFn, gimbal_signal.h

Definition at line 81 of file gimbal_closure.h.

Friends And Related Symbol Documentation

◆ GblClosure_setMarshal()

void GblClosure_setMarshal ( GblClosure * pSelf,
GblMarshalFn pFnMarshal )
related

Sets the closure's marshal to the function pointed to by pFnMarshal.

◆ GblClosure_setMetaMarshal()

GBL_RESULT GblClosure_setMetaMarshal ( GblClosure * pSelf,
GblMarshalFn pFnMeta )
related

Sets the closure's class's meta marshal to the function pointed to by pFnMeta, swizzling its class.

◆ GblClosure_hasMarshal()

GblBool GblClosure_hasMarshal ( const GblClosure * pSelf)
related

Returns whether the GblClosure has an instance marshal or not.

◆ GblClosure_hasMetaMarshal()

GblBool GblClosure_hasMetaMarshal ( const GblClosure * pSelf)
related

Returns whether the GblClosure's class has a meta marshal or not.

◆ GblClosure_invoke()

GBL_RESULT GblClosure_invoke ( GblClosure * pSelf,
GblVariant * pRetValue,
size_t argCount,
GblVariant * pArgValues )
related

Invokes the given GblClosure, marshalling args in and a value out as variants.

Field Documentation

◆ pClass

GblClosureClass* GblClosure::pClass

Pointer to class/vtable structure.

Definition at line 81 of file gimbal_closure.h.

◆ base

GblBox GblClosure::base

Inherited base instance structure.

Definition at line 81 of file gimbal_closure.h.

◆ pFnMarshal

GblMarshalFn GblClosure::pFnMarshal

Per-instance marshal function, private.

Definition at line 83 of file gimbal_closure.h.


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