[uim-commit] r221 - in trunk: scm uim

yamaken@freedesktop.org yamaken@freedesktop.org
Mon Jan 10 04:46:00 PST 2005


Author: yamaken
Date: 2005-01-10 04:45:57 -0800 (Mon, 10 Jan 2005)
New Revision: 221

Modified:
   trunk/scm/plugin.scm
   trunk/uim/plugin.c
Log:
* scm/plugin.scm
  - (uim-plugin-lib-load-path, uim-plugin-scm-load-path): Simiplify
    the definition
  - (record plugin-entry): New record to simplify the implementation
  - (plugin-list-append): Simplify with plugin-entry
  - (plugin-list-query-library, plugin-list-query-instance-init,
    plugin-list-query-instance-quit):
    * Simplify with plugin-entry
    * Add existence check for plugin entry corresponding to
      plugin-name

* uim/plugin.c
  - (uim_quit_plugin): Fix memory leaks


Modified: trunk/scm/plugin.scm
===================================================================
--- trunk/scm/plugin.scm	2005-01-10 12:09:48 UTC (rev 220)
+++ trunk/scm/plugin.scm	2005-01-10 12:45:57 UTC (rev 221)
@@ -32,41 +32,45 @@
 ;;; SUCH DAMAGE.
 ;;;;
 
+(require "util.scm")
+
 (define uim-plugin-lib-load-path
-  (list (string-append (getenv "HOME") "/.uim.d/plugin")
-	(string-append (sys-pkglibdir) "/plugin")))
+  (filter string?
+	  (append (list (string-append (getenv "HOME") "/.uim.d/plugin")
+			(string-append (sys-pkglibdir) "/plugin")
+			(getenv "LIBUIM_PLUGIN_DIR"))
+		  ;; XXX
+		  (if (getenv "LD_LIBRARY_PATH")
+		      (string-split (getenv "LD_LIBRARY_PATH") ":")
+		      ()))))
+
 (define uim-plugin-scm-load-path
-  (list (string-append (getenv "HOME") "/.uim.d/plugin")
-	(sys-pkgdatadir)))
+  (filter string?
+	  (list (string-append (getenv "HOME") "/.uim.d/plugin")
+		(sys-pkgdatadir)
+		(getenv "LIBUIM_SCM_FILES"))))
 
-(if (getenv "LIBUIM_PLUGIN_DIR")
-    (set! uim-plugin-lib-load-path
-	  (append (list (getenv "LIBUIM_PLUGIN_DIR"))
-		  uim-plugin-lib-load-path)))
-(if (getenv "LIBUIM_SCM_FILES")
-    (set! uim-plugin-scm-load-path
-	  (append (list (getenv "LIBUIM_SCM_FILES"))
-		  uim-plugin-scm-load-path)))
-
-;;; XXX
-(if (getenv "LD_LIBRARY_PATH")
-    (set! uim-plugin-lib-load-path
-	  (append uim-plugin-lib-load-path
-		  (string-split (getenv "LD_LIBRARY_PATH") ":"))))
-
 ;; 'print' prevents testing framework from normal run.
 ;;(print uim-plugin-lib-load-path)
 ;;(print uim-plugin-scm-load-path)
+
 (define plugin-alist ())
 (define plugin-func-alist ())
 
+(define-record 'plugin-entry
+  '((name      "")
+    ;;(desc      "")
+    ;;(author    "")
+    ;;(version   #f)
+    (library   #f)
+    (init-proc #f)
+    (quit-proc #f)))
+
 (define plugin-list-append
   (lambda (plugin-name library init quit)
-   (let
-     ((funcs (list init quit)))
+   (let ((entry (plugin-entry-new plugin-name library init quit)))
      (set! plugin-alist
-       (append plugin-alist
-	       (list (list plugin-name library funcs)))))))
+	   (append plugin-alist (list entry))))))
 
 (define plugin-list-query
   (lambda (plugin-name)
@@ -74,17 +78,18 @@
 
 (define plugin-list-query-library
   (lambda (plugin-name)
-    (let ((plugin-entry (plugin-list-query plugin-name)))
-      (nth 1 plugin-entry))))
+    (let ((entry (plugin-list-query plugin-name)))
+      (and entry
+	   (plugin-entry-library entry)))))
 
 (define plugin-list-query-instance-init
   (lambda (plugin-name)
-    (let* ((plugin-entry (plugin-list-query plugin-name))
-	   (plugin-funcs (nth 2 plugin-entry)))
-      (car plugin-funcs))))
+    (let ((entry (plugin-list-query plugin-name)))
+      (and entry
+	   (plugin-entry-init-proc entry)))))
 
 (define plugin-list-query-instance-quit
   (lambda (plugin-name)
-    (let* ((plugin-entry (plugin-list-query plugin-name))
-	   (plugin-funcs (nth 2 plugin-entry)))
-      (nth 1 plugin-funcs))))
+    (let ((entry (plugin-list-query plugin-name)))
+      (and entry
+	   (plugin-entry-quit-proc entry)))))

Modified: trunk/uim/plugin.c
===================================================================
--- trunk/uim/plugin.c	2005-01-10 12:09:48 UTC (rev 220)
+++ trunk/uim/plugin.c	2005-01-10 12:45:57 UTC (rev 221)
@@ -203,10 +203,12 @@
 
     name = uim_scm_car(list_car);
 
-    UIM_EVAL_FSTRING1(NULL, "(plugin-list-query-library \"%s\")", uim_scm_c_str(name));
+    UIM_EVAL_FSTRING1(NULL, "(plugin-list-query-library \"%s\")",
+		      uim_scm_refer_c_str(name));
     library = uim_scm_c_ptr(uim_scm_return_value());
 
-    UIM_EVAL_FSTRING1(NULL, "(plugin-list-query-instance-quit \"%s\")", uim_scm_c_str(name));
+    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)();



More information about the Uim-commit mailing list