[armedbear-ticket] [armedbear] #251: ffi callbacks don't unbox integer values

armedbear armedbear-devel at common-lisp.net
Fri Oct 19 05:35:48 UTC 2012


#251: ffi callbacks don't unbox integer values
-----------------------+----------------------------------------------------
 Reporter:  sboukarev  |       Owner:  nobody   
     Type:  defect     |      Status:  new      
 Priority:  major      |   Milestone:  1.1.0    
Component:  java       |     Version:  1.1.0-dev
 Keywords:             |  
-----------------------+----------------------------------------------------
 It very well may be a cffi issue.

 Compile the following C code
 with gcc -shared test.c -o test.so


 {{{
 #ifdef WIN32
 #define DLLEXPORT __declspec(dllexport)
 #else
 #define DLLEXPORT
 #endif

 DLLEXPORT
 short test(short (*f)(short, short))
 {
  return f(23, 24);
 }
 }}}

 Then


 {{{
 (cffi:load-foreign-library "/tmp/test.so")

 (cffi:defcfun test :short
   (function :pointer))

 (cffi:defcallback (test-callback)
     :short ((a :short) (b :short))
   (+ a b))

 }}}

 And finally

 {{{
 (test (cffi:get-callback 'test-callback)) =>
 The value #<java.lang.Short 23 {5EE76547}> is not of type NUMBER.
 }}}

 That's on 64-bit x86 linux, with OpenJDK 1.6.0_24 and jna downloaded by
 maven.

-- 
Ticket URL: <http://trac.common-lisp.net/armedbear/ticket/251>
armedbear <http://common-lisp.net/project/armedbear>
armedbear


More information about the armedbear-ticket mailing list