So now I have "more or less compilable Felix" bindings to all of Posix.
It remains to do the ugly and hard bit: define the types,
and figure out the storage and access structure.

There is a "bug" in Felix that needs to be addressed. Since we don't have
a bug tracker at the moment, a note here:

AFAICR*,  Felix treats struct and cstruct the same, except it doesn't generate
a definition for a cstruct.

Unfortunately, there is a problem initialising cstructs. Structs are initialised
"in place" with a simple cheat:

        struct X { x:int; y:double; }; 
        var x = X(1,2.2);

Here an X is initialised with a tuple, which is done by *casting* the tuple.

The problem for cstructs is that this only works if the cstruct is fully 
populated.
If you leave out a field. the tuple and underlying C struct will not be layout
compatible and AHWBL**.

I need to make cstruct initialisation memberwise. This is particularly true
for Posix, since it only specifies what a vendor must include in a struct type,
it doesn't preclude addition of other fields.

Unfortunately it isn't trivial to do this. The method is:

* Make a C++ class from the C struct with an associated (but different) name.
* put the C struct in it as a member
* write a constructor that initialises it
* use the constructor to make the C struct, and cast the C++ away

Sounds bad, but actually this is how arrays are initialised :)


*AFAICR (as far as i can remember)
**AHWBL (all hell will break loose)

--
john skaller
skal...@users.sourceforge.net
http://felix-lang.org




------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to