Fix BARE-STRUCT-TYPE-P & STRUCTURE-BY-VALUE-P
authorCrLF0710 <crlf0710@gmail.com>
Mon, 21 Jan 2013 02:17:44 +0000 (10:17 +0800)
committerLuís Oliveira <loliveira@common-lisp.net>
Thu, 21 Feb 2013 22:28:16 +0000 (22:28 +0000)
src/early-types.lisp
src/functions.lisp

index 28164b7..29a6ffb 100644 (file)
@@ -215,6 +215,14 @@ Signals an error if FOREIGN-TYPE is undefined."))
 
 ;;;# Structure Type
 
+(defgeneric bare-struct-type-p (foreign-type)
+  (:documentation
+   "Return true if FOREIGN-TYPE is a bare struct type or an alias of a bare struct type. "))
+
+(defmethod bare-struct-type-p ((type foreign-type))
+  "Return true if FOREIGN-TYPE is a bare struct type or an alias of a bare struct type. "
+  nil)
+
 (defclass foreign-struct-type (named-foreign-type)
   ((slots
     ;; Hash table of slots in this structure, keyed by name.
index 7131f66..f7e122f 100644 (file)
 
 (defun structure-by-value-p (ctype)
   "A structure or union is to be called or returned by value."
-  (typep (follow-typedefs (parse-type ctype))
-         '(or foreign-struct-type foreign-union-type
-           #+cffi::no-long-long emulated-llong-type)))
+  (let ((actual-type (follow-typedefs (parse-type ctype))))
+    (or (and (typep actual-type 'foreign-struct-type)
+             (not (bare-struct-type-p actual-type)))
+        #+cffi::no-long-long (typep actual-type '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."