Luís Oliveira wrote:
> 
> Marco Gidde <[EMAIL PROTECTED]>
> writes:
> > I just made a quick test with SBCL 0.9.12 on x86-64 and had to change
> > one line in pygetarg from
> >
> >    (string (cffi:foreign-string-to-lisp (cffi:mem-ref variable :string)))
> >
> > to
> >
> >    (string (cffi:mem-ref variable :string))
> >
> > Someone else posted that everything worked fine for him with a very
> > similar configuration, so I *guess*, that it might be a change between
> > different CFFI versions. I ASDF-INSTALLed it a few weeks ago and it is
> > version 0.9.1. Maybe cvs CFFI is different in this regard?
> 
> Many (?) months ago, way before 0.9.0 (the first actual release of
> CFFI), the behaviour of MEM-REF (and others) changed so that the type
> translators are called (in this case, the :STRING type translator). So,
> MEM-REF will call FOREIGN-STRING-TO-LISP for you.

Thanks guys, that's great news. I've implemented the fix so it does it
with the 'old' CFFI (the one I use!) which doesn't automatically do
this, and the new one (which does), by using 'typep' to check for
string-ness.

I'm not sure if this is really the proper use of 'case' but Lisp allows
'if' to specify any of 2 values, so I think it'll work.

I'll upload it soon if it works with the newer CFFI. I haven't got CVS
running at common-lisp.net yet, but I'll look into it when I have time.

(defun pygetarg (variable type)
  "Helper function for handling python arguments, used by
gen-pycallback. Should never be used directly from code - use defpyfun
with its arg format"
  (case type
    (long (cffi:mem-ref variable :long))
    ;If it's decoded by the new version of CFFI
    (if (typep (cffi:mem-ref variable :string) 'string)
          (string (cffi:mem-ref variable :string))))
          (string (cffi:foreign-string-to-lisp (cffi:mem-ref variable
:string))))

Jeremy.
-- 
| Jeremy Smith BSc (Hons)
| Chief Scientist, Decompiler Technologies
_______________________________________________
Gardeners mailing list
[email protected]
http://www.lispniks.com/mailman/listinfo/gardeners

Reply via email to