[Libguestfs] [PATCH 3/7] generator: Add new return types to ABI: RLenNode and RLenValue

Richard W.M. Jones rjones at redhat.com
Thu Oct 13 07:26:23 UTC 2011


On Wed, Oct 12, 2011 at 08:09:09PM -0700, Alex Nelson wrote:
> Hi Rich,
> 
> Sorry for letting this one sit for a while.
> 
> I decided the appropriate way to make sure everything was correct was to just write some unit tests and include them for runs with 'make check' - a bit more than you said to do, but I think it makes sense.  Unfortunately, an OCaml type error is biting me, and I'm hung on that for verifying the OCaml bindings.
> 
> In the attached patch, the test ocaml/t/hivex_120_rlenvalue.ml has an error arising from the type abbreviation (is that the right term here? Or is it "synonym"?) of "value" and "int".  From what I can do at the OCaml prompt (pwd=.../hivex/ocaml), this is the confusion:
> # (2:Hivex.value);;
> Error: This expression has type int but an expression was expected of type
>          Hivex.value

You can't just cast between types in OCaml since that would be unsafe
(weak typing like C).  For the purpose of this test, it seems
acceptable to do an unsafe cast though:

  (Obj.magic 2 : Hivex.value)

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming blog: http://rwmj.wordpress.com
Fedora now supports 80 OCaml packages (the OPEN alternative to F#)
http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora




More information about the Libguestfs mailing list