# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
+# version 2 of the License, or (at your option) any later version,
+# with the OCaml linking exception described in ../COPYING.LIB.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
-# Please see the file ../COPYING.LIB.
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
# This generates libvirt_c.c (the core of the bindings). You don't
# need to run this program unless you are extending the bindings
# It is interpreted by the generation functions below to indicate what
# "class" the function falls into, and to generate the right class of
# binding.
-#
-# Any function added since libvirt 0.2.1 must be marked weak.
my @functions = (
{ name => "virConnectClose", sig => "conn : free" },
- { name => "virConnectGetHostname", sig => "conn : string", weak => 1 },
- { name => "virConnectGetURI", sig => "conn : string", weak => 1 },
+ { name => "virConnectGetHostname", sig => "conn : string" },
+ { name => "virConnectGetURI", sig => "conn : string" },
{ name => "virConnectGetType", sig => "conn : static string" },
{ name => "virConnectNumOfDomains", sig => "conn : int" },
{ name => "virConnectListDomains", sig => "conn, int : int array" },
{ name => "virConnectNumOfDefinedNetworks", sig => "conn : int" },
{ name => "virConnectListDefinedNetworks",
sig => "conn, int : string array" },
- { name => "virConnectNumOfStoragePools", sig => "conn : int", weak => 1 },
+ { name => "virConnectNumOfStoragePools", sig => "conn : int" },
{ name => "virConnectListStoragePools",
- sig => "conn, int : string array", weak => 1 },
+ sig => "conn, int : string array" },
{ name => "virConnectNumOfDefinedStoragePools",
- sig => "conn : int", weak => 1 },
+ sig => "conn : int" },
{ name => "virConnectListDefinedStoragePools",
- sig => "conn, int : string array", weak => 1 },
+ sig => "conn, int : string array" },
{ name => "virConnectGetCapabilities", sig => "conn : string" },
+ { name => "virConnectDomainEventDeregisterAny",
+ sig => "conn, int : unit" },
{ name => "virDomainCreateLinux", sig => "conn, string, 0U : dom" },
- { name => "virDomainCreateLinuxJob",
- sig => "conn, string, 0U : job", weak => 1 },
{ name => "virDomainFree", sig => "dom : free" },
{ name => "virDomainDestroy", sig => "dom : free" },
{ name => "virDomainLookupByName", sig => "conn, string : dom" },
{ name => "virDomainGetUUIDString", sig => "dom : uuid string" },
{ name => "virDomainGetMaxVcpus", sig => "dom : int" },
{ name => "virDomainSave", sig => "dom, string : unit" },
- { name => "virDomainSaveJob",
- sig => "dom, string : job from dom", weak => 1 },
{ name => "virDomainRestore", sig => "conn, string : unit" },
- { name => "virDomainRestoreJob",
- sig => "conn, string : job", weak => 1 },
{ name => "virDomainCoreDump", sig => "dom, string, 0 : unit" },
- { name => "virDomainCoreDumpJob",
- sig => "dom, string, 0 : job from dom", weak => 1 },
{ name => "virDomainSuspend", sig => "dom : unit" },
{ name => "virDomainResume", sig => "dom : unit" },
{ name => "virDomainShutdown", sig => "dom : unit" },
{ name => "virDomainDefineXML", sig => "conn, string : dom" },
{ name => "virDomainUndefine", sig => "dom : unit" },
{ name => "virDomainCreate", sig => "dom : unit" },
- { name => "virDomainCreateJob",
- sig => "dom, 0U : job from dom", weak => 1 },
{ name => "virDomainAttachDevice", sig => "dom, string : unit" },
{ name => "virDomainDetachDevice", sig => "dom, string : unit" },
{ name => "virDomainGetAutostart", sig => "dom : bool" },
{ name => "virNetworkGetUUIDString", sig => "net : uuid string" },
{ name => "virNetworkUndefine", sig => "net : unit" },
{ name => "virNetworkCreateXML", sig => "conn, string : net" },
- { name => "virNetworkCreateXMLJob",
- sig => "conn, string : job", weak => 1 },
{ name => "virNetworkDefineXML", sig => "conn, string : net" },
{ name => "virNetworkCreate", sig => "net : unit" },
- { name => "virNetworkCreateJob",
- sig => "net : job from net", weak => 1 },
{ name => "virNetworkGetAutostart", sig => "net : bool" },
{ name => "virNetworkSetAutostart", sig => "net, bool : unit" },
- { name => "virStoragePoolFree", sig => "pool : free", weak => 1 },
- { name => "virStoragePoolDestroy", sig => "pool : free", weak => 1 },
+ { name => "virStoragePoolFree", sig => "pool : free" },
+ { name => "virStoragePoolDestroy", sig => "pool : free" },
{ name => "virStoragePoolLookupByName",
- sig => "conn, string : pool", weak => 1 },
+ sig => "conn, string : pool" },
{ name => "virStoragePoolLookupByUUID",
- sig => "conn, uuid : pool", weak => 1 },
+ sig => "conn, uuid : pool" },
{ name => "virStoragePoolLookupByUUIDString",
- sig => "conn, string : pool", weak => 1 },
+ sig => "conn, string : pool" },
{ name => "virStoragePoolGetName",
- sig => "pool : static string", weak => 1 },
+ sig => "pool : static string" },
{ name => "virStoragePoolGetXMLDesc",
- sig => "pool, 0U : string", weak => 1 },
+ sig => "pool, 0U : string" },
{ name => "virStoragePoolGetUUID",
- sig => "pool : uuid", weak => 1 },
+ sig => "pool : uuid" },
{ name => "virStoragePoolGetUUIDString",
- sig => "pool : uuid string", weak => 1 },
+ sig => "pool : uuid string" },
{ name => "virStoragePoolCreateXML",
- sig => "conn, string, 0U : pool", weak => 1 },
+ sig => "conn, string, 0U : pool" },
{ name => "virStoragePoolDefineXML",
- sig => "conn, string, 0U : pool", weak => 1 },
+ sig => "conn, string, 0U : pool" },
{ name => "virStoragePoolBuild",
- sig => "pool, uint : unit", weak => 1 },
+ sig => "pool, uint : unit" },
{ name => "virStoragePoolUndefine",
- sig => "pool : unit", weak => 1 },
+ sig => "pool : unit" },
{ name => "virStoragePoolCreate",
- sig => "pool, 0U : unit", weak => 1 },
+ sig => "pool, 0U : unit" },
{ name => "virStoragePoolDelete",
- sig => "pool, uint : unit", weak => 1 },
+ sig => "pool, uint : unit" },
{ name => "virStoragePoolRefresh",
- sig => "pool, 0U : unit", weak => 1 },
+ sig => "pool, 0U : unit" },
{ name => "virStoragePoolGetAutostart",
- sig => "pool : bool", weak => 1 },
+ sig => "pool : bool" },
{ name => "virStoragePoolSetAutostart",
- sig => "pool, bool : unit", weak => 1 },
+ sig => "pool, bool : unit" },
{ name => "virStoragePoolNumOfVolumes",
- sig => "pool : int", weak => 1 },
+ sig => "pool : int" },
{ name => "virStoragePoolListVolumes",
- sig => "pool, int : string array", weak => 1 },
+ sig => "pool, int : string array" },
- { name => "virStorageVolFree", sig => "vol : free", weak => 1 },
+ { name => "virStorageVolFree", sig => "vol : free" },
{ name => "virStorageVolDelete",
- sig => "vol, uint : unit", weak => 1 },
+ sig => "vol, uint : unit" },
{ name => "virStorageVolLookupByName",
- sig => "pool, string : vol from pool", weak => 1 },
+ sig => "pool, string : vol from pool" },
{ name => "virStorageVolLookupByKey",
- sig => "conn, string : vol", weak => 1 },
+ sig => "conn, string : vol" },
{ name => "virStorageVolLookupByPath",
- sig => "conn, string : vol", weak => 1 },
+ sig => "conn, string : vol" },
{ name => "virStorageVolCreateXML",
- sig => "pool, string, 0U : vol from pool", weak => 1 },
+ sig => "pool, string, 0U : vol from pool" },
{ name => "virStorageVolGetXMLDesc",
- sig => "vol, 0U : string", weak => 1 },
+ sig => "vol, 0U : string" },
{ name => "virStorageVolGetPath",
- sig => "vol : string", weak => 1 },
+ sig => "vol : string" },
{ name => "virStorageVolGetKey",
- sig => "vol : static string", weak => 1 },
+ sig => "vol : static string" },
{ name => "virStorageVolGetName",
- sig => "vol : static string", weak => 1 },
+ sig => "vol : static string" },
{ name => "virStoragePoolLookupByVolume",
- sig => "vol : pool from vol", weak => 1 },
-
- { name => "virJobFree",
- sig => "job : free", weak => 1 },
- { name => "virJobCancel",
- sig => "job : unit", weak => 1 },
- { name => "virJobGetNetwork",
- sig => "job : net from job", weak => 1 },
- { name => "virJobGetDomain",
- sig => "job : dom from job", weak => 1 },
+ sig => "vol : pool from vol" },
);
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 2 of the License, or (at your option) any later version,
+ * with the OCaml linking exception described in ../COPYING.LIB.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
- * Please see the file ../COPYING.LIB.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "config.h"
elsif ($_ eq "net") { "virNetworkPtr" }
elsif ($_ eq "pool") { "virStoragePoolPtr" }
elsif ($_ eq "vol") { "virStorageVolPtr" }
- elsif ($_ eq "job") { "virJobPtr" }
else {
die "unknown short name $_"
}
}
-# Generate a C signature for the original function. Used when building
-# weak bindings.
-
-sub gen_c_signature
-{
- my $sig = shift;
- my $c_name = shift;
-
- if ($sig =~ /^(\w+) : string$/) {
- my $c_type = short_name_to_c_type ($1);
- "char *$c_name ($c_type $1)"
- } elsif ($sig =~ /^(\w+) : static string$/) {
- my $c_type = short_name_to_c_type ($1);
- "const char *$c_name ($c_type $1)"
- } 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 =~ /^(\w+), int : string array$/) {
- my $c_type = short_name_to_c_type ($1);
- "int $c_name ($c_type $1, char **const names, int maxnames)"
- } elsif ($sig =~ /^(\w+), 0(U?) : string$/) {
- my $c_type = short_name_to_c_type ($1);
- 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);
- 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)"
- } elsif ($sig =~ /^(\w+) : free$/) {
- my $c_type = short_name_to_c_type ($1);
- "int $c_name ($c_type $1)"
- } elsif ($sig =~ /^(\w+), string : unit$/) {
- my $c_type = short_name_to_c_type ($1);
- "int $c_name ($c_type $1, const char *str)"
- } elsif ($sig =~ /^(\w+), string, 0(U?) : unit$/) {
- my $c_type = short_name_to_c_type ($1);
- my $unsigned = $2 eq "U" ? "unsigned " : "";
- "int $c_name ($c_type $1, const char *str, ${unsigned}int flags)"
- } 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, const char *str)"
- } elsif ($sig =~ /^(\w+), string, 0(U?) : (\w+)$/) {
- my $c_type = short_name_to_c_type ($1);
- my $unsigned = $2 eq "U" ? "unsigned " : "";
- my $c_ret_type = short_name_to_c_type ($3);
- "$c_ret_type $c_name ($c_type $1, const char *str, ${unsigned}int flags)"
- } elsif ($sig =~ /^(\w+), (u?)int : unit$/) {
- my $c_type = short_name_to_c_type ($1);
- my $unsigned = $2 eq "u" ? "unsigned " : "";
- "int $c_name ($c_type $1, ${unsigned}int i)"
- } elsif ($sig =~ /^(\w+), (u?)int : (\w+)$/) {
- my $c_type = short_name_to_c_type ($1);
- my $unsigned = $2 eq "u" ? "unsigned " : "";
- my $c_ret_type = short_name_to_c_type ($3);
- "$c_ret_type $c_name ($c_type $1, ${unsigned}int i)"
- } elsif ($sig =~ /^(\w+), uuid : (\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, const unsigned char *str)"
- } elsif ($sig =~ /^(\w+), 0(U?) : (\w+)$/) {
- my $c_type = short_name_to_c_type ($1);
- my $unsigned = $2 eq "U" ? "unsigned " : "";
- my $c_ret_type = short_name_to_c_type ($3);
- "$c_ret_type $c_name ($c_type $1, $unsigned int flags)"
- } elsif ($sig =~ /^(\w+) : (\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)"
- } elsif ($sig =~ /^(\w+), string : (\w+) from \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, const char *str)"
- } elsif ($sig =~ /^(\w+), string, 0(U?) : (\w+) from \w+$/) {
- my $c_type = short_name_to_c_type ($1);
- my $unsigned = $2 eq "U" ? "unsigned " : "";
- my $c_ret_type = short_name_to_c_type ($3);
- "$c_ret_type $c_name ($c_type $1, const char *str, $unsigned int flags)"
- } elsif ($sig =~ /^(\w+), 0(U?) : (\w+) from \w+$/) {
- my $c_type = short_name_to_c_type ($1);
- my $unsigned = $2 eq "U" ? "unsigned " : "";
- my $c_ret_type = short_name_to_c_type ($3);
- "$c_ret_type $c_name ($c_type $1, $unsigned int flags)"
- } elsif ($sig =~ /^(\w+) : (\w+) from \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)"
- } else {
- die "unknown signature $sig"
- }
-}
-
# OCaml argument names.
sub gen_arg_names
} elsif ($_ eq "vol") {
"virStorageVolPtr vol = Volume_val (volv);\n".
" virConnectPtr conn = Connect_volv (volv);"
- } elsif ($_ eq "job") {
- "virJobPtr job = Job_val (jobv);\n".
- " virConnectPtr conn = Connect_jobv (jobv);"
} else {
die "unknown short name $_"
}
elsif ($_ eq "net") { "rv = Val_network (r, connv);" }
elsif ($_ eq "pool") { "rv = Val_pool (r, connv);" }
elsif ($_ eq "vol") { "rv = Val_volume (r, connv);" }
- elsif ($_ eq "job") { "rv = Val_job (r, connv);" }
else {
die "unknown short name $_"
}
elsif ($_ eq "net") { "Network_val (netv) = NULL;" }
elsif ($_ eq "pool") { "Pool_val (poolv) = NULL;" }
elsif ($_ eq "vol") { "Volume_val (volv) = NULL;" }
- elsif ($_ eq "job") { "Job_val (jobv) = NULL;" }
else {
die "unknown short name $_"
}
int r;
NONBLOCKING (r = $c_name ($1, i));
- CHECK_ERROR (!r, conn, \"$c_name\");
+ CHECK_ERROR (r == -1, conn, \"$c_name\");
CAMLreturn (Val_unit);
"
foreach my $function (@functions) {
my $c_name = $function->{name};
- my $is_weak = $function->{weak};
my $sig = $function->{sig};
#print "generating $c_name with sig \"$sig\" ...\n";
END
- # Generate a full function prototype if the function is weak.
- my $have_name = "HAVE_" . uc ($c_name);
- if ($is_weak) {
- my $c_sig = gen_c_signature ($sig, $c_name);
- print F <<END;
-#ifdef HAVE_WEAK_SYMBOLS
-#ifdef $have_name
-extern $c_sig __attribute__((weak));
-#endif
-#endif
-
-END
- }
-
my @arg_names = gen_arg_names ($sig);
my $nr_arg_names = scalar @arg_names;
my $arg_names = join ", ", @arg_names;
CAMLparam$nr_arg_names ($arg_names);
END
- # If weak, check the function exists at compile time or runtime.
- if ($is_weak) {
- print F <<END;
-#ifndef $have_name
- /* Symbol $c_name not found at compile time. */
- not_supported ("$c_name");
- CAMLnoreturn;
-#else
- /* Check that the symbol $c_name
- * is in runtime version of libvirt.
- */
- WEAK_SYMBOL_CHECK ($c_name);
-END
- }
-
# Generate the internals of the function.
print F (gen_c_code ($sig, $c_name));
- # Finish off weak #ifdef.
- if ($is_weak) {
- print F <<END;
-#endif
-END
- }
-
# Finish off the function.
print F <<END;
}