ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/cfperl.h
Revision: 1.3
Committed: Fri Aug 25 13:24:50 2006 UTC (17 years, 9 months ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.2: +32 -17 lines
Log Message:
Implemented a rough outline of the new event system and made use of it
for a number of events. The corresponding plugin-events have been disabled.

File Contents

# User Rev Content
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     DT_LONG,
13     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     };
23    
24 root 1.3 enum event_klass {
25     KLASS_GLOBAL,
26     KLASS_PLAYER,
27     KLASS_OBJECT,
28     KLASS_MAP,
29     };
30    
31 root 1.2 enum event_type {
32 root 1.3 # define def(klass,name) EV_ ## klass ## name,
33 root 1.2 # include "eventinc.h"
34     # undef def
35     };
36    
37 root 1.3 #define ARG_INT(v) DT_INT , static_cast<int> (v)
38     #define ARG_LONG(v) DT_LONG , static_cast<long> (v)
39     #define ARG_DOUBLE(v) DT_DOUBLE, static_cast<double> (v)
40     #define ARG_STRING(v) DT_STRING, static_cast<char *> (v)
41     #define ARG_DATA(s,l) DT_DATA , static_cast<void *> (s), (l)
42     #define ARG_OBJECT(o) DT_OBJECT, static_cast<struct object *> (o)
43     #define ARG_MAP(o) DT_MAP , static_cast<struct mapstruct *> (o)
44     #define ARG_PLAYER(o) DT_PLAYER, static_cast<struct pl *> (o)
45     #define ARG_ARCH(o) DT_ARCH , static_cast<struct archetype *> (o)
46     #define ARG_PARTY(o) DT_PARTY , static_cast<struct party *> (o)
47     #define ARG_REGION(o) DT_REGION, static_cast<struct region *> (o)
48    
49     // the ", ## __VA_ARGS" is, unfortunately, a gnu-cpp extension
50 root 1.2
51 root 1.3 #define INVOKE(klass, event, ...) cfperl_invoke (EV_ ## klass ## event, ## __VA_ARGS__, DT_END)
52 root 1.1
53 root 1.3 #define INVOKE_GLOBAL(event, ...) INVOKE (GLOBAL, event, ## __VA_ARGS__)
54     #define INVOKE_OBJECT(event, op, ...) INVOKE (OBJECT, event, ARG_OBJECT (op), ## __VA_ARGS__)
55     #define INVOKE_PLAYER(event, pl, ...) INVOKE (PLAYER, event, ARG_PLAYER (pl), ## __VA_ARGS__)
56     #define INVOKE_MAP(event, map, ...) INVOKE (MAP , event, ARG_MAP (map) , ## __VA_ARGS__)
57    
58     int cfperl_invoke (event_type event, ...);
59     void cfperl_free_ob (object *op);
60    
61     void cfperl_init ();
62 root 1.1 void cfperl_main ();
63 root 1.2
64     #endif
65 root 1.3