[uim-commit] r266 - trunk/uim

yamaken@freedesktop.org yamaken@freedesktop.org
Wed Jan 12 08:14:26 PST 2005


Author: yamaken
Date: 2005-01-12 08:14:03 -0800 (Wed, 12 Jan 2005)
New Revision: 266

Modified:
   trunk/uim/canna.c
   trunk/uim/plugin.c
   trunk/uim/siod.h
   trunk/uim/slib.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 suppresses pedantic warnings. No logical changes have
  been applied actually

* uim/uim-scm.h
  - (uim_func_ptr): New type
  - (uim_scm_c_func_ptr, uim_scm_make_func_ptr): New function
* uim/uim-scm.c
  - (uim_scm_c_func_ptr, uim_scm_make_func_ptr): New function
  - Modify the word expression of header comment to suppress warning
* uim/siod.h
  - Add a coumment about static declarations in this file
  - (struct obj): Add new member c_func_pointer
  - (tc_c_func_pointer, FPOINTERP, NFPOINTERP): New macro
  - (C_FUNC): New type
  - (get_c_func_pointer, funcptrcons): New static function
* uim/slib.c
  - (get_c_func_pointer, funcptrcons, func_pointer_prin1): New static
    function
  - (init_storage): Add initialization of print hook for tc_c_func_pointer

* uim/uim-compat-scm.c
  - (uim_scm_c_list_free): Formal rewriting to suppress warning

* uim/uim-custom.c
  - (extract_choice_list): Formal rewriting to suppress warning
  - (uim_custom_cb_update_cb_gate): Replace uim_scm_c_ptr() with
    uim_scm_c_func_ptr() to suppress warning
  - (uim_custom_cb_add): Replace uim_scm_make_ptr() with
    uim_scm_make_func_ptr() to suppress warning

* uim/plugin.c
  - (plugin_load):
    * Cosmetic change
    * Replace uim_scm_make_ptr() with uim_scm_make_func_ptr() to
      suppress warning
  - (plugin_unload): Replace uim_scm_c_ptr() with uim_scm_c_func_ptr()
    to suppress warning

* uim/canna.c
  - (UIM_CANNA_DEBUG): New macro. Commented out by default
  - (context_array_len): Comment out the unused variable to suppress
    warning
  - (get_canna_context): Enclose printf debug messages into #ifdef
    UIM_CANNA_DEBUG
  - (_update_segment, get_nth_candidate):
    * Ditto
    * Cast buf arg for RkGetKanji() to suppress warning
  - (commit_segment): Comment out unused variables to suppress warnings
  - (uim_plugin_instance_quit): Comment out unused dynamic loading
    related check to suppress warning


Modified: trunk/uim/canna.c
===================================================================
--- trunk/uim/canna.c	2005-01-12 10:38:11 UTC (rev 265)
+++ trunk/uim/canna.c	2005-01-12 16:14:03 UTC (rev 266)
@@ -45,6 +45,8 @@
 #include "uim-compat-scm.h"
 #include "plugin.h"
 
+/* #define UIM_CANNA_DEBUG */
+
 #define MAX_CONTEXT 256
 #define LIBCANNA_SO	"libcanna.so"
 
@@ -65,7 +67,9 @@
 
 static struct canna_context *context_array = NULL;
 
+#if 0
 static int context_array_len;
+#endif
 static int rk_initialized = -1;
 static char *cannaserver = NULL;
 
@@ -81,9 +85,10 @@
     return NULL;
   for(i = 0; i < id; i++)
     context++;
-
-/*  printf("rk_context_id: %d\n", context->rk_context_id);
-    printf("segment_num: %d\n", context->segment_num); */
+#ifdef UIM_CANNA_DEBUG
+  printf("rk_context_id: %d\n", context->rk_context_id);
+  printf("segment_num: %d\n", context->segment_num);
+#endif
   return context;
 }
 
@@ -246,8 +251,10 @@
   for(i = 0; i <= tmp_segment_num; i++) {
     int len;
     RkGoTo(cc->rk_context_id, i);
-    len = RkGetKanji(cc->rk_context_id, buf, BUFSIZE);
-/*    printf("segment: %d, buf: %s\n", i, buf); */
+    len = RkGetKanji(cc->rk_context_id, (unsigned char *)buf, BUFSIZE);
+#ifdef UIM_CANNA_DEBUG
+    printf("segment: %d, buf: %s\n", i, buf);
+#endif
   }
 
   RkGoTo(cc->rk_context_id, tmp_segment_num);
@@ -308,9 +315,10 @@
     nth = 0;
 
   RkXfer(cc->rk_context_id, nth);
-  len = RkGetKanji(cc->rk_context_id, buf, BUFSIZE);
-
-/*  printf("nth: %d, kanji: %s\n", nth, buf); */
+  len = RkGetKanji(cc->rk_context_id, (unsigned char *)buf, BUFSIZE);
+#ifdef UIM_CANNA_DEBUG
+  printf("nth: %d, kanji: %s\n", nth, buf);
+#endif
   return uim_scm_make_str(buf);
 }
 
@@ -383,8 +391,10 @@
 commit_segment(uim_lisp id_, uim_lisp s_, uim_lisp nth_)
 {
   int id = uim_scm_c_int(id_);
+#if 0
   int s = uim_scm_c_int(s_);
   int nth = uim_scm_c_int(nth_);
+#endif
   struct canna_context *cc = get_canna_context(id);
 
   if(cc == NULL)
@@ -433,7 +443,7 @@
      cannaserver = NULL;
   }
 
-  if(RkFinalize && rk_initialized == 1) {
+  if(/* RkFinalize && */ rk_initialized == 1) {
      RkFinalize();
      rk_initialized = -1;
   }

Modified: trunk/uim/plugin.c
===================================================================
--- trunk/uim/plugin.c	2005-01-12 10:38:11 UTC (rev 265)
+++ trunk/uim/plugin.c	2005-01-12 16:14:03 UTC (rev 266)
@@ -63,7 +63,8 @@
 #define PLUGIN_SUFFIX ".so"
 
 static uim_lisp 
-plugin_load(uim_lisp _name) {
+plugin_load(uim_lisp _name)
+{
   char *plugin_name;
   char *plugin_lib_filename, *plugin_scm_filename;
 #ifdef UIM_SCM_NESTED_EVAL
@@ -157,8 +158,8 @@
     form = uim_scm_list5(uim_scm_make_symbol("plugin-list-append"),
 		         _name,
 		         uim_scm_make_ptr(library),
-			 uim_scm_make_ptr((void *)plugin_instance_init),
-			 uim_scm_make_ptr((void *)plugin_instance_quit));
+			 uim_scm_make_func_ptr(plugin_instance_init),
+			 uim_scm_make_func_ptr(plugin_instance_quit));
     uim_scm_eval(form);
   }
   free(plugin_scm_filename);
@@ -183,7 +184,7 @@
 
   UIM_EVAL_FSTRING1(NULL, "(plugin-list-query-instance-quit \"%s\")",
 		    uim_scm_refer_c_str(_name));
-  plugin_instance_quit = (void (*)(void))uim_scm_c_ptr(uim_scm_return_value());
+  plugin_instance_quit = uim_scm_c_func_ptr(uim_scm_return_value());
 
   (plugin_instance_quit)();
   dlclose(library);

Modified: trunk/uim/siod.h
===================================================================
--- trunk/uim/siod.h	2005-01-12 10:38:11 UTC (rev 265)
+++ trunk/uim/siod.h	2005-01-12 16:14:03 UTC (rev 266)
@@ -129,6 +129,11 @@
 	    void *data;
 	  }
 	c_pointer;
+	struct
+	  {
+	    void (*func)(void);
+	  }
+	c_func_pointer;
       }
     storage_as;
 #if DEBUG_SCM
@@ -185,27 +190,35 @@
 #define tc_subr_2n 21
 #define tc_user_min 50
 #define tc_c_pointer 50
+#define tc_c_func_pointer 51
 #define tc_user_max 100
 
 #define tc_table_dim 100
 
 typedef struct obj *LISP;
 typedef LISP (*SUBR_FUNC) (void);
+typedef void (*C_FUNC) (void);
 
 #define CONSP(x)   TYPEP(x,tc_cons)
 #define INTNUMP(x) TYPEP(x,tc_intnum)
 #define SYMBOLP(x) TYPEP(x,tc_symbol)
 #define STRINGP(x) TYPEP(x,tc_string)
 #define POINTERP(x) TYPEP(x,tc_c_pointer)
+#define FPOINTERP(x) TYPEP(x,tc_c_func_pointer)
 
 #define NCONSP(x)   NTYPEP(x,tc_cons)
 #define NINTNUMP(x) NTYPEP(x,tc_intnum)
 #define NSYMBOLP(x) NTYPEP(x,tc_symbol)
 #define NSTRINGP(x) NTYPEP(x,tc_string)
 #define NPOINTERP(x) NTYPEP(x,tc_c_pointer)
+#define NFPOINTERP(x) NTYPEP(x,tc_c_func_pointer)
 
 #define TKBUFFERN 5120
 
+/*
+  These static functions will be moved into slib.c siod.h is only a
+  temporary place.  -- YamaKen 2005-01-12
+*/
 static void siod_init (int argc, char **argv, int warnflag, FILE *);
 static void siod_quit (void);
 
@@ -218,6 +231,7 @@
 static int get_c_int (LISP x);
 static long nlength(LISP x);
 static void *get_c_pointer (LISP x);
+static C_FUNC get_c_func_pointer (LISP x);
 
 static LISP cons (LISP x, LISP y);
 static LISP car (LISP x);
@@ -232,6 +246,7 @@
 static LISP rintern (const char *name);
 static LISP closure (LISP env, LISP code);
 static LISP ptrcons (void *ptr);
+static LISP funcptrcons (C_FUNC ptr);
 
 static void init_subr (char *name, long type, SUBR_FUNC fcn);
 static void init_subr_0 (char *name, LISP (*fcn) (void));

Modified: trunk/uim/slib.c
===================================================================
--- trunk/uim/slib.c	2005-01-12 10:38:11 UTC (rev 265)
+++ trunk/uim/slib.c	2005-01-12 16:14:03 UTC (rev 266)
@@ -2197,8 +2197,44 @@
   gput_st (f, ">");
 }
 
+static C_FUNC
+get_c_func_pointer (LISP x)
+{
+  if NFPOINTERP
+    (x) my_err ("not a C function pointer", x);
+  return (x->storage_as.c_func_pointer.func);
+}
 
+static LISP
+funcptrcons (C_FUNC ptr)
+{
+  LISP x;
+  NEWCELL (x, tc_c_func_pointer);
+  (*x).storage_as.c_func_pointer.func = ptr;
+  return (x);
+}
+
 static void
+func_pointer_prin1 (LISP ptr, struct gen_printio *f)
+{
+  void *c_ptr;
+#if 0
+  c_ptr = (void *)ptr->storage_as.c_func_pointer.func;
+#else
+  /*
+    to suppress warning about function pointer to object pointer, we
+    use a dirty trick.  -- YamaKen 2005-01-12
+  */
+  c_ptr = ptr->storage_as.c_pointer.data;
+#endif
+  gput_st (f, "#<FUNC_PTR ");
+  sprintf (tkbuffer, " %p", c_ptr);
+  gput_st (f, tkbuffer);
+  gput_st (f, ">");
+}
+
+
+static void
 init_storage_1 (void)
 {
   LISP ptr;
@@ -2271,6 +2307,7 @@
   set_gc_hooks (tc_c_file, 0, file_gc_free);
   set_print_hooks (tc_c_file, file_prin1);
   set_print_hooks (tc_c_pointer, pointer_prin1);
+  set_print_hooks (tc_c_func_pointer, func_pointer_prin1);
 }
 
 static void

Modified: trunk/uim/uim-compat-scm.c
===================================================================
--- trunk/uim/uim-compat-scm.c	2005-01-12 10:38:11 UTC (rev 265)
+++ trunk/uim/uim-compat-scm.c	2005-01-12 16:14:03 UTC (rev 266)
@@ -297,7 +297,8 @@
   if (!list)
     return;
 
-  for (p = list; elem = *p; p++) {
+  for (p = list; *p; p++) {
+    elem = *p;
     free_func(elem);
   }
   free(list);

Modified: trunk/uim/uim-custom.c
===================================================================
--- trunk/uim/uim-custom.c	2005-01-12 10:38:11 UTC (rev 265)
+++ trunk/uim/uim-custom.c	2005-01-12 16:14:03 UTC (rev 266)
@@ -271,7 +271,8 @@
   if (!choice_sym_list)
     return NULL;
 
-  for (p = choice_sym_list; choice_sym = *p; p++) {
+  for (p = choice_sym_list; *p; p++) {
+    choice_sym = *p;
     custom_choice = uim_custom_choice_get(custom_sym, choice_sym);
     *p = (char *)custom_choice;  /* intentionally overwrite */
   }
@@ -1177,7 +1178,7 @@
   void *c_ptr;
   char *c_custom_sym;
 
-  update_cb = (uim_custom_cb_update_cb_t)uim_scm_c_ptr(cb);
+  update_cb = (uim_custom_cb_update_cb_t)uim_scm_c_func_ptr(cb);
   c_ptr = uim_scm_c_ptr(ptr);
   c_custom_sym = uim_scm_c_symbol(custom_sym);
   (*update_cb)(c_ptr, c_custom_sym);
@@ -1210,7 +1211,7 @@
 		       uim_scm_make_symbol(custom_sym),
 		       uim_scm_make_ptr(ptr),
 		       uim_scm_make_symbol("custom-update-cb-gate"),
-		       uim_scm_make_ptr((void *)update_cb));
+		       uim_scm_make_func_ptr((void (*)(void))update_cb));
   succeeded = uim_scm_c_bool(uim_scm_eval(form));
   uim_scm_gc_unprotect_stack(&stack_start);
 

Modified: trunk/uim/uim-scm.c
===================================================================
--- trunk/uim/uim-scm.c	2005-01-12 10:38:11 UTC (rev 265)
+++ trunk/uim/uim-scm.c	2005-01-12 16:14:03 UTC (rev 266)
@@ -47,10 +47,10 @@
   static and wrapped into uim-scm.c by direct inclusion rather than
   linked via public symbols. After elaboration of uim-scm API, the
   Scheme interpreter implementation can be switched to another one
-  such as uim-scm-tinyscheme.c or uim-scm-gauche.c. But uim/*.[hc] and
-  scm/*.scm are still depending on siod in several ways. At least full
-  test suite for *.scm files are required to migrate to another Scheme
-  implementation.  -- YamaKen 2004-12-21, 2005-01-10
+  such as uim-scm-tinyscheme.c or uim-scm-gauche.c. But *.[hc] under
+  uim/ and *.scm are still depending on siod in several ways. At least
+  full test suite for *.scm files are required to migrate to another
+  Scheme implementation.  -- YamaKen 2004-12-21, 2005-01-10
 */
 #include "slib.c"
 #ifdef UIM_COMPAT_SCM
@@ -167,6 +167,18 @@
   return (uim_lisp)ptrcons(ptr);
 }
 
+uim_func_ptr
+uim_scm_c_func_ptr(uim_lisp func_ptr)
+{
+  return get_c_func_pointer((LISP)func_ptr);
+}
+
+uim_lisp
+uim_scm_make_func_ptr(uim_func_ptr func_ptr)
+{
+  return (uim_lisp)funcptrcons(func_ptr);
+}
+
 void
 uim_scm_gc_protect(uim_lisp *location)
 {

Modified: trunk/uim/uim-scm.h
===================================================================
--- trunk/uim/uim-scm.h	2005-01-12 10:38:11 UTC (rev 265)
+++ trunk/uim/uim-scm.h	2005-01-12 16:14:03 UTC (rev 266)
@@ -64,6 +64,7 @@
   uim_opaque exists only for type check and has no actual definition.
 */
 typedef struct uim_opaque * uim_lisp;
+typedef void (*uim_func_ptr)(void);
 
 #define TRUEP(x) (uim_scm_eq(x, uim_scm_t()))
 #define FALSEP(x) (uim_scm_eq(x, uim_scm_f()))
@@ -138,6 +139,11 @@
 uim_lisp
 uim_scm_make_ptr(void *ptr);
 
+uim_func_ptr
+uim_scm_c_func_ptr(uim_lisp func_ptr);
+uim_lisp
+uim_scm_make_func_ptr(uim_func_ptr func_ptr);
+
 void
 uim_scm_init_subr_0(char *name, uim_lisp (*fcn)(void));
 void



More information about the Uim-commit mailing list