|
:malloc-free allocation (was: FFI guru/wizard award to be rewarde d): msg#00071lisp.clisp.general
Hoehle, Joerg-Cyril writes: > >I also wrote a thin C wrapper around DB functions, since it is > Do you believe you would have written a CLISP module if you > had known about my article earlier? well, I have written a module! > One of my points is that writing FFI+C code is half the way of a > writing module, *and* writing modules prevents you from the > CAST/TYPECASE madness. why? OK, if it is explained in your article I'll try to find it. > OTOH, you need to be more confident with CLISP's C-level functions, > e.g. allocate_string() etc. which are not documented :( > >impossible to use DB structure and its function pointers from Lisp: > I guess one of your points is that the functions to be called are > like db->get(), i.e. there's nothing with a fixed name like > "BDB_get()". This looks like instance methods -- not impossible, > but possibly impractical. I never thought about these, but they > are conceptually close to shared-library functions: they hang of > the library, here the DB pointer. > > Is there anything else which makes you feel that it's impossible? no. Initially my idea was to define a Lis DB type using def-c-struct and faithfully translate all the C struct members into Lisp slots. A nightmare: DB has tens of members! Furthermore, it is probably better to keep DB and other BDB C structures opaque to Lisp. There is no need to make implementation details, such as structure members, available at Lisp level. > Why don't you use something along > (typecase > ((unsigned-int 32) > (values 'int/uint32 (FFI:sizeof 'int-or-uint32)) > ((signed-int 32) (values 'sint32 (sizeof 'sint32)) > ... Constant-folding by hand? > Fixnum can be pretty small (i.e. only 24 bits). yes, I know. I'm going to add more integer subtypes later. ------------------------------------------------------- This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger for complex code. Debugging C/C++ programs can leave you feeling lost and disoriented. TotalView can help you find your way. Available on major UNIX and Linux platforms. Try it free. www.etnus.com |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | :malloc-free allocation -- here: instance methods: 00071, Aurelio Bignoli |
|---|---|
| Next by Date: | Re: New, from-scratch implementation of backquote.: 00071, Kaz Kylheku |
| Previous by Thread: | :malloc-free allocation (was: FFI guru/wizard award to be rewarde d)i: 00071, Hoehle, Joerg-Cyril |
| Next by Thread: | :malloc-free allocation -- here: instance methods: 00071, Hoehle, Joerg-Cyril |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |