Changeset 11470


Ignore:
Timestamp:
Dec 8, 2008, 11:07:06 AM (11 years ago)
Author:
gb
Message:

We really want definitions of functions that return structure types
to be explicit about that; at this level, we can't just translate
those functions into things that accepts a pointer argument and
returns NIL, since that loses information.

There was a variable - *FFI-EXPLICIT-STRUCT-RETURN* - that controlled
whether this happened or not; when it was true, the translator printed
infomation about functions that returned structures, and when it was
false, the return type was set to :VOID and an extra pointer arg was
added. Possibly to avoid printing that cryptic-looking info, the
variable was erroneously set false at some point in the past.

(At a higher level, functions that return structures do need to accept
a pointer to a structure as their fist argument, but how that pointer's
used depends on the ABI.)

In any case. botching this means that the interfaces that we've been
using for the last year or two (whenever this change was made) are
missing struct return info for foreign functions (though it's present
for ObjC methods), so we'll need new interfaces for most platforms.
(Darwin makes heaviest use of struct return.)

Here, don't think that making struct return explicit is optional.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/library/parse-ffi.lisp

    r11197 r11470  
    1818
    1919(defvar *parse-ffi-target-ftd* *target-ftd*)
    20 (defvar *ffi-struct-return-explicit* nil)
    2120(defvar *ffi-lisp-readtable* (copy-readtable nil))
    2221(defvar *ffi-ordinal* -1)
     
    715714    (if (eq (car (last args)) *ffi-void-reference*)
    716715      (setq args (butlast args)))
    717     (when (ffi-record-type-p retval)
    718       (if  *ffi-struct-return-explicit*
    719         (format t "~&;; Note: explict struct return in function ~s" (ffi-function-string  ffi-function))
    720         (progn
    721           (push retval args)
    722           (push `(:pointer ,retval) (ffi-function-arglist ffi-function))
    723           (setf (ffi-function-return-value ffi-function) *ffi-void-reference*)
    724           (setq retval *ffi-void-reference*))))
    725716    (dolist (arg args) (ensure-referenced-type-defined arg))
    726717    (ensure-referenced-type-defined retval)
     
    790781         (*target-ftd* ftd)
    791782         (*target-backend* backend)
    792          (*ffi-struct-return-explicit* nil)
     783         (*ffi-struct-return-explicit* t)
    793784         (d (use-interface-dir dirname ftd))
    794785         (interface-dir (merge-pathnames
Note: See TracChangeset for help on using the changeset viewer.