[uim-commit] r1410 - in branches/r5rs: sigscheme uim
yamaken at freedesktop.org
yamaken at freedesktop.org
Sun Sep 4 11:06:00 PDT 2005
Author: yamaken
Date: 2005-09-04 11:05:58 -0700 (Sun, 04 Sep 2005)
New Revision: 1410
Modified:
branches/r5rs/sigscheme/datas.c
branches/r5rs/sigscheme/sigscheme.h
branches/r5rs/uim/uim-scm.c
Log:
* sigscheme/sigscheme.h
- (Scm_GetInt, Scm_GetString, Scm_GetCPointer, Scm_GetCFuncPointer):
Removed because libsscm should not provide such getter function
combined with fixed-style error handling. Clients of libsscm
should explicitly check type of the object and do error handlings
appropriate for each application
* sigscheme/datas.c
- (Scm_GetInt, Scm_GetString, Scm_GetCPointer, Scm_GetCFuncPointer):
Ditto
* uim/uim-scm.c
- (uim_scm_error): New function
- (uim_scm_c_int, uim_scm_c_ptr, uim_scm_c_func_ptr): Follow the
removal of the function and optimized
- (uim_scm_refer_c_str):
* Ditto
* Fix the memory leak
Modified: branches/r5rs/sigscheme/datas.c
===================================================================
--- branches/r5rs/sigscheme/datas.c 2005-09-04 17:15:13 UTC (rev 1409)
+++ branches/r5rs/sigscheme/datas.c 2005-09-04 18:05:58 UTC (rev 1410)
@@ -862,49 +862,6 @@
return sym;
}
-int Scm_GetInt(ScmObj num)
-{
- if (FALSEP(ScmOp_numberp(num)))
- SigScm_ErrorObj("Scm_GetInt : number required but got ", num);
-
- return SCM_INT_VALUE(num);
-}
-
-char* Scm_GetString(ScmObj str)
-{
- char *ret = NULL;
- switch (SCM_TYPE(str)) {
- case ScmString:
- ret = SCM_STRING_STR(str);
- break;
- case ScmSymbol:
- ret = SCM_SYMBOL_NAME(str);
- break;
- default:
- SigScm_Error("Scm_GetString : cannot get string of not string nor symbol\n");
- }
-
- return ret;
-}
-
-#if SCM_USE_NONSTD_FEATURES
-void *Scm_GetCPointer(ScmObj c_ptr)
-{
- if (!C_POINTERP(c_ptr))
- SigScm_ErrorObj("Scm_GetCPointer : c_ptr required but got ", c_ptr);
-
- return SCM_C_POINTER_VALUE(c_ptr);
-}
-
-ScmCFunc Scm_GetCFuncPointer(ScmObj c_funcptr)
-{
- if (!C_FUNCPOINTERP(c_funcptr))
- SigScm_ErrorObj("Scm_GetCFuncPointer : c_funcptr required but got ", c_funcptr);
-
- return SCM_C_FUNCPOINTER_VALUE(c_funcptr);
-}
-#endif /* SCM_USE_NONSTD_FEATURES */
-
ScmObj Scm_eval_c_string(const char *exp)
{
ScmObj stack_start;
Modified: branches/r5rs/sigscheme/sigscheme.h
===================================================================
--- branches/r5rs/sigscheme/sigscheme.h 2005-09-04 17:15:13 UTC (rev 1409)
+++ branches/r5rs/sigscheme/sigscheme.h 2005-09-04 18:05:58 UTC (rev 1410)
@@ -126,12 +126,6 @@
ScmObj Scm_NewCFuncPointer(ScmCFunc func);
#endif
ScmObj Scm_Intern(const char *name);
-int Scm_GetInt(ScmObj num);
-char* Scm_GetString(ScmObj str);
-#if SCM_USE_NONSTD_FEATURES
-void* Scm_GetCPointer(ScmObj c_ptr);
-ScmCFunc Scm_GetCFuncPointer(ScmObj c_funcptr);
-#endif
ScmObj Scm_eval_c_string(const char *exp);
#if SCM_COMPAT_SIOD
ScmObj Scm_return_value(void);
Modified: branches/r5rs/uim/uim-scm.c
===================================================================
--- branches/r5rs/uim/uim-scm.c 2005-09-04 17:15:13 UTC (rev 1409)
+++ branches/r5rs/uim/uim-scm.c 2005-09-04 18:05:58 UTC (rev 1410)
@@ -50,11 +50,24 @@
static int uim_siod_fatal;
static FILE *uim_output = NULL;
+static void uim_scm_error(const char *msg, uim_lisp errobj);
+
#ifdef UIM_COMPAT_SCM
#include "uim-compat-scm.c"
#endif
+static void
+uim_scm_error(const char *msg, uim_lisp errobj)
+{
+ uim_lisp stack_start;
+
+ uim_scm_gc_protect_stack(&stack_start);
+ /* FIXME: don't terminate the process */
+ SigScm_ErrorObj(msg, (ScmObj)errobj);
+ uim_scm_gc_unprotect_stack(&stack_start);
+}
+
FILE *
uim_scm_get_output(void)
{
@@ -82,16 +95,13 @@
int
uim_scm_c_int(uim_lisp integer)
{
- int c_int;
- uim_lisp stack_start;
-
- uim_scm_gc_protect_stack(&stack_start); /* required for my_err() */
-
- protected_arg0 = integer;
- c_int = Scm_GetInt((ScmObj)integer);
- uim_scm_gc_unprotect_stack(&stack_start);
-
- return c_int;
+ if (SCM_INTP((ScmObj)integer)) {
+ return SCM_INT_VALUE((ScmObj)integer);
+ } else {
+ uim_scm_error("uim_scm_c_int: number required but got ",
+ (uim_lisp)integer);
+ return -1;
+ }
}
uim_lisp
@@ -113,16 +123,15 @@
const char *
uim_scm_refer_c_str(uim_lisp str)
{
- char *c_str;
- uim_lisp stack_start;
-
- uim_scm_gc_protect_stack(&stack_start); /* required for my_err() */
- protected_arg0 = str;
- /* FIXME: return value of this function must be freed somewhere... */
- c_str = Scm_GetString((ScmObj)str);
- uim_scm_gc_unprotect_stack(&stack_start);
-
- return c_str;
+ if (SCM_STRINGP((ScmObj)str)) {
+ return SCM_STRING_STR((ScmObj)str);
+ } else if (SCM_SYMBOLP((ScmObj)str)) {
+ return SCM_SYMBOL_NAME((ScmObj)str);
+ } else {
+ uim_scm_error("uim_scm_refer_c_str: string or symbol required but got ",
+ (uim_lisp)str);
+ return NULL;
+ }
}
uim_lisp
@@ -146,7 +155,12 @@
void *
uim_scm_c_ptr(uim_lisp ptr)
{
- return Scm_GetCPointer((ScmObj)ptr);
+ if (SCM_C_POINTERP((ScmObj)ptr)) {
+ return SCM_C_POINTER_VALUE((ScmObj)ptr);
+ } else {
+ uim_scm_error("uim_scm_c_ptr: C pointer required but got ", (uim_lisp)ptr);
+ return NULL;
+ }
}
uim_lisp
@@ -158,7 +172,13 @@
uim_func_ptr
uim_scm_c_func_ptr(uim_lisp func_ptr)
{
- return (uim_func_ptr)Scm_GetCFuncPointer((ScmObj)func_ptr);
+ if (SCM_C_FUNCPOINTERP((ScmObj)func_ptr)) {
+ return SCM_C_FUNCPOINTER_VALUE((ScmObj)func_ptr);
+ } else {
+ uim_scm_error("uim_scm_c_func_ptr: C function pointer required but got ",
+ (uim_lisp)func_ptr);
+ return NULL;
+ }
}
uim_lisp
@@ -215,7 +235,7 @@
if (!fn)
return UIM_FALSE;
- /* TODO: fixme! */
+ /* FIXME! */
SigScm_load(fn);
return UIM_TRUE;
More information about the uim-commit
mailing list