SPRAAK
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Working with SPRAAK classes and objects

The syntax

Some examples

For a more elaborate example see taipan_cpp.c (C++ style multiple inheritance) and taipan_objc.c (single inheritance and Java/objective-C style interfaces) in the examples subdirectory.

Some guidelines

Constructors

Destructor

Internal operation

Some notes on the internal operation:

Naming conventions:

Automatically generated types, variables and defines:

SprRTTI__class__method
typedef function pointer for each method (static of virtual); used by SprMethodPtr()
SprRTTI__class spr_rttid__class,spr_rttis__class;
typedef + variable: the run-time information contains run-time type information and the virtual functions dispatch table; the structure mimics the hierarchical structure of the class (base classes)
const char spr_rtti_mid__class__method[]
unique name of the method (given the class in which the method was defined)
const char spr_rtti_cid__class[]
unique name of the class
const char *const *spr_rtti_method__class[]
array containing the names of the virtual methods
SPR_DO__class__method
macro that does that provides the necessary information for the combination of class and method for SPR_DO(), SPR_DO_FPTR() and SPR_DO_OPTR()
SPR_CAST__class__base
macro that does that actual combination of class and base for SPR_CAST()
SPR_INIT__class
macro that does the actual initialisation; used by SPR_OBJECT_INIT() and SPR_LVAR_OBJECT_INIT()

Planned extensions:

SPR_DYNCAST(object,class_id)
cast the type of the object to the class with the given class id; this is a slow function; returns NULL if the cast fails
SPR_CLASSID_FROM_OBJ(object)
get the id (a pointer to a unique string) of the class the object belongs to
SPR_CLASSID_FORM_CLASS(class)
get the id (a pointer to a unique string) for the given class
SPR_OBJ_ISINSTANCE_OF(object,class_id)
check if the object can be casted the class with the given id; is a slow function
SPR_OBJ_DYN_ROOT(object)
convert the object to its root object (go all the way up in the hierarchy)