… | |
… | |
51 | |
51 | |
52 | static f_plug_api gethook; |
52 | static f_plug_api gethook; |
53 | static f_plug_api registerGlobalEvent; |
53 | static f_plug_api registerGlobalEvent; |
54 | static f_plug_api unregisterGlobalEvent; |
54 | static f_plug_api unregisterGlobalEvent; |
55 | static f_plug_api systemDirectory; |
55 | static f_plug_api systemDirectory; |
|
|
56 | static f_plug_api object_set_property; |
56 | |
57 | |
57 | typedef struct |
58 | typedef struct |
58 | { |
59 | { |
59 | object* who; |
60 | object* who; |
60 | object* activator; |
61 | object* activator; |
… | |
… | |
334 | printf (PLUGIN_VERSION " post init\n"); |
335 | printf (PLUGIN_VERSION " post init\n"); |
335 | |
336 | |
336 | registerGlobalEvent = gethook (&rtype, hooktype, "cfapi_system_register_global_event"); |
337 | registerGlobalEvent = gethook (&rtype, hooktype, "cfapi_system_register_global_event"); |
337 | unregisterGlobalEvent = gethook (&rtype, hooktype, "cfapi_system_unregister_global_event"); |
338 | unregisterGlobalEvent = gethook (&rtype, hooktype, "cfapi_system_unregister_global_event"); |
338 | systemDirectory = gethook (&rtype, hooktype, "cfapi_system_directory"); |
339 | systemDirectory = gethook (&rtype, hooktype, "cfapi_system_directory"); |
|
|
340 | object_set_property = gethook (&rtype, hooktype, "cfapi_object_set_property"); |
339 | cf_init_plugin (gethook); |
341 | cf_init_plugin (gethook); |
340 | |
342 | |
341 | /* Pick the global events you want to monitor from this plugin */ |
343 | /* Pick the global events you want to monitor from this plugin */ |
342 | registerGlobalEvent (NULL, EVENT_BORN, PLUGIN_NAME, globalEventListener); |
344 | registerGlobalEvent (NULL, EVENT_BORN, PLUGIN_NAME, globalEventListener); |
343 | registerGlobalEvent (NULL, EVENT_CLOCK, PLUGIN_NAME, globalEventListener); |
345 | registerGlobalEvent (NULL, EVENT_CLOCK, PLUGIN_NAME, globalEventListener); |
… | |
… | |
543 | |
545 | |
544 | BOOT: |
546 | BOOT: |
545 | { |
547 | { |
546 | HV *stash = gv_stashpv ("cf", 1); |
548 | HV *stash = gv_stashpv ("cf", 1); |
547 | |
549 | |
548 | const struct { |
550 | static const struct { |
549 | const char *name; |
551 | const char *name; |
550 | IV iv; |
552 | IV iv; |
551 | } *civ, const_iv[] = { |
553 | } *civ, const_iv[] = { |
552 | # define const_iv(name) { # name, (IV)name }, |
554 | # define const_iv(name) { # name, (IV)name }, |
553 | const_iv (llevError) |
555 | const_iv (llevError) |
… | |
… | |
837 | }; |
839 | }; |
838 | |
840 | |
839 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
841 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
840 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
842 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
841 | |
843 | |
842 | const struct { |
844 | static const struct { |
843 | const char *name; |
845 | const char *name; |
844 | IV iv; |
846 | IV iv; |
845 | } *event, event_list[] = { |
847 | } *event, event_list[] = { |
846 | # define const_event(name) { # name, (IV)EVENT_ ## name }, |
848 | # define const_event(name) { # name, (IV)EVENT_ ## name }, |
847 | const_event (NONE) |
849 | const_event (NONE) |
… | |
… | |
878 | AV *av = get_av ("cf::EVENT", 1); |
880 | AV *av = get_av ("cf::EVENT", 1); |
879 | |
881 | |
880 | for (event = event_list + sizeof (event_list) / sizeof (event_list [0]); event-- > event_list; ) |
882 | for (event = event_list + sizeof (event_list) / sizeof (event_list [0]); event-- > event_list; ) |
881 | av_store (av, event->iv, newSVpv ((char *)event->name, 0)); |
883 | av_store (av, event->iv, newSVpv ((char *)event->name, 0)); |
882 | |
884 | |
883 | const struct { |
885 | static const struct { |
884 | int dtype; |
886 | int dtype; |
885 | const char *name; |
887 | const char *name; |
886 | IV idx; |
888 | IV idx; |
887 | } *cprop, prop_table[] = { |
889 | } *cprop, prop_table[] = { |
888 | # define prop(type, name) { type, # name, (IV) CFAPI_ ## name }, |
890 | # define prop(type, name) { type, # name, (IV) CFAPI_ ## name }, |
… | |
… | |
1067 | cf_object_set_int_property (obj, idx, SvIV (newval)); |
1069 | cf_object_set_int_property (obj, idx, SvIV (newval)); |
1068 | break; |
1070 | break; |
1069 | case CFAPI_LONG: |
1071 | case CFAPI_LONG: |
1070 | cf_object_set_long_property (obj, idx, SvNV (newval)); |
1072 | cf_object_set_long_property (obj, idx, SvNV (newval)); |
1071 | break; |
1073 | break; |
|
|
1074 | case CFAPI_DOUBLE: |
|
|
1075 | { |
|
|
1076 | int unused_type; |
|
|
1077 | object_set_property (&unused_type, obj, idx, (double)SvNV (newval)); |
|
|
1078 | } |
|
|
1079 | break; |
1072 | case CFAPI_STRING: |
1080 | case CFAPI_STRING: |
1073 | cf_object_set_string_property (obj, idx, SvPV_nolen (newval)); |
1081 | cf_object_set_string_property (obj, idx, SvPV_nolen (newval)); |
1074 | break; |
1082 | break; |
1075 | default: |
1083 | default: |
1076 | croak ("unhandled type '%d' in set_property '%d'", type, idx); |
1084 | croak ("unhandled type '%d' in set_property '%d'", type, idx); |