New patches: [demonstrate differing behavior between foreign-dyn expansions Stephen Compall **20060301194122 - change expand-type-to-foreign-dyn for foreign-typedef to not short-circuit expand-type-to-foreign when falling back (see paste 17379) - add tests showing that you can change the foreign-dyn expansion semantics by providing an expand-to-foreign method that falls back ] < > { hunk ./src/early-types.lisp 456 (expand-to-foreign-dyn value var body (name type))) ;; If there is to-foreign _expansion_ we use that. ((applicablep #'expand-to-foreign value (name type)) - `(let ((,var ,(expand-to-foreign value (name type)))) + `(let ((,var ,(expand-type-to-foreign value type))) ,@body)) ;; Else... (t *runtime-translator-form*))) hunk ./tests/misc-types.lisp 192 (deftest misc-types.expand.4 (expand-expect-int-sum (callback expand-int-sum)) t) + +(defctype translate-tracker :int) + +(declaim (special .fto-called.)) + +(defmethod free-translated-object (value (type-name (eql 'translate-tracker)) + param) + (declare (ignore value param)) + (setf .fto-called. t)) + +(defctype expand-tracker :int) + +(defmethod free-translated-object (value (type-name (eql 'expand-tracker)) + param) + (declare (ignore value param)) + (setf .fto-called. t)) + +(eval-when (:compile-toplevel :load-toplevel :execute) + (defmethod expand-to-foreign (value (type-name (eql 'expand-tracker))) + (declare (ignore value)) + *runtime-translator-form*)) + +(defcfun ("abs" ttracker-abs) :int + (n translate-tracker)) + +(defcfun ("abs" etracker-abs) :int + (n expand-tracker)) + +;; free-translated-object must be called when there is no etf +(deftest misc-types.expand.5 + (let ((.fto-called. nil)) + (ttracker-abs -1) + .fto-called.) + t) + +;; free-translated-object must not be called when there is an etf, but +;; they answer *runtime-translator-form* +(deftest misc-types.expand.6 + (let ((.fto-called. nil)) + (etracker-abs -1) + .fto-called.) + nil) + } [remove *runtime-translator-form* from the effective interface Stephen Compall **20060315184804 - Add default methods to expand-to-foreign-dyn, expand-to-foreign, and expand-from-foreign, and always use them as fallback, as the "fallback" for specializations that want to fail should be exactly the same as that when there are no specializations. - Use *fto-called* instead of .fto-called. in misc-types.lisp. - misc-types.expand.6 test: expect T instead of NIL. ] < > { hunk ./src/early-types.lisp 398 ,@body)))) (defun %expand-type-to-foreign (value type) + ;; used only where free-type-translated-object is not called (if (translate-p type) hunk ./src/early-types.lisp 400 - `(translate-type-to-foreign ,value ,type) + `(values (translate-type-to-foreign ,value ,type)) value)) (defun %expand-type-from-foreign (value type) hunk ./src/early-types.lisp 408 `(translate-type-from-foreign ,value ,type) `(values ,value))) -;;; This special variable is bound by the various :around methods below -;;; to the respective form generated by the above %EXPAND-* functions. -;;; This way, an expander can "bail out" by returning it. -(defvar *runtime-translator-form*) +;;; This special variable is bound by the various :around methods +;;; below to the respective form generated by the above %EXPAND-* +;;; functions. This way, an expander can "bail out" by calling the +;;; next method. All 6 of the below-defined GFs have a default method +;;; that simply answers the rtf bound by the default :around method. +(declaim (special *runtime-translator-form*)) (defgeneric expand-type-to-foreign-dyn (value var body type) (:method :around (value var body type) hunk ./src/early-types.lisp 421 (%expand-type-to-foreign-dyn value var body type))) (call-next-method))) (:method (value var body type) - ;; If COMPUTE-APPLICABLE-METHODS only finds one method it's - ;; the default one meaning that there is no to-foreign expander - ;; therefore we return *RUNTIME-TRANSLATOR-FORM* instead. - (if (< 1 (length (compute-applicable-methods - #'expand-type-to-foreign (list value type)))) - `(let ((,var ,(expand-type-to-foreign value type))) - ,@body) - *runtime-translator-form*))) + (declare (ignore value var body type)) + ;; as explained in specialization (t t t foreign-typedef) + *runtime-translator-form*)) (defgeneric expand-type-to-foreign (value type) (:method :around (value type) hunk ./src/early-types.lisp 441 (declare (ignore value type)) *runtime-translator-form*)) -(defgeneric expand-to-foreign-dyn (value var body type)) -(defgeneric expand-to-foreign (value type)) -(defgeneric expand-from-foreign (value type)) - -(defun applicablep (gf &rest args) - "Returns true if GF has any applicable methods for ARGS." - (not (null (compute-applicable-methods gf args)))) +(defgeneric expand-to-foreign-dyn (value var body type) + (:method (value var body type) + (declare (ignore value var body type)) + *runtime-translator-form*)) +(defgeneric expand-to-foreign (value type) + (:method (value type) + (declare (ignore value type)) + *runtime-translator-form*)) +(defgeneric expand-from-foreign (value type) + (:method (value type) + (declare (ignore value type)) + *runtime-translator-form*)) (defmethod expand-type-to-foreign-dyn (value var body (type foreign-typedef)) hunk ./src/early-types.lisp 455 - (cond ((applicablep #'expand-to-foreign-dyn value var body (name type)) - (expand-to-foreign-dyn value var body (name type))) - ;; If there is to-foreign _expansion_ we use that. - ((applicablep #'expand-to-foreign value (name type)) - `(let ((,var ,(expand-type-to-foreign value type))) - ,@body)) - ;; Else... - (t *runtime-translator-form*))) + (expand-to-foreign-dyn value var body (name type))) (defmethod expand-type-to-foreign (value (type foreign-typedef)) hunk ./src/early-types.lisp 458 - (if (applicablep #'expand-to-foreign value (name type)) - (expand-to-foreign value (name type)) - *runtime-translator-form*)) + (expand-to-foreign value (name type))) (defmethod expand-type-from-foreign (value (type foreign-typedef)) hunk ./src/early-types.lisp 461 - (if (applicablep #'expand-from-foreign value (name type)) - (expand-from-foreign value (name type)) - *runtime-translator-form*)) + (expand-from-foreign value (name type))) ;;; User interface for converting values from/to foreign using the ;;; type translators. Something doesn't feel right about this, makes hunk ./src/early-types.lisp 485 (defun free-converted-object (value type param) (free-type-translated-object value type param)) + hunk ./tests/misc-types.lisp 195 (defctype translate-tracker :int) -(declaim (special .fto-called.)) +(declaim (special *fto-called*)) (defmethod free-translated-object (value (type-name (eql 'translate-tracker)) param) hunk ./tests/misc-types.lisp 200 (declare (ignore value param)) - (setf .fto-called. t)) + (setf *fto-called* t)) (defctype expand-tracker :int) hunk ./tests/misc-types.lisp 207 (defmethod free-translated-object (value (type-name (eql 'expand-tracker)) param) (declare (ignore value param)) - (setf .fto-called. t)) + (setf *fto-called* t)) (eval-when (:compile-toplevel :load-toplevel :execute) (defmethod expand-to-foreign (value (type-name (eql 'expand-tracker))) hunk ./tests/misc-types.lisp 222 ;; free-translated-object must be called when there is no etf (deftest misc-types.expand.5 - (let ((.fto-called. nil)) + (let ((*fto-called* nil)) (ttracker-abs -1) hunk ./tests/misc-types.lisp 224 - .fto-called.) + *fto-called*) t) ;; free-translated-object must not be called when there is an etf, but hunk ./tests/misc-types.lisp 230 ;; they answer *runtime-translator-form* (deftest misc-types.expand.6 - (let ((.fto-called. nil)) + (let ((*fto-called* nil)) (etracker-abs -1) hunk ./tests/misc-types.lisp 232 - .fto-called.) - nil) + *fto-called*) + t) } Context: [Remove known issues sub-section from the manual. Luis Oliveira **20060228193623 - Listing the expected failures in the manual is too much trouble. Removed those. - Also, renamed "The Scieneer Common Lisp" to "Scieneer CL" for consistency. ] [TODO item about a pointer type, suggested by Jörg Höhle Luis Oliveira **20060228191642] [More testing Luis Oliveira **20060227194854 - Make defcfun.undefined an expected failure for SBCL on non linkage-table platforms. - New file: tests/misc.lisp. - Added a couple of tests for cffi-features. ] [TODO item about our use of EVAL Luis Oliveira **20060227194813] [manual: convert-* interface, optimizing translators overview optimized Stephen Compall **20060301043349 - (Wrapper generators): Add comment about the 30-90% figure. - Reword `Pointers' to be shorter/clearer. - Promote `Optimizing Type Translators' to a full section, a few other things here, most conspicuously expanding on the note about expand-* method definition time. - (Tutorial-Conclusion): Not a first draft anymore. - Document convert-to-foreign, convert-from-foreign, and free-converted-object. ] [manual: strings, foreign allocation, add `Wrapper generators' Stephen Compall **20060228162638 - Explain the difference between mem-aref and mem-ref by analogy with C operators. - Use ::= instead of = in with-foreign-object's syntax. - (Strings): Explain that it is portable code. - (Other Types): Don't use metasyntactic variables in Lisp examples. - Add `Wrapper generators' section on Verrazano et al. - (Foreign Type Translators): Use Please note: instead of Note: to suppress makeinfo warning. ] [Try to improve the wording in foreign-alloc's description.. Luis Oliveira **20060225155627] [Minor change to foreign-alloc's documentation Luis Oliveira **20060225041058 - make it slightly clearer that count can be omitted when initial-contents is supplied. - add reference to with-foreign-object. ] [foreign-alloc changes Luis Oliveira **20060225034634 - bugfix, foreign-alloc doesn't need to call translate-type-to-foreign explicitly since mem-aref already does. Bug reported by Greg Pfeil. - new keyword argument: NULL-TERMINATE-P. - new regression tests for the bug described above and new tests for the new keyword argument. - document new argument. ] [More tests Luis Oliveira **20060224192231 - A couple of new tests involving defcfun/foreign-funcall/defcallback and lots of doubles and floats. These were written to figure out what exactly was going on with the CALLBACKS.BFF.[12] failures. ] [Fix cffi-lispworks bug in foreign-funcall. Luis Oliveira **20060224131735 - Add same declarations to define-foreign-funcallable as those used for define-foreign-callable. - Makes FUNCALL.FLOAT pass on linux/x86. ] [SCL port, courtesy of Douglas Crosher Luis Oliveira **20060223061757 - Makefile: new test-scl target. Add SCL's fasl file extensions to the clean target. - Remove SCL TODO item. - New file: cffi-scl.lisp. - New primitive type :long-double. Since it's only supported by SCL, it's not worth adding a no-long-double feature just yet. - New tests for :long-double. - Add information about SCL and the new :long-double type to the user manual. ] [Update TODO item about fixnums. Luis Oliveira **20060223181831] [Implement and use my_llabs instead of llabs in tests Luis Oliveira **20060223081406] [Make CLISP not throw an error on undefined functions Luis Oliveira **20060220044813 - Catch the error in %foreign-funcall and throw a warning instead. - Regression test: DEFCFUN.UNDEFINED. (CMUCL fails) ] [Fix LOOP indentation in backends. James Bielman **20060217204457 - Thanks for Luís for showing me how to configure Emacs to get this right. ] [Fix and add tests for %MEM-REF and %MEM-SET evaluation order. James Bielman **20060216083448 - Some minor reformatting of LOOP forms to pacify cl-indent. - Add new regression tests to check the evaluation order of %MEM-REF and %MEM-SET. - Add the necessary ONCE-ONLY forms to the compiler macros. - Have the CFFI-TESTS package use CFFI-SYS for testing primitives. ] [Fix typo. extend -> extent Luis Oliveira **20060216051544] [Minor change to tests/defcfun.lisp Luis Oliveira **20060216050735 - Remove unnecessary (setf (mem-ref s :char) 0) forms. ] [CFFI Manual update Luis Oliveira **20060216045547 - Update known issues (callback.bff.[12] failures). - defbitfield, foreign-bitfield-symbols and foreign-bitfield-value. - Fix typo in tutorial. defenum -> defcenum. - New section "Other Types" documenting :string, :boolean and :wrapper. - Add note about the translate-* methods not being meant to be called directly and suggesting convert-* instead. - Document the macroexpansion-time translators in a new "Optimizing Type Translators" sub-section. - Document defcenum's base-type option. - Document defcfun's varargs support. ] [New functions convert-to/from-foreign and free-converted-object Luis Oliveira **20060216045335 - These functions basically export the functionality of translate-type-to-foreign, translate-type-from-foreign and free-translated-object. - TODO: document these. ] [New TODO item: defcfun compiler macros Luis Oliveira **20060216045240] [Implement compiler macros for %MEM-REF and %MEM-SET in LispWorks. James Bielman **20060215222559 - Use FLI:FOREIGN-TYPED-AREF if available and dereferencing a number. - Avoid calling INC-POINTER when the offset is a multiple of the type size allowing direct use of the INDEX argument to FOREIGN-TYPED-AREF. - Fall back to open-coding the call to FLI:DEREFERENCE otherwise. ] [Delete LispWorks/Linux .ufsl files on make clean. James Bielman **20060215213442] [Use C limits for foreign floats and doubles instead of Lisp's. James Bielman **20060215201514 - Export 'float_min', 'float_max', 'double_min', and 'double_max' from the libtest shared library with the values of FLT_MIN, FLT_MAX, DBL_MIN, and DBL_MAX, respectively. - Use *FLOAT-MIN*, *FLOAT-MAX*, *DOUBLE-MIN*, and *DOUBLE-MAX* as test values for foreign floats/doubles instead of the Lisp constants -POSITIVE--FLOAT. ] [Oops, fix tests. Luis Oliveira **20060215174316 - MISC-TYPES.BOOLEAN.2 was using the wrong ff name. - MISC-TYPES.EXPAND.* need the expand-* methods defined at macroexpansion-time. ] [Change +REQUIRED-DLL-VERSION+ to *REQUIRED-DLL-VERSION*. James Bielman **20060215171631] [Remove completed TODO item about building 32 and 64 bit libtest. James Bielman **20060215091337] [A few more tests Luis Oliveira **20060215163551 - Tests for the new macroexpansion-time type translator interface: MISC-TYPES.EXPAND.[1234] - New tests: DEREF.LONG-LONG and DEREF.UNSIGNED-LONG-LONG. - Tests for mem-ref with non-constant type arguments: DEREF.NONCONST.* - Fix some comments in tests/memory.lisp. - New test: MISC-TYPES.BOOLEAN.2 (accepting typedefs to integer types) ] [Minor test changes Luis Oliveira **20060215030152 - Use long instead of int in the big C functions in libtest.c. - Mark callbacks.bff.[12] as expect failures for a couple of lisps. ] [Make (%callback 'non-existant-callback) signal an error Luis Oliveira **20060215025906 - Make %callback signal an error for non-existing callbacks. (allegro, sbcl and openmcl) - Regression test: callbacks.non-existant ] [Implement %MEM-REF and %MEM-SET compiler macros for Allegro CL. James Bielman **20060215025257] [Ignore RETTYPE in Allegro CL %DEFCALLBACK. James Bielman **20060215022651] [Fix float varargs promotion. Luis Oliveira **20060214042928 - Convert floats to doubles in foreign-funcall-varargs. Test DEFCFUN.VARARGS.FLOAT now passes. ] [Preliminary random tester. Luis Oliveira **20060214042733 - Push random-tester.lisp. This was used to generate the BFF tests, but is still not automated. - Update respective TODO item. ] [MORE TESTS Luis Oliveira **20060214032830 - New tests: callbacks.funcall.2, callbacks.bff.[12], defcfun.bff.[12]. - Re-enable defcfun.varargs.double. - Use #'float instead of #'coerce in the defcfun.varargs.* tests. - Fix dll version in libtest.c. ] [Change defconstant to defparameter in bindings.lisp Luis Oliveira **20060214002839] [Macroexpansion-time translators Luis Oliveira **20060214001931 - New interface. expand-to-foreign-dyn, expand-to-foreign and expand-from-foreign. - defcfun/foreign-funcall/defcallback/defcvar use this as well as the compiler macros and setf-expanders for mem-ref, mem-aref, and foreign-slot-value. - Also, parse ignore declarations and use them to avoid translating such types (thus avoiding breaking the ignore declaration). ] [Implement simple version check for libtest DLL Jack Unrue **20060212182709] [Push CFFI-FEATURES:X86-64 on Allegro/amd64. James Bielman **20060211003123] [Removed outdated comment from the colorize script. Luis Oliveira **20060210220055] [Use slanted instead of italic for VAR in style.css Luis Oliveira **20060210195248] [use lispcmt for code comments instead of @r Stephen Compall **20060210160507 - Add ROMANCOMMENTS option to manual. - Change all instances of @r to @lispcmt. ] [make Texinfo @r and colorize play nice Stephen Compall **20060210035038 - Comment out master menu entry for explain-foreign-slot-value so manual builds again. - Add @r to all Lisp comments in manual. - (Tutorial-easy_setopt): Revert previous @dots{}; it is literal `...', not an ellipsis. Oops. - In colorize-lisp-examples.lisp, remove the output generated by @r from Lisp blocks. Also shove around the process-file code some. ] [Remove @r{} in manual's code comments Luis Oliveira **20060210021117 (at least until the colorize script can cope with these) ] [More minor doc changes. Luis Oliveira **20060210005707 - @emph -> @var. - change var's style to something more sensible in the CSS file. - remove (setf callback) from the docs. - fix some typos. ] [Make :boolean accept typedefs to integer types. Luis Oliveira **20060210003650] [Minor documentation changes Luis Oliveira **20060209225109 - Have the Makefile's clean target delete some more of the temporary texinfo files. - Comment out reference to explain-foreign-slot-value. ] [reference prose in Pointers and Strings manual chapters Stephen Compall **20060209183938 - (Tutorial-easy_setopt): Use @dots{}. - (seealso): Remove old comment about @code formatting. - Pointers chapter: Describe the theory of foreign data, dealing with pointers per se, and expand on the allocation description. - (Strings): A short paragraph by way of introduction. ] [Remove note about unsupported FOREIGN-FUNCALL on Lispworks. James Bielman **20060206185439] [TAG 0.9.0 James Bielman **20060204082912] Patch bundle hash: 6274cbe373e30b1b10bd8d7cd44c5f6ebd98f106