Thu Dec 29 00:54:27 CET 2005 Luis Oliveira <loliveira(a)common-lisp.net>
* Document FOREIGN-SLOT-NAMES and FOREIGN-SLOT-OFFSET.
M ./TODO -1 +1
M ./doc/cffi-manual.texinfo -2 +95
M ./src/types.lisp -1 +1
Wed Dec 28 20:58:43 CET 2005 Luis Oliveira <loliveira(a)common-lisp.net>
* FOREIGN-SLOT-NAMES and FOREIGN-SLOT-OFFSET
- New functions: FOREIGN-SLOT-NAMES and FOREIGN-SLOT-OFFSET.
- Test FOREIGN-SLOT-NAMES: STRUCT.NAMES
- Removed respective TODO item and …
[View More]added a new one: document these.
M ./TODO -1 +1
M ./src/early-types.lisp +9
M ./src/package.lisp +2
M ./src/types.lisp -5 +10
M ./tests/struct.lisp +4
An updated tarball of CFFI's source can be downloaded here:
http://common-lisp.net/project/cffi/tarballs/cffi-051229.tar.gz
[View Less]
Wed Dec 28 16:15:36 CET 2005 Luis Oliveira <loliveira(a)common-lisp.net>
* Add some links to the TODO file.
M ./TODO -1 +4
Wed Dec 28 16:04:24 CET 2005 Luis Oliveira <loliveira(a)common-lisp.net>
* New TODO list and updated README.
- New file: TODO. 46 items!
- Removed the outdated paragraph about implementation support from
the README file.
M ./README -4
A ./TODO
An updated tarball of CFFI's source can be downloaded here:
http://common-lisp.net/project/cffi/tarballs/cffi-051228.tar.gz
Tue Dec 27 16:47:53 CET 2005 Luis Oliveira <loliveira(a)common-lisp.net>
* Fix compiler macros on foreign-slot-value/set
- foreign-struct-slot-value-form and foreign-struct-slot-set-form
were not quoting the type in the resulting mem-ref form.
- struct.5, regression test.
M ./src/types.lisp -2 +2
M ./tests/struct.lisp +13
An updated tarball of CFFI's source can be downloaded here:
http://common-lisp.net/project/cffi/tarballs/cffi-051227.tar.gz
Hi,
How do I call a function that expect char**?
I test it with
/** C Code */
#include <stdio.h>
void expect_charpp(char** buffs){
printf("I got %s and %s", buffs[0], buffs[1]);
}
;; Lisp side
(cffi:with-foreign-object (argv :pointer 2)
(setf (cffi:mem-ref argv :pointer 0)
(cffi:foreign-string-alloc "Hello"))
(setf (cffi:mem-ref argv :pointer 1)
(cffi:foreign-string-alloc "Hello"))
(cffi:foreign-funcall "expect_charpp" :pointer argv))
And I got a …
[View More]memory fault error in SBCL.
If i comment out the code in C to make it not accessing the data, it
won't err. So it looks like the error is in how I allocate the memory.
Please advice.
Pisin Bootvong,
[View Less]
Mon Dec 26 14:58:06 CET 2005 Luis Oliveira <loliveira(a)common-lisp.net>
* cffi-uffi-compat:allocate-foreign-object optimization
Convert TYPE to the equivalent UFFI type at macro-expansion time
when constant.
M ./uffi-compat/uffi-compat.lisp -1 +4
Mon Dec 26 14:53:22 CET 2005 Luis Oliveira <loliveira(a)common-lisp.net>
* Don't save (anonymous) parsed types in *foreign-types*
Don't save parsed types in the *foreign-types* hashtable. This
way they can be …
[View More]garbage collected and the hashtable won't grow
indefinitely.
Issue reported by Novikov Leonid <ln (at) bk.ru>
M ./src/early-types.lisp -3 +1
An updated tarball of CFFI's source can be downloaded here:
http://common-lisp.net/project/cffi/tarballs/cffi-051226.tar.gz
[View Less]
Hi all,
While working through my fancy gettimeofday CFFI example, I've added a
type translator used as the return type for standard C functions that
return a negative integer on error and set 'errno'.
Since errno is often a macro expanding to a function, I can't very well
define it as a foreign global. Most CL implementations seem to have a
function used internally to safely get errno for the current thread. I
propose adding such an interface to CFFI-SYS to safely get 'errno'.
Here's what …
[View More]I added to CFFI-SYS for SBCL:
(defun errno-value ()
(sb-alien:get-errno))
This should be equally simple for CMUCL, OpenMCL, and LispWorks. I
haven't found anything in Allegro CL or CLISP (Jörg?) for this yet.
I don't intend to do anything with the return value except call
'strerror' on it, since the values themselves are also defined as macros
and not introspectable from Lisp either...argh!
(I know errno isn't _completely_ portable---at least one OS I use
regularly, Windows CE, doesn't have it at all, even though some
functions are documented as setting it! I'm willing to put that off
until we run into the problem though...)
James
[View Less]
Fri Dec 23 16:35:00 CET 2005 James Bielman <jamesjb(a)jamesjb.com>
* remove bogus extra right parenthesis
M ./examples/gettimeofday.lisp -2 +2
Fri Dec 23 15:47:49 CET 2005 James Bielman <jamesjb(a)jamesjb.com>
* pull out and improve some cffi examples
M ./cffi-examples.asd -1 +3
M ./examples/examples.lisp -70 +1
A ./examples/gethostname.lisp
A ./examples/gettimeofday.lisp
Fri Dec 23 15:47:01 CET 2005 James Bielman <jamesjb(a)jamesjb.com>
* …
[View More]define type translators at compile time
M ./src/types.lisp -1 +1
Fri Dec 23 14:53:21 CET 2005 Joerg-Cyril Hoehle <hoehle(a)users.sourceforge.net>
* clisp %mem-set use unexported ffi::stuff to enforce left-to-right evaluation
M ./src/cffi-clisp.lisp -5 +3
Fri Dec 23 14:14:08 CET 2005 Joerg-Cyril Hoehle <hoehle(a)users.sourceforge.net>
* more tests: verify left to right evaluation rule
M ./tests/memory.lisp +18
Fri Dec 23 14:13:05 CET 2005 Joerg-Cyril Hoehle <hoehle(a)users.sourceforge.net>
* precision of wording (offset in bytes) & typo
M ./doc/cffi-manual.texinfo -1 +1
M ./doc/cffi-sys-spec.texinfo -1 +1
M ./src/types.lisp -2 +2
Fri Dec 23 13:37:12 CET 2005 Joerg-Cyril Hoehle <hoehle(a)users.sourceforge.net>
* clisp: (setf %mem-ref) is gone, optimize %mem-set
M ./src/cffi-clisp.lisp +10
Fri Dec 23 13:35:49 CET 2005 Joerg-Cyril Hoehle <hoehle(a)users.sourceforge.net>
* with-foreign-object: optimize constant type case + use eval
M ./src/types.lisp -6 +7
Fri Dec 23 12:33:30 CET 2005 James Bielman <jamesjb(a)jamesjb.com>
* inform rt of expected test failures under openmcl
M ./tests/callbacks.lisp +3
M ./tests/foreign-globals.lisp +2
Fri Dec 23 12:35:23 CET 2005 James Bielman <jamesjb(a)jamesjb.com>
* macrology to OAOO definition of %MEM-REF and %MEM-SET
M ./src/cffi-cmucl.lisp -74 +42
M ./src/cffi-openmcl.lisp -94 +44
M ./src/cffi-sbcl.lisp -75 +42
Fri Dec 23 12:08:05 CET 2005 James Bielman <jamesjb(a)jamesjb.com>
* export %MEM-SET from cffi-sys and use instead of (SETF %MEM-REF)
M ./src/cffi-allegro.lisp -1 +3
M ./src/cffi-clisp.lisp -1 +2
M ./src/cffi-cmucl.lisp -25 +2
M ./src/cffi-corman.lisp -1 +3
M ./src/cffi-ecl.lisp -1 +2
M ./src/cffi-gcl.lisp -1 +3
M ./src/cffi-lispworks.lisp -1 +2
M ./src/cffi-openmcl.lisp -25 +2
M ./src/cffi-sbcl.lisp -25 +2
M ./src/strings.lisp -2 +3
M ./src/types.lisp -3 +3
Fri Dec 23 10:12:03 CET 2005 Luis Oliveira <loliveira(a)common-lisp.net>
* uffi-compat optimization on deref-array
Determine the element type at macro-expansion time when
the array type is constant.
M ./uffi-compat/uffi-compat.lisp -3 +6
Fri Dec 23 10:11:39 CET 2005 Luis Oliveira <loliveira(a)common-lisp.net>
* Free old callbacks on clisp.
M ./src/cffi-clisp.lisp +3
Fri Dec 23 11:21:06 CET 2005 Luis Oliveira <loliveira(a)common-lisp.net>
* Revert brainfart. What missing value?
M ./src/types.lisp -1 +1
Fri Dec 23 11:17:48 CET 2005 Luis Oliveira <loliveira(a)common-lisp.net>
* Fix conflict and missing "value". Oops.
M ./src/types.lisp -4 +4
Thu Dec 22 16:13:02 CET 2005 Joerg-Cyril Hoehle <hoehle(a)users.sourceforge.net>
* fix foreign-struct-set-form & enable foreign-slot-set optimization
M! ./src/types.lisp -8 +6
Thu Dec 22 15:19:31 CET 2005 Joerg-Cyril Hoehle <hoehle(a)users.sourceforge.net>
* clisp: inline %mem-ref when given constant type
M ./src/cffi-clisp.lisp +6
Thu Dec 22 15:15:06 CET 2005 Joerg-Cyril Hoehle <hoehle(a)users.sourceforge.net>
* fix foreign-struct-*-form thus enable foreign-slot-value optimization
M ./src/types.lisp -5 +3
Fri Dec 23 02:43:50 CET 2005 James Bielman <jamesjb(a)jamesjb.com>
* fix bugs in example implementation of mem-vector functions
M ./doc/mem-vector.txt -3 +4
[View Less]
Hi all,
I've done yet-another rewrite of the type translator interface. It does
everything through generic functions at run-time, which allows us to
specialize on both the Lisp object being converted, and the foreign type
we are converting to.
DEFINE-TYPE-TRANSLATOR is gone---instead you simply specialize the
generic functions as needed. For example (taken from
examples/gettimeofday.lisp):
;; A NULL-POINTER is a :POINTER that must always be NULL.
(defctype null-pointer :pointer)
;…
[View More]; Translator that ensures VALUE is a null pointer. NIL is
;; also converted to a null pointer for convenience.
(defmethod translate-to-foreign (value type (name (eql 'null-pointer)))
(declare (ignore type name))
(cond
((null value) (null-pointer))
((null-pointer-p value) value)
(t (error "~A is not a null pointer." value))))
This method on TRANSLATE-TO-FOREIGN replaces the :TO-C case of
DEFINE-TYPE-TRANSLATOR. Specializing the other GFs is similar---I've
also added a FREE-TRANSLATED-OBJECT generic function.
There isn't yet a mechanism for optimizing the case where we are
converting a Lisp object to a C object with dynamic extent---I will add
this next, with some sort of compiler-macro-like interface.
The branch can be downloaded via:
darcs get http://slacknet.com/~jamesjb/cffi-new-translators
Please give it a spin and let me know what you think! Documentation
updates coming soon...
James
[View Less]