-# 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"
- }
-}
-