Hi,

the structure is pretty simple :

// This is a STRUCT3
struct A {...}

struct B {
   enum {E1,E2} kind // ok for mapping enum
   union {
      int64_t ref ; // there was a discussion about int64 platform independant 
conversion. I just defined a Cint64_t as Clong
      struct A *a;
   } arg
}


As i explained, my problem is to differentiate int64_t from Cpointer Cstruct  
in my vol2enum function..


Cheers







Le Lundi 20 Août 2012 18:18 CEST, David Matthews 
<[email protected]> a écrit:

> On 20/08/2012 17:04, Gabriel Dos Reis wrote:
> > On Mon, Aug 20, 2012 at 10:27 AM, David Matthews
> > <[email protected]> wrote:
> >> On 20/08/2012 15:28, Pierre-Alain Bourdil wrote:
> >>>
> >>>
> >>> In ForeignTest, the vol2tree method use fromClong to differentiate
> >>> between NullTree, or Tree. My union, is made of 2 variants : a struct
> >>> pointer and a int64_t . I can't figure out how to decide if a given
> >>> vol is a pointer or an int64_t.  is there a solution ?   The inverse
> >>> conversion is pretty forward
> >>
> >>
> >> It's difficult to know what to do if you can't tell whether you have a
> >> number or the pointer to something.  Are you actually returning these sort
> >> of values from your C code to ML?  If not you can just use a dummy function
> >> that raises an exception in the conversion from a vol to the ML datatype.
> >>
> >> David
> >
> > I suspect Pierre-Alain is implicitly assuming that somehow PolyML uses
> > some form of low bits tag to differentiate whether an integer
> > bit-pattern (e.g. a
> > value of type intptr_t) is either a vol or an int64_t.  I suspect the
> > answer is no.
>
> Perhaps it would help if we could see the definition of the union type in C.
>
> David
> _______________________________________________
> polyml mailing list
> [email protected]
> http://lists.inf.ed.ac.uk/mailman/listinfo/polyml





_______________________________________________
polyml mailing list
[email protected]
http://lists.inf.ed.ac.uk/mailman/listinfo/polyml

Reply via email to