#include <stdarg.h>
#include <sys/types.h>
#include <string.h>
#include <assert.h>
#include "interface.h"
Go to the source code of this file.
Classes |
| struct | class |
Defines |
| #define | _ISOC99_SOURCE |
| #define | CLASS_MAGIC 0xFEFE |
| #define | CLASS(name) |
| #define | EXTENDS(parent) const char _[sizeof(struct c_##parent)] |
| #define | _NULL NULL |
| #define | CREATE_CLASS(name, _parent,...) |
| #define | _CALL(object, _iface, method,...) |
| #define | CALL(object, _iface, method,...) |
| #define | RETCALL(object, _iface, method, ret,...) |
| #define | IFACE_GET(class, iface) (interfaceGet(&((class)->impl),(iface))) |
| #define | IFACE_EXISTS(class, iface) (NULL != IFACE_GET((class),(iface))) |
| #define | HAS_PARENT(class) (NULL != ((class)->parent)) |
Typedefs |
| typedef void(* | fptr_classInit )(void) |
| typedef struct class * | class_ptr |
Functions |
| void * | class_getInterface (class_ptr *, iface_ptr) |
| class_ptr | class_getClass (void *) |
Define Documentation
| #define _CALL |
( |
|
object, |
|
|
|
_iface, |
|
|
|
method, |
|
|
|
... |
|
) |
| |
Value:: actually i use gcc feature ## for variadoc... think about a way to make this standard.
Definition at line 43 of file class.h.
| #define CALL |
( |
|
object, |
|
|
|
_iface, |
|
|
|
method, |
|
|
|
... |
|
) |
| |
Value:do { \
_CALL(object, _iface, method, ##__VA_ARGS__); \
iface->method(object, ##__VA_ARGS__); \
} while(0)
Definition at line 55 of file class.h.
Value:struct c_##name; \
typedef struct c_##name * name; \
extern struct class * const _##name; \
struct c_##name
Definition at line 15 of file class.h.
| #define CLASS_MAGIC 0xFEFE |
| #define CREATE_CLASS |
( |
|
name, |
|
|
|
_parent, |
|
|
|
... |
|
) |
| |
Value:static struct class c_##name; \
static void _classInit_(void) { \
c_##name.parent = _##_parent; \
c_##name.init = NULL; \
} \
static struct class c_##name = { \
CLASS_MAGIC, \
NULL, \
sizeof(struct c_##name), \
_classInit_, \
INIT_IMPL(__VA_ARGS__) \
}; struct class * const _##name = &c_##name
Definition at line 25 of file class.h.
| #define EXTENDS |
( |
|
parent | ) |
const char _[sizeof(struct c_##parent)] |
| #define HAS_PARENT |
( |
|
class | ) |
(NULL != ((class)->parent)) |
| #define IFACE_EXISTS |
( |
|
class, |
|
|
|
iface |
|
) |
| (NULL != IFACE_GET((class),(iface))) |
| #define IFACE_GET |
( |
|
class, |
|
|
|
iface |
|
) |
| (interfaceGet(&((class)->impl),(iface))) |
| #define RETCALL |
( |
|
object, |
|
|
|
_iface, |
|
|
|
method, |
|
|
|
ret, |
|
|
|
... |
|
) |
| |
Value:do { \
_CALL(object, _iface, method, ##__VA_ARGS__); \
ret = iface->method(object, ##__VA_ARGS__); \
} while(0)
Definition at line 61 of file class.h.
Typedef Documentation
Function Documentation
Definition at line 8 of file class.c.
{
void * iface = (void *)IFACE_GET(*class, _iface);
while(NULL == iface && HAS_PARENT(*class)) {
*class = (*class)->parent;
iface = (void *)IFACE_GET(*class, _iface);
}
return iface;
}