@ -118,23 +118,25 @@
/**
* NEW . Create a static instance of a class .
* Create a static instance of a class .
* This is new and currently it is only possible to create
* instances for class that does not need a constructor .
*
* \ todo
* This macro requires to close the initializer
* with an extra curly brancket . This is not nice . . . find a
* way to prevent this .
* \ todo
* This does not call any constructor with any value . . . this
* has to be fixed .
* has to be fixed . / / When this macro is used within a global
* ( static ) context this can ' t be fixed . No function can be
* called from there . Instead I add a TR_objectInit function which
* takes an object name ( created on either the stack or the
* heap ) and a variable argument list and calls its constructor
* with the arguments .
*/
# define TR_INSTANCE(class, name) \
# define TR_INSTANCE(class, name, ... ) \
struct c_ # # class # # _object _ # # name ; \
class name = & ( _ # # name . data ) ; \
struct c_ # # class # # _object _ # # name = { \
& c_ # # class ,
& c_ # # class , \
{ # # __VA_ARGS__ } \
}
/**
* I initialize _ ( the class ' s base or parent class )
@ -204,7 +206,7 @@
*
* \ cond PRIVATE
*/
# define _TR_CALL(_class,_iface,method,... ) \
# define _TR_CALL(_class,_iface,method) \
do { \
TR_class_ptr class = _class ; \
iface = ( struct i_ # # _iface * ) TR_IFACE_GET ( class , & i_ # # _iface ) ; \
@ -229,7 +231,7 @@
# define TR_CALL(object,_iface,method,...) \
do { \
struct i_ # # _iface * iface ; \
_TR_CALL ( TR_GET_CLASS ( object ) , _iface , method , # # __VA_ARGS__ ) ; \
_TR_CALL ( TR_GET_CLASS ( object ) , _iface , method ) ; \
iface - > method ( object , # # __VA_ARGS__ ) ; \
} while ( 0 )
@ -243,7 +245,7 @@
# define TR_RETCALL(object,_iface,method,ret,...) \
do { \
struct i_ # # _iface * iface ; \
_TR_CALL ( TR_GET_CLASS ( object ) , _iface , method , # # __VA_ARGS__ ) ; \
_TR_CALL ( TR_GET_CLASS ( object ) , _iface , method ) ; \
ret = iface - > method ( object , # # __VA_ARGS__ ) ; \
} while ( 0 )
@ -258,7 +260,7 @@
struct i_ # # _iface * iface ; \
TR_class_ptr pc_class = TR_GET_CLASS ( ( object ) ) ; \
assert ( TR_HAS_PARENT ( pc_class ) ) ; \
_TR_CALL ( pc_class - > parent , _iface , method , # # __VA_ARGS__ ) ; \
_TR_CALL ( pc_class - > parent , _iface , method ) ; \
iface - > method ( object , # # __VA_ARGS__ ) ; \
} while ( 0 )
@ -273,7 +275,7 @@
struct i_ # # _iface * iface ; \
TR_class_ptr pc_class = TR_GET_CLASS ( ( object ) ) ; \
assert ( TR_HAS_PARENT ( pc_class ) ) ; \
_TR_CALL ( pc_class - > parent , _iface , method , # # __VA_ARGS__ ) ; \
_TR_CALL ( pc_class - > parent , _iface , method ) ; \
ret = iface - > method ( object , # # __VA_ARGS__ ) ; \
} while ( 0 )