* [Caml-list] Quick question - accessing variant value from C
@ 2001-03-29 5:48 David Fox
2001-03-29 7:54 ` Jean-Christophe Filliatre
0 siblings, 1 reply; 3+ messages in thread
From: David Fox @ 2001-03-29 5:48 UTC (permalink / raw)
To: caml-list
I have a value of the following type being passed to an external:
type pointer = Null | Address of string
and I'd like to determine (in the C code) which variant the value is
and get the pointer to the string. I've stared at mlvalues.h for a
while, but I can't really figure it out. Can anyone help? You won't
regret it...
-------------------
To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] Quick question - accessing variant value from C
2001-03-29 5:48 [Caml-list] Quick question - accessing variant value from C David Fox
@ 2001-03-29 7:54 ` Jean-Christophe Filliatre
2001-03-29 8:36 ` Sven LUTHER
0 siblings, 1 reply; 3+ messages in thread
From: Jean-Christophe Filliatre @ 2001-03-29 7:54 UTC (permalink / raw)
To: David Fox; +Cc: caml-list
Hi,
You can use the macros Is_long / Is_block to discriminate between Null
and Address, since the first one is represented as an integer and the
second one as a structured block (in the later case, you can then
access the string with the Field macro).
Hope this helps,
--
Jean-Christophe FILLIATRE
mailto:Jean-Christophe.Filliatre@lri.fr
http://www.lri.fr/~filliatr
David Fox writes:
> I have a value of the following type being passed to an external:
>
> type pointer = Null | Address of string
>
> and I'd like to determine (in the C code) which variant the value is
> and get the pointer to the string. I've stared at mlvalues.h for a
> while, but I can't really figure it out. Can anyone help? You won't
> regret it...
> -------------------
> To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr
-------------------
To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] Quick question - accessing variant value from C
2001-03-29 7:54 ` Jean-Christophe Filliatre
@ 2001-03-29 8:36 ` Sven LUTHER
0 siblings, 0 replies; 3+ messages in thread
From: Sven LUTHER @ 2001-03-29 8:36 UTC (permalink / raw)
To: Jean-Christophe Filliatre; +Cc: David Fox, caml-list
On Thu, Mar 29, 2001 at 09:54:02AM +0200, Jean-Christophe Filliatre wrote:
>
> Hi,
>
> You can use the macros Is_long / Is_block to discriminate between Null
> and Address, since the first one is represented as an integer and the
> second one as a structured block (in the later case, you can then
> access the string with the Field macro).
Additionally, some reading of the "Interfacing C with Objective Caml" chapter
of the ocaml documentation is a must read for this, far more inmportant than
the mlvalues.h file, i think.
Friendly,
Sven Luther
-------------------
To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2001-03-29 8:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-03-29 5:48 [Caml-list] Quick question - accessing variant value from C David Fox
2001-03-29 7:54 ` Jean-Christophe Filliatre
2001-03-29 8:36 ` Sven LUTHER
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox