X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=libchimara%2Fdispatch.c;h=8473b20899fe3772c88642bd5823230852c2c0a4;hb=1e0dc5378f314f555e3b923c6d95f5017abd528b;hp=51c89f3afa5654b2c75183c5d54040c1c596fd5e;hpb=2613327f29349b786f93050c107f3a233169c653;p=projects%2Fchimara%2Fchimara.git diff --git a/libchimara/dispatch.c b/libchimara/dispatch.c index 51c89f3..8473b20 100644 --- a/libchimara/dispatch.c +++ b/libchimara/dispatch.c @@ -3,8 +3,9 @@ #include "window.h" #include "stream.h" #include "fileref.h" +#include "schannel.h" -extern GPrivate *glk_data_key; +extern GPrivate glk_data_key; /** * gidispatch_set_object_registry: @@ -27,15 +28,15 @@ extern GPrivate *glk_data_key; * actually executing VM code.) You pass in two function pointers, matching the * following prototypes: * |[ - * #gidispatch_rock_t my_vm_reg_object(void *obj, #glui32 objclass); - * void my_vm_unreg_object(void *obj, #glui32 objclass, #gidispatch_rock_t objrock); + * gidispatch_rock_t my_vm_reg_object(void *obj, glui32 objclass); + * void my_vm_unreg_object(void *obj, glui32 objclass, gidispatch_rock_t objrock); * ]| * - * Whenever the Glk library creates an object, it will call my_vm_reg_object(). - * It will pass the object pointer and the class number (from 0 to - * N - 1N - - * 1, where N is the value returned by - * gidispatch_count_classes().) + * Whenever the Glk library creates an object, it will call + * my_vm_reg_object(). It will pass the object + * pointer and the class number (from 0 to N - + * 1N - 1, where N is the value + * returned by gidispatch_count_classes().) * * You can return any value in the #gidispatch_rock_t object; the library will * stash this away inside the object. @@ -46,8 +47,8 @@ extern GPrivate *glk_data_key; * * * Whenever the Glk library destroys an object, it will call - * my_vm_unreg_object(). It passes you the object pointer, class number, and the - * object rock. + * my_vm_unreg_object(). It passes you the object + * pointer, class number, and the object rock. * * One significant detail: It is possible that some Glk objects will already * exist when your glk_main() function is called. @@ -58,8 +59,8 @@ extern GPrivate *glk_data_key; * * * So when you call gidispatch_set_object_registry(), it may immediately call - * your my_vm_reg_object() callback, notifying you of the existing objects. You - * must be prepared for this possibility. + * your my_vm_reg_object() callback, notifying + * you of the existing objects. You must be prepared for this possibility. * * * If you are keeping hash tables, for example, create them before you call @@ -69,7 +70,7 @@ extern GPrivate *glk_data_key; void gidispatch_set_object_registry(gidispatch_rock_t (*regi)(void *obj, glui32 objclass), void (*unregi)(void *obj, glui32 objclass, gidispatch_rock_t objrock)) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); winid_t win; strid_t str; frefid_t fref; @@ -108,6 +109,7 @@ gidispatch_rock_t gidispatch_get_objrock(void *obj, glui32 objclass) { g_return_val_if_fail(obj, (gidispatch_rock_t)NULL); + switch(objclass) { @@ -117,6 +119,8 @@ gidispatch_get_objrock(void *obj, glui32 objclass) return ((strid_t)obj)->disprock; case gidisp_Class_Fileref: return ((frefid_t)obj)->disprock; + case gidisp_Class_Schannel: + return ((schanid_t)obj)->disprock; default: { gidispatch_rock_t dummy; @@ -144,17 +148,17 @@ gidispatch_get_objrock(void *obj, glui32 objclass) * * Again, you pass in two function pointers: * |[ - * #gidispatch_rock_t my_vm_reg_array(void *array, #glui32 len, char *typecode); - * void my_vm_unreg_array(void *array, #glui32 len, char *typecode, #gidispatch_rock_t objrock); + * gidispatch_rock_t my_vm_reg_array(void *array, glui32 len, char *typecode); + * void my_vm_unreg_array(void *array, glui32 len, char *typecode, gidispatch_rock_t objrock); * ]| * - * Whenever a Glk function retains an array, it will call my_vm_reg_array(). - * This occurs only if you pass an array to an argument with the - * "#!" prefix. + * Whenever a Glk function retains an array, it will call + * my_vm_reg_array(). This occurs only if you + * pass an array to an argument with the "#!" prefix. * * - * But not in every such case. Wait for the my_vm_reg_array() call to confirm - * it. + * But not in every such case. Wait for the + * my_vm_reg_array() call to confirm it. * * * The library passes the array and its length, exactly as you put them in the @@ -172,9 +176,9 @@ gidispatch_get_objrock(void *obj, glui32 objclass) * stash this away with the array. * * When a Glk function releases a retained array, it will call - * my_vm_unreg_array(). It passes back the same @array, @len, and @typecode - * parameters, as well as the #gidispatch_rock_t you returned from - * my_vm_reg_array(). + * my_vm_unreg_array(). It passes back the same + * @array, @len, and @typecode parameters, as well as the #gidispatch_rock_t you + * returned from my_vm_reg_array(). * * With these callbacks, you can maintain a collection of retained arrays. You * can use this to copy data from C arrays to your own data structures, or keep @@ -184,7 +188,7 @@ gidispatch_get_objrock(void *obj, glui32 objclass) void 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)) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); glk_data->register_arr = regi; glk_data->unregister_arr = unregi; }