|
libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
|

Files | |
| file | gimbal_c_closure.h |
| file | gimbal_class_closure.h |
| file | gimbal_closure.h |
| file | gimbal_marshal.h |
| file | gimbal_signal.h |
| file | gimbal_signal_closure.h |
Data Structures | |
| struct | GblCClosure |
| struct | GblClassClosure |
| struct | GblClosure |
| struct | GblSignalClosure |
Typedefs | |
| typedef GBL_RESULT(* | GblMarshalFn) (GblClosure *pClosure, GblVariant *pRetValue, size_t argCount, GblVariant *pArgs, GblPtr pMarshalData) |
Signal emission mechanism and its types and API.
libGimbal's signal system implements a powerful cross-language event callback mechanism which decouples event emitting types from those types which receive or listen for events. It is based upon both GTk's "signals" and Qt's "signals and slots" and is expecially powerful for GUI/widget programming.
It is a good practice to use DSL macros to predeclare any signals which are associated with a GblType as part of their public API declaration within their respective header file. As an example, the signals associated with the GblOptionGroup are declared by:
This declares GblOptionGroup as being able to emit 3 different signals, with parsePrePass and parsePostPass sending pointers to GblStringList as their parameters, and parseError passing along an error code as a GblEnum as its parameter.
The first thing that must happen before signals can be used is that they get registered at runtime with an actual type. This is typically done within the GblTypeInfo::pFnClassInit routine for a given type, only when its reference count is 0, meaning it is being instantiated for the first time:
In order to get notified when a signal gets fired from a particular GblInstance subtype, we must first connect a closure to it, so that it can be invoked later when the signal fires. The simplest way is to use a C function pointer as the callback:
| typedef GBL_RESULT(* GblMarshalFn) (GblClosure *pClosure, GblVariant *pRetValue, size_t argCount, GblVariant *pArgs, GblPtr pMarshalData) |
#include <gimbal_marshal.h>
Function signature for a generic marshal function.
Marshal functions form the basis of the closure system, and are used by all GblClosure instances. They are the primary entry point for generic function invocation, and are the glue between a generic GblClosure and an actual language-dependent real function call.
They take a generic list of arguments, marshal them into an actual function (which is typically stored with GblClosure), then demarshal out the return type.
Definition at line 50 of file gimbal_marshal.h.