projects/cffi/cffi.git
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.

17 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.

18 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.

18 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]

19 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.

19 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

20 months agoFSBV calls in foreign-funcall-form
Liam M. Healy [Sun, 18 Sep 2011 03:07:01 +0000] 
FSBV calls in foreign-funcall-form

Check in foreign-funcall-form if arguments or return are foreign
structures by value, if they are, expand with
*foreign-structures-by-value* which will eventually call
prepare-function in CFFI-FSBV.

20 months agoFixes to libffi-type-pointer
Liam M. Healy [Sat, 17 Sep 2011 23:45:39 +0000] 
Fixes to libffi-type-pointer

20 months agoImplement (:STRUCT foo) and (:UNION foo) type parsing.
Luís Oliveira [Sat, 17 Sep 2011 23:12:26 +0000] 
Implement (:STRUCT foo) and (:UNION foo) type parsing.

:STRUCT and :UNION types live one their own namespaces (as in C) and this
supported by FIND-TYPE-PARSER itself. (Although one has to manually
implement parse methods for each namespace, as we did for :STRUCT and
:UNION.)

Bare FOO references are parsed to (:STRUCT foo) or (:POINTER (:STRUCT foo))
depending on context and signal a style warning about their deprecation.

Note that CANONICALIZE now returns a list like (:STRUCT/:UNION foo) for
struct/union types instead of always returning a keyword denoting a
built-in type.

Unions now have their own FOREIGN-UNION-TYPE, a subclass of
FOREIGN-STRUCT-TYPE.

20 months agoDefine prepare-function
Liam M. Healy [Sat, 17 Sep 2011 19:40:10 +0000] 
Define prepare-function

Define #'prepare-function which generates a form to make the
preparation and call into libffi.  The form looks correct but it has
not been tested yet.

20 months agogrovel: fix CVAR's Lisp-side expansion.
Luís Oliveira [Sat, 17 Sep 2011 15:02:10 +0000] 
grovel: fix CVAR's Lisp-side expansion.

Patch courtesy of pinterface. Fixes LP bug #852192.

20 months agoMake libffi-type-pointer a slot and method, define for built-in types
Liam M. Healy [Sat, 17 Sep 2011 14:52:10 +0000] 
Make libffi-type-pointer a slot and method, define for built-in types

1. Idea: Make a slot for libffi-type-pointer and define for all
built-in types, then define methods to make the pointer on demand for
other type classes.
2. Add slot [libffi-type-pointer] with generic function to defclass
foreign-type.
3. New file [built-in-types.lisp] defines all built-in types, and
libffi-type-pointer :around method for typedefs/aliases.
4. New [libffi-type-pointer :around method] for foreign-struct-type.
5. New lists exported from CFFI for possible other uses, and needed
here: *other-builtin-types* *built-in-integer-types*
*built-in-float-types*.

20 months agoDefine *built-in-foreign-types*
Liam M. Healy [Sat, 17 Sep 2011 03:27:52 +0000] 
Define *built-in-foreign-types*

20 months agoFunction integer-type-association
Liam M. Healy [Wed, 14 Sep 2011 03:28:42 +0000] 
Function integer-type-association

20 months agoSort out built-in types
Liam M. Healy [Tue, 13 Sep 2011 23:39:41 +0000] 
Sort out built-in types

20 months agoMerge branch 'fsbv' of github.com:cffi/cffi into fsbv
Liam M. Healy [Mon, 12 Sep 2011 03:34:19 +0000] 
Merge branch 'fsbv' of github.com:cffi/cffi into fsbv

20 months agoNew function cstruct-libffi-type-pointer
Liam M. Healy [Mon, 12 Sep 2011 03:33:42 +0000] 
New function cstruct-libffi-type-pointer

Created a function cstruct-libffi-type-pointer that generates the
libffi-type structure for any foreign structure type, so that this
structure may be used as an argument or return call by value to a
foreign function.  It replaces the automatic generation of this
structure when defstruct is compiled or loaded (via
*defcstruct-hook*), so that it is only made when needed and cffi-fsbv
need not be loaded when the defcstruct is compiled.  The structure
will only be made once; it is bound to the plist of the type symbol
(as before), and is reused if needed again.  This function compiles
but has not yet been tested.

20 months agoAdded tests for the translation of embedded structures.
Luís Oliveira [Sun, 11 Sep 2011 18:36:03 +0000] 
Added tests for the translation of embedded structures.

20 months agoExport {convert,translate,expand}-foreign-memory.
Luís Oliveira [Sun, 11 Sep 2011 18:34:48 +0000] 
Export {convert,translate,expand}-foreign-memory.

20 months agoDefine structure interface to libffi
Liam M. Healy [Sun, 11 Sep 2011 04:56:24 +0000] 
Define structure interface to libffi

Generic function translate-into-foreign-memory and funtion
convert-into-foreign-memory definitions now loaded by cffi.  System
cffi-fsbv defined for calling functions with foreign structures by
value using libffi.  Current state of this system is to make
libffi-type-pointer and associate with the structure in defcstruct.
This works on test structure
(macroexpand '(defcstruct (complex :class complex-type) (real :double) (imag :double)))
but nothing further is done with the libffi-type-pointer.

To do: fix lookup-type so that if there is no type defined, it returns
nil.  Do iterate-foreign-structure in advance of macro expansion in
cstruct-libffi-hook, if any arguments lack type translation, then
return nil.  This means that that structure can not be passed/returned
by value.  Then load cif after cstruct.  Secondary bug fix: defsynonym
'unsigned to something, not sure what it's supposed to be; :uint?

20 months agoExample definitions for complex and real-and-complex
Liam M. Healy [Sat, 10 Sep 2011 23:01:56 +0000] 
Example definitions for complex and real-and-complex

Remove all old example definitions, and replace with new ones
compatible with Luis' recent changes to CFFI.  Examples with complex
and real-and-complex as comments.  For now, macro
define-structure-conversion is commented out.

20 months agoTest cases for structures by hand
Liam M. Healy [Sat, 10 Sep 2011 18:33:33 +0000] 
Test cases for structures by hand

20 months agocffi-manual: fix secondary values in examples of CONVERT-{TO,FROM}-FOREIGN.
Luís Oliveira [Sat, 10 Sep 2011 16:31:45 +0000] 
cffi-manual: fix secondary values in examples of CONVERT-{TO,FROM}-FOREIGN.

20 months agogitignore *.xfasl
Luís Oliveira [Sat, 10 Sep 2011 16:26:56 +0000] 
gitignore *.xfasl

20 months agocffi-tests: fix duplicate test name.
Luís Oliveira [Sat, 10 Sep 2011 16:26:29 +0000] 
cffi-tests: fix duplicate test name.

20 months agoMake structures translatable when :class is specified.
Luís Oliveira [Sat, 10 Sep 2011 16:25:49 +0000] 
Make structures translatable when :class is specified.

Update STRUCT-VALUES.* tests.

20 months agoMove ENHANCED-FOREIGN-TYPE translatableness to TRANSLATABLE-FOREIGN-TYPE.
Luís Oliveira [Sat, 10 Sep 2011 16:23:53 +0000] 
Move ENHANCED-FOREIGN-TYPE translatableness to TRANSLATABLE-FOREIGN-TYPE.

20 months agobugfix: default EXPAND-TO-FOREIGN expansion was ignoring secondary value.
Luís Oliveira [Sat, 10 Sep 2011 16:00:57 +0000] 
bugfix: default EXPAND-TO-FOREIGN expansion was ignoring secondary value.

Said expansion breaks the protocol between TRANSLATE-TO-FOREIGN and
FREE-TRANSLATED-OBJECT.

This wasn't an issue when using EXPAND-TO-FOREIGN-DYN since it discards
the default expansion of EXPAND-TO-FOREIGN. Only CONVERT-OBJECT-FOREIGN
and DEFCALLBACK call EXPAND-TO-FOREIGN directly and the latter has to
discard the second value anyway.

20 months agoAdded new "Structure as Values" tests.
Luís Oliveira [Sat, 10 Sep 2011 13:24:14 +0000] 
Added new "Structure as Values" tests.

All fail but STRUCT-VALUES.TRANSLATION.1.

20 months agocffi-tests: remove bogus const qualifier in my_strfree().
Luís Oliveira [Fri, 9 Sep 2011 23:26:01 +0000] 
cffi-tests: remove bogus const qualifier in my_strfree().