Commit d1fecbf9512471ad2bb0ab46cd931a37c7cdc2d5

Authored by Georg Hopp
1 parent e0e05bf8

add ability to call interface methods with return value

Showing 1 changed file with 22 additions and 13 deletions
@@ -40,19 +40,28 @@ @@ -40,19 +40,28 @@
40 * @TODO: actually i use gcc feature ## for variadoc... think about 40 * @TODO: actually i use gcc feature ## for variadoc... think about
41 * a way to make this standard. 41 * a way to make this standard.
42 */ 42 */
43 -#define CALL(object,_iface,method,...) \  
44 - do { \  
45 - class_ptr class = class_getClass((object)); \  
46 - struct i_##_iface * iface; \  
47 - if (class->init) class->init(); \  
48 - iface = (struct i_##_iface *)class_getInterface(&class, &i_##_iface); \  
49 - while ((NULL == iface || NULL == iface->method) && HAS_PARENT(class)) { \  
50 - class = class->parent; \  
51 - if (class->init) class->init(); \  
52 - iface = (struct i_##_iface *)class_getInterface(&class, &i_##_iface); \  
53 - }; \  
54 - assert(NULL != iface->method); \  
55 - iface->method(object, ##__VA_ARGS__); \ 43 +#define _CALL(object,_iface,method,...) \
  44 + class_ptr class = class_getClass((object)); \
  45 + struct i_##_iface * iface; \
  46 + if (class->init) class->init(); \
  47 + iface = (struct i_##_iface *)class_getInterface(&class, &i_##_iface); \
  48 + while ((NULL == iface || NULL == iface->method) && HAS_PARENT(class)) { \
  49 + class = class->parent; \
  50 + if (class->init) class->init(); \
  51 + iface = (struct i_##_iface *)class_getInterface(&class, &i_##_iface); \
  52 + }; \
  53 + assert(NULL != iface->method);
  54 +
  55 +#define CALL(object,_iface,method,...) \
  56 + do { \
  57 + _CALL(object, _iface, method, ##__VA_ARGS__); \
  58 + iface->method(object, ##__VA_ARGS__); \
  59 + } while(0)
  60 +
  61 +#define RETCALL(object,_iface,method,ret,...) \
  62 + do { \
  63 + _CALL(object, _iface, method, ##__VA_ARGS__); \
  64 + ret = iface->method(object, ##__VA_ARGS__); \
56 } while(0) 65 } while(0)
57 66
58 67
Please register or login to post a comment