Re: Re: Problems with FFI
Chris Double <[email protected]> Tue, 8 Apr 2003 02:00:56 +1200
| Newsgroups | gmane.lisp.corman |
|---|---|
| Organization | none |
| Message-ID | <[email protected]> |
On Tue, 08 Apr 2003 01:43, goobamarino wrote:
> So if I see ** in the function prototype I declare TYPEBLAH* and if I
> see * in the function prototype I declare TYPEBLAH.
Yes, so your lisp code will look like:
> void call_some_func(TYPEBLAH** yourNumber);
>
> TYPEBLAH *pblah;
> call_some_func(&pblah);
(let ((ppTYPEBLAH (malloc (sizeof '(TYPEBLAH *)))))
(setf (cref (TYPEBLAH *) ppTYPEBLAH 0) null)
(call-some-func ppTYPEBLAH))
To get the pointer value that the function stored in your pp variable:
(let ((pTYPEBLAH (cref (TYPEBLAH *) ppTYPEBLAH 0)))
..)
And the following:
> void call_some_func(long* yourNumber);
> TYPEBLAH blah = 0;
> call_some_func(&blah);
Becomes
(let ((pTYPEBLAH (malloc (sizeof 'TYPEBLAH))))
(setf (cref TYPEBLAH pTYPEBLAH some_struct_field) some_value)
(call-some-func pTYPEBLAH))
To get access to the fields of the structure stored inthe p variable:
(let ((value (cref TYPEBLAH ppTYPEBLAH some_struct_field)))
..)
Cheers,
Chris.
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get 128 Bit SSL Encryption!
http://us.click.yahoo.com/xaxhjB/hdqFAA/VygGAA/SyjtlB/TM
---------------------------------------------------------------------~->
To unsubscribe from this group, send an email to:
[email protected]
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/