[mercury-users] C FFI for discriminated union types.
Julien Fischer
juliensf at csse.unimelb.edu.au
Sun Jun 19 21:53:29 AEST 2011
Hi,
On Sun, 19 Jun 2011, Guillaume Yziquel wrote:
> I am now concerned with the C foreign function interface, most notably
> concerning discriminated union types. I currently have the following
> type declaration:
>
> :- type term_def --->
> term_def(term) ;
> term_def_string(str) .
>
> And I am passing back values of this type to C code, and would ideally
> like to map them to an OCaml algebraic datatype. So I'd like to do the
> conversion in my C stub code.
>
> However, everything seems to be an MR_Word, and there isn't much
> structural type information for such discriminated datatypes available
> on the C side.
> So how should I deconstruct them? The reference guide is fairly
> explicit for C# and such, but not for C...
The data representation used for (non-enum) discriminated union types in
the C grades is lower level that used in the non-C grades and is not
very amenable to being manipulated in handwritten C code. I suggest
you consider doing at least some of the conversion in Mercury code.
Julien.
--------------------------------------------------------------------------
mercury-users mailing list
Post messages to: mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions: mercury-users-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the users
mailing list