| 1 |
root |
1.1 |
// |
| 2 |
|
|
// cfperl.h perl interface |
| 3 |
|
|
// |
| 4 |
root |
1.2 |
#ifndef CFPERL_H__ |
| 5 |
|
|
#define CFPERL_H__ |
| 6 |
|
|
|
| 7 |
|
|
// could have used templates, but a more traditional C api |
| 8 |
|
|
// uses more explicit typing which is ok for this purpose. |
| 9 |
|
|
enum data_type { |
| 10 |
|
|
DT_END, // no further arguments |
| 11 |
|
|
DT_INT, |
| 12 |
root |
1.5 |
DT_INT64, |
| 13 |
root |
1.2 |
DT_DOUBLE, |
| 14 |
|
|
DT_STRING, // 0-terminated string |
| 15 |
|
|
DT_DATA, // string + length |
| 16 |
|
|
DT_OBJECT, |
| 17 |
|
|
DT_MAP, |
| 18 |
|
|
DT_PLAYER, |
| 19 |
|
|
DT_ARCH, |
| 20 |
|
|
DT_PARTY, |
| 21 |
|
|
DT_REGION, |
| 22 |
root |
1.5 |
|
| 23 |
|
|
// following are only for cfapi-compatibility |
| 24 |
|
|
DT_INT_PTR, |
| 25 |
|
|
DT_INT64_PTR, |
| 26 |
|
|
DT_DOUBLE_PTR, |
| 27 |
root |
1.2 |
}; |
| 28 |
|
|
|
| 29 |
root |
1.3 |
enum event_klass { |
| 30 |
|
|
KLASS_GLOBAL, |
| 31 |
|
|
KLASS_PLAYER, |
| 32 |
|
|
KLASS_OBJECT, |
| 33 |
|
|
KLASS_MAP, |
| 34 |
|
|
}; |
| 35 |
|
|
|
| 36 |
root |
1.2 |
enum event_type { |
| 37 |
root |
1.5 |
# define def(klass,name) EV_ ## klass ## _ ## name, |
| 38 |
root |
1.2 |
# include "eventinc.h" |
| 39 |
|
|
# undef def |
| 40 |
root |
1.4 |
NUM_EVENT_TYPES |
| 41 |
root |
1.2 |
}; |
| 42 |
|
|
|
| 43 |
root |
1.3 |
#define ARG_INT(v) DT_INT , static_cast<int> (v) |
| 44 |
root |
1.5 |
#define ARG_INT64(v) DT_INT64 , static_cast<sint64> (v) |
| 45 |
root |
1.3 |
#define ARG_DOUBLE(v) DT_DOUBLE, static_cast<double> (v) |
| 46 |
root |
1.5 |
#define ARG_STRING(v) DT_STRING, static_cast<const char *> (v) |
| 47 |
|
|
#define ARG_DATA(s,l) DT_DATA , static_cast<const void *> (s), (l) |
| 48 |
root |
1.3 |
#define ARG_OBJECT(o) DT_OBJECT, static_cast<struct object *> (o) |
| 49 |
|
|
#define ARG_MAP(o) DT_MAP , static_cast<struct mapstruct *> (o) |
| 50 |
|
|
#define ARG_PLAYER(o) DT_PLAYER, static_cast<struct pl *> (o) |
| 51 |
|
|
#define ARG_ARCH(o) DT_ARCH , static_cast<struct archetype *> (o) |
| 52 |
|
|
#define ARG_PARTY(o) DT_PARTY , static_cast<struct party *> (o) |
| 53 |
|
|
#define ARG_REGION(o) DT_REGION, static_cast<struct region *> (o) |
| 54 |
|
|
|
| 55 |
|
|
// the ", ## __VA_ARGS" is, unfortunately, a gnu-cpp extension |
| 56 |
root |
1.2 |
|
| 57 |
root |
1.4 |
// all these return true when the normal event processing should be skipped (if any) |
| 58 |
root |
1.5 |
#define INVOKE(klass, event, ...) cfperl_invoke (EV_ ## klass ## _ ## event, ## __VA_ARGS__, DT_END) |
| 59 |
root |
1.1 |
|
| 60 |
root |
1.3 |
#define INVOKE_GLOBAL(event, ...) INVOKE (GLOBAL, event, ## __VA_ARGS__) |
| 61 |
|
|
#define INVOKE_OBJECT(event, op, ...) INVOKE (OBJECT, event, ARG_OBJECT (op), ## __VA_ARGS__) |
| 62 |
|
|
#define INVOKE_PLAYER(event, pl, ...) INVOKE (PLAYER, event, ARG_PLAYER (pl), ## __VA_ARGS__) |
| 63 |
|
|
#define INVOKE_MAP(event, map, ...) INVOKE (MAP , event, ARG_MAP (map) , ## __VA_ARGS__) |
| 64 |
|
|
|
| 65 |
root |
1.4 |
bool cfperl_invoke (event_type event, ...); |
| 66 |
root |
1.3 |
void cfperl_free_ob (object *op); |
| 67 |
|
|
|
| 68 |
|
|
void cfperl_init (); |
| 69 |
root |
1.1 |
void cfperl_main (); |
| 70 |
root |
1.2 |
|
| 71 |
|
|
#endif |
| 72 |
root |
1.3 |
|