Modify STRUCTURE-BY-VALUE-P and include test cases
authorCrLF0710 <crlf0710@gmail.com>
Fri, 18 Jan 2013 13:04:25 +0000 (21:04 +0800)
committerCrLF0710 <crlf0710@gmail.com>
Fri, 18 Jan 2013 13:04:25 +0000 (21:04 +0800)
src/functions.lisp
tests/fsbv.lisp
tests/libfsbv.c

index bb138de..7131f66 100644 (file)
@@ -90,7 +90,9 @@
 
 (defun structure-by-value-p (ctype)
   "A structure or union is to be called or returned by value."
-  (member (alexandria:ensure-car ctype) '(:struct :union)))
+  (typep (follow-typedefs (parse-type ctype))
+         '(or foreign-struct-type foreign-union-type
+           #+cffi::no-long-long emulated-llong-type)))
 
 (defun fn-call-by-value-p (argument-types return-type)
   "One or more structures in the arguments or return from the function are called by value."
index 98bce14..13a7b0c 100644 (file)
   8
   10
   5.0d0)
+
+;;; Typedef fsbv test
+
+(defcfun ("sumpair" sumpair2) :int
+  (p struct-pair-typedef1))
+
+(deftest fsbv.5
+    (sumpair2 '(1 . 2))
+  3)
+
+;;; Test ulonglong on no-long-long implementations.
+
+(defcfun "ullsum" :unsigned-long-long
+  (a :unsigned-long-long) (b :unsigned-long-long))
+
+(deftest fsbv.6
+    (ullsum #x10DEADBEEF #x2300000000)
+  #x33DEADBEEF)
index c5aa0ca..e6f3045 100644 (file)
@@ -97,3 +97,9 @@ struct struct_pair_double doublepairdouble (struct struct_pair_double pd)
   ret.dbl = 2*pd.dbl;
   return ret;
 }
+
+DLLEXPORT
+unsigned long long ullsum (unsigned long long a, unsigned long long b)
+{
+  return a + b;
+}