[Libguestfs] example script for GObject

Hilko Bengen bengen at hilluzination.de
Thu Jan 26 11:54:55 UTC 2012


* Richard W.M. Jones:

>   var optargs = new Guestfs.AddDriveOpts ({readonly: true});
>   g.add_drive_opts (filename, optargs);
>
> This awkward style is required because GObject Introspection doesn't
> support optional arguments.

This is really, really ugly. Couldn't one use some sort of list instead?

Something that could be translated to Javascript as

    g.add_drive_opts (filename, [ Guestfs.AddDriveOpts.FORMAT, "raw" ] )

or even

    g.add_drive_opts (filename, Guestfs.AddDriveOpts.FORMAT, "raw" )

would be much nicer.

>> g.add_drive (file.get_path (), Guestfs.AddDriveOpts.OPTS_FORMAT, "raw");
> I think Javascript is simply ignoring the second and third arguments.
> I'm a bit surprised there is no error ...

Oh, thanks for noticing.

-Hilko




More information about the Libguestfs mailing list