[linedit-devel] A patch for moving linedit to CFFI

Samium Gromoff _deepfire at feelingofgreen.ru
Sun Mar 18 00:33:33 UTC 2007


In what appeared as a surprisingly easy effort was born this:

diff -urN linedit_0.15.12/editor.lisp linedit_0.15.12_new/editor.lisp
--- linedit_0.15.12/editor.lisp	2004-04-25 19:08:43.000000000 +0400
+++ linedit_0.15.12_new/editor.lisp	2007-03-18 00:19:41.000000000 +0300
@@ -125,16 +125,12 @@
 	 (,string (get-string ,editor)))
      , at forms))
 
-(uffi:def-function ("linedit_interrupt" c-interrupt)
-    ()
-  :returning :void)
+(cffi:defcfun ("linedit_interrupt" c-interrupt) :void)
 
 (defun editor-interrupt (editor)
   (without-backend editor (c-interrupt)))
 
-(uffi:def-function ("linedit_stop" c-stop)
-    ()
-  :returning :void)
+(cffi:defcfun ("linedit_stop" c-stop) :void)
 
 (defun editor-stop (editor)
   (without-backend editor (c-stop)))
diff -urN linedit_0.15.12/linedit.asd linedit_0.15.12_new/linedit.asd
--- linedit_0.15.12/linedit.asd	2004-04-25 19:08:43.000000000 +0400
+++ linedit_0.15.12_new/linedit.asd	2007-03-18 00:21:10.000000000 +0300
@@ -33,19 +33,19 @@
 			"-fPIC"))
 
 ;;; Separate class so that we don't mess up other packages
-(defclass uffi-c-source-file (c-source-file) ())
+(defclass cffi-c-source-file (c-source-file) ())
 
-(defmethod output-files ((o compile-op) (c uffi-c-source-file))
+(defmethod output-files ((o compile-op) (c cffi-c-source-file))
   (list (make-pathname :name (component-name c)
 		       :type "so"
 		       :defaults (component-pathname c))))
 
-(defmethod perform ((o load-op) (c uffi-c-source-file))
-  (let ((loader (intern "LOAD-FOREIGN-LIBRARY" :uffi)))
+(defmethod perform ((o load-op) (c cffi-c-source-file))
+  (let ((loader (intern "LOAD-FOREIGN-LIBRARY" :cffi)))
     (dolist (f (asdf::input-files o c))
       (funcall loader f))))
 
-(defmethod perform ((o compile-op) (c uffi-c-source-file))
+(defmethod perform ((o compile-op) (c cffi-c-source-file))
   (unless (zerop (run-shell-command "~A ~A ~{~A ~}-o ~A"
 				    *gcc*
 				    (namestring (component-pathname c))
@@ -55,7 +55,7 @@
 
 (defsystem :linedit
     :version "0.15.12"
-    :depends-on (:uffi :terminfo :osicat)
+    :depends-on (:cffi :terminfo :osicat)
     :components
   (;; Common
    (:file "packages")
@@ -65,7 +65,7 @@
 
    ;; Backend
    (:file "backend" :depends-on ("utility-macros"))
-   (:uffi-c-source-file "terminal_glue")
+   (:cffi-c-source-file "terminal_glue")
    (:file "terminal-translations" :depends-on ("packages"))
    (:file "terminal" :depends-on ("terminal-translations" "backend" "terminal_glue"))
    (:file "smart-terminal" :depends-on ("terminal" "matcher"))
@@ -76,7 +76,7 @@
    (:file "line" :depends-on ("utility-macros"))
    (:file "buffer" :depends-on ("utility-macros"))
    (:file "command-keys" :depends-on ("packages"))
-   (:uffi-c-source-file "signals")
+   (:cffi-c-source-file "signals")
    (:file "editor" :depends-on ("backend" "rewindable" "signals"
 				"line" "buffer" "command-keys"))
    (:file "main" :depends-on ("editor"))
diff -urN linedit_0.15.12/terminal.lisp linedit_0.15.12_new/terminal.lisp
--- linedit_0.15.12/terminal.lisp	2004-04-25 19:08:43.000000000 +0400
+++ linedit_0.15.12_new/terminal.lisp	2007-03-18 00:20:11.000000000 +0300
@@ -25,32 +25,26 @@
   ((translations :initform *terminal-translations*)
    (dirty-p :initform t :accessor dirty-p)))
 
-(uffi:def-function ("linedit_terminal_columns" c-terminal-columns)
-    ((default :int))
-  :returning :int)
+(cffi:defcfun ("linedit_terminal_columns" c-terminal-columns) :int
+    (default :int))
 
 (defmethod backend-columns ((backend terminal))
   (c-terminal-columns *default-columns*))
 
-(uffi:def-function ("linedit_terminal_lines" c-terminal-lines)
-    ((default :int))
-  :returning :int)
+(cffi:defcfun ("linedit_terminal_lines" c-terminal-lines) :int
+    (default :int))
 
 (defmethod backend-lines ((backend terminal))
   (c-terminal-lines *default-lines*))
 
-(uffi:def-function ("linedit_terminal_init" c-terminal-init)
-    ()
-  :returning :int)
+(cffi:defcfun ("linedit_terminal_init" c-terminal-init) :int)
 
 (defmethod backend-init ((backend terminal))
   (invariant (not (backend-ready-p backend)))
   (invariant (zerop (c-terminal-init)))
   (setf (backend-ready-p backend) t))
 
-(uffi:def-function ("linedit_terminal_close" c-terminal-close)
-    ()
-  :returning :int)
+(cffi:defcfun ("linedit_terminal_close" c-terminal-close) :int)
 
 (defmethod backend-close ((backend terminal))
   (invariant (backend-ready-p backend))


Tested, albeit only lightly, with SBCL 1.0.3.35/CFFI 0.9.2

regards, Samium Gromoff



More information about the linedit-devel mailing list