I have been playing a little with cells-gtk and have run into some
problems between SBCL and CFFI.
I was using CFFI 0.9.2 but this triggers a package lock violation with
SBCL 1.0.22 (on x86 linux) so I upgraded to the most recent CFFI version
(0.10.4), but then cells-gtk stopped working.
The error I get when trying to run a little simple demo is this:
The value of STRING is #(71 85 73 32 68 101 109 111),
which is not of type STRING.
ultimately coming from a call to GTK-FFI:GTK-WINDOW-SET-TITLE with a
string argument ("GUI Demo").
Presumably CFFI used to accept octet sequences as string arguments but
doesn't anymore.
Anyway, if I then disable the sbcl code specific code in 'lisp-to-utf-8'
and 'utf-8-to-lisp' in "gtk-ffi/gtk-ffi-impl.lisp", then our little demo
works again.
I have attached the stack trace and a diff for the aforementioned
disabling to illustrate what I have done.
I am however unsure as to what the proper solution is. I suspect that
code was invented for a reason, but it is unclear to me if those reasons
remain valid in the face of the newer CFFI and what we may lose by
disabling it.
I should perhaps also mention that I am running with this in my .sbclrc:
(setq sb-impl::*default-external-format* :latin-1)
in case that makes a difference.
------------------------+-----------------------------------------------------
Christian Lynbech | christian #\@ defun #\. dk
------------------------+-----------------------------------------------------
Hit the philistines three times over the head with the Elisp reference manual.
- [email protected] (Michael A. Petonic)
The value of STRING is #(71 85 73 32 68 101 109
111), which is not of type STRING.
[Condition of type SIMPLE-TYPE-ERROR]
Restarts:
0: [STORE-VALUE] Supply a new value for STRING.
1: [RETRY] Retry SLIME REPL evaluation request.
2: [ABORT] Return to SLIME's top level.
3: [TERMINATE-THREAD] Terminate this thread (#<THREAD "repl-thread" RUNNING
{B044AE9}>)
Backtrace:
0: (SB-KERNEL:CHECK-TYPE-ERROR STRING #(71 85 73 32 68 101 ...) STRING NIL)
1: (CFFI:FOREIGN-STRING-ALLOC #(71 85 73 32 68 101 ...))[:EXTERNAL]
2: (GTK-FFI::GTK_WINDOW_SET_TITLE #.(SB-SYS:INT-SAP #X080AA558) #(71 85 73 32
68 101 ...))
3: (GTK-FFI:GTK-WINDOW-SET-TITLE #.(SB-SYS:INT-SAP #X080AA558) "GUI Demo")
4: ((LAMBDA (SB-PCL::.PV. SB-PCL::.NEXT-METHOD-CALL. SB-PCL::.ARG0.
SB-PCL::.ARG1. SB-PCL::.ARG2. SB-PCL::.ARG3. SB-PCL::.ARG4. SB-PCL::.ARG5.)) ..)
5: ((SB-PCL::FAST-METHOD CELLS:MD-AWAKEN (CELLS::MODEL-OBJECT)) #<unavailable
argument> #<unavailable argument> TEST-GUI)
6: ((LAMBDA (SB-PCL::.PV. SB-PCL::.NEXT-METHOD-CALL. SB-PCL::.ARG0.))
#<unavailable argument> #<unavailable argument> TEST-GUI)
7: ((SB-PCL::FAST-METHOD CELLS:MD-AWAKEN :AROUND (CELLS::MODEL-OBJECT)) ..)
8: (CELLS::CALL-WITH-INTEGRITY :AWAKEN TEST-GUI #<CLOSURE (LAMBDA #)
{ACC1515}> #<unavailable argument>)
9: ((LAMBDA (SB-PCL::.PV. SB-PCL::.NEXT-METHOD-CALL. SB-PCL::.ARG0.
SB-PCL::.ARG1. SB-INT:&MORE SB-PCL::.DFUN-MORE-CONTEXT.
SB-PCL::.DFUN-MORE-COUNT.)) ..)
10: ((SB-PCL::FAST-METHOD SHARED-INITIALIZE :AROUND (CELLS:MODEL T))
..)[:EXTERNAL]
11: ((LAMBDA (SB-PCL::.PV. SB-PCL::.NEXT-METHOD-CALL. SB-PCL::.ARG0.
SB-INT:&MORE SB-PCL::.DFUN-MORE-CONTEXT. SB-PCL::.DFUN-MORE-COUNT.)) #<unused
argument> #<unused argument> TEST-GUI -310034821 26)
12: ((SB-PCL::FAST-METHOD MAKE-INSTANCE (CLASS)) #<unavailable argument>
#<unavailable argument> #<STANDARD-CLASS CL-MDM-GUI::TEST-GUI>)[:EXTERNAL]
13: (CELLS-GTK::SHOW-WIN CL-MDM-GUI::TEST-GUI)[:EXTERNAL]
14: (CELLS-GTK:START-APP CL-MDM-GUI::TEST-GUI)[:EXTERNAL]
15: (SB-INT:SIMPLE-EVAL-IN-LEXENV (CL-MDM-GUI:GUI-DEMO) #<NULL-LEXENV>)
--more--
Index: cl/cells-gtk3/gtk-ffi/gtk-ffi-impl.lisp
===================================================================
--- cl/cells-gtk3/gtk-ffi/gtk-ffi-impl.lisp (revision 91)
+++ cl/cells-gtk3/gtk-ffi/gtk-ffi-impl.lisp (working copy)
@@ -18,13 +18,13 @@
;;;
(defun lisp-to-utf-8 (str)
- #-(or clisp sbcl) (return-from lisp-to-utf-8 str)
+ #-(or clisp sbcl-not-really) (return-from lisp-to-utf-8 str)
(when str
#+clisp (ext:convert-string-to-bytes str charset:utf-8)
- #+sbcl (sb-ext:string-to-octets str :external-format :utf-8)))
+ #+sbcl-not-really (sb-ext:string-to-octets str :external-format :utf-8)))
(defun utf-8-to-lisp (str)
- #-(or clisp sbcl) (return-from utf-8-to-lisp str)
+ #-(or clisp sbcl-not-really) (return-from utf-8-to-lisp str)
(when str
(let* ((nat (lisp-to-utf-8 str))
(oct (coerce (loop for i from 0 below (length nat)
@@ -34,7 +34,7 @@
if (= b 195) do (incf i 2))
'(vector (unsigned-byte 8)))))
#+clisp (ext:convert-string-from-bytes oct charset:utf-8)
- #+sbcl (sb-ext:octets-to-string oct :external-format :utf-8))))
+ #+sbcl-not-really (sb-ext:octets-to-string oct :external-format :utf-8))))
_______________________________________________
cells-gtk-devel site list
[email protected]
http://common-lisp.net/mailman/listinfo/cells-gtk-devel