Re: [Libguestfs] About the return value of value_value

Richard W.M. Jones
Sun, 10 Aug 2014 15:26:07 -0000

On Sun, Aug 10, 2014 at 05:04:01PM +0200, Peter Wu
wrote:
> Hi,
>
> I have been working on a Python application that uses hivex. Meanwhile I
have
> encountered some Python bindings issues which could be fixed.
>
> The next issue I see now is about the value_value function. This is briefly
> documented as: "return data length, data type and data of a
value".
>
> For Perl, Python and OCaml, this is not true. A tuple is returned
> for both without the length (as this can be calculated from the data
> value). Ruby is the outlier here that uses a dictionary with three
> keys. I am not familar with Ruby and neither do I know Ruby users of
> hivex.
>
> The documentation should likely be fixed to exclude the length, but
> what about the Ruby API? Is it correct or should a documentation
> note be added that Ruby differs

Note that the documentation applies to the C API (where length is
returned).  Since the same generated documentation is used for the
other languages too, that can make it a bit patchy.

In Ruby it seems as if the length could be calculated from the string.
On the other hand, I'm not sure there is any point in intentionally
removing the length from the return value, as that might break callers
for no particular reason.

The best plan here is probably to add a note to the Ruby documentation
for RLenTypeVal saying what the hash contains on Ruby.

Rich.

--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.