<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<font face="Consolas">Hello Luis,<br>
<br>
Thank you for your reply!<br>
</font>
<pre wrap=""><font color="#000066" face="Consolas">>> (defcenum (:a 1) ... (:c #.(logior 1 2)) ...).</font></pre>
<font face="Consolas">My point regarding "enum" definition was
actually if it is<br>
possible to write down a definition of enum in CFFI without<br>
breaking the "abstraction". In the body of enum as you see <br>
there is an interdependency between the fields of enum <br>
being defined: the value of c depends on a and b and <br>
the value of d depends on c.<br>
<br>
<font color="#000066">>> but it has some limitations and
it's<br>
>> undocumented (see src/types.lisp).<br>
</font><br>
With that CFFI array type "<b><i>typedef char XXX[8]</i></b>"<br>
</font><font face="Consolas">can be translated now as "<i><b>(defctype
XXX (:array :char 8))</b></i>"!<br>
<br>
What are those limitations?<br>
<br>
Regards<br>
Nik</font>
<br>
<br>
On 03/07/2011 11:14 AM, Luís Oliveira wrote:
<blockquote
cite="mid:AANLkTikiV3+Bp_8dMjRr27V3M5MN4VBiQid4ZtgVRQrd@mail.gmail.com"
type="cite">
<pre wrap="">Hello Nik,
On Mar 2, 2011 6:01 PM, "nitralime" <a class="moz-txt-link-rfc2396E" href="mailto:nitralime@googlemail.com"><nitralime@googlemail.com></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hopefully here is the right place to ask CFFI user related questions.
What would be an appropriate CFFI definition for the following C entities?
1) typedef enum {
a = 0x01,
b = 0x02,
c = a | b,
d = 0x04 | c
} test;
</pre>
</blockquote>
<pre wrap="">
It's a bit cumbersome to express that with CFFI. Something like
(defcenum (:a 1) ... (:c #.(logior 1 2)) ...).
</pre>
<blockquote type="cite">
<pre wrap="">2) typedef char XXX[8];
How are the C arrays handled in CFFI?
</pre>
</blockquote>
<pre wrap="">
There are some array operations such as mem-aref, and you can allocate
them using foreign-alloc. defcstruct supports arrays via :count.
There's also an :array type that will convert C arrays to Lisp arrays,
but it has some limitations and it's
undocumented (see src/types.lisp).
HTH,
--
Luís Oliveira
<a class="moz-txt-link-freetext" href="http://r42.eu/~luis">http://r42.eu/~luis</a>
</pre>
</blockquote>
<br>
</body>
</html>