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.34 by root, Mon Dec 11 23:35:37 2006 UTC vs.
Revision 1.35 by root, Thu Dec 14 05:09:32 2006 UTC

33 33
34enum event_klass 34enum event_klass
35{ 35{
36 KLASS_NONE, 36 KLASS_NONE,
37 KLASS_GLOBAL, 37 KLASS_GLOBAL,
38 KLASS_SOCKET,
38 KLASS_PLAYER, 39 KLASS_PLAYER,
39 KLASS_OBJECT, 40 KLASS_OBJECT,
40 KLASS_MAP, 41 KLASS_MAP,
41 KLASS_COMMAND, 42 KLASS_COMMAND,
42}; 43};
59#define ARG_MAP(o) DT_MAP , (void *)static_cast<maptile *> (o) 60#define ARG_MAP(o) DT_MAP , (void *)static_cast<maptile *> (o)
60#define ARG_PLAYER(o) DT_PLAYER, (void *)static_cast<player *> (o) 61#define ARG_PLAYER(o) DT_PLAYER, (void *)static_cast<player *> (o)
61#define ARG_ARCH(o) DT_ARCH , (void *)static_cast<archetype *> (o) 62#define ARG_ARCH(o) DT_ARCH , (void *)static_cast<archetype *> (o)
62#define ARG_PARTY(o) DT_PARTY , (void *)static_cast<party *> (o) 63#define ARG_PARTY(o) DT_PARTY , (void *)static_cast<party *> (o)
63#define ARG_REGION(o) DT_REGION, (void *)static_cast<region *> (o) 64#define ARG_REGION(o) DT_REGION, (void *)static_cast<region *> (o)
65#define ARG_SOCKET(o) DT_SOCKET, (void *)static_cast<client_socket *> (o)
64 66
65// the ", ## __VA_ARGS" is, unfortunately, a gnu-cpp extension 67// the ", ## __VA_ARGS" is, unfortunately, a gnu-cpp extension
66 68
67// all these return true when the normal event processing should be skipped (if any) 69// all these return true when the normal event processing should be skipped (if any)
68#define INVOKE_(event, ...) cfperl_invoke (event, ## __VA_ARGS__, DT_END) 70#define INVOKE_(event, ...) cfperl_invoke (event, ## __VA_ARGS__, DT_END)
69 71
70#define INVOKE(klass, event, ...) INVOKE_(EVENT_ ## klass ## _ ## event, ## __VA_ARGS__) 72#define INVOKE(klass, event, ...) INVOKE_(EVENT_ ## klass ## _ ## event, ## __VA_ARGS__)
71#define INVOKE_GLOBAL(event, ...) INVOKE_(EVENT_ ## GLOBAL ## _ ## event, ## __VA_ARGS__) 73#define INVOKE_GLOBAL(event, ...) INVOKE_(EVENT_ ## GLOBAL ## _ ## event, ## __VA_ARGS__)
72#define INVOKE_OBJECT(event, op, ...) INVOKE_(EVENT_ ## OBJECT ## _ ## event, ARG_OBJECT (op), ## __VA_ARGS__) 74#define INVOKE_OBJECT(event, op, ...) INVOKE_(EVENT_ ## OBJECT ## _ ## event, ARG_OBJECT (op), ## __VA_ARGS__)
75#define INVOKE_SOCKET(event, ns, ...) INVOKE_(EVENT_ ## SOCKET ## _ ## event, ARG_SOCKET (ns), ## __VA_ARGS__)
73#define INVOKE_PLAYER(event, pl, ...) INVOKE_(EVENT_ ## PLAYER ## _ ## event, ARG_PLAYER (pl), ## __VA_ARGS__) 76#define INVOKE_PLAYER(event, pl, ...) INVOKE_(EVENT_ ## PLAYER ## _ ## event, ARG_PLAYER (pl), ## __VA_ARGS__)
74#define INVOKE_MAP(event, map, ...) INVOKE_(EVENT_ ## MAP ## _ ## event, ARG_MAP (map) , ## __VA_ARGS__) 77#define INVOKE_MAP(event, map, ...) INVOKE_(EVENT_ ## MAP ## _ ## event, ARG_MAP (map) , ## __VA_ARGS__)
75 78
76//TODO should index into @result 79//TODO should index into @result
77#define RESULT(idx,type) cfperl_result_ ## type (idx) 80#define RESULT(idx,type) cfperl_result_ ## type (idx)
82double cfperl_result_DOUBLE (int idx); 85double cfperl_result_DOUBLE (int idx);
83int cfperl_result_INT (int idx); 86int cfperl_result_INT (int idx);
84 87
85struct attachable_base 88struct attachable_base
86{ 89{
87 SV *self; 90 SV *self; // CF+ perl self
88 AV *cb; // CF+ perl self and callback 91 AV *cb; // CF+ callbacks
89 shstr attach; // generic extension attachment information 92 shstr attach; // generic extension attachment information
90 93
91 void clear (); // called when free'ing objects 94 void clear (); // called when free'ing objects
92 void optimise (); // possibly save some memory by destroying unneeded data 95 void optimise (); // possibly save some memory by destroying unneeded data
93 void instantiate (data_type type, void *obj); 96 void instantiate (data_type type, void *obj);
112 attachable_base (const attachable_base &src) 115 attachable_base (const attachable_base &src)
113 : self (0), cb (0), attach (src.attach) 116 : self (0), cb (0), attach (src.attach)
114 { 117 {
115 } 118 }
116 119
117 attachable_base &operator = (const attachable_base &src) 120 attachable_base &operator =(const attachable_base &src)
118 { 121 {
119 clear (); 122 clear ();
120 attach = src.attach; 123 attach = src.attach;
121 return *this; 124 return *this;
122 } 125 }
123}; 126};
124 127
125// objects attachable from perl (or any other extension) should include or 128// objects attachable from perl (or any other extension) should include or
126// derive using the curiously recurring template pattern, to avoid 129// derive using the curiously recurring template pattern, to avoid

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines