X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=libvirt%2Fgenerator.pl;h=4fd07b8e00e7cfbe4f301da2cb8852e1a6bbf49e;hb=b6098f4c7419486227cbe2112904cbc9d58ed787;hp=fa7f5bc653d02902b4e6ad7983d47b07b00a15ef;hpb=aee5f1b6aa2b80873a34de67727c40ad43cccca7;p=virt-top.git diff --git a/libvirt/generator.pl b/libvirt/generator.pl index fa7f5bc..4fd07b8 100755 --- a/libvirt/generator.pl +++ b/libvirt/generator.pl @@ -56,20 +56,28 @@ my @functions = ( { name => "virDomainGetName", sig => "dom : static string" }, { name => "virDomainGetOSType", sig => "dom : string" }, { name => "virDomainGetXMLDesc", sig => "dom, 0 : string" }, + { name => "virDomainGetUUID", sig => "dom : uuid" }, + { name => "virDomainGetUUIDString", sig => "dom : uuid string" }, { name => "virDomainSuspend", sig => "dom : unit" }, { name => "virDomainResume", sig => "dom : unit" }, { name => "virDomainShutdown", sig => "dom : unit" }, { name => "virDomainReboot", sig => "dom, 0 : unit" }, { name => "virDomainUndefine", sig => "dom : unit" }, { name => "virDomainCreate", sig => "dom : unit" }, + { name => "virDomainGetAutostart", sig => "dom : bool" }, + { name => "virDomainSetAutostart", sig => "dom, bool : unit" }, { name => "virNetworkLookupByName", sig => "conn, string : net" }, { name => "virNetworkLookupByUUIDString", sig => "conn, string : net" }, { name => "virNetworkGetName", sig => "net : static string" }, { name => "virNetworkGetXMLDesc", sig => "net, 0 : string" }, { name => "virNetworkGetBridgeName", sig => "net : string" }, + { name => "virNetworkGetUUID", sig => "net : uuid" }, + { name => "virNetworkGetUUIDString", sig => "net : uuid string" }, { name => "virNetworkUndefine", sig => "net : unit" }, { name => "virNetworkCreate", sig => "net : unit" }, + { name => "virNetworkGetAutostart", sig => "net : bool" }, + { name => "virNetworkSetAutostart", sig => "net, bool : unit" }, { name => "virStoragePoolLookupByName", sig => "conn, string : pool", weak => 1 }, @@ -79,29 +87,37 @@ my @functions = ( sig => "pool : static string", weak => 1 }, { name => "virStoragePoolGetXMLDesc", sig => "pool, 0 : string", weak => 1 }, + { name => "virStoragePoolGetUUID", + sig => "pool : uuid", weak => 1 }, + { name => "virStoragePoolGetUUIDString", + sig => "pool : uuid string", weak => 1 }, { name => "virStoragePoolUndefine", - sig => "pool : string", weak => 1 }, + sig => "pool : unit", weak => 1 }, { name => "virStoragePoolCreate", - sig => "pool : string", weak => 1 }, + sig => "pool : unit", weak => 1 }, { name => "virStoragePoolShutdown", - sig => "pool : string", weak => 1 }, + sig => "pool : unit", weak => 1 }, { name => "virStoragePoolRefresh", - sig => "pool, 0 : string", weak => 1 }, - - { name => "virStorageVolLookupByName", - sig => "conn, string : vol", weak => 1 }, + sig => "pool, 0U : unit", weak => 1 }, + { name => "virStoragePoolGetAutostart", + sig => "pool : bool", weak => 1 }, + { name => "virStoragePoolSetAutostart", + sig => "pool, bool : unit", weak => 1 }, + +# { name => "virStorageVolLookupByName", XXX see libvir-list posting +# sig => "pool, string : vol", weak => 1 }, { name => "virStorageVolLookupByKey", sig => "conn, string : vol", weak => 1 }, { name => "virStorageVolLookupByPath", sig => "conn, string : vol", weak => 1 }, { name => "virStorageVolGetXMLDesc", - sig => "pool, 0 : string", weak => 1 }, + sig => "vol, 0 : string", weak => 1 }, { name => "virStorageVolGetPath", - sig => "pool : string", weak => 1 }, + sig => "vol : string", weak => 1 }, { name => "virStorageVolGetKey", - sig => "pool : static string", weak => 1 }, + sig => "vol : static string", weak => 1 }, { name => "virStorageVolGetName", - sig => "pool : static string", weak => 1 }, + sig => "vol : static string", weak => 1 }, ); @@ -117,18 +133,15 @@ my @unimplemented = ( "ocaml_libvirt_connect_create_linux_job", "ocaml_libvirt_network_create_job", "ocaml_libvirt_network_create_xml_job", - "ocaml_libvirt_storage_pool_set_autostart", - "ocaml_libvirt_storage_pool_get_autostart", "ocaml_libvirt_storage_pool_get_info", - "ocaml_libvirt_storage_pool_get_uuid_string", - "ocaml_libvirt_storage_pool_get_uuid", - "ocaml_libvirt_storage_pool_free", - "ocaml_libvirt_storage_pool_destroy", + "ocaml_libvirt_storage_pool_free", #? + "ocaml_libvirt_storage_pool_destroy", #? "ocaml_libvirt_storage_pool_define_xml", "ocaml_libvirt_storage_pool_create_xml", "ocaml_libvirt_storage_pool_lookup_by_uuid", - "ocaml_libvirt_storage_vol_free", - "ocaml_libvirt_storage_vol_destroy", + "ocaml_libvirt_storage_vol_lookup_by_name", # XXX + "ocaml_libvirt_storage_vol_free", #? + "ocaml_libvirt_storage_vol_destroy", #? "ocaml_libvirt_storage_vol_create_xml", "ocaml_libvirt_storage_vol_get_info", "ocaml_libvirt_pool_of_volume", @@ -148,7 +161,10 @@ open F, ">$filename" or die "$filename: $!"; # Write the prologue. print F <<'END'; -/* WARNING: THIS FILE IS AUTOMATICALLY GENERATED BY 'generator.pl'. +/* !!! WARNING WARNING WARNING WARNING WARNING WARNING WARNING !!! + * + * THIS FILE IS AUTOMATICALLY GENERATED BY 'generator.pl'. + * * Any changes you make to this file may be overwritten. */ @@ -238,23 +254,37 @@ sub gen_c_signature } elsif ($sig =~ /^(\w+) : int$/) { my $c_type = short_name_to_c_type ($1); "int $c_name ($c_type $1)" + } elsif ($sig =~ /^(\w+) : uuid$/) { + my $c_type = short_name_to_c_type ($1); + "int $c_name ($c_type $1, unsigned char *)" + } elsif ($sig =~ /^(\w+) : uuid string$/) { + my $c_type = short_name_to_c_type ($1); + "int $c_name ($c_type $1, char *)" + } elsif ($sig =~ /^(\w+) : bool$/) { + my $c_type = short_name_to_c_type ($1); + "int $c_name ($c_type $1, int *r)" + } elsif ($sig =~ /^(\w+), bool : unit$/) { + my $c_type = short_name_to_c_type ($1); + "int $c_name ($c_type $1, int b)" } elsif ($sig eq "conn, int : int array") { "int $c_name (virConnectPtr conn, int *ids, int maxids)" } elsif ($sig eq "conn, int : string array") { "int $c_name (virConnectPtr conn, char **const names, int maxnames)" - } elsif ($sig =~ /^(\w+), 0 : string$/) { + } elsif ($sig =~ /^(\w+), 0(U?) : string$/) { my $c_type = short_name_to_c_type ($1); - "char *$c_name ($c_type $1, int flags)" - } elsif ($sig =~ /^(\w+), 0 : unit$/) { + my $unsigned = $2 eq "U" ? "unsigned " : ""; + "char *$c_name ($c_type $1, $unsigned int flags)" + } elsif ($sig =~ /^(\w+), 0(U?) : unit$/) { my $c_type = short_name_to_c_type ($1); - "int $c_name ($c_type $1, int flags)" + my $unsigned = $2 eq "U" ? "unsigned " : ""; + "int $c_name ($c_type $1, $unsigned int flags)" } elsif ($sig =~ /^(\w+) : unit$/) { my $c_type = short_name_to_c_type ($1); - "int $c_name ($c_type $1 dom)" + "int $c_name ($c_type $1)" } elsif ($sig =~ /^(\w+), string : (\w+)$/) { my $c_type = short_name_to_c_type ($1); my $c_ret_type = short_name_to_c_type ($2); - "$c_ret_type $c_name ($c_type $1 dom)" + "$c_ret_type $c_name ($c_type $1, const char *str)" } else { die "unknown signature $sig" } @@ -270,13 +300,21 @@ sub gen_arg_names ( "$1v" ) } elsif ($sig =~ /^(\w+) : int$/) { ( "$1v" ) + } elsif ($sig =~ /^(\w+) : uuid$/) { + ( "$1v" ) + } elsif ($sig =~ /^(\w+) : uuid string$/) { + ( "$1v" ) + } elsif ($sig =~ /^(\w+) : bool$/) { + ( "$1v" ) + } elsif ($sig =~ /^(\w+), bool : unit$/) { + ( "$1v", "bv" ) } elsif ($sig eq "conn, int : int array") { ( "connv", "iv" ) } elsif ($sig eq "conn, int : string array") { ( "connv", "iv" ) - } elsif ($sig =~ /^(\w+), 0 : string$/) { + } elsif ($sig =~ /^(\w+), 0U? : string$/) { ( "$1v" ) - } elsif ($sig =~ /^(\w+), 0 : unit$/) { + } elsif ($sig =~ /^(\w+), 0U? : unit$/) { ( "$1v" ) } elsif ($sig =~ /^(\w+) : unit$/) { ( "$1v" ) @@ -365,6 +403,54 @@ sub gen_c_code CAMLreturn (Val_int (r)); " + } elsif ($sig =~ /^(\w+) : uuid$/) { + "\ + CAMLlocal1 (rv); + " . gen_unpack_args ($1) . " + unsigned char uuid[VIR_UUID_BUFLEN]; + int r; + + NONBLOCKING (r = $c_name ($1, uuid)); + CHECK_ERROR (r == -1, conn, \"$c_name\"); + + rv = caml_copy_string ((char *) uuid); + CAMLreturn (rv); +" + } elsif ($sig =~ /^(\w+) : uuid string$/) { + "\ + CAMLlocal1 (rv); + " . gen_unpack_args ($1) . " + char uuid[VIR_UUID_STRING_BUFLEN]; + int r; + + NONBLOCKING (r = $c_name ($1, uuid)); + CHECK_ERROR (r == -1, conn, \"$c_name\"); + + rv = caml_copy_string (uuid); + CAMLreturn (rv); +" + } elsif ($sig =~ /^(\w+) : bool$/) { + "\ + " . gen_unpack_args ($1) . " + int r, b; + + NONBLOCKING (r = $c_name ($1, &b)); + CHECK_ERROR (r == -1, conn, \"$c_name\"); + + CAMLreturn (b ? Val_true : Val_false); +" + } elsif ($sig =~ /^(\w+), bool : unit$/) { + "\ + " . gen_unpack_args ($1) . " + int r, b; + + b = bv == Val_true ? 1 : 0; + + NONBLOCKING (r = $c_name ($1, b)); + CHECK_ERROR (r == -1, conn, \"$c_name\"); + + CAMLreturn (Val_unit); +" } elsif ($sig eq "conn, int : int array") { "\ CAMLlocal1 (rv); @@ -401,7 +487,7 @@ sub gen_c_code CAMLreturn (rv); " - } elsif ($sig =~ /^(\w+), 0 : string$/) { + } elsif ($sig =~ /^(\w+), 0U? : string$/) { "\ CAMLlocal1 (rv); " . gen_unpack_args ($1) . " @@ -424,7 +510,7 @@ sub gen_c_code CAMLreturn (Val_unit); " - } elsif ($sig =~ /^(\w+), 0 : unit$/) { + } elsif ($sig =~ /^(\w+), 0U? : unit$/) { "\ " . gen_unpack_args ($1) . " int r;