From _deepfire at feelingofgreen.ru Sun Mar 18 00:33:33 2007 From: _deepfire at feelingofgreen.ru (Samium Gromoff) Date: Sun, 18 Mar 2007 03:33:33 +0300 Subject: [linedit-devel] A patch for moving linedit to CFFI In-Reply-To: References: Message-ID: <87y7lv75lu.wl@betelheise.deep.net> 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 From nikodemus at random-state.net Sun Mar 18 01:27:30 2007 From: nikodemus at random-state.net (Nikodemus Siivola) Date: Sat, 17 Mar 2007 21:27:30 -0400 Subject: [linedit-devel] Patch for div by zero error In-Reply-To: <3990b5930610251745p6ceaaf9by5e6e2a3edb4ac5c6@mail.gmail.com> References: <3990b5930610251745p6ceaaf9by5e6e2a3edb4ac5c6@mail.gmail.com> Message-ID: <45FC9582.4090208@random-state.net> Lui Fungsin wrote: > For some reason, if I drive the terminal with a expect script, > backend-columns will return 0 and cause a div by zero error. I finally got around to committing this. Sorry for the huge delay. Cheers, -- Nikodemus From nikodemus at random-state.net Sun Mar 18 01:39:47 2007 From: nikodemus at random-state.net (Nikodemus Siivola) Date: Sat, 17 Mar 2007 21:39:47 -0400 Subject: [linedit-devel] Re: Exception when using linedit:linedit on lispworks 5.0 (linux 2.6) In-Reply-To: <3990b5930610192250g5ea74983g1bac0d5204885155@mail.gmail.com> References: <3990b5930608181724wc8ee1c6rc8d23d83788bd7e2@mail.gmail.com> <3990b5930608181733v4289f229tcc8dd510ebd46e97@mail.gmail.com> <3990b5930610192250g5ea74983g1bac0d5204885155@mail.gmail.com> Message-ID: <45FC9863.7070808@random-state.net> Lui Fungsin wrote: > So I spent some time reading the lispworks manual, the uffi manual and > the linedit source to debug a little. > > It turns out that the :module keyword arg is required for lw and that > it needs to be unique for different "so" object files. Finally merged. Sorry for the huge delay. Cheers, -- Nikodemus From nikodemus at random-state.net Sun Mar 18 01:48:30 2007 From: nikodemus at random-state.net (Nikodemus Siivola) Date: Sat, 17 Mar 2007 21:48:30 -0400 Subject: [linedit-devel] Re: Exception when using linedit:linedit on lispworks 5.0 (linux 2.6) In-Reply-To: <3990b5930610200018k40f3c3a3rd6be65010b8b8d45@mail.gmail.com> References: <3990b5930608181724wc8ee1c6rc8d23d83788bd7e2@mail.gmail.com> <3990b5930610200018k40f3c3a3rd6be65010b8b8d45@mail.gmail.com> Message-ID: <45FC9A6E.1050206@random-state.net> Lui Fungsin wrote: > It turns out that terminfo.lisp needs a lispworks patch to read the > env var TERM. > > Also, after some trial and error I located that the problem with smart > terminal w/ lispworks is in the smart-terminal display method. Finally committed. Thanks for the patch, and apologies about the delay! Cheers, -- Nikodemus