1 #include <libchimara/glk.h>
2 #include "chimara-glk-private.h"
7 extern GPrivate *glk_data_key;
10 gidispatch_set_object_registry(gidispatch_rock_t (*regi)(void *obj, glui32 objclass), void (*unregi)(void *obj, glui32 objclass, gidispatch_rock_t objrock))
12 ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
17 glk_data->register_obj = regi;
18 glk_data->unregister_obj = unregi;
20 if(glk_data->register_obj)
22 /* It's now necessary to go through all existing objects, and register them. */
23 for(win = glk_window_iterate(NULL, NULL); win; win = glk_window_iterate(win, NULL))
24 win->disprock = (*glk_data->register_obj)(win, gidisp_Class_Window);
25 for(str = glk_stream_iterate(NULL, NULL); str; str = glk_stream_iterate(str, NULL))
26 str->disprock = (*glk_data->register_obj)(str, gidisp_Class_Stream);
27 for(fref = glk_fileref_iterate(NULL, NULL); fref; fref = glk_fileref_iterate(fref, NULL))
28 fref->disprock = (*glk_data->register_obj)(fref, gidisp_Class_Fileref);
33 gidispatch_get_objrock(void *obj, glui32 objclass)
37 case gidisp_Class_Window:
38 return ((winid_t)obj)->disprock;
39 case gidisp_Class_Stream:
40 return ((strid_t)obj)->disprock;
41 case gidisp_Class_Fileref:
42 return ((frefid_t)obj)->disprock;
45 gidispatch_rock_t dummy;
53 gidispatch_set_retained_registry(gidispatch_rock_t (*regi)(void *array, glui32 len, char *typecode), void (*unregi)(void *array, glui32 len, char *typecode, gidispatch_rock_t objrock))
55 ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
56 glk_data->register_arr = regi;
57 glk_data->unregister_arr = unregi;