Subject: [clisp-list] c-ptr nil vs c-pointer and cparse/SWIG -> FFI calls

From: "Hoehle, Joerg-Cyril" <[email-masked]>
Date: Wed Apr 3 12:09:00 2002

Hi,
 
Dan Stanger wrote:
>My goal is to parse the cygwin win32 api headers and
> produce ffi calls for them
I think you cannot generate ffi:DEF-CALL forms without knowing about :in/:out (i.e. parameter modes) for each function, i.e. how it is to be used.

BTW, what did the creators of linux.lisp do? hand-edit each function?

Have you gained confidence (e.g. tested) that CLISP can indeed call win32?
From what I read, this needs the "stdcall" (= seems to be name for Pascal stack order) calling convention of which Sam recently said it was not really implemented (however src/foreign.d doesn't mention any incompleteness). I heard that most other .dll use the regular C calling convention, so you may try them first.

BTW, a truly dynamic FFI will be coming -- but don't hold your breath.

>I assumed that
>one could refer to a pointer to void by c-ptr nil.

C void is void, but C void* is more a notation (to me) than a pointer to nothing.
(FFI:C-PTR NIL) will not make you happy, as this pointer cannot be read or set and CLISP won't let you pass or receive arguments for this. It's definitely not what you want.

Look at the Common Lisp type hierarchy. NIL is at bottom and T at the top. C probably didn't want to spend another keyword. void is clearly NIL, but void* is akin to T - for pointer types.

CLISP has a very precise means of specifying foreign types. On the downside, precision is in the way of genericity (e.g. write(void* buf, size_t len) -> ?). E.g., you cannot use (:arguments (buf C-POINTER) #) when you need a string...

Regards,
	Jorg Hohle.

---

From: Sam Steingold <[email-masked]>
Date: Thu Apr 4 06:42:23 2002

> * In message <[email-masked]>
> * On the subject of "[clisp-list] c-ptr nil vs c-pointer and cparse/SWIG -> FFI calls"
> * Sent on Wed, 3 Apr 2002 11:17:51 +0200
> * Honorable "Hoehle, Joerg-Cyril" <[email-masked]> writes:
>
> From what I read, this needs the "stdcall" (= seems to be name for
> Pascal stack order) calling convention of which Sam recently said it
> was not really implemented (however src/foreign.d doesn't mention any
> incompleteness). I heard that most other .dll use the regular C
> calling convention, so you may try them first.

Bruno said that stdcall is not used anymore and may be removed.
I decided against removing.

-- 
Sam Steingold (http://www.podval.org/~sds) running RedHat7.2 GNU/Linux
Keep Jerusalem united! <http://www.onejerusalem.org/Petition.asp>
Read, think and remember! <http://www.iris.org.il> <http://www.memri.org/>
Lisp is a way of life.  C is a way of death.

---

From: Reini Urban <[email-masked]>
Date: Tue Apr 9 05:23:18 2002

> I decided against removing.

thanks. 
stdcall is the most often used calling convention nowadays (winapi).

sometimes the dictator is wrong.
-- 
Reini Urban
http://xarch.tu-graz.ac.at/home/rurban/