From ef9ed40239a32206e0b9c61684fce8f66806ae7c Mon Sep 17 00:00:00 2001 From: Wesley Kerfoot Date: Sat, 9 Nov 2019 22:41:35 -0500 Subject: [PATCH] Refactor scheme-related functions into separate file --- browser.c | 21 +-------------------- browser.h | 4 +++- scheme_functions.h | 29 +++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 21 deletions(-) create mode 100644 scheme_functions.h diff --git a/browser.c b/browser.c index 74e30fa..efbf9f7 100644 --- a/browser.c +++ b/browser.c @@ -5,6 +5,7 @@ #include #include "browser.h" +#include "scheme_functions.h" static void load_modules(void) { @@ -64,20 +65,6 @@ qu_push(enum BrowserEvent msg_type, return 1; } -static SCM -scm_qu_push(SCM scm_msg_type, - SCM scm_message, - SCM scm_qu) { - - enum BrowserEvent msg_type = scm_to_int(scm_msg_type); - char *data = scm_to_locale_string(scm_message); - GAsyncQueue *g_queue = scm_to_pointer(scm_qu); - - qu_push(msg_type, data, g_queue); - - return SCM_BOOL_T; -} - static int conf_val(char * const key) { /* Lookup a key value in a Scheme hash-table */ @@ -95,12 +82,6 @@ conf_val(char * const key) { } } -static SCM -scm_ref(const char *var_name) { - /* Lookup and de-reference a Scheme value */ - return scm_variable_ref(scm_c_lookup(var_name)); -} - static WebKitWebView* make_webview() { WebKitSettings *settings = webkit_settings_new(); diff --git a/browser.h b/browser.h index 070bf49..78a9408 100644 --- a/browser.h +++ b/browser.h @@ -19,6 +19,8 @@ struct BrowserMessage { static SCM scm_ref(const char *); static int read_config_val(char * const); -static SCM qu_push(enum BrowserEvent, char *, GAsyncQueue *); +static int qu_push(enum BrowserEvent, char *, GAsyncQueue *); +static SCM scm_qu_push(SCM, SCM, SCM); + diff --git a/scheme_functions.h b/scheme_functions.h new file mode 100644 index 0000000..d52a6e5 --- /dev/null +++ b/scheme_functions.h @@ -0,0 +1,29 @@ + +static SCM +scm_qu_pop(SCM scm_qu) { + GAsyncQueue *g_queue = scm_to_pointer(scm_qu); + struct BrowserMessage *msg = g_async_queue_timeout_pop(g_queue, 10); + +} + +static SCM +scm_qu_push(SCM scm_msg_type, + SCM scm_message, + SCM scm_qu) { + + enum BrowserEvent msg_type = scm_to_int(scm_msg_type); + char *data = scm_to_locale_string(scm_message); + GAsyncQueue *g_queue = scm_to_pointer(scm_qu); + + qu_push(msg_type, data, g_queue); + + return SCM_BOOL_T; +} + +static SCM +scm_ref(const char *var_name) { + /* Lookup and de-reference a Scheme value */ + return scm_variable_ref(scm_c_lookup(var_name)); +} + +