Fix use of interface instances in pidl.
authorJelmer Vernooij <jelmer@samba.org>
Fri, 9 May 2008 11:44:12 +0000 (13:44 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Mon, 15 Sep 2008 15:37:09 +0000 (17:37 +0200)
source4/pidl/lib/Parse/Pidl/Samba4/COM/Header.pm
source4/pidl/lib/Parse/Pidl/Samba4/Python.pm

index 85dab37246490ea00cabb899778c894018926d96..f8ba4fc18a92c022bf4f5c417d126b701d34db4a 100644 (file)
@@ -3,7 +3,7 @@
 
 package Parse::Pidl::Samba4::COM::Header;
 
-use Parse::Pidl::Typelist qw(mapType);
+use Parse::Pidl::Typelist qw(mapTypeName);
 use Parse::Pidl::Util qw(has_property is_constant);
 
 use vars qw($VERSION);
@@ -18,7 +18,7 @@ sub GetArgumentProtoList($)
 
        foreach my $a (@{$f->{ELEMENTS}}) {
 
-               $res .= ", " . mapType($a->{TYPE}) . " ";
+               $res .= ", " . mapTypeName($a->{TYPE}) . " ";
 
                my $l = $a->{POINTERS};
                $l-- if (Parse::Pidl::Typelist::scalar_is_reference($a->{TYPE}));
@@ -62,7 +62,7 @@ sub HeaderVTable($)
 
        my $data = $interface->{DATA};
        foreach my $d (@{$data}) {
-               $res .= "\t" . mapType($d->{RETURN_TYPE}) . " (*$d->{NAME}) (struct $interface->{NAME} *d, TALLOC_CTX *mem_ctx" . GetArgumentProtoList($d) . ");\\\n" if ($d->{TYPE} eq "FUNCTION");
+               $res .= "\t" . mapTypeName($d->{RETURN_TYPE}) . " (*$d->{NAME}) (struct $interface->{NAME} *d, TALLOC_CTX *mem_ctx" . GetArgumentProtoList($d) . ");\\\n" if ($d->{TYPE} eq "FUNCTION");
        }
        $res .= "\n";
        $res .= "struct $interface->{NAME}_vtable {\n";
index b7d092015ceb7e35c783db27f931be8615b25734..3b7e875260f1edef9c81275b43c7e947b771f68f 100644 (file)
@@ -9,6 +9,7 @@ use Exporter;
 @ISA = qw(Exporter);
 
 use strict;
+use Parse::Pidl qw(warning fatal);
 use Parse::Pidl::Typelist qw(hasType resolveType getType mapTypeName expandAlias);
 use Parse::Pidl::Util qw(has_property ParseExpr);
 use Parse::Pidl::NDR qw(GetPrevLevel GetNextLevel ContainsDeferred is_charset_array);
@@ -846,7 +847,7 @@ sub ConvertObjectFromPythonData($$$$$$)
                return;
        }
 
-       if ($actual_ctype->{TYPE} eq "STRUCT") {
+       if ($actual_ctype->{TYPE} eq "STRUCT" or $actual_ctype->{TYPE} eq "INTERFACE") {
                $self->pidl("PY_CHECK_TYPE($ctype->{NAME}, $cvar, $fail);");
                $self->assign($target, "py_talloc_get_ptr($cvar)");
                return;
@@ -889,7 +890,7 @@ sub ConvertObjectFromPythonData($$$$$$)
                return;
        }
 
-       die("unknown type ".mapTypeName($ctype) . ": $cvar");
+       fatal($ctype, "unknown type $actual_ctype->{TYPE} for ".mapTypeName($ctype) . ": $cvar");
 
 }
 
@@ -1026,13 +1027,12 @@ sub ConvertObjectToPythonData($$$$$)
        } elsif ($actual_ctype->{TYPE} eq "SCALAR") {
                return $self->ConvertScalarToPython($actual_ctype->{NAME}, $cvar);
        } elsif ($actual_ctype->{TYPE} eq "UNION") {
-               # FIXME: Should be fatal() rather than die()
-               die("union without discriminant: " . mapTypeName($ctype) . ": $cvar");
+               fatal($ctype, "union without discriminant: " . mapTypeName($ctype) . ": $cvar");
        } elsif ($actual_ctype->{TYPE} eq "STRUCT" or $actual_ctype->{TYPE} eq "INTERFACE") {
                return "py_talloc_import_ex(&$ctype->{NAME}_Type, $mem_ctx, $cvar)";
        }
 
-       die("unknown type ".mapTypeName($ctype) . ": $cvar");
+       fatal($ctype, "unknown type $actual_ctype->{TYPE} for ".mapTypeName($ctype) . ": $cvar");
 }
 
 sub fail_on_null($$$)