From: Philip Chimento Date: Sat, 31 Aug 2013 21:48:37 +0000 (-0700) Subject: Use statically-allocated thread private data X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=1e0dc5378f314f555e3b923c6d95f5017abd528b;p=projects%2Fchimara%2Fchimara.git Use statically-allocated thread private data Dynamically allocating GPrivate is discouraged, and g_private_new() is deprecated since GLib 2.32. --- diff --git a/libchimara/abort.c b/libchimara/abort.c index 26eb8c4..3e85536 100644 --- a/libchimara/abort.c +++ b/libchimara/abort.c @@ -6,7 +6,7 @@ #include "chimara-glk-private.h" #include "window.h" -extern GPrivate *glk_data_key; +extern GPrivate glk_data_key; /** * glk_set_interrupt_handler: @@ -31,7 +31,7 @@ extern GPrivate *glk_data_key; void glk_set_interrupt_handler(void (*func)(void)) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); glk_data->interrupt_handler = func; } @@ -40,7 +40,7 @@ user's interrupt handler. */ static void abort_glk(void) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); if(glk_data->interrupt_handler) (*(glk_data->interrupt_handler))(); shutdown_glk_pre(); @@ -57,7 +57,7 @@ abort_glk(void) void check_for_abort(void) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); g_mutex_lock(&glk_data->abort_lock); if(glk_data->abort_signalled) { @@ -72,8 +72,8 @@ check_for_abort(void) void shutdown_glk_pre(void) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); - + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); + /* Stop any timers */ glk_request_timer_events(0); @@ -123,8 +123,8 @@ shutdown_glk_pre(void) void shutdown_glk_post(void) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); - + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); + /* Free all opaque objects; can't iterate normally, because the objects are being removed from the global iteration lists */ if(glk_data->root_window) diff --git a/libchimara/chimara-glk.c b/libchimara/chimara-glk.c index 33c64e8..a350c5a 100644 --- a/libchimara/chimara-glk.c +++ b/libchimara/chimara-glk.c @@ -1128,8 +1128,8 @@ glk_main() runs. Takes ownership of @startup and will free it. */ static gpointer glk_enter(struct StartupData *startup) { - extern GPrivate *glk_data_key; - g_private_set(glk_data_key, startup->glk_data); + extern GPrivate glk_data_key; + g_private_set(&glk_data_key, startup->glk_data); /* Acquire the Glk thread's references to the input queues */ g_async_queue_ref(startup->glk_data->char_input_queue); diff --git a/libchimara/dispatch.c b/libchimara/dispatch.c index c4c95e3..8473b20 100644 --- a/libchimara/dispatch.c +++ b/libchimara/dispatch.c @@ -5,7 +5,7 @@ #include "fileref.h" #include "schannel.h" -extern GPrivate *glk_data_key; +extern GPrivate glk_data_key; /** * gidispatch_set_object_registry: @@ -70,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; @@ -188,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; } diff --git a/libchimara/event.c b/libchimara/event.c index dd348a9..18f7281 100644 --- a/libchimara/event.c +++ b/libchimara/event.c @@ -8,7 +8,7 @@ #include "chimara-glk.h" #include "chimara-glk-private.h" -extern GPrivate *glk_data_key; +extern GPrivate glk_data_key; #define EVENT_TIMEOUT_MICROSECONDS (3000000) @@ -56,7 +56,7 @@ event_throw(ChimaraGlk *glk, glui32 type, winid_t win, glui32 val1, glui32 val2) static void get_appropriate_event(event_t *event) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); g_mutex_lock(&glk_data->event_lock); @@ -152,7 +152,7 @@ glk_select(event_t *event) flush_window_buffer(win); } - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); get_appropriate_event(event); @@ -234,8 +234,8 @@ glk_select_poll(event_t *event) { g_return_if_fail(event != NULL); - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); - + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); + event->type = evtype_None; event->win = NULL; event->val1 = 0; diff --git a/libchimara/fileref.c b/libchimara/fileref.c index 5838996..716586c 100644 --- a/libchimara/fileref.c +++ b/libchimara/fileref.c @@ -10,7 +10,7 @@ #include "chimara-glk-private.h" #include "gi_dispa.h" -extern GPrivate *glk_data_key; +extern GPrivate glk_data_key; /* Internal function: create a fileref using the given parameters. If @basename is NULL, compute a basename from @filename. */ @@ -19,8 +19,8 @@ fileref_new(char *filename, char *basename, glui32 rock, glui32 usage, glui32 or { g_return_val_if_fail(filename != NULL, NULL); - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); - + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); + frefid_t f = g_new0(struct glk_fileref_struct, 1); f->magic = MAGIC_FILEREF; f->rock = rock; @@ -45,8 +45,8 @@ fileref_new(char *filename, char *basename, glui32 rock, glui32 usage, glui32 or static void fileref_close_common(frefid_t fref) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); - + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); + glk_data->fileref_list = g_list_delete_link(glk_data->fileref_list, fref->fileref_list); if(glk_data->unregister_obj) @@ -78,7 +78,7 @@ glk_fileref_iterate(frefid_t fref, glui32 *rockptr) { VALID_FILEREF_OR_NULL(fref, return NULL); - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); GList *retnode; if(fref == NULL) @@ -225,8 +225,8 @@ glk_fileref_create_by_prompt(glui32 usage, glui32 fmode, glui32 rock) for each usage */ GtkWidget *chooser; - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); - + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); + gdk_threads_enter(); switch(fmode) @@ -432,8 +432,8 @@ glk_fileref_create_by_name(glui32 usage, char *name, glui32 rock) { g_return_val_if_fail(name != NULL && strlen(name) > 0, NULL); - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); - + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); + /* Do any string-munging here to remove illegal Latin-1 characters from filename. On ext3, the only illegal characters are '/' and '\0', but the Glk spec calls for removing any other tricky characters. */ diff --git a/libchimara/garglk.c b/libchimara/garglk.c index a879ca8..27ddd07 100644 --- a/libchimara/garglk.c +++ b/libchimara/garglk.c @@ -8,7 +8,7 @@ #include "style.h" #include "garglk.h" -extern GPrivate *glk_data_key; +extern GPrivate glk_data_key; /** * garglk_fileref_get_name: @@ -40,7 +40,7 @@ garglk_fileref_get_name(frefid_t fref) void garglk_set_program_name(const char *name) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); glk_data->program_name = g_strdup(name); g_object_notify(G_OBJECT(glk_data->self), "program-name"); } @@ -64,7 +64,7 @@ garglk_set_program_name(const char *name) void garglk_set_program_info(const char *info) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); glk_data->program_info = g_strdup(info); g_object_notify(G_OBJECT(glk_data->self), "program-info"); } @@ -83,7 +83,7 @@ garglk_set_program_info(const char *info) void garglk_set_story_name(const char *name) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); glk_data->story_name = g_strdup(name); g_object_notify(G_OBJECT(glk_data->self), "story-name"); } @@ -118,7 +118,7 @@ garglk_set_story_title(const char *title) void garglk_unput_string(char *str) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); g_return_if_fail(glk_data->current_stream != NULL); WARNING(_("Not implemented")); @@ -135,7 +135,7 @@ garglk_unput_string(char *str) void garglk_unput_string_uni(glui32 *str) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); g_return_if_fail(glk_data->current_stream != NULL); WARNING(_("Not implemented")); @@ -293,7 +293,7 @@ garglk_set_zcolors_stream(strid_t str, glui32 fg, glui32 bg) void garglk_set_zcolors(glui32 fg, glui32 bg) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); g_return_if_fail(glk_data->current_stream != NULL); garglk_set_zcolors_stream(glk_data->current_stream, fg, bg); @@ -389,7 +389,7 @@ garglk_set_reversevideo_stream(strid_t str, glui32 reverse) void garglk_set_reversevideo(glui32 reverse) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); g_return_if_fail(glk_data->current_stream != NULL); g_return_if_fail(glk_data->current_stream->window != NULL); diff --git a/libchimara/glk.c b/libchimara/glk.c index b86daed..f3ae9c1 100644 --- a/libchimara/glk.c +++ b/libchimara/glk.c @@ -7,7 +7,7 @@ #include "gi_blorb.h" #include "window.h" -G_GNUC_INTERNAL GPrivate *glk_data_key = NULL; +G_GNUC_INTERNAL GPrivate glk_data_key = G_PRIVATE_INIT(NULL); /** * glk_exit: @@ -43,7 +43,7 @@ G_GNUC_INTERNAL GPrivate *glk_data_key = NULL; void glk_exit(void) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); shutdown_glk_pre(); diff --git a/libchimara/glkunix.c b/libchimara/glkunix.c index ddaf848..bdadbaf 100644 --- a/libchimara/glkunix.c +++ b/libchimara/glkunix.c @@ -7,7 +7,7 @@ #include "fileref.h" #include "stream.h" -extern GPrivate *glk_data_key; +extern GPrivate glk_data_key; /** * glkunix_stream_open_pathname_gen: @@ -27,7 +27,7 @@ extern GPrivate *glk_data_key; strid_t glkunix_stream_open_pathname_gen(char *pathname, glui32 writemode, glui32 textmode, glui32 rock) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); if(!glk_data->in_startup) ILLEGAL("glkunix_stream_open_pathname_gen() may only be called from " @@ -58,7 +58,7 @@ glkunix_stream_open_pathname_gen(char *pathname, glui32 writemode, glui32 textmo strid_t glkunix_stream_open_pathname(char *pathname, glui32 textmode, glui32 rock) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); if(!glk_data->in_startup) ILLEGAL("glkunix_stream_open_pathname() may only be called from " @@ -89,8 +89,8 @@ glkunix_set_base_file(char *filename) g_return_if_fail(filename); g_return_if_fail(strlen(filename) > 0); - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); - + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); + gchar *dirname = g_path_get_dirname(filename); if(!g_file_test(dirname, G_FILE_TEST_IS_DIR)) { diff --git a/libchimara/graphics.c b/libchimara/graphics.c index f83ec0e..ab06d8f 100644 --- a/libchimara/graphics.c +++ b/libchimara/graphics.c @@ -4,7 +4,7 @@ #define BUFFER_SIZE (1024) -extern GPrivate *glk_data_key; +extern GPrivate glk_data_key; void on_size_prepared(GdkPixbufLoader *loader, gint width, gint height, struct image_info *info); void on_pixbuf_closed(GdkPixbufLoader *loader, gpointer data); glui32 draw_image_common(winid_t win, GdkPixbuf *pixbuf, glsi32 val1, glsi32 val2); @@ -15,7 +15,7 @@ static gboolean size_determined; static struct image_info* load_image_from_blorb(giblorb_result_t resource, glui32 image, gint width, gint height) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); GError *pixbuf_error = NULL; guchar *buffer; @@ -97,7 +97,7 @@ load_image_from_file(const gchar *filename, glui32 image, gint width, gint heigh static struct image_info* load_image_in_cache(glui32 image, gint width, gint height) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); struct image_info *info = NULL; /* Lookup the proper resource */ @@ -146,7 +146,7 @@ load_image_in_cache(glui32 image, gint width, gint height) void on_size_prepared(GdkPixbufLoader *loader, gint width, gint height, struct image_info *info) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); g_mutex_lock(&glk_data->resource_lock); info->width = width; @@ -161,7 +161,7 @@ on_pixbuf_closed(GdkPixbufLoader *loader, gpointer data) { gdk_threads_enter(); - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); g_mutex_lock(&glk_data->resource_lock); image_loaded = TRUE; @@ -182,7 +182,7 @@ clear_image_cache(struct image_info *data, gpointer user_data) static struct image_info* image_cache_find(struct image_info* to_find) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); GSList *link = glk_data->image_cache; gdk_threads_enter(); @@ -351,7 +351,7 @@ glk_image_draw_scaled(winid_t win, glui32 image, glsi32 val1, glsi32 val2, glui3 VALID_WINDOW(win, return FALSE); g_return_val_if_fail(win->type == wintype_Graphics || win->type == wintype_TextBuffer, FALSE); - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); struct image_info *to_find = g_new0(struct image_info, 1); struct image_info *info; struct image_info *scaled_info; diff --git a/libchimara/hyperlink.c b/libchimara/hyperlink.c index 1f40bc3..4545f99 100644 --- a/libchimara/hyperlink.c +++ b/libchimara/hyperlink.c @@ -4,7 +4,7 @@ #include "chimara-glk-private.h" #include "magic.h" -extern GPrivate *glk_data_key; +extern GPrivate glk_data_key; /** * glk_set_hyperlink: @@ -16,7 +16,7 @@ extern GPrivate *glk_data_key; void glk_set_hyperlink(glui32 linkval) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); g_return_if_fail(glk_data->current_stream != NULL); glk_set_hyperlink_stream(glk_data->current_stream, linkval); } diff --git a/libchimara/init.c b/libchimara/init.c index d2d161a..ab7522c 100644 --- a/libchimara/init.c +++ b/libchimara/init.c @@ -34,10 +34,6 @@ chimara_init(void) /*if( !gst_is_initialized() )*/ gst_init(NULL, NULL); #endif - - /* Initialize thread-private data */ - extern GPrivate *glk_data_key; - glk_data_key = g_private_new(NULL); } } diff --git a/libchimara/input.c b/libchimara/input.c index c54fe8b..f6b7fb5 100644 --- a/libchimara/input.c +++ b/libchimara/input.c @@ -5,7 +5,7 @@ #include "chimara-glk-private.h" #include "garglk.h" -extern GPrivate *glk_data_key; +extern GPrivate glk_data_key; /* Forward declarations */ static int finish_text_buffer_line_input(winid_t win, gboolean emit_signal); @@ -41,7 +41,7 @@ request_char_event_common(winid_t win, gboolean unicode) gdk_threads_leave(); /* Emit the "waiting" signal to let listeners know we are ready for input */ - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); g_signal_emit_by_name(glk_data->self, "waiting"); } @@ -247,7 +247,7 @@ glk_request_line_event(winid_t win, char *buf, glui32 maxlen, glui32 initlen) cancel_old_input_request(win); - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); /* Register the buffer */ if(glk_data->register_arr) @@ -320,7 +320,7 @@ glk_request_line_event_uni(winid_t win, glui32 *buf, glui32 maxlen, glui32 initl g_return_if_fail(initlen <= maxlen); cancel_old_input_request(win); - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); /* Register the buffer */ if(glk_data->register_arr) @@ -404,7 +404,7 @@ glk_cancel_line_event(winid_t win, event_t *event) } gdk_threads_leave(); - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); if(glk_data->unregister_arr) { if(win->input_request_type == INPUT_REQUEST_LINE_UNICODE) @@ -916,7 +916,7 @@ keyval_to_glk_keycode(guint keyval, gboolean unicode) void force_char_input_from_queue(winid_t win, event_t *event) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); guint keyval = GPOINTER_TO_UINT(g_async_queue_pop(glk_data->char_input_queue)); glk_cancel_char_event(win); @@ -936,7 +936,7 @@ force_char_input_from_queue(winid_t win, event_t *event) void force_line_input_from_queue(winid_t win, event_t *event) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); const gchar *text = g_async_queue_pop(glk_data->line_input_queue); glui32 chars_written = 0; diff --git a/libchimara/resource.c b/libchimara/resource.c index ba47dd4..49ef352 100644 --- a/libchimara/resource.c +++ b/libchimara/resource.c @@ -1,7 +1,7 @@ #include "resource.h" #include "stream.h" -extern GPrivate *glk_data_key; +extern GPrivate glk_data_key; /** * giblorb_set_resource_map: @@ -20,7 +20,7 @@ extern GPrivate *glk_data_key; giblorb_err_t giblorb_set_resource_map(strid_t file) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); giblorb_map_t *newmap; /* create map allocates memory */ giblorb_err_t error = giblorb_create_map(file, &newmap); @@ -53,8 +53,8 @@ giblorb_set_resource_map(strid_t file) giblorb_map_t* giblorb_get_resource_map() { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); - + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); + if(glk_data->resource_map == NULL) { WARNING("Resource map not set yet.\n"); } diff --git a/libchimara/schannel.c b/libchimara/schannel.c index c92e7fc..b64470d 100644 --- a/libchimara/schannel.c +++ b/libchimara/schannel.c @@ -15,7 +15,7 @@ #define VOLUME_TIMER_RESOLUTION 1.0 /* In milliseconds */ -extern GPrivate *glk_data_key; +extern GPrivate glk_data_key; #ifdef GSTREAMER_SOUND /* Stop any currently playing sound on this channel, and remove any @@ -221,7 +221,7 @@ schanid_t glk_schannel_create_ext(glui32 rock, glui32 volume) { #ifdef GSTREAMER_SOUND - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); schanid_t s = g_new0(struct glk_schannel_struct, 1); s->magic = MAGIC_SCHANNEL; @@ -294,7 +294,7 @@ glk_schannel_destroy(schanid_t chan) VALID_SCHANNEL(chan, return); #ifdef GSTREAMER_SOUND - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); if(!gst_element_set_state(chan->pipeline, GST_STATE_NULL)) WARNING_S(_("Could not set GstElement state to"), "NULL"); @@ -336,7 +336,7 @@ glk_schannel_iterate(schanid_t chan, glui32 *rockptr) VALID_SCHANNEL_OR_NULL(chan, return NULL); #ifdef GSTREAMER_SOUND - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); GList *retnode; if(chan == NULL) @@ -443,7 +443,7 @@ glk_schannel_play_ext(schanid_t chan, glui32 snd, glui32 repeats, glui32 notify) { VALID_SCHANNEL(chan, return 0); #ifdef GSTREAMER_SOUND - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); GInputStream *stream; /* Stop the previous sound */ @@ -557,7 +557,7 @@ glk_schannel_play_multi(schanid_t *chanarray, glui32 chancount, glui32 *sndarray VALID_SCHANNEL(chanarray[count], return 0); #ifdef GSTREAMER_SOUND - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); GInputStream *stream; if(!glk_data->resource_map && !glk_data->resource_load_callback) { @@ -894,7 +894,7 @@ void glk_sound_load_hint(glui32 snd, glui32 flag) { #ifdef GSTREAMER_SOUND - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); giblorb_result_t resource; giblorb_err_t result; diff --git a/libchimara/stream.c b/libchimara/stream.c index 0b1e2d8..46a2efc 100644 --- a/libchimara/stream.c +++ b/libchimara/stream.c @@ -10,14 +10,14 @@ #include #include "chimara-glk-private.h" -extern GPrivate *glk_data_key; +extern GPrivate glk_data_key; /* Internal function: create a stream with a specified rock value */ strid_t stream_new_common(glui32 rock) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); - + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); + strid_t str = g_new0(struct glk_stream_struct, 1); str->magic = MAGIC_STREAM; str->rock = rock; @@ -36,7 +36,7 @@ stream_new_common(glui32 rock) void stream_close_common(strid_t str, stream_result_t *result) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); if(glk_data->unregister_obj) { @@ -85,7 +85,7 @@ glk_stream_iterate(strid_t str, glui32 *rockptr) { VALID_STREAM_OR_NULL(str, return NULL); - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); GList *retnode; if(str == NULL) @@ -131,8 +131,8 @@ glk_stream_set_current(strid_t str) { VALID_STREAM_OR_NULL(str, return); - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); - + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); + if(str != NULL && str->file_mode == filemode_Read) { ILLEGAL("Cannot set current stream to non output stream"); @@ -152,7 +152,7 @@ glk_stream_set_current(strid_t str) strid_t glk_stream_get_current() { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); return glk_data->current_stream; } @@ -167,7 +167,7 @@ glk_stream_get_current() void glk_put_char(unsigned char ch) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); VALID_STREAM(glk_data->current_stream, return); glk_put_char_stream(glk_data->current_stream, ch); } @@ -183,7 +183,7 @@ glk_put_char(unsigned char ch) void glk_put_char_uni(glui32 ch) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); VALID_STREAM(glk_data->current_stream, return); glk_put_char_stream_uni(glk_data->current_stream, ch); } @@ -203,7 +203,7 @@ glk_put_char_uni(glui32 ch) void glk_put_string(char *s) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); VALID_STREAM(glk_data->current_stream, return); glk_put_string_stream(glk_data->current_stream, s); } @@ -219,7 +219,7 @@ glk_put_string(char *s) void glk_put_string_uni(glui32 *s) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); VALID_STREAM(glk_data->current_stream, return); glk_put_string_stream_uni(glk_data->current_stream, s); } @@ -240,7 +240,7 @@ glk_put_string_uni(glui32 *s) void glk_put_buffer(char *buf, glui32 len) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); VALID_STREAM(glk_data->current_stream, return); glk_put_buffer_stream(glk_data->current_stream, buf, len); } @@ -256,7 +256,7 @@ glk_put_buffer(char *buf, glui32 len) void glk_put_buffer_uni(glui32 *buf, glui32 len) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); VALID_STREAM(glk_data->current_stream, return); glk_put_buffer_stream_uni(glk_data->current_stream, buf, len); } @@ -292,7 +292,7 @@ glk_stream_open_memory(char *buf, glui32 buflen, glui32 fmode, glui32 rock) if(buf && buflen) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); str->buffer = buf; str->buflen = buflen; if(glk_data->register_arr) @@ -331,7 +331,7 @@ glk_stream_open_memory_uni(glui32 *buf, glui32 buflen, glui32 fmode, glui32 rock if(buf && buflen) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); str->ubuffer = buf; str->buflen = buflen; if(glk_data->register_arr) @@ -637,7 +637,7 @@ glk_stream_close(strid_t str, stream_result_t *result) case STREAM_TYPE_MEMORY: { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); if(glk_data->unregister_arr) { if(str->unicode) diff --git a/libchimara/style.c b/libchimara/style.c index 406a884..6724076 100644 --- a/libchimara/style.c +++ b/libchimara/style.c @@ -8,7 +8,7 @@ #include "stream.h" #include "strio.h" -extern GPrivate *glk_data_key; +extern GPrivate glk_data_key; static gboolean style_accept(GScanner *scanner, GTokenType token); static gboolean style_accept_style_selector(GScanner *scanner, ChimaraGlk *glk); @@ -34,7 +34,7 @@ static void style_cascade_colors(GtkTextTag *tag, GtkTextTag *glk_tag, GtkTextTa void glk_set_style(glui32 styl) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); g_return_if_fail(glk_data->current_stream != NULL); glk_set_style_stream(glk_data->current_stream, styl); } @@ -128,7 +128,7 @@ style_init_textbuffer(GtkTextBuffer *buffer) { g_return_if_fail(buffer != NULL); - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); /* Place the default text tags in the textbuffer's tag table */ g_hash_table_foreach(glk_data->styles->text_buffer, style_copy_tag_to_textbuffer, gtk_text_buffer_get_tag_table(buffer)); @@ -146,8 +146,8 @@ void style_init_textgrid(GtkTextBuffer *buffer) { g_return_if_fail(buffer != NULL); - - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); /* Place the default text tags in the textbuffer's tag table */ g_hash_table_foreach(glk_data->styles->text_grid, style_copy_tag_to_textbuffer, gtk_text_buffer_get_tag_table(buffer)); @@ -641,7 +641,7 @@ apply_stylehint_to_tag(GtkTextTag *tag, glui32 wintype, glui32 styl, glui32 hint { g_return_if_fail(tag != NULL); - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); GObject *tag_object = G_OBJECT(tag); gint reverse_color = GPOINTER_TO_INT( g_object_get_data(tag_object, "reverse-color") ); @@ -801,7 +801,7 @@ query_tag(GtkTextTag *tag, glui32 wintype, glui32 hint) g_return_val_if_fail(tag != NULL, 0); - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); switch(hint) { case stylehint_Indentation: @@ -896,7 +896,7 @@ glk_stylehint_set(glui32 wintype, glui32 styl, glui32 hint, glsi32 val) g_printf("glk_stylehint_set(wintype=%d, styl=%d, hint=%d, val=%d)\n", wintype, styl, hint, val); #endif - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); GtkTextTag *to_change; if(wintype == wintype_TextBuffer || wintype == wintype_AllTypes) { @@ -931,7 +931,7 @@ glk_stylehint_clear(glui32 wintype, glui32 styl, glui32 hint) g_printf("glk_stylehint_clear(wintype=%d, styl=%d, hint=%d)\n", wintype, styl, hint); #endif - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); GtkTextTag *tag; switch(wintype) { @@ -1057,7 +1057,7 @@ glk_style_measure(winid_t win, glui32 styl, glui32 hint, glui32 *result) g_printf("glk_style_measure(win->rock=%d, styl=%d, hint=%d, result=...)\n", win->rock, styl, hint); #endif - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); GtkTextTag *tag; switch(win->type) { @@ -1083,7 +1083,7 @@ glk_style_measure(winid_t win, glui32 styl, glui32 hint, glui32 *result) PangoFontDescription * get_current_font(guint32 wintype) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); GHashTable *styles, *glk_styles; PangoFontDescription *font; diff --git a/libchimara/timer.c b/libchimara/timer.c index ddaa4a8..cebe6fe 100644 --- a/libchimara/timer.c +++ b/libchimara/timer.c @@ -1,6 +1,6 @@ #include "timer.h" -extern GPrivate *glk_data_key; +extern GPrivate glk_data_key; /** * glk_request_timer_events: @@ -46,8 +46,8 @@ extern GPrivate *glk_data_key; void glk_request_timer_events(glui32 millisecs) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); - + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); + // Stop any existing timer if(glk_data->timer_id != 0) { g_source_remove(glk_data->timer_id); diff --git a/libchimara/window.c b/libchimara/window.c index bcdce55..a4366b4 100644 --- a/libchimara/window.c +++ b/libchimara/window.c @@ -5,12 +5,12 @@ #include "gi_dispa.h" #include "pager.h" -extern GPrivate *glk_data_key; +extern GPrivate glk_data_key; static winid_t window_new_common(glui32 rock) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); winid_t win = g_new0(struct glk_window_struct, 1); win->magic = MAGIC_WINDOW; @@ -52,7 +52,7 @@ window_new_common(glui32 rock) static void window_close_common(winid_t win, gboolean destroy_node) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); if(glk_data->unregister_obj) { @@ -100,8 +100,8 @@ winid_t glk_window_iterate(winid_t win, glui32 *rockptr) { VALID_WINDOW_OR_NULL(win, return NULL); - - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); GNode *retnode; if(win == NULL) @@ -216,7 +216,7 @@ glk_window_get_sibling(winid_t win) winid_t glk_window_get_root() { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); if(glk_data->root_window == NULL) return NULL; return (winid_t)glk_data->root_window->data; @@ -466,8 +466,8 @@ glk_window_open(winid_t split, glui32 method, glui32 size, glui32 wintype, if(method != (method & (winmethod_DirMask | winmethod_DivisionMask | winmethod_BorderMask))) WARNING("Unrecognized bits in method constant"); - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); - + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); + if(split == NULL && glk_data->root_window != NULL) { ILLEGAL("Tried to open a new root window, but there is already a root window"); @@ -828,8 +828,8 @@ glk_window_close(winid_t win, stream_result_t *result) { VALID_WINDOW(win, return); - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); - + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); + gdk_threads_enter(); /* Prevent redraw while we're trashing the window */ /* If any pair windows have this window or its children as a key window, @@ -941,8 +941,8 @@ glk_window_clear(winid_t win) VALID_WINDOW(win, return); g_return_if_fail(win->input_request_type != INPUT_REQUEST_LINE && win->input_request_type != INPUT_REQUEST_LINE_UNICODE); - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); - + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); + switch(win->type) { case wintype_Blank: @@ -1136,8 +1136,8 @@ glk_window_get_size(winid_t win, glui32 *widthptr, glui32 *heightptr) VALID_WINDOW(win, return); GtkAllocation allocation; - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); - + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); + switch(win->type) { case wintype_Blank: @@ -1284,8 +1284,8 @@ glk_window_set_arrangement(winid_t win, glui32 method, glui32 size, winid_t keyw g_return_if_fail(method == (method & (winmethod_DirMask | winmethod_DivisionMask))); g_return_if_fail(!(((method & winmethod_DivisionMask) == winmethod_Proportional) && size > 100)); - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); - + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); + win->split_method = method; win->constraint_size = size; if(keywin) @@ -1362,8 +1362,8 @@ glk_window_move_cursor(winid_t win, glui32 xpos, glui32 ypos) flush_window_buffer(win); - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); - + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); + /* Wait until the window's size is current */ g_mutex_lock(&glk_data->arrange_lock); if(glk_data->needs_rearrange)