Browse Source

add ability to call interface methods with return value

master
Georg Hopp 14 years ago
parent
commit
d1fecbf951
  1. 15
      include/class.h

15
include/class.h

@ -40,8 +40,7 @@
* @TODO: actually i use gcc feature ## for variadoc... think about
* a way to make this standard.
*/
#define CALL(object,_iface,method,...) \
do { \
#define _CALL(object,_iface,method,...) \
class_ptr class = class_getClass((object)); \
struct i_##_iface * iface; \
if (class->init) class->init(); \
@ -51,10 +50,20 @@
if (class->init) class->init(); \
iface = (struct i_##_iface *)class_getInterface(&class, &i_##_iface); \
}; \
assert(NULL != iface->method); \
assert(NULL != iface->method);
#define CALL(object,_iface,method,...) \
do { \
_CALL(object, _iface, method, ##__VA_ARGS__); \
iface->method(object, ##__VA_ARGS__); \
} while(0)
#define RETCALL(object,_iface,method,ret,...) \
do { \
_CALL(object, _iface, method, ##__VA_ARGS__); \
ret = iface->method(object, ##__VA_ARGS__); \
} while(0)
#define IFACE_GET(class,iface) (interfaceGet(&((class)->impl),(iface)))
#define IFACE_EXISTS(class,iface) (NULL != IFACE_GET((class),(iface)))

Loading…
Cancel
Save