[uim-commit] r1518 - trunk/uim
yamaken at freedesktop.org
yamaken at freedesktop.org
Sun Sep 18 07:18:20 PDT 2005
Author: yamaken
Date: 2005-09-18 07:18:18 -0700 (Sun, 18 Sep 2005)
New Revision: 1518
Modified:
trunk/uim/editline.c
trunk/uim/plugin.c
trunk/uim/uim-compat-scm.c
trunk/uim/uim-custom.c
trunk/uim/uim-scm.c
trunk/uim/uim-scm.h
Log:
* This commit enables UIM_SCM_GCC4_READY_GC by default. Please let me
know if something has been unstabilized. If no problems are
reported, I'll port this into r5rs and stable branch
* uim/uim-scm.h
- (UIM_SCM_GCC4_READY_GC): Defaults to 1
* uim/uim-scm.c
- (uim_scm_c_int, uim_scm_refer_c_str, uim_scm_eval, siod_init_subr,
uim_scm_eval_c_string): Add UIM_SCM_GCC4_READY_GC support
- (uim_scm_c_int_internal, uim_scm_refer_c_str_internal,
uim_scm_eval_internal, siod_init_subr_internal,
uim_scm_eval_c_string_internal): New static function
* uim/uim-compat-scm.c
- (uim_scm_symbol_value_int, uim_scm_symbol_value_str): Add
UIM_SCM_GCC4_READY_GC support
- (uim_scm_symbol_value_int_internal,
uim_scm_symbol_value_str_internal): New static function
* uim/uim-custom.c
- (literalize_string, custom_cb_add): Add UIM_SCM_GCC4_READY_GC support
- (literalize_string_internal, custom_cb_add_internal): New static
function
* uim/plugin.c
- (plugin_unload, uim_quit_plugin): Add UIM_SCM_GCC4_READY_GC support
- (plugin_unload_internal, uim_quit_plugin_internal): New static
function
* uim/editline.c
- (uim_editline_readline): Add UIM_SCM_GCC4_READY_GC support
- (uim_editline_readline_internal): New static function
Modified: trunk/uim/editline.c
===================================================================
--- trunk/uim/editline.c 2005-09-18 13:14:33 UTC (rev 1517)
+++ trunk/uim/editline.c 2005-09-18 14:18:18 UTC (rev 1518)
@@ -58,6 +58,12 @@
static uim_lisp uim_editline_readline(void);
static char *prompt(EditLine *e);
+#if UIM_SCM_GCC4_READY_GC
+static UIM_SCM_GC_PROTECTED_FUNC_DECL(uim_lisp,
+ uim_editline_readline_internal,
+ (void));
+#endif
+
void
editline_init(void)
{
@@ -82,12 +88,29 @@
static uim_lisp
uim_editline_readline(void)
+#if UIM_SCM_GCC4_READY_GC
{
+ uim_lisp ret;
+
+ UIM_SCM_GC_CALL_PROTECTED_FUNC(ret, uim_editline_readline_internal, ());
+
+ return ret;
+}
+
+static uim_lisp
+uim_editline_readline_internal(void)
+#endif
+{
const char *line;
int count = 0;
- uim_lisp ret, stack_start;
+#if !UIM_SCM_GCC4_READY_GC
+ uim_lisp stack_start;
+#endif
+ uim_lisp ret;
+#if !UIM_SCM_GCC4_READY_GC
uim_scm_gc_protect_stack(&stack_start);
+#endif
line = el_gets(el, &count);
@@ -98,7 +121,9 @@
ret = uim_scm_make_str("");
}
+#if !UIM_SCM_GCC4_READY_GC
uim_scm_gc_unprotect_stack(&stack_start);
+#endif
return ret;
}
Modified: trunk/uim/plugin.c
===================================================================
--- trunk/uim/plugin.c 2005-09-18 13:14:33 UTC (rev 1517)
+++ trunk/uim/plugin.c 2005-09-18 14:18:18 UTC (rev 1518)
@@ -67,6 +67,13 @@
#define DPRINTFN(n,x)
#endif
+#if UIM_SCM_GCC4_READY_GC
+static UIM_SCM_GC_PROTECTED_FUNC_DECL(uim_lisp, plugin_unload_internal,
+ (uim_lisp _name));
+static UIM_SCM_GC_PROTECTED_FUNC_DECL(void, uim_quit_plugin_internal, (void));
+#endif
+
+
static uim_lisp
plugin_load(uim_lisp _name)
{
@@ -188,12 +195,28 @@
static uim_lisp
plugin_unload(uim_lisp _name)
+#if UIM_SCM_GCC4_READY_GC
{
+ uim_lisp ret;
+
+ UIM_SCM_GC_CALL_PROTECTED_FUNC(ret, plugin_unload_internal, (_name));
+
+ return ret;
+}
+
+static uim_lisp
+plugin_unload_internal(uim_lisp _name)
+#endif
+{
+#if !UIM_SCM_GCC4_READY_GC
uim_lisp stack_start;
+#endif
void *library;
void (*plugin_instance_quit)(void);
+#if !UIM_SCM_GCC4_READY_GC
uim_scm_gc_protect_stack(&stack_start);
+#endif
UIM_EVAL_FSTRING1(NULL, "(plugin-list-query-library \"%s\")",
uim_scm_refer_c_str(_name));
@@ -212,7 +235,11 @@
UIM_EVAL_FSTRING1(NULL, "(plugin-list-delete \"%s\")",
uim_scm_refer_c_str(_name));
+
+#if !UIM_SCM_GCC4_READY_GC
uim_scm_gc_unprotect_stack(&stack_start);
+#endif
+
return uim_scm_t();
}
@@ -229,11 +256,24 @@
/* Called from uim_quit */
void
uim_quit_plugin(void)
+#if UIM_SCM_GCC4_READY_GC
{
+ UIM_SCM_GC_CALL_PROTECTED_VOID_FUNC(uim_quit_plugin_internal, ());
+}
+
+static void
+uim_quit_plugin_internal(void)
+#endif
+{
+#if !UIM_SCM_GCC4_READY_GC
uim_lisp stack_start;
+#endif
uim_lisp alist, rest, entry, name;
+#if !UIM_SCM_GCC4_READY_GC
uim_scm_gc_protect_stack(&stack_start);
+#endif
+
alist = uim_scm_eval_c_string("plugin-alist");
for (rest = alist; !uim_scm_nullp(rest); rest = uim_scm_cdr(rest)) {
entry = uim_scm_car(rest);
@@ -241,5 +281,8 @@
plugin_unload(name);
}
+
+#if !UIM_SCM_GCC4_READY_GC
uim_scm_gc_unprotect_stack(&stack_start);
+#endif
}
Modified: trunk/uim/uim-compat-scm.c
===================================================================
--- trunk/uim/uim-compat-scm.c 2005-09-18 13:14:33 UTC (rev 1517)
+++ trunk/uim/uim-compat-scm.c 2005-09-18 14:18:18 UTC (rev 1518)
@@ -41,6 +41,15 @@
#include "context.h"
+#if UIM_SCM_GCC4_READY_GC
+static UIM_SCM_GC_PROTECTED_FUNC_DECL(int,
+ uim_scm_symbol_value_int_internal,
+ (const char *symbol_str));
+static UIM_SCM_GC_PROTECTED_FUNC_DECL(char *,
+ uim_scm_symbol_value_str_internal,
+ (const char *symbol_str));
+#endif
+
static uim_lisp return_val;
static uim_lisp quote_sym;
@@ -67,12 +76,29 @@
int
uim_scm_symbol_value_int(const char *symbol_str)
+#if UIM_SCM_GCC4_READY_GC
{
+ int ret;
+
+ UIM_SCM_GC_CALL_PROTECTED_FUNC(ret, uim_scm_symbol_value_int_internal,
+ (symbol_str));
+
+ return ret;
+}
+
+static int
+uim_scm_symbol_value_int_internal(const char *symbol_str)
+#endif
+{
+#if !UIM_SCM_GCC4_READY_GC
uim_lisp stack_start;
+#endif
uim_lisp val_;
int val;
+#if !UIM_SCM_GCC4_READY_GC
uim_scm_gc_protect_stack(&stack_start);
+#endif
val_ = uim_scm_symbol_value(symbol_str);
if NFALSEP(val_) {
@@ -80,7 +106,9 @@
} else {
val = 0;
}
+#if !UIM_SCM_GCC4_READY_GC
uim_scm_gc_unprotect_stack(&stack_start);
+#endif
return val;
}
@@ -93,12 +121,29 @@
char *
uim_scm_symbol_value_str(const char *symbol_str)
+#if UIM_SCM_GCC4_READY_GC
{
+ char *ret;
+
+ UIM_SCM_GC_CALL_PROTECTED_FUNC(ret, uim_scm_symbol_value_str_internal,
+ (symbol_str));
+
+ return ret;
+}
+
+static char *
+uim_scm_symbol_value_str_internal(const char *symbol_str)
+#endif
+{
+#if !UIM_SCM_GCC4_READY_GC
uim_lisp stack_start;
+#endif
uim_lisp val_ = uim_scm_f();
char *val;
+#if !UIM_SCM_GCC4_READY_GC
uim_scm_gc_protect_stack(&stack_start);
+#endif
val_ = uim_scm_symbol_value(symbol_str);
if NFALSEP(val_) {
@@ -106,7 +151,9 @@
} else {
val = NULL;
}
+#if !UIM_SCM_GCC4_READY_GC
uim_scm_gc_unprotect_stack(&stack_start);
+#endif
return val;
}
Modified: trunk/uim/uim-custom.c
===================================================================
--- trunk/uim/uim-custom.c 2005-09-18 13:14:33 UTC (rev 1517)
+++ trunk/uim/uim-custom.c 2005-09-18 14:18:18 UTC (rev 1518)
@@ -132,6 +132,15 @@
static uim_bool uim_custom_load_group(const char *group);
static uim_bool uim_custom_save_group(const char *group);
+#if UIM_SCM_GCC4_READY_GC
+static UIM_SCM_GC_PROTECTED_FUNC_DECL(char *, literalize_string_internal,
+ (const char *str));
+static UIM_SCM_GC_PROTECTED_FUNC_DECL(uim_bool, custom_cb_add_internal,
+ (const char *hook, const char *validator,
+ const char *custom_sym, void *ptr,
+ const char *gate_func, void (*cb)(void)));
+#endif
+
static const char str_list_arg[] = "uim-custom-c-str-list-arg";
static const char custom_subdir[] = "customs";
static const char custom_msg_tmpl[] = "prop_update_custom\n%s\n%s\n";
@@ -141,16 +150,36 @@
static char *
literalize_string(const char *str)
+#if UIM_SCM_GCC4_READY_GC
{
+ char *ret;
+
+ UIM_SCM_GC_CALL_PROTECTED_FUNC(ret, literalize_string_internal, (str));
+
+ return ret;
+}
+
+static char *
+literalize_string_internal(const char *str)
+#endif
+{
+#if !UIM_SCM_GCC4_READY_GC
uim_lisp stack_start;
+#endif
uim_lisp form;
char *escaped;
+#if !UIM_SCM_GCC4_READY_GC
uim_scm_gc_protect_stack(&stack_start);
+#endif
+
form = uim_scm_list2(uim_scm_make_symbol("string-escape"),
uim_scm_make_str(str));
escaped = uim_scm_c_str(uim_scm_eval(form));
+
+#if !UIM_SCM_GCC4_READY_GC
uim_scm_gc_unprotect_stack(&stack_start);
+#endif
return escaped;
}
@@ -1372,12 +1401,33 @@
custom_cb_add(const char *hook, const char *validator,
const char *custom_sym, void *ptr,
const char *gate_func, void (*cb)(void))
+#if UIM_SCM_GCC4_READY_GC
{
+ uim_bool ret;
+
+ UIM_SCM_GC_CALL_PROTECTED_FUNC(ret, custom_cb_add_internal,
+ (hook, validator, custom_sym, ptr, gate_func,
+ cb));
+
+ return ret;
+}
+
+static uim_bool
+custom_cb_add_internal(const char *hook, const char *validator,
+ const char *custom_sym, void *ptr,
+ const char *gate_func, void (*cb)(void))
+#endif
+{
uim_bool succeeded;
+#if !UIM_SCM_GCC4_READY_GC
uim_lisp stack_start;
+#endif
uim_lisp form;
+#if !UIM_SCM_GCC4_READY_GC
uim_scm_gc_protect_stack(&stack_start);
+#endif
+
form = uim_scm_list5(uim_scm_make_symbol(validator),
uim_scm_quote(uim_scm_make_symbol(custom_sym)),
uim_scm_make_ptr(ptr),
@@ -1386,7 +1436,10 @@
form = uim_scm_cons(uim_scm_quote(uim_scm_make_symbol(hook)), form);
form = uim_scm_cons(uim_scm_make_symbol("custom-register-cb"), form);
succeeded = uim_scm_c_bool(uim_scm_eval(form));
+
+#if !UIM_SCM_GCC4_READY_GC
uim_scm_gc_unprotect_stack(&stack_start);
+#endif
return succeeded;
}
Modified: trunk/uim/uim-scm.c
===================================================================
--- trunk/uim/uim-scm.c 2005-09-18 13:14:33 UTC (rev 1517)
+++ trunk/uim/uim-scm.c 2005-09-18 14:18:18 UTC (rev 1518)
@@ -59,6 +59,25 @@
static void siod_init_subr(const char *name, long type, SUBR_FUNC fcn);
+#if UIM_SCM_GCC4_READY_GC
+static UIM_SCM_GC_PROTECTED_FUNC_DECL(int,
+ uim_scm_c_int_internal,
+ (uim_lisp integer));
+static UIM_SCM_GC_PROTECTED_FUNC_DECL(const char *,
+ uim_scm_refer_c_str_internal,
+ (uim_lisp str));
+static UIM_SCM_GC_PROTECTED_FUNC_DECL(uim_lisp,
+ uim_scm_eval_internal,
+ (uim_lisp obj));
+static UIM_SCM_GC_PROTECTED_FUNC_DECL(void,
+ siod_init_subr_internal,
+ (const char *name, long type,
+ SUBR_FUNC fcn));
+static UIM_SCM_GC_PROTECTED_FUNC_DECL(uim_lisp,
+ uim_scm_eval_c_string_internal,
+ (const char *str));
+#endif
+
static uim_lisp true_sym;
static uim_lisp false_sym;
static uim_lisp protected_arg0;
@@ -93,14 +112,33 @@
int
uim_scm_c_int(uim_lisp integer)
+#if UIM_SCM_GCC4_READY_GC
{
+ int ret;
+
+ UIM_SCM_GC_CALL_PROTECTED_FUNC(ret, uim_scm_c_int_internal, (integer));
+
+ return ret;
+}
+
+static int
+uim_scm_c_int_internal(uim_lisp integer)
+#endif
+{
int c_int;
+#if !UIM_SCM_GCC4_READY_GC
uim_lisp stack_start;
- uim_scm_gc_protect_stack(&stack_start); /* required for my_err() */
+ /* stack protection is required for my_err() */
+ uim_scm_gc_protect_stack(&stack_start);
+#endif
+
protected_arg0 = integer;
c_int = get_c_int((LISP)integer);
+
+#if !UIM_SCM_GCC4_READY_GC
uim_scm_gc_unprotect_stack(&stack_start);
+#endif
return c_int;
}
@@ -123,14 +161,33 @@
const char *
uim_scm_refer_c_str(uim_lisp str)
+#if UIM_SCM_GCC4_READY_GC
{
+ const char *ret;
+
+ UIM_SCM_GC_CALL_PROTECTED_FUNC(ret, uim_scm_refer_c_str_internal, (str));
+
+ return ret;
+}
+
+static const char *
+uim_scm_refer_c_str_internal(uim_lisp str)
+#endif
+{
char *c_str;
+#if !UIM_SCM_GCC4_READY_GC
uim_lisp stack_start;
- uim_scm_gc_protect_stack(&stack_start); /* required for my_err() */
+ /* stack protection is required for my_err() */
+ uim_scm_gc_protect_stack(&stack_start);
+#endif
+
protected_arg0 = str;
c_str = get_c_string((LISP)str);
+
+#if !UIM_SCM_GCC4_READY_GC
uim_scm_gc_unprotect_stack(&stack_start);
+#endif
return c_str;
}
@@ -293,20 +350,50 @@
uim_lisp
uim_scm_eval(uim_lisp obj)
+#if UIM_SCM_GCC4_READY_GC
{
+ uim_lisp ret;
+
+ UIM_SCM_GC_CALL_PROTECTED_FUNC(ret, uim_scm_eval_internal, (obj));
+
+ return ret;
+}
+
+static uim_lisp
+uim_scm_eval_internal(uim_lisp obj)
+#endif
+{
uim_lisp ret; /* intentionally outside of next stack_start */
+#if !UIM_SCM_GCC4_READY_GC
uim_lisp stack_start;
uim_scm_gc_protect_stack(&stack_start);
+#endif
+
ret = (uim_lisp)leval((LISP)obj, NIL);
+
+#if !UIM_SCM_GCC4_READY_GC
uim_scm_gc_unprotect_stack(&stack_start);
+#endif
return ret;
}
uim_lisp
uim_scm_eval_c_string(const char *str)
+#if UIM_SCM_GCC4_READY_GC
{
+ uim_lisp ret;
+
+ UIM_SCM_GC_CALL_PROTECTED_FUNC(ret, uim_scm_eval_c_string_internal, (str));
+
+ return ret;
+}
+
+static uim_lisp
+uim_scm_eval_c_string_internal(const char *str)
+#endif
+{
repl_c_string((char *)str, 0, 0);
return uim_scm_return_value();
}
@@ -391,13 +478,26 @@
static void
siod_init_subr(const char *name, long type, SUBR_FUNC fcn)
+#if UIM_SCM_GCC4_READY_GC
{
+ UIM_SCM_GC_CALL_PROTECTED_VOID_FUNC(siod_init_subr_internal,
+ (name, type, fcn));
+}
+
+static void
+siod_init_subr_internal(const char *name, long type, SUBR_FUNC fcn)
+{
+ init_subr(name, type, fcn);
+}
+#else
+{
uim_lisp stack_start;
uim_scm_gc_protect_stack(&stack_start);
init_subr(name, type, fcn);
uim_scm_gc_unprotect_stack(&stack_start);
}
+#endif
void
uim_scm_init_subr_0(const char *name, uim_lisp (*fcn)(void))
Modified: trunk/uim/uim-scm.h
===================================================================
--- trunk/uim/uim-scm.h 2005-09-18 13:14:33 UTC (rev 1517)
+++ trunk/uim/uim-scm.h 2005-09-18 14:18:18 UTC (rev 1518)
@@ -59,7 +59,7 @@
#endif
-#define UIM_SCM_GCC4_READY_GC 0
+#define UIM_SCM_GCC4_READY_GC 1
/*
uim companion tools should treat lisp object as opaque. struct
More information about the uim-commit
mailing list