FFI questions 
Author Message
 FFI questions

I've made quite a bit of progress on Pidgin in the past day, and
*might* be approaching something workable. I just have a few questions
about FFI.

First, how are arrays represented? How would I do:

char foo[10];

Are they just pointers, or is there more to them than that?

Second, how are enums and bitfields handled?

And, when subtyping, how do I create pointer designator classes? If I
do:

define C-subtype <nothing> (<C-void>) end;

is it then just a matter of doing:

define C-subtype <nothing*> (<C-void*>) end;

or is there more?

And, assuming I can tackle these issues, are there any Fun-O users who
would be interested in helping me tackle the portability issues, as
well as actually testing the produced FFI, since all I can do locally
is eyeball it for obvious mistakes? Portability should be rather
clean; my only concern is locating standard include files under
windows compilers..

Thanks.



Tue, 05 Nov 2002 03:00:00 GMT  
 FFI questions

Quote:

> Second, how are enums and bitfields handled?

Enums can be mapped to constants. Or maybe to a one-of()
definition. I'm not sure what the standard approach is.

Bitfields are described in section 1.6.3 of the C-FFI and Win32
Reference for Functional Developer. It talks about the 'slot' accessor
of a c-struct:

  "A slot-spec has the following syntax:

  [slot-adjective] slot getter-name :: c-type #key setter
  address-getter c-name length width

  The slot-adjective can be either array or bitfield. The array slot
  adjective indicates that the slot is repeated and the dimensions
  option is used to indicate how many repetitions are defined, and how
  it is accessed. The bitfield slot adjective indicates that the slot
  is really a bitfield. If bitfield is given then the width option
  must also be given. The c-type given for a bitfield slot must be an
  integer designator. The c-type for a bitfield slot indicates how the
  value is interpreted in Dylan by the slot accessor. A slot may not
  be specified as both an array and a bitfield."

Quote:
> And, when subtyping, how do I create pointer designator classes?

Have a look at section 1.6.1 of the C-FFI reference. There is a
'pointer-type-name' option you can pass to define c-subtype:

  define C-struct <_Matrix-struct>
    slot rank :: <C-int>;
    slot dimensions :: <C-int*>;
    slot values :: <C-int*>;
    pointer-type-name: <_Matrix-struct*>;
  end C-struct;

Quote:
> And, assuming I can tackle these issues, are there any Fun-O users who
> would be interested in helping me tackle the portability issues, as
> well as actually testing the produced FFI, since all I can do locally
> is eyeball it for obvious mistakes? Portability should be rather
> clean; my only concern is locating standard include files under
> windows compilers..

I'd be happy to test anything that you produce. I'm love to see a
working Pidgin!

Chris.
--
http://www.double.co.nz/dylan



Wed, 06 Nov 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Fun-O Win32 FFI Question

2. c-ffi question involving c-struct

3. C FFI question

4. FFI question #2: Getting the address of a C function

5. FFI question: Setting array elements

6. FFI Question

7. ACL FFI question

8. FFI question in ACL/W 2.0

9. C-FFI: GC questions, wchar_t, Melange redesign

10. C-FFI: GC questions, wchar_t, Melange redesign

11. FFI survey for smalltalk

12. portable FFI representation

 

 
Powered by phpBB® Forum Software