libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
|
#include <gimbal_interface.h>
Data Fields | ||
GblClass | base | |
size_t | outerClassOffset_ | |
Data Fields inherited from GblClass | ||
struct { | ||
uintptr_t metaClassInfo | ||
} | private_ | |
Base struct for all interfaces, inherits from GblClass.
An interface is a special type of GblClass which represents an abstract collection of data which may be "implemented" by another class and then queried for later. This data is typically in the form of function pointers, which may or may not have default values, which can then be set by a the class constructor of another type.
The main advantage of modeling overriddable methods within an interface as opposed to just putting them within a class is that the interface can be implemented by any class, without having to inherit or derive from it.
GblInterface is the base structure which is to be inherited by all interface structures within the meta type system. This means placing it or a type "inheriting" from it as the first member of an interface struct, when using C.
In terms of implementation, a GblInterface is actually implemented as a type of mappable "subclass" which is then embedded within a the structure of a GblClass-inheriting structure. When a type which implements an interface is registered, its location within the class is provided to the type system via GblTypeInfo::pInterfaceImpls.
Definition at line 24 of file gimbal_interface.h.
|
related |
Convenience function-style cast operator that returns the given class as a GblInterface, provided it is actually one, erroring out upon failure.
klass | pointer to a GblClass or derived |
Definition at line 14 of file gimbal_interface.h.
|
related |
Convenience function-style cast operator that returns the given class as a GblInterface, provided it is actually one.
klass | pointer to a GblClass or derived |
Definition at line 15 of file gimbal_interface.h.
|
related |
Convenience macro wrapping GblInterface_outerClass(), automatically casting the input parameter.
iface | pointer to a GblInterface or derived |
Definition at line 16 of file gimbal_interface.h.
|
related |
Convenience macro wrapping GblInterface_outerMostClass(), automatically casting the input parameter.
iface | pointer to a GblInterface or derived |
Definition at line 17 of file gimbal_interface.h.
|
related |
|
related |
Returns the top-level GblClass implementing the interface.
The top-level class will either be its outer class, in the case of a regular embedded interface, or it could be multiple levels out, in the case of an interface mapping an interface.
pSelf | interface |
GblClass GblInterface::base |
inherited GblClass base info
Definition at line 25 of file gimbal_interface.h.
size_t GblInterface::outerClassOffset_ |
offset from the interface to the class containing it (private, managed by internals)
Definition at line 26 of file gimbal_interface.h.