projects/gsll/fsbv.git
2 months agoMark FSBV as obsolete master
Liam M. Healy [Wed, 27 Feb 2013 06:46:03 +0000] 
Mark FSBV as obsolete

21 months agoPush name onto *converter-types* in expanded form
Liam M. Healy [Fri, 19 Aug 2011 02:57:30 +0000] 
Push name onto *converter-types* in expanded form

Push the name of the structure onto *converter-types* in defconvert in
the macroexpansion so that when the expanded form is run,
*converter-types* will be correct.  Previously, it only pushed the
name at macroexpand time, so that the converter was known only in
sessions which included compilation.

2 years agoSplit init.lisp into pkgdcl.lisp and init.lisp
Liam M. Healy [Tue, 30 Nov 2010 17:35:15 +0000] 
Split init.lisp into pkgdcl.lisp and init.lisp

Split init.lisp into pkgdcl.lisp and init.lisp in preparation for
splitting them into separate systems; convert.lisp does not require a
foreign library (e.g. libffi) to load.

2 years agoConversion between foreign and CL objects in its own file
Liam Healy [Sun, 28 Nov 2010 03:45:06 +0000] 
Conversion between foreign and CL objects in its own file

There is a new file, convert.lisp, which now contains all of the
definitions needed to define new foreign structures and convert
between pointers to them and CL objects.  This file does not depend on
anything else in FSBV, nor does its use depend on having any foreign
library.

2 years agoAccept an index to foreign-object-components and its setf
Liam M. Healy [Thu, 8 Jul 2010 13:27:59 +0000] 
Accept an index to foreign-object-components and its setf

The index argument to the set and get of foreign-object-components was
previously ignored.  It is now used; this permits getting and setting
vectors of foreign structs.

2 years agoDon't make a defun if the function name is apparently uninterned
Liam M. Healy [Fri, 11 Jun 2010 15:31:13 +0000] 
Don't make a defun if the function name is apparently uninterned

3 years agoAdd "Installation note" about lost header files 0.2
Liam Healy [Mon, 19 Oct 2009 02:55:33 +0000] 
Add "Installation note" about lost header files

Add advice to those trying to get FSBV and cffi-grovel to find their
ffi.h when it's not installed in a place that cffi-grovel
automatically search.

3 years agoHandle conditional cflags in the grovel file
Liam Healy [Sun, 23 Aug 2009 13:57:51 +0000] 
Handle conditional cflags in the grovel file

Handle conditional cflags in the grovel file instead of modifying the
cffi-grovel::*cc-flags* variable.  Also use strings for dependencies.
Patch by Stelian Ionescu.

3 years agoAdd include path for OSX
Liam Healy [Sat, 22 Aug 2009 20:25:37 +0000] 
Add include path for OSX

Darwin ports installs .h files under /opt/local/include/, so put -I
option onto cffi-grovel::*cc-flags*.

3 years agoRemove non-existent cbuiltin
Liam Healy [Wed, 19 Aug 2009 02:28:50 +0000] 
Remove non-existent cbuiltin

The C builtin :uint (ffi_type_uint) doesn't exist, so it has been
removed.  Compilation problem noted by David A. Ventimiglia, patch
created by Juan Jose Garcia-Ripoll.

4 years agoDirect get/set simple structure slots
Liam Healy [Tue, 19 May 2009 18:40:55 +0000] 
Direct get/set simple structure slots

For simple foreign structure slots (specified without :count), the
value of the object is returned or set directly, without using
#'object or #'(setf object); these are used for aggregate slots.  See
http://common-lisp.net/project/cffi/manual/html_node/foreign_002dslot_002dvalue.html#foreign_002dslot_002dvalue.
Now defcstruct expands so that simple slots do not have the (object
...) form wrapping them.  Aggregate slots still expand with the
wrapping.

4 years agoAdd support for OS X
Liam Healy [Tue, 12 May 2009 19:31:41 +0000] 
Add support for OS X

Compile on Apple with libffi.dylib and ffi.h installed by OS X.

4 years agoFunction defined-type-p
Liam Healy [Mon, 4 May 2009 02:22:25 +0000] 
Function defined-type-p

Function defined-type-p renamed from user-defined and exported,
returns true if the argument names a structure that has been defined
using fsbv:defcstruct.

4 years agoBreak out defcfun-args-from-ff-args as a separate function 0.1
Liam Healy [Sun, 3 May 2009 20:39:09 +0000] 
Break out defcfun-args-from-ff-args as a separate function

Break out defcfun-args-from-ff-args as a separate function, and export
it, because it's useful for GSLL and maybe other users as well.

4 years agoAdd :fsbv to *features*, rename/export error
Liam Healy [Sun, 3 May 2009 16:14:34 +0000] 
Add :fsbv to *features*, rename/export error

Added :fsbv to *features* for convience in compiling dependent code.
Error for an function preparation failure changed to
'foreign-function-not-prepared from 'libffi-not-prepared, and the
symbol is now exported.

4 years agoFix HTML fomatting
Liam Healy [Sun, 3 May 2009 02:41:24 +0000] 
Fix HTML fomatting

Fix HTML fomatting in readme.html so it looks right on gitweb.

4 years agoDefine :void type
Liam Healy [Sun, 3 May 2009 02:33:51 +0000] 
Define :void type

Restore definition of :void type in the defcbuiltin mechanism.

4 years agoSave prepared function; defcfun
Liam Healy [Sun, 3 May 2009 01:00:20 +0000] 
Save prepared function; defcfun

The function prepared for libffi is now saved by defcfun; this will
be reused either in calls to the defined function or in calls to
foreign-funcall when passed a symbol for the function name, as opposed
to a string, which will cause a re-preparation on each invocation.

4 years agoReturned foreign structures converted to Lisp
Liam Healy [Sat, 2 May 2009 18:33:17 +0000] 
Returned foreign structures converted to Lisp

Foreign structures that are returned by the foreign function are
automatically converted to a Lisp object using #'object, so this need
not be applied separately.  This also means that normally #'object and
#'(setf object) won't be needed directly, but they are used
internally.  The symbols are still exported for the convenience of
users.  Updated documentation and examples.

4 years agoDefine built-in types with defcbuiltin
Liam Healy [Sat, 2 May 2009 18:10:56 +0000] 
Define built-in types with defcbuiltin

Define the CFFI built-in types using a new macro defcbuiltin in a new
file cbuiltin.lisp.  This unifies the setting of the
libffi-type-pointer with that of foreign-object-components and
setf-foreign-object-components, as has been done in defcstruct for
user definitions.

4 years agoEnumerations and synonyms
Liam Healy [Thu, 30 Apr 2009 02:48:04 +0000] 
Enumerations and synonyms

Define enumerations to FSBV with defcenum-aux and synonyms for known
types with defsynonym.

4 years agoMore specific errors
Liam Healy [Tue, 28 Apr 2009 02:56:19 +0000] 
More specific errors

Errors are now signalled in #'object and #'(setf object) if there is
no function defined for converting the object to or from foreign,
i.e., from a fsbv:defcstruct.  Made a condition 'libffi-not-prepared
to be signalled in #'libffi-function-wrapper.

4 years agoUse structure slot name from defcstruct
Liam Healy [Sat, 25 Apr 2009 21:14:01 +0000] 
Use structure slot name from defcstruct

In expansion for 'foreign-object-components and
'setf-foreign-object-components, read the structure slot name from the
defcstruct, rather than the hardwired structure slot name 'dat which
was left over from the complex number example.  There is a potential
inefficiency now in the expansion because the pointer to the first
element of the filed is recomputed for each one; comment added to the
top of the file.

4 years agoMacro with-foreign-objects, functions object and (setf object)
Liam Healy [Sun, 19 Apr 2009 03:05:08 +0000] 
Macro with-foreign-objects, functions object and (setf object)

The macro with-foreign-objects works like CFFI's except that it takes
an optional initial-value argument, which it uses to initialize the
foreign object.  The functions object and (setf object) (renamed from
foreign-object-components) gets and sets respectively the foreign
object to/from a Lisp object.  The example and readme.html have been
updated to reflect the current state of the code.

4 years agoArgs :constructor, :deconstructor to defcstruct name-and-options
Liam Healy [Sat, 18 Apr 2009 22:10:17 +0000] 
Args :constructor, :deconstructor to defcstruct name-and-options

In defcstruct, you may supply :constructor (default 'list) and
:deconstructor (default 'elt) that will assemble or disassemble a CL
object from the pieces in the foreign struct, respectively.  The
deconstructor can be a symbol (as in the default value), in which case
each component is extracted by calling that function with the object
and then a sequence number, e.g. (elt foreign-struct 2), or it may be
a list of symbols, in which case each component is extracted by apply
each function in succession.  The example of complex numbers has been
updated.

4 years agoFix example in readme.html
Liam Healy [Fri, 17 Apr 2009 17:37:41 +0000] 
Fix example in readme.html

Update example in readme.html to use new examples.

4 years agoExpand foreign-object-components in defcstruct
Liam Healy [Fri, 17 Apr 2009 17:32:06 +0000] 
Expand foreign-object-components in defcstruct

#'defcstruct now expands foreign-object-components and (setf
 foreign-object-components) definitions.  Replaced the example
 definitions using new macros with-complex-input and complex-return
 that expand to these functions.  Split cstruct and function
 definitions out of interface.lisp into two different files.

4 years agoForeign struct accessor foreign-object-components
Liam Healy [Fri, 17 Apr 2009 02:56:24 +0000] 
Foreign struct accessor foreign-object-components

Defined functions
#'foreign-object-components
#'(setf foreign-object-components)
and a macro def-foc-direct that defines for built-in types like
:double, :int.  These functions read and write a foreign object from
the pointer.  Hand-wrote an interface to complex, but this should
eventually be part of the defcstruct macro expansion.

4 years agoUse macros in readme.html
Liam Healy [Mon, 13 Apr 2009 18:14:22 +0000] 
Use macros in readme.html

The macros introduced into examples.lisp are also be used in
readme.html.

4 years agoUse macros in examples
Liam Healy [Mon, 13 Apr 2009 18:07:26 +0000] 
Use macros in examples

New macros foreign-realpart, foreign-imagpart to access the real or
imaginary parts of the foreign structure make the code a little
cleaner.

4 years agoAdded two more examples
Liam Healy [Mon, 13 Apr 2009 02:23:40 +0000] 
Added two more examples

Add an example of two structs in, and a struct return (#'complex-add)
and a struct and a non-struct in, and a struct return
(#'complex-add-real), illustrating the need to pass every argument by
reference, including the :double.

4 years agoPermit :void return type by not making or referencing such an object
Liam Healy [Sun, 12 Apr 2009 02:28:54 +0000] 
Permit :void return type by not making or referencing such an object

Added (libffi-type-pointer :void) and modify libffi-function-wrapper
to avoid generating a 'result if the return type is :void.

4 years agoComment out examples
Liam Healy [Sat, 11 Apr 2009 20:35:35 +0000] 
Comment out examples

The example file depends on the GSL libraries being present; comment
out in the asd file so those without the libraries installed can still
load fsbv.

4 years agoFix .asd
Liam Healy [Sat, 11 Apr 2009 20:06:21 +0000] 
Fix .asd

Fixed license reference in asd file to refer to readme.html, which is
a verbatim copy of CFFI's license.

4 years agoAdd foreign-funcall and readme.html
Liam Healy [Sat, 11 Apr 2009 19:43:43 +0000] 
Add foreign-funcall and readme.html

New macro fsbv:foreign-funcall with the same arguments as
cffi:foreign-funcall works and used in examples.  Created a
readme.html showing examples.

4 years agoUsing libffi-function-wrapper in examples
Liam Healy [Sat, 11 Apr 2009 16:59:59 +0000] 
Using libffi-function-wrapper in examples

Examples are simplified greatly using libffi-function-wrapper, and
work as before.

4 years agoStarted libffi-function-wrapper
Liam Healy [Fri, 10 Apr 2009 03:00:26 +0000] 
Started libffi-function-wrapper

Macro libffi-function-wrapper will make the necessary libffi
structures and call the prep function.  Does not work yet.

4 years agoAll libffi types are obtained by libffi-type-pointer
Liam Healy [Fri, 10 Apr 2009 02:39:51 +0000] 
All libffi types are obtained by libffi-type-pointer

Replaced the defvars of +pointer-type-...+ with use of
libffi-type-pointer.

4 years agoFix missing null pointer
Liam Healy [Fri, 10 Apr 2009 02:15:55 +0000] 
Fix missing null pointer

In #'defcstruct, the last element in the list of elements needs to be
a null pointer.  Its absence caused strange memory problems in SBCL
when run from SLIME.  This is now fixed.

4 years agoNew macro defcstruct
Liam Healy [Thu, 9 Apr 2009 04:43:17 +0000] 
New macro defcstruct

Introduce new macro fsbv:defcstruct which expands to cffi:defcstruct
and a form that bind the symbol property 'type-pointer to the libffi
structure.  This means that to define a new structure that can be
passed to and returned from a foreign function, the user need only
declare with fsbv:defcstruct, whose syntax is identical to
cffi:defcstruct.  The example structure 'complex is now defined this
way, and the example functions work.  Several very small files have
now been consolidated into two files init.lisp and defs.lisp.

4 years agoStart interface; don't use package cffi
Liam Healy [Wed, 8 Apr 2009 02:55:56 +0000] 
Start interface; don't use package cffi

Macros in interface will mimic CFFI macros.  Added explicit package
names to all CFFI usage, and no longer use the package.

4 years agoExamples now in separate file; comments added
Liam Healy [Wed, 8 Apr 2009 02:22:58 +0000] 
Examples now in separate file; comments added

Moved examples to examples.lisp from functions.lisp, cleaned up, and
added comments to explain the examples.

4 years agoSuccessful pass and return of struct to foreign function
Liam Healy [Wed, 8 Apr 2009 02:09:24 +0000] 
Successful pass and return of struct to foreign function

New function #'complex-in-out uses GSL's gsl_complex_conjugate to take
and return a complex number:
FSBV> (complex-in-out #C(3.0d0 2.0d0))
#C(3.0 -2.0)
FSBV> (complex-in-out #C(12.0d0 4.0d0))
#C(12.0 -4.0)

4 years agoSuccessful passing of struct to foreign function
Liam Healy [Wed, 8 Apr 2009 01:55:19 +0000] 
Successful passing of struct to foreign function

Based on GSL's definition of a complex as
typedef struct
  {
    double dat[2];
  }
gsl_complex;
I have defined defcstruct to match, defined the interface to
gsl_complex_abs, and can successfully call compute the absolute value
(magnitude) of complex numbers:
FSBV> (test-call #C(1.0d0 2.0d0))
2.23606797749979
FSBV> (test-call #C(3.0d0 4.0d0))
5.0

4 years agoDefine prep-cif and call; tested prep-cif
Liam Healy [Tue, 7 Apr 2009 03:55:28 +0000] 
Define prep-cif and call; tested prep-cif

Define CFFI interfaces to libffi #'prep-cif and #'call.  Define
constants representing libffi types in ffi.h using the groveller as
+type-...+.  Rename symbols in types.lisp to +size-...+ that are read
from the library to free up those symbol names and be more
descriptive.

4 years agoChange types
Liam Healy [Sun, 5 Apr 2009 03:08:47 +0000] 
Change types

Change types to :int from :pointer, define +pointer-type-*+ variables.

4 years agoDefine package, all grovel types; load libffi; define structs
Liam Healy [Mon, 23 Feb 2009 03:30:00 +0000] 
Define package, all grovel types; load libffi; define structs

Define the :fsbv package.  Define types that are defined in the
library.  Define structs: ffi-type (ffi_type) is defined using the
groveller because it has a name after the "typedef struct" in ffi.h;
ffi-cif (ffi_cif) is defined by hand in structs.lisp because it
doesn't, so gcc can't handle it.  Everything compiles and load in
linux/amd64.

4 years agoSet up CFFI-grovel definitions for libffi
Liam Healy [Sun, 22 Feb 2009 14:54:21 +0000] 
Set up CFFI-grovel definitions for libffi

Define foreign constants and types by imitation of iolib definitions.
Untested.