Hello,
Here's the Changelog for the new changes to my branch since my last update:
Fri Aug 26 15:47:08 WEST 2005 Luis Oliveira loliveira@common-lisp.net * Type system improvements and more.
- New tests: tests/enums.lisp (4 tests) and tests/misc-types.lisp (3 tests). - New file: objects.lisp, skeleton of the safe typed pointer interface. I also added a :boolean type here, it's looking for a better home still. - (early-types.lisp): type parsers, DEFINE-TYPE-SPEC-PARSER and PARSE-TYPE. Added abbility to have anonymous types (ie. a name is no longer required for FOREIGN-TYPE). Moved DEFCTYPE to types.lisp. - (enum.lisp): improved DEFCENUM, the values for each keyword are now optional, like in C. Added the anonymous type (:enum ...) - (types.lisp): - Renamed :TO-C-ARG to :TO-C-DYNAMIC. - Renamed FOREIGN-AREF to MEM-AREF and implemented compiler macros for it. - New exported macro: DEFINE-FOREIGN-TYPE for parameterized types. - Change DEFINE-TYPE-TRANSLATOR back to the previous interface, translators take aow and we have translators available at runtime now too. - FOREIGN-TYPEDEF's now inherit their parent type's translators. - New :wrapper type, for anonymous typedefs with translators. - (strings.lisp): Renamed string to :string. Added new type, :string+ptr. - (utils.lisp): renamed let-if to bif. - (tests/callbacks.lisp): two tests were not being run for SBCL because I thought it triggered a bug but it's actually only one that triggers the bug. Fixed that. - Updated examples and tests to use :string instead of string.
Sun Aug 21 14:35:13 WEST 2005 Luis Oliveira loliveira@common-lisp.net * A couple of minor changes.
- Move #-cffi/no-foreign-funcall from cffi-tests.asd to tests/funcall.lisp and have the lisps that don't support this push the feature in cffi-<lisp>.lisp instead of defpackage. - New file: utils.lisp - Make Allegro, CMUCL, Corman and OpenMCL use callback-symbol-name (from cffi-utils) to safely intern callback symbol. - Clisp: consider (pointerp NIL) => T
Thu Aug 11 05:43:53 WEST 2005 Luis Oliveira loliveira@common-lisp.net * Clisp: use FOREIGN-ADDRESS-NULL in NULL-PTR-P
Wed Aug 10 02:00:07 WEST 2005 Luis Oliveira loliveira@common-lisp.net * Lispworks: use :byte for cffi's :char types
What are the ramifications of the anonymous type stuff? In particular, does this mean that defctype behaves more like C's "typedef" (in that the source type doesn't yet need to be defined)? Could any of the new type system changes achieve that result? The dependence of defctype on having its source type already defined makes handling automatic declaration generation quite complicated in a lot of idiomatic C code. Since the dependence graph of C type definitions might have cycles, it becomes impossible to impose a total ordering on definitions. This isn't a problem when typedefs are fully resolved to their target types (as Verrazano does currently), but is a problem if you want the C-FFI binding to more closely resemble the C header file with regards to type naming.
On 8/26/05, Luis Oliveira luismbo@gmail.com wrote:
Hello,
Here's the Changelog for the new changes to my branch since my last update:
Fri Aug 26 15:47:08 WEST 2005 Luis Oliveira loliveira@common-lisp.net
- Type system improvements and more.
- New tests: tests/enums.lisp (4 tests) and tests/misc-types.lisp (3
tests).
- New file: objects.lisp, skeleton of the safe typed pointer
interface. I also added a :boolean type here, it's looking for a better home still.
- (early-types.lisp): type parsers, DEFINE-TYPE-SPEC-PARSER and
PARSE-TYPE. Added abbility to have anonymous types (ie. a name is no longer required for FOREIGN-TYPE). Moved DEFCTYPE to types.lisp.
- (enum.lisp): improved DEFCENUM, the values for each keyword are now
optional, like in C. Added the anonymous type (:enum ...)
- (types.lisp):
- Renamed :TO-C-ARG to :TO-C-DYNAMIC.
- Renamed FOREIGN-AREF to MEM-AREF and implemented compiler macros
for it.
- New exported macro: DEFINE-FOREIGN-TYPE for parameterized types.
- Change DEFINE-TYPE-TRANSLATOR back to the previous interface,
translators take aow and we have translators available at runtime now too.
- FOREIGN-TYPEDEF's now inherit their parent type's translators.
- New :wrapper type, for anonymous typedefs with translators.
- (strings.lisp): Renamed string to :string. Added new type,
:string+ptr.
- (utils.lisp): renamed let-if to bif.
- (tests/callbacks.lisp): two tests were not being run for SBCL
because I thought it triggered a bug but it's actually only one that triggers the bug. Fixed that.
- Updated examples and tests to use :string instead of string.
Sun Aug 21 14:35:13 WEST 2005 Luis Oliveira loliveira@common-lisp.net
- A couple of minor changes.
- Move #-cffi/no-foreign-funcall from cffi-tests.asd to
tests/funcall.lisp and have the lisps that don't support this push the feature in cffi-<lisp>.lisp instead of defpackage.
- New file: utils.lisp
- Make Allegro, CMUCL, Corman and OpenMCL use callback-symbol-name
(from cffi-utils) to safely intern callback symbol.
- Clisp: consider (pointerp NIL) => T
Thu Aug 11 05:43:53 WEST 2005 Luis Oliveira loliveira@common-lisp.net
- Clisp: use FOREIGN-ADDRESS-NULL in NULL-PTR-P
Wed Aug 10 02:00:07 WEST 2005 Luis Oliveira loliveira@common-lisp.net
- Lispworks: use :byte for cffi's :char types
-- Luís Oliveira http://student.dei.uc.pt/~lmoliv/ Equipa Portuguesa do Translation Project http://www2.iro.umontreal.ca/~pinard/po/registry.cgi?team=pt _______________________________________________ cffi-devel mailing list cffi-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/cffi-devel
On 26/ago/2005, at 23:06, Rayiner Hashem wrote:
What are the ramifications of the anonymous type stuff? In particular, does this mean that defctype behaves more like C's "typedef" (in that the source type doesn't yet need to be defined)?
Hmm, I was going to say no. But actually that'll work for DEFINE-FOREIGN-TYPE.
CFFI> (define-foreign-type foo () 'bar) FOO CFFI> (defctype bar :boolean) BAR CFFI> (translate-from-c 0 (parse-type 'foo)) NIL CFFI> (translate-from-c 666 (parse-type 'foo)) T
That won't work for types defined with DEFCTYPE because of some (premature?) optimizations though:
? (defctype foo unexistant-type)
Error in process listener(1): Unknown CFFI type: UNEXISTANT-TYPE.
This has nothing to do with anonymous types anyway.
Could any of the new type system changes achieve that result? The dependence of defctype on having its source type already defined makes handling automatic declaration generation quite complicated in a lot of idiomatic C code.
Use DEFINE-FOREIGN-TYPE instead of DEFCTYPE then, I'll remember to keep that feature when I refactor this stuff.
Since the dependence graph of C type definitions might have cycles, it becomes impossible to impose a total ordering on definitions. This isn't a problem when typedefs are fully resolved to their target types (as Verrazano does currently), but is a problem if you want the C-FFI binding to more closely resemble the C header file with regards to type naming.
Heh, I'm glad I helped then. My previous version of this type system didn't do that, but I noticed that it wouldn't always behave correctly because types defined with DEFINE-FOREIGN-TYPE can eventually resolve to different types depending on, say, its arguments.
(define-foreign-type type-picker (type-number) (case type-number (1 :int) (2 :float)))
(now this was a crappy example... Kenny I'll try to come up with better examples for the manual, heh. I'll probably search real life examples.)