// // cfperl.h perl interface // #ifndef CFPERL_H__ #define CFPERL_H__ // could have used templates, but a more traditional C api // uses more explicit typing which is ok for this purpose. enum data_type { DT_END, // no further arguments DT_INT, DT_LONG, DT_DOUBLE, DT_STRING, // 0-terminated string DT_DATA, // string + length DT_OBJECT, DT_MAP, DT_PLAYER, DT_ARCH, DT_PARTY, DT_REGION, }; enum event_type { # define def(name) EV_ ## name, # include "eventinc.h" # undef def }; #define DT_INT(v) DT_INT , (int)(v) #define DT_LONG(v) DT_LONG , (long)(v) #define DT_DOUBLE(v) DT_DOUBLE, (double)(v) #define DT_STRING(v) DT_STRING, (char *)(v) #define DT_DATA(s,l) DT_DATA , (void *)(s), (l) #define DT_OBJECT(o) DT_OBJECT, (object *)(o) #define DT_MAP(o) DT_MAP , (map *)(o) #define DT_PLAYER(o) DT_PLAYER, (player *)(o) #define DT_ARCH(o) DT_ARCH , (archetype *)(o) #define DT_PARTY(o) DT_PARTY , (party *)(o) #define DT_REGION(o) DT_REGION, (region *)(o) #define INVOKE(event, ...) cfperl_invoke ("cf::invoke" , EV_ # event, __VA_ARGS__, DT_END) // should be called on all objects, should be optimised #define INVOKE_ON(object,event, ...) cfperl_invoke ("cf::invoke_on" , EV_ # event, DT_OBJECT(object), __VA_ARGS__, DT_END) int cfperl_invoke (const char *klass, event_type event, ...); void cfperl_main (); #endif