ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/cfperl.h
(Generate patch)

Comparing deliantra/server/include/cfperl.h (file contents):
Revision 1.4 by root, Fri Aug 25 15:21:56 2006 UTC vs.
Revision 1.5 by root, Fri Aug 25 17:11:53 2006 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines