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.36 by root, Thu Dec 14 20:39:54 2006 UTC vs.
Revision 1.40 by root, Tue Dec 19 04:58:04 2006 UTC

25#undef getprotobyname 25#undef getprotobyname
26#undef gethostbyname 26#undef gethostbyname
27#undef ctime 27#undef ctime
28#undef strerror 28#undef strerror
29 29
30// same here, massive symbol spamming
31#undef do_open
32#undef do_close
33
30// perl bug #40256: perl does overwrite those with reentrant versions 34// perl bug #40256: perl does overwrite those with reentrant versions
31// but does not initialise their state structures. 35// but does not initialise their state structures.
32#undef random 36#undef random
33#undef crypt 37#undef crypt
34 38
37 41
38enum event_klass 42enum event_klass
39{ 43{
40 KLASS_NONE, 44 KLASS_NONE,
41 KLASS_GLOBAL, 45 KLASS_GLOBAL,
42 KLASS_SOCKET, 46 KLASS_CLIENT,
43 KLASS_PLAYER, 47 KLASS_PLAYER,
44 KLASS_OBJECT, 48 KLASS_OBJECT,
45 KLASS_MAP, 49 KLASS_MAP,
46 KLASS_COMMAND, 50 KLASS_COMMAND,
47}; 51};
64#define ARG_MAP(o) DT_MAP , (void *)static_cast<maptile *> (o) 68#define ARG_MAP(o) DT_MAP , (void *)static_cast<maptile *> (o)
65#define ARG_PLAYER(o) DT_PLAYER, (void *)static_cast<player *> (o) 69#define ARG_PLAYER(o) DT_PLAYER, (void *)static_cast<player *> (o)
66#define ARG_ARCH(o) DT_ARCH , (void *)static_cast<archetype *> (o) 70#define ARG_ARCH(o) DT_ARCH , (void *)static_cast<archetype *> (o)
67#define ARG_PARTY(o) DT_PARTY , (void *)static_cast<party *> (o) 71#define ARG_PARTY(o) DT_PARTY , (void *)static_cast<party *> (o)
68#define ARG_REGION(o) DT_REGION, (void *)static_cast<region *> (o) 72#define ARG_REGION(o) DT_REGION, (void *)static_cast<region *> (o)
69#define ARG_SOCKET(o) DT_SOCKET, (void *)static_cast<client_socket *> (o) 73#define ARG_CLIENT(o) DT_CLIENT, (void *)static_cast<client *> (o)
70 74
71// the ", ## __VA_ARGS" is, unfortunately, a gnu-cpp extension 75// the ", ## __VA_ARGS" is, unfortunately, a gnu-cpp extension
72 76
73// all these return true when the normal event processing should be skipped (if any) 77// all these return true when the normal event processing should be skipped (if any)
74#define INVOKE_(event, ...) cfperl_invoke (event, ## __VA_ARGS__, DT_END) 78#define INVOKE_(event, ...) cfperl_invoke (event, ## __VA_ARGS__, DT_END)
75 79
76#define INVOKE(klass, event, ...) INVOKE_(EVENT_ ## klass ## _ ## event, ## __VA_ARGS__) 80#define INVOKE(klass, event, ...) INVOKE_(EVENT_ ## klass ## _ ## event, ## __VA_ARGS__)
77#define INVOKE_GLOBAL(event, ...) INVOKE_(EVENT_ ## GLOBAL ## _ ## event, ## __VA_ARGS__) 81#define INVOKE_GLOBAL(event, ...) INVOKE_(EVENT_ ## GLOBAL ## _ ## event, ## __VA_ARGS__)
78#define INVOKE_OBJECT(event, op, ...) INVOKE_(EVENT_ ## OBJECT ## _ ## event, ARG_OBJECT (op), ## __VA_ARGS__) 82#define INVOKE_OBJECT(event, op, ...) INVOKE_(EVENT_ ## OBJECT ## _ ## event, ARG_OBJECT (op), ## __VA_ARGS__)
79#define INVOKE_SOCKET(event, ns, ...) INVOKE_(EVENT_ ## SOCKET ## _ ## event, ARG_SOCKET (ns), ## __VA_ARGS__) 83#define INVOKE_CLIENT(event, ns, ...) INVOKE_(EVENT_ ## CLIENT ## _ ## event, ARG_CLIENT (ns), ## __VA_ARGS__)
80#define INVOKE_PLAYER(event, pl, ...) INVOKE_(EVENT_ ## PLAYER ## _ ## event, ARG_PLAYER (pl), ## __VA_ARGS__) 84#define INVOKE_PLAYER(event, pl, ...) INVOKE_(EVENT_ ## PLAYER ## _ ## event, ARG_PLAYER (pl), ## __VA_ARGS__)
81#define INVOKE_MAP(event, map, ...) INVOKE_(EVENT_ ## MAP ## _ ## event, ARG_MAP (map) , ## __VA_ARGS__) 85#define INVOKE_MAP(event, map, ...) INVOKE_(EVENT_ ## MAP ## _ ## event, ARG_MAP (map) , ## __VA_ARGS__)
82 86
83//TODO should index into @result 87//TODO should index into @result
84#define RESULT(idx,type) cfperl_result_ ## type (idx) 88#define RESULT(idx,type) cfperl_result_ ## type (idx)
355 359
356private: 360private:
357 void cancel () { GEventAPI->cancel ((pe_watcher *)pe); } // private 361 void cancel () { GEventAPI->cancel ((pe_watcher *)pe); } // private
358}; 362};
359 363
364struct iw : watcher<pe_idle>, callback<void (iw &)>
365{
366 template<class O, class M>
367 iw (O object, M method)
368 : callback<void (iw &)> (object, method)
369 {
370 alloc ();
371 }
372
373private:
374 void alloc ();
375};
376
360struct iow : watcher<pe_io>, callback<void (iow &, int)> 377struct iow : watcher<pe_io>, callback<void (iow &, int)>
361{ 378{
362 template<class O, class M> 379 template<class O, class M>
363 iow (O object, M method) 380 iow (O object, M method)
364 : callback<void (iow &, int)> (object, method) 381 : callback<void (iow &, int)> (object, method)
365 { 382 {
366 alloc (); 383 alloc ();
367 } 384 }
368 385
369 iow &fd (int fd); 386 void fd (int fd);
370 int poll (); 387 int poll ();
371 iow &poll (int events); 388 void poll (int events);
372 389
373private: 390private:
374 void alloc (); 391 void alloc ();
375}; 392};
376 393

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines