[Ecls-list] Fix for callbacks with :VOID or :UNSIGNED-BYTE return type

Goffioul Michael goffioul at imec.be
Mon Oct 24 02:17:47 UTC 2005


The following patch fixes problems with :VOID and :UNSIGNED-BYTE return
type. For the second case, it's related to the fact that MSVC doesn't
like the "unsigned byte" type when byte has been declared as "unsigned char".

OK to commit?

Index: src/cmp/cmpcbk.lsp
===================================================================
RCS file: /cvsroot/ecls/ecls/src/cmp/cmpcbk.lsp,v
retrieving revision 1.5
diff -u -3 -p -r1.5 cmpcbk.lsp
--- src/cmp/cmpcbk.lsp  19 Oct 2005 07:54:24 -0000      1.5
+++ src/cmp/cmpcbk.lsp  24 Oct 2005 09:11:07 -0000
@@ -68,8 +68,10 @@
     (cdr x)))
 
 (defun t3-defcallback (lisp-name c-name c-name-constant return-type
-                      arg-types arg-type-constants call-type)
+                      arg-types arg-type-constants call-type &aux (return-p t))
   (cond ((ffi::foreign-elt-type-p return-type))
+       ((member return-type '(nil :void))
+        (setf return-p nil))
        ((and (consp return-type)
              (member (first return-type) '(* array)))
         (setf return-type :pointer-void))
@@ -92,7 +94,8 @@
            (setf comma ",")))
     (wt ")")
     (wt-nl1 "{")
-    (wt-nl return-type-name " output;")
+    (when return-p
+      (wt-nl return-type-name " output;"))
     (wt-nl "cl_object aux;")
     (loop for n from 0
          and type in arg-types
@@ -106,9 +109,10 @@
     (wt-nl "aux = cl_apply_from_stack(" (length arg-types)
           ",ecl_fdefinition(" c-name-constant "));")
     (wt-nl "cl_stack_pop_n(" (length arg-types) ");")
-    (wt-nl "ecl_foreign_data_set_elt(&output,"
-          (foreign-elt-type-code return-type) ",aux);")
-    (wt-nl "return output;")
+    (when return-p
+      (wt-nl "ecl_foreign_data_set_elt(&output,"
+            (foreign-elt-type-code return-type) ",aux);")
+      (wt-nl "return output;"))
     (wt-nl1 "}")))
 
 (put-sysprop 'FFI:DEFCALLBACK 'C1 #'c1-defcallback)
Index: src/cmp/cmpffi.lsp
===================================================================
RCS file: /cvsroot/ecls/ecls/src/cmp/cmpffi.lsp,v
retrieving revision 1.22
diff -u -3 -p -r1.22 cmpffi.lsp
--- src/cmp/cmpffi.lsp  17 Oct 2005 21:09:17 -0000      1.22
+++ src/cmp/cmpffi.lsp  24 Oct 2005 09:11:07 -0000
@@ -18,8 +18,8 @@
 (defconstant +representation-types+
   '(;; These types can be used by ECL to unbox data
     ;; They are sorted from the most specific, to the least specific one.
-    :byte ((signed-byte 8) "byte")
-    :unsigned-byte ((unsigned-byte 8) "unsigned byte")
+    :byte ((signed-byte 8) "int8_t")
+    :unsigned-byte ((unsigned-byte 8) "uint8_t")
     :fixnum (fixnum "cl_fixnum")
     :int ((integer #.si:c-int-min #.si:c-int-max) "int")
     :unsigned-int ((integer 0 #.si:c-uint-max) "unsigned int")

Michael.




More information about the ecl-devel mailing list