libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
Loading...
Searching...
No Matches
gimbal_class_closure.h
Go to the documentation of this file.
1/*! \file
2 * \ingroup signals
3 * \brief GblClassClosure, virtual method invoking closure, and API
4 *
5 * This file contains GblClassClosure and its associated API.
6 * It is used to invoke a virtual method on given GblInstance
7 *
8 * \sa GblClassClosure
9 *
10 * \author 2023 Falco Girgis
11 * \copyright MIT License
12 */
13#ifndef GIMBAL_CLASS_CLOSURE_H
14#define GIMBAL_CLASS_CLOSURE_H
15
16#include "gimbal_closure.h"
17
18#define GBL_CLASS_CLOSURE_TYPE (GBL_TYPEID(GblClassClosure)) //!< GblType UUID for GblClassClosure
19
20#define GBL_CLASS_CLOSURE(self) (GBL_CAST(GblClassClosure, self)) //!< Cast a GblInstance to GblClassClosure
21#define GBL_CLASS_CLOSURE_CLASS(klass) (GBL_CLASS_CAST(GblClassClosure, self)) //!< Cast a GblClass ot GblClassClosureClass
22#define GBL_CLASS_CLOSURE_GET_CLASS(self) (GBL_CLASSOF(GblClassClosure, self)) //!< Get a GblClassClosureClass from GblInstance
23
24#define GBL_SELF_TYPE GblClassClosure
25
27
28/*! \struct GblClassClosureClass
29 * \extends GblClosureClass
30 * \brief GblClass VTable structure for GblClassClosure
31 * \sa GblClassClosure
32 */
33GBL_CLASS_DERIVE_EMPTY(GblClassClosure, GblClosure)
34
35/*! \struct GblClassClosure
36 * \extends GblClosure
37 * \ingroup signals
38 * \brief GblClosure type for calling into virtual methods
39 *
40 * GblClassClosure allows for mapping a generic marshal call
41 * to invoke a virtual method on the GblClass of a GblInstance.
42 */
45 GblType classType; //!< PRIVATE: Type of class to invoke the method on
46 size_t offset; //!< PRIVATE: Offset of the virtual function to invoke
47 GblInstance* pInstance; //!< PRIVATE: Instance to invoke the class method on
50
51//! Returns the GblType UUID associated with GblClassClosure
53
54//! Creates a new GblClassClosure with the given values, returning a pointer to it
55GBL_EXPORT GblClassClosure* GblClassClosure_create (GblType classType,
56 size_t offset,
57 GblInstance* pInstance,
58 void* pUserdata) GBL_NOEXCEPT;
59
60/*! \name Accessor Methods
61 * \brief Setter methods for GblClassClosure values
62 * \relatesalso GblClassClosure
63 * @{
64 */
65//! Sets the offset of the virtual method pointer into the GblClass to invoke the closure on
67 GblType classType,
68 size_t offset) GBL_NOEXCEPT;
69//! Sets the GblInstance to call the GblClass virtual method on
71 GblInstance* pInstance) GBL_NOEXCEPT;
72//! @}
73
75
76#undef GBL_SELF_TYPE
77
78#endif // GIMBAL_CLASS_CLOSURE_H
#define GBL_CLASS_CAST(cType, klass)
GblClassClosure * GblClassClosure_create(GblType classType, size_t offset, GblInstance *pInstance, void *pUserdata)
Creates a new GblClassClosure with the given values, returning a pointer to it.
GblType GblClassClosure_type(void)
Returns the GblType UUID associated with GblClassClosure.
#define GBL_NOEXCEPT
#define GBL_DECLS_BEGIN
#define GBL_TYPEID(instanceStruct)
#define GBL_INSTANCE_DERIVE(derivedInstance, baseInstance)
#define GBL_PRIVATE_BEGIN
#define GBL_INSTANCE_END
#define GBL_CLASS_DERIVE_EMPTY(...)
#define GBL_EXPORT
#define GBL_PRIVATE_END
Private data structure.
#define GBL_CLASSOF(cType, self)
#define GBL_CAST(cType, self)
uintptr_t GblType
Meta Type UUID.
Definition gimbal_type.h:51
GblClosure type for calling into virtual methods.
GblType classType
PRIVATE: Type of class to invoke the method on.
size_t offset
PRIVATE: Offset of the virtual function to invoke.
void GblClassClosure_setInstance(GblClassClosure *pSelf, GblInstance *pInstance)
Sets the GblInstance to call the GblClass virtual method on.
GblInstance * pInstance
PRIVATE: Instance to invoke the class method on.
void GblClassClosure_setMethod(GblClassClosure *pSelf, GblType classType, size_t offset)
Sets the offset of the virtual method pointer into the GblClass to invoke the closure on.