projects/cffi/cffi.git
11 months agoNew method #'translate-into-foreign-memory for foreign-string-type stub
Liam M. Healy [Sat, 26 May 2012 22:03:57 +0000] 
New method #'translate-into-foreign-memory for foreign-string-type

12 months agoLoad cffi-libffi and do FSBV tests in cffi-tests
Liam M. Healy [Mon, 14 May 2012 13:18:36 +0000] 
Load cffi-libffi and do FSBV tests in cffi-tests

12 months agoCreate a function named die, use it for error messages
Stelian Ionescu [Sun, 6 May 2012 14:54:34 +0000] 
Create a function named die, use it for error messages

12 months agoIgnore TYPE in default method of EXPAND-TO-FOREIGN-DYN-INDIRECT
Stelian Ionescu [Sun, 6 May 2012 09:33:08 +0000] 
Ignore TYPE in default method of EXPAND-TO-FOREIGN-DYN-INDIRECT

12 months agoDefine BARE-STRUCT-TYPE-P for FOREIGN-TYPEDEFs
Stelian Ionescu [Sun, 6 May 2012 09:32:46 +0000] 
Define BARE-STRUCT-TYPE-P for FOREIGN-TYPEDEFs

12 months agoTests for cffi-libffi working
Liam M. Healy [Sat, 5 May 2012 15:32:22 +0000] 
Tests for cffi-libffi working

Fix an error in the recursive call in libffi-type-pointer for
foreign-struct-type, now parse the slot-type, which is unparsed.  This
makes FSBV.3 and FSBV.4 succeed.  Removed quote from test FSBV.2; this
makes FSBV.2 succeed.

12 months agocffi-tests: make compilation of libtest2_32 and libfsbv_32 optional.
Luís Oliveira [Fri, 4 May 2012 13:37:57 +0000] 
cffi-tests: make compilation of libtest2_32 and libfsbv_32 optional.

12 months agoRemove *parse-bare-structs-as-pointers* binding in test
Liam M. Healy [Thu, 3 May 2012 16:15:33 +0000] 
Remove *parse-bare-structs-as-pointers* binding in test

12 months agoRewrite backwards-compatibility mode for bare struct types.
Luís Oliveira [Tue, 1 May 2012 03:14:30 +0000] 
Rewrite backwards-compatibility mode for bare struct types.

* Instead of a special variable, the parsed struct type instance is now
  annotated to let the type system know whether we're dealing with
  deprecated semantics (struct type canonicalizes to :pointer) or not.

  This approach should hopefully be much less error-prone.

* Disabled translations for bare structs.

* Fixed and commented out some bogus tests.

12 months agoRevert "Bind *PARSE-BARE-STRUCTS-AS-POINTERS* to T in #'MEM-AREF"
Stelian Ionescu [Mon, 30 Apr 2012 21:17:06 +0000] 
Revert "Bind *PARSE-BARE-STRUCTS-AS-POINTERS* to T in #'MEM-AREF"

This broke other stuff, so revert until we understand what's happening

This reverts commit 944d33183d7b4965d6ea86b37138c6691cd160ca.

12 months agoMerge branch 'bugfix-v0.10.7.1'
Luís Oliveira [Mon, 30 Apr 2012 21:17:33 +0000] 
Merge branch 'bugfix-v0.10.7.1'

12 months agoUse new struct spec in DEFINE-C-STRUCT-WRAPPER
Stelian Ionescu [Mon, 30 Apr 2012 18:39:41 +0000] 
Use new struct spec in DEFINE-C-STRUCT-WRAPPER

12 months agoBind *PARSE-BARE-STRUCTS-AS-POINTERS* to T in #'MEM-AREF
Stelian Ionescu [Mon, 30 Apr 2012 18:38:49 +0000] 
Bind *PARSE-BARE-STRUCTS-AS-POINTERS* to T in #'MEM-AREF

13 months agoImprove documentation of structure reference
Liam M. Healy [Fri, 20 Apr 2012 03:29:27 +0000] 
Improve documentation of structure reference

Improved the documentation for Foreign Structure Types to more clearly
describe the behavior of mem-aref under the new structure reference
syntax and the compatibility of the bare structure reference with the
old behavior.

13 months agoFix compiler macro for mem-aptr (Stas Boukarev)
Liam M. Healy [Thu, 19 Apr 2012 17:51:21 +0000] 
Fix compiler macro for mem-aptr (Stas Boukarev)

13 months agocffi-ecl: check for long-long support. bugfix-v0.10.7.1 v0.10.7.1
Luís Oliveira [Sat, 14 Apr 2012 19:27:40 +0000] 
cffi-ecl: check for long-long support.

13 months agocffi-tests: don't attempt to create threads when Lisp doesn't support them.
Luís Oliveira [Sat, 14 Apr 2012 19:27:22 +0000] 
cffi-tests: don't attempt to create threads when Lisp doesn't support them.

13 months agocffi-tests: exclude encodings requiring BOM in STRING.ENCODINGS.ALL.BASIC.
Luís Oliveira [Sat, 14 Apr 2012 18:39:29 +0000] 
cffi-tests: exclude encodings requiring BOM in STRING.ENCODINGS.ALL.BASIC.

13 months agocffi-tests: replace UTF-16 test with explicit UTF-16{BE,LE} versions.
Luís Oliveira [Sat, 14 Apr 2012 18:23:05 +0000] 
cffi-tests: replace UTF-16 test with explicit UTF-16{BE,LE} versions.

13 months agoFix expand-to-foreign-dyn-indirect
Liam M. Healy [Sat, 14 Apr 2012 17:58:52 +0000] 
Fix expand-to-foreign-dyn-indirect

Create a new function #'foreign-expand-runtime-translator-or-binding
which is what the methods
  expand-to-foreign-dyn (value var body (type enhanced-foreign-type))
  expand-to-foreign-dyn-indirect (value var body (type translatable-foreign-type))
both call.  Previously, the body of that function was the body of the
first method, and the second method called that generic function.
This did not work as intended however, the result being that libffi
calls were passed the actual object instead of the pointer.  This
change fixes that problem.

13 months agocffi-manual: fix TRANSLATE-NAME-FROM-FOREIGN example.
Luís Oliveira [Sat, 14 Apr 2012 17:28:11 +0000] 
cffi-manual: fix TRANSLATE-NAME-FROM-FOREIGN example.

13 months agoApply CANONICALIZE-SYMBOL-NAME-CASE to symbols created via DEFCVAR.
Luís Oliveira [Sat, 14 Apr 2012 17:25:34 +0000] 
Apply CANONICALIZE-SYMBOL-NAME-CASE to symbols created via DEFCVAR.

13 months agoFix typo: signed 64bit accessor is sb-sys:signed-sap-ref-64
Stelian Ionescu [Thu, 12 Apr 2012 13:31:34 +0000] 
Fix typo: signed 64bit accessor is sb-sys:signed-sap-ref-64

13 months agoFix typo: signed 64bit accessor is sb-sys:signed-sap-ref-64
Stelian Ionescu [Thu, 12 Apr 2012 13:31:34 +0000] 
Fix typo: signed 64bit accessor is sb-sys:signed-sap-ref-64

13 months agoNew function expand-to-foreign-dyn-indirect libffi
Liam M. Healy [Sun, 25 Mar 2012 19:16:01 +0000] 
New function expand-to-foreign-dyn-indirect

New function expand-to-foreign-dyn-indirect split out from
expand-to-foreign-dyn, and the latter function returned to its
definition as given in the tip of master, ab10be4fb8.  This function
is used if the optional argument 'indirect to translate-objects is T,
which in turn the case when functions are calling or return structures
by value.

13 months agoCompiler macro for mem-aptr
Liam M. Healy [Fri, 23 Mar 2012 02:09:35 +0000] 
Compiler macro for mem-aptr

Multi-level optimizations depending what arguments are constantp;
the constantp arguments need to be evaled.

14 months agoAdd libffi.so.6, libffi32.so.6 to unix load list
Liam M. Healy [Sun, 18 Mar 2012 02:56:38 +0000] 
Add libffi.so.6, libffi32.so.6 to unix load list

Ubuntu 11.10 ships with libffi6 and not libff5, so these libraries are
now added to the load list.

14 months agoChange comment to refer to "libffi"
Liam M. Healy [Fri, 16 Mar 2012 04:12:27 +0000] 
Change comment to refer to "libffi"

Comment referred to "FSBV" now corrected to "libffi".  Other uses (the
tests and foreign library for tests, the *feature* symbol, and the
variable 'fsbvp resulting from fn-call-by-value-p) genuinely refer to
FSBV and not specifically libffi.  Distinction: "FSBV" refers to all
calls of structures by value, whether accomplished with the help of
libffi or not (some compilers have FSBV built in), "libffi" refers to
the use of the libffi library whether or not for calling foreign
structures by value (there are other functions not yet made use of in
CFFI, but someday might).

14 months agoMerge branch 'master' into libffi
Liam M. Healy [Fri, 16 Mar 2012 04:02:54 +0000] 
Merge branch 'master' into libffi

Conflicts:
tests/GNUmakefile

14 months agoDefine a compiler macro for #'mem-aptr
Liam M. Healy [Fri, 16 Mar 2012 03:46:07 +0000] 
Define a compiler macro for #'mem-aptr

14 months agocffi-abcl: implement callbacks. v0.10.7
Luís Oliveira [Sun, 11 Mar 2012 21:11:42 +0000] 
cffi-abcl: implement callbacks.

Patch courtesy of Mark Evenson.

14 months agocffi-abcl: autoload JNA dependency.
Luís Oliveira [Sun, 11 Mar 2012 21:11:16 +0000] 
cffi-abcl: autoload JNA dependency.

Patch courtesy of Mark Evenson.

14 months agoAdd support for Digitool MCL.
Luís Oliveira [Sat, 10 Mar 2012 10:54:31 +0000] 
Add support for Digitool MCL.

Patch courtesy of James Anderson.

14 months agoUpdate manual to include mem-aptr
Liam M. Healy [Mon, 5 Mar 2012 04:32:44 +0000] 
Update manual to include mem-aptr

14 months agoDefine mem-aptr; untested
Liam M. Healy [Thu, 1 Mar 2012 04:44:36 +0000] 
Define mem-aptr; untested

New function mem-aptr will return the pointer to the requested element
of the array, and add documentation.  It is untested.

15 months agoFix alloc_pair test return type syntax
Liam M. Healy [Sun, 12 Feb 2012 16:09:28 +0000] 
Fix alloc_pair test return type syntax

15 months agoRename system to cffi-libffi, add restart to default *foreign-structures-by-value*
Liam M. Healy [Sun, 5 Feb 2012 22:02:08 +0000] 
Rename system to cffi-libffi, add restart to default *foreign-structures-by-value*

15 months agoUse hash table for libffi-type-pointer
Liam M. Healy [Sat, 4 Feb 2012 18:10:52 +0000] 
Use hash table for libffi-type-pointer

Use hash table for libffi-type-pointer instead of a class slot, and
simplify #'libffi-type-pointer methods.  Remove obsolete package
definition file.  Tests in cffi-tests not run due to error in load,
but GSLL tests pass.

15 months agoMoved slots-in-order after foreign-struct-type, clean up libffi-*.lisp
Liam M. Healy [Sun, 29 Jan 2012 02:10:26 +0000] 
Moved slots-in-order after foreign-struct-type, clean up libffi-*.lisp

15 months agocffi-abcl: fix bitrot. s/calling-convention/convention
Luís Oliveira [Thu, 26 Jan 2012 01:03:55 +0000] 
cffi-abcl: fix bitrot. s/calling-convention/convention

Bug reported by Anton Vodonosov.

15 months agoFix conditionalization syntax in cffi-fsbv.asd
Liam M. Healy [Mon, 23 Jan 2012 20:10:20 +0000] 
Fix conditionalization syntax in cffi-fsbv.asd

15 months agoAdd Windows grovel file
Liam M. Healy [Mon, 23 Jan 2012 14:54:06 +0000] 
Add Windows grovel file

Added a Windows grovel file from CRLF0710, modified from the
standalone FSBV unix file.  Minimally modified for CFFI with updated
header and package, not tested at all.

16 months agoEliminate package cffi-fsbv, put :sizet in keyword package
Liam M. Healy [Fri, 13 Jan 2012 04:34:18 +0000] 
Eliminate package cffi-fsbv, put :sizet in keyword package

16 months agocffi-allegro: signal clearer error when [u]llong is unsupported
Luís Oliveira [Fri, 13 Jan 2012 01:31:49 +0000] 
cffi-allegro: signal clearer error when [u]llong is unsupported

16 months agocffi-tests: fix bug in ullong(); mark expected failure.
Luís Oliveira [Tue, 10 Jan 2012 22:11:05 +0000] 
cffi-tests: fix bug in ullong(); mark expected failure.

DEFCFUN.UNSIGNED-LONG-LONG fails on Allegro: lp#914500.

16 months agominor fix for allegrocl's long-long support
Jianshi Huang [Fri, 6 Jan 2012 21:14:15 +0000] 
minor fix for allegrocl's long-long support

16 months agoNew tests: DEFCFUN.UNSIGNED-LONG-LONG and FUNCALL.UNSIGNED-LONG-LONG.
Luís Oliveira [Sat, 7 Jan 2012 01:02:07 +0000] 
New tests: DEFCFUN.UNSIGNED-LONG-LONG and FUNCALL.UNSIGNED-LONG-LONG.

16 months agocffi-tests: make compilation of 32-bit libtest optional.
Luís Oliveira [Fri, 6 Jan 2012 00:17:38 +0000] 
cffi-tests: make compilation of 32-bit libtest optional.

Fixes lp#911557. Reported by Elias Pipping. Solution courtesy of
Daniel Herring.

17 months agoUse soname with major version for libffi on unix
Liam M. Healy [Fri, 25 Nov 2011 20:03:44 +0000] 
Use soname with major version for libffi on unix

Use soname with major version for libffi on unix as advocated on
http://lispcaveats.tumblr.com/post/13259176455/ffi-linking-against-shared-libraries.

17 months agoArgument 'indirect to #'expand-to-foreign-dyn is key instead of optional
Liam M. Healy [Thu, 24 Nov 2011 22:44:13 +0000] 
Argument 'indirect to #'expand-to-foreign-dyn is key instead of optional

Argument 'indirect to #'expand-to-foreign-dyn is key instead of
optional, so that other systems that define a method can just have
&key, and they do not have to add this argument if they don't need to
use it.

17 months agoBind (*parse-bare-structs-as-pointers* t) when parsing function definitions
Liam M. Healy [Thu, 24 Nov 2011 22:28:53 +0000] 
Bind (*parse-bare-structs-as-pointers* t) when parsing function definitions

In parse-args-and-types, foreign-funcall-form,
foreign-funcall-varargs-form, bind
(*parse-bare-structs-as-pointers* t)
when parsing function definitions so that if a bare structure is
specified, the expanded form with have :pointer or (:pointer (:struct
foo)) and therefore the type will be correctly recognized.

18 months agoFix uffi-compat:octets-to-string.
Luís Oliveira [Mon, 21 Nov 2011 02:17:49 +0000] 
Fix uffi-compat:octets-to-string.

Initial patch courtesy of François-René Rideau.

18 months agoFixed incorrect use of sap-ref-word for longs on 64-bit Windows.
Anton Kovalenko [Wed, 16 Nov 2011 09:09:06 +0000] 
Fixed incorrect use of sap-ref-word for longs on 64-bit Windows.

Implemented automatic accessor lookup for integer types, based on
alien type size and CFFI keyword -> alien type mapping.

18 months agoAdditional methods for translate-into-foreign-memory and expand-to-foreign-dyn
Liam M. Healy [Sun, 13 Nov 2011 16:17:41 +0000] 
Additional methods for translate-into-foreign-memory and expand-to-foreign-dyn

In order that structures called by value work correctly (in
cffi-fsbv), add methods:
translate-into-foreign-memory
  foreign-built-in-type
  enhanced-typedef
expand-to-foreign-dyn
  foreign-built-in-type
  foreign-pointer-type

18 months agoIndirecting foreign objects for libffi
Liam M. Healy [Sun, 13 Nov 2011 06:17:42 +0000] 
Indirecting foreign objects for libffi

The generic function translate-into-foreign-memory has been slightly
repurposed and expanded to provide indirection of enums and pointers.
The function translate-objects and generic function
expand-to-foreign-dyn have a new argument, 'indirect, that when set,
expand to with-foreign-object and translate-into-foreign-memory
instead of translate-to-foreign, unwind-protect, and
free-translated-object.  This insures that all arguments to functions
passed to libffi are indirected one level, as is required.

18 months agoAdded stdcall callback support for SBCL back-end
Dmitry Ignatiev [Thu, 9 Dec 2010 15:11:54 +0000] 
Added stdcall callback support for SBCL back-end

18 months agogrovel: dispatch on size of :POINTER to initialize *CPU-WORD-SIZE-FLAGS*
Luís Oliveira [Thu, 10 Nov 2011 21:16:48 +0000] 
grovel: dispatch on size of :POINTER to initialize *CPU-WORD-SIZE-FLAGS*

We were previously using :LONG, but that does not match the machine word
size on some platforms, namely Windows.

Bug reported by Anton Kovalenko.

18 months agoUse structure specification (:struct foo) in defcstruct expansion
Liam M. Healy [Mon, 31 Oct 2011 04:09:22 +0000] 
Use structure specification (:struct foo) in defcstruct expansion

Modify #'generate-struct-accessors so that when generating accessors,
the structure is referred to with the (:struct foo) syntax, rather
than just 'foo.  While such a reference usually generates only a style
warning, if parse-deprecated-struct-type hasn't been called yet, as is
the case for slot defintions in the defcstruct expansion, it results
in an error.  This problem prevented shuffletron from compiling.

18 months agoCall-by-value with :void return, do not allocate return object
Liam M. Healy [Sun, 30 Oct 2011 03:12:40 +0000] 
Call-by-value with :void return, do not allocate return object

18 months agoRemove fsbv-standalone
Liam M. Healy [Sun, 30 Oct 2011 02:57:28 +0000] 
Remove fsbv-standalone

18 months agoRelocate default type class name in defcfun
Liam M. Healy [Sat, 29 Oct 2011 22:31:34 +0000] 
Relocate default type class name in defcfun

Moved the generation of a default type class name (appending '-tclass)
in defcfun so that notice-foreign-struct-definition gets the class
name in 'options.  Use the proper :struct form for structure.

18 months agoGroveler fixes for new structure syntax
Liam M. Healy [Sat, 29 Oct 2011 20:36:07 +0000] 
Groveler fixes for new structure syntax

Two fixes related to the change to the new syntax (:struct foo):
1) For size-of-* defconstant generation, emit with :struct.
2) Parse name and size in defcunion, not just leaving that to
notice-foreign-union-definition, because define-parse-method needs a
clean name.

Osicat now compiles cleanly.

18 months agoDefault type class, define-translation-method
Liam M. Healy [Wed, 26 Oct 2011 03:22:23 +0000] 
Default type class, define-translation-method

Make a default :class argument in defcstruct which is the structure
name and '-tclass concatenated.  New macro define-translation-method
for convenience to define translation methods.  It's a first cut, not
quite how I'd like, and untested.

18 months agoFix mem-set: for aggregates, pointer is incremented by offset
Liam M. Healy [Sun, 23 Oct 2011 15:30:20 +0000] 
Fix mem-set: for aggregates, pointer is incremented by offset

Recently added test struct-values.translation.mem-aref.1 that tested
conversion of arrays of structures was failing because mem-set did not
increment the pointer by the offset amount, so it was always writing
into the first position of the array and the rest was garbage.  This
is now fixed.

(with-foreign-object (p '(:struct struct-pair) 2)
      (setf (mem-aref p '(:struct struct-pair) 0) '(1 . 2)
            (mem-aref p '(:struct struct-pair) 1) '(3 . 4))
      (values (mem-aref p '(:struct struct-pair) 0)
              (mem-aref p '(:struct struct-pair) 1)))
(1 . 2)
(3 . 4)

18 months agoTest conversion of array of structs
Liam M. Healy [Sun, 23 Oct 2011 14:50:59 +0000] 
Test conversion of array of structs

Added test struct-values.translation.mem-aref.1 that creates an array
of two struct-pairs, sets their values, then retrieves both pairs.
This test fails: the returned first pair is actually the second, and
the returned second pair is garbage.  Repeating the same test gives
different garbage.

(with-foreign-object (p '(:struct struct-pair) 2)
      (setf (mem-aref p '(:struct struct-pair) 0) '(1 . 2)
            (mem-aref p '(:struct struct-pair) 1) '(3 . 4))
      (values (mem-aref p '(:struct struct-pair) 0)
              (mem-aref p '(:struct struct-pair) 1)))
(3 . 4)
(213829 . 0)

(with-foreign-object (p '(:struct struct-pair) 2)
      (setf (mem-aref p '(:struct struct-pair) 0) '(1 . 2)
            (mem-aref p '(:struct struct-pair) 1) '(3 . 4))
      (values (mem-aref p '(:struct struct-pair) 0)
              (mem-aref p '(:struct struct-pair) 1)))
(3 . 4)
(425347 . 0)

18 months agoTest foreign function calls with recursive structure by value
Liam M. Healy [Sun, 23 Oct 2011 02:53:23 +0000] 
Test foreign function calls with recursive structure by value

Add definition of C functions prodsumpair and doublepairdouble that
take, and for the latter, return, the structure struct-pair+double
(struct_pair_double) that has a structure struct-pair (struct_pair) in
its slot 'pr.  Two tests, fsbv.3 and fsbv.4, have been defined, and
pass.  Fixed argument to libffi-type-pointer call in
libffi-type-pointer :around method so that these will work.

18 months agoAdd struct-pair+double recursive structure translation test
Liam M. Healy [Sat, 22 Oct 2011 23:51:21 +0000] 
Add struct-pair+double recursive structure translation test

Add struct-pair+double recursive structure translation test, which
passes when run individually in SBCL.

19 months agoTests for CFFI-FSBV libffi; fix return value translation in ffcall-body-libffi
Liam M. Healy [Sat, 22 Oct 2011 03:34:24 +0000] 
Tests for CFFI-FSBV libffi; fix return value translation in ffcall-body-libffi

Tests fsbv.1 and fsbv.2 added that test foreign structure call and
return by value.  This includes the C file and addition to makefile to
generate the appropriate library, libfsbv.  So that the tests are
properly defined, load cffi-fsbv and then cffi-tests.  Both tests
should pass.  The test returning a structure, fsbv.2, exposed an error
in the form generated by ffcall-body-libffi; because it always
generated a mem-aref on the return value, the subsequent
translate-from-foreign was effectively making a double translation.
Thus, this form generation has been conditionalized so that if
translate-from-foreign will not be applied (e.g., built-in-type) to
call mem-aref, otherwise just return the pointer.

19 months agoTranslate structure to plist; fix to mem-ref function
Liam M. Healy [Fri, 21 Oct 2011 18:20:57 +0000] 
Translate structure to plist; fix to mem-ref function

Define a structure struct-pair-default-translate and test
struct-values-default.translation.mem-ref.1 to test translation from
foreign structure to plist.  In order to make this work, rewrite
mem-ref function to parallel exactly the mem-ref compiler macro,
because conditionals were not correct.

19 months agoDocumentation for structure conversion; push :fsbv onto features
Liam M. Healy [Wed, 19 Oct 2011 03:50:02 +0000] 
Documentation for structure conversion; push :fsbv onto features

Documentation for structure conversion; push :fsbv onto features,
export macro translation-forms-for-class.

19 months agoIn mem-ref function, call inc-pointer instead of %mem-ref
Liam M. Healy [Sun, 16 Oct 2011 04:06:03 +0000] 
In mem-ref function, call inc-pointer instead of %mem-ref

In mem-ref function, call inc-pointer and not %mem-ref if type is not
a bare struct, which mirrors what the compiler macro does.

19 months agoAdd :argument-precedence-order to defgenerics
Liam M. Healy [Sun, 9 Oct 2011 02:09:29 +0000] 
Add :argument-precedence-order to defgenerics

Add :argument-precedence-order to defgenerics
translate-into-foreign-memory and translate-to-foreign, and removed
the 'cons specializer in the tests.

19 months agoFirst stab at structs-by-value within MEM-REF and MEM-SET.
Luís Oliveira [Thu, 6 Oct 2011 08:23:18 +0000] 
First stab at structs-by-value within MEM-REF and MEM-SET.

19 months agoMake STRUCT-PAIR's translate-into-foreign-memory more specific.
Luís Oliveira [Thu, 6 Oct 2011 08:23:01 +0000] 
Make STRUCT-PAIR's translate-into-foreign-memory more specific.

Otherwise the default plist-handling method kicks in.

19 months agoImprove docstring for condition foreign-function-not-prepared
Liam M. Healy [Wed, 5 Oct 2011 17:35:30 +0000] 
Improve docstring for condition foreign-function-not-prepared

19 months agoFix variadic DEFCFUNs. Moved call-by-value conditionalization to %DEFCFUN.
Luís Oliveira [Wed, 5 Oct 2011 15:09:08 +0000] 
Fix variadic DEFCFUNs. Moved call-by-value conditionalization to %DEFCFUN.

Simplifies DEFCFUN, but due to the ACL-specific DEFCFUN-HELPER-FORMS hack,
this complicates %DEFCFUN a little bit.

19 months agoMove *PARSE-BARE-STRUCTS-AS-POINTERS* up.
Luís Oliveira [Wed, 5 Oct 2011 15:07:46 +0000] 
Move *PARSE-BARE-STRUCTS-AS-POINTERS* up.

19 months agoAdd default free-translated-object, remove aggregate slot code, add documentation
Liam M. Healy [Mon, 3 Oct 2011 02:17:56 +0000] 
Add default free-translated-object, remove aggregate slot code, add documentation

The default free-translated-object for foreign structures.  The code
for translating a structure with aggregate slots was wrong, because it
did not recognize an existing translator (e.g. complex), so it has
been removed.  Description in manual for defcfun and foreign-funcall
include structure-by-value call specification and requirements.

19 months agoRemove unneeded function
Liam M. Healy [Fri, 30 Sep 2011 21:34:39 +0000] 
Remove unneeded function

19 months agoNew function translation-forms-for-class
Liam M. Healy [Fri, 30 Sep 2011 14:48:53 +0000] 
New function translation-forms-for-class

New function translation-forms-for-class will generate two
defmethods, one for translate-from-foreign, and the other for
translate-into-foreign-memory, which specialize on the particular
type.  If the CL equivalent is defined to be a class, these methods do
the translation between CL object and foreign struct.

19 months agoFix description of file
Liam M. Healy [Fri, 30 Sep 2011 13:23:56 +0000] 
Fix description of file

19 months agoAggregate slot type translation, untested
Liam M. Healy [Fri, 30 Sep 2011 04:07:12 +0000] 
Aggregate slot type translation, untested

19 months agoDefault plist conversion of foreign structures
Liam M. Healy [Fri, 30 Sep 2011 03:14:10 +0000] 
Default plist conversion of foreign structures

Convert foreign structures from/to plists works with simple example
CFFI> (defparameter rc (convert-to-foreign '(r 7.0d0 c #C(2.0d0 3.0d0)) '(:struct real-and-complex)))
RC
CFFI> (convert-from-foreign rc '(:struct real-and-complex))
(C #C(2.0d0 3.0d0) R 7.0d0)

19 months agoPlist translators for structures
Liam M. Healy [Thu, 29 Sep 2011 03:53:44 +0000] 
Plist translators for structures

19 months agoMerge branch 'fsbv' of github.com:cffi/cffi into fsbv
Liam M. Healy [Tue, 27 Sep 2011 04:44:46 +0000] 
Merge branch 'fsbv' of github.com:cffi/cffi into fsbv

Conflicts:
fsbv/examples.lisp

19 months agoStructures by value in defcfun
Liam M. Healy [Tue, 27 Sep 2011 04:41:32 +0000] 
Structures by value in defcfun

Foreign functions defined through defcfun can have structures by value
arguments and/or return.

19 months agoMove recursive structure example to fsbv/examples.lisp
Liam M. Healy [Mon, 26 Sep 2011 14:16:33 +0000] 
Move recursive structure example to fsbv/examples.lisp

19 months agoSimplified ffcall-body-libffi (was callable-function)
Liam M. Healy [Mon, 26 Sep 2011 02:57:48 +0000] 
Simplified ffcall-body-libffi (was callable-function)

Removed duplicate translations to and from foreign, and changed
function bound to *foreign-structures-by-value* to only return the
body, not the entire lambda. Changed the call in foreign-funcall-form
to not apply to args, as there is already an applied lambda and
cleanup.  Funcation is now called ffcall-body-libffi, was
callable-function.

19 months agoCFFI-FSBV with foreign-funcall-pointer
Liam M. Healy [Mon, 26 Sep 2011 02:11:35 +0000] 
CFFI-FSBV with foreign-funcall-pointer

Structures by value should work with foreign-funcall-pointer, untested.

19 months agoFunctioning structure calls by value with foreign-funcall
Liam M. Healy [Sun, 25 Sep 2011 23:42:25 +0000] 
Functioning structure calls by value with foreign-funcall

1. Definition of test structure in GSL with (dat :double :count 2),
not two separate doubles.
2. When computing libffi-type-pointer, iterate through slots in
order.
3. When computing libffi-type-pointer, count the multiplicity of the
slot and set each; for aggregate slots, this can be greater than one.
4. The returned value from the callable-function is the result set by
the call to #'call.
5. This works correctly for the example definitions in
fsbv/examples.lisp using GSL.
CFFI(12): (foreign-funcall "gsl_complex_conjugate"
            (:struct complex-double) #C(3.0d0 4.0d0)
            (:struct complex-double))
#C(3.0d0 -4.0d0)
CFFI(13): (foreign-funcall "gsl_complex_abs"
            (:struct complex-double) #C(3.0d0 4.0d0) :double)
5.0d0

19 months agoFix and add example, quote args
Liam M. Healy [Sat, 24 Sep 2011 03:51:26 +0000] 
Fix and add example, quote args

Fix example gsl_complex_abs so that it has the right return type, add
example for gsl_complex_conjugate.  Error
Unhandled memory fault at #x7FFEFEA1EA10.
   [Condition of type SB-SYS:MEMORY-FAULT-ERROR]

20 months agoCFFI-FSBV, make the callable function, move example to fsbv
Liam M. Healy [Thu, 22 Sep 2011 03:51:25 +0000] 
CFFI-FSBV, make the callable function, move example to fsbv

Make the callable function incorrectly in fsbv, try on complex-double
example now in fsbv.

20 months agoUse a hash table keyed by foreign function name to save CIF
Liam M. Healy [Wed, 21 Sep 2011 03:35:02 +0000] 
Use a hash table keyed by foreign function name to save CIF

Save the libffi "CIF" (foreign structure with information prepared
about function) in a hash table keyed by the foreign function name; if
a function is in the hash table, it is retrieved on call to
#'prepare-function, otherwise it is generated, saved in the table, and
returned.  Information may be removed from the table with
#'unprepare-function.  Start writing #'callable-function which will
generate a lambda that can be called on Lisp arguments and calls
#'call with the CIF and the arguments.

20 months agoBetter use of prepare-function in foreign-funcall-form, still not correct
Liam M. Healy [Mon, 19 Sep 2011 04:29:00 +0000] 
Better use of prepare-function in foreign-funcall-form, still not correct

20 months agocffi-tests: use (:pointer (:struct foo)) in latest struct tests.
Luís Oliveira [Sun, 18 Sep 2011 19:45:25 +0000] 
cffi-tests: use (:pointer (:struct foo)) in latest struct tests.

20 months agoFix misplaced comma in foreign-funcall-form.
Luís Oliveira [Sun, 18 Sep 2011 19:39:57 +0000] 
Fix misplaced comma in foreign-funcall-form.

20 months agoAdd UNPARSE-TYPE method FOREIGN-STRUCT-TYPE.
Luís Oliveira [Sun, 18 Sep 2011 19:39:29 +0000] 
Add UNPARSE-TYPE method FOREIGN-STRUCT-TYPE.

Add respective struct tests, one of which fails. Also, missing union
tests.

20 months agocffi-fsbv: load trivial-features before DEFSYSTEM form is read.
Luís Oliveira [Sun, 18 Sep 2011 19:36:47 +0000] 
cffi-fsbv: load trivial-features before DEFSYSTEM form is read.

20 months agoSwitch order of defsystem depends per Luis
Liam M. Healy [Sun, 18 Sep 2011 04:06:27 +0000] 
Switch order of defsystem depends per Luis

20 months agoDefine libffi-type-pointer for enums
Liam M. Healy [Sun, 18 Sep 2011 03:35:34 +0000] 
Define libffi-type-pointer for enums