summaryrefslogtreecommitdiff
path: root/pidl
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2010-11-30 23:48:46 +0100
committerJelmer Vernooij <jelmer@samba.org>2010-12-01 01:48:25 +0100
commit3bff03723d8920faece76dd57bcf5d19b84d7b02 (patch)
tree84b73d72844f0802b4511f0a2ef50e70711f2408 /pidl
parentba2110d19060c4d84656917eb6be7b78afc6df6b (diff)
downloadsamba-3bff03723d8920faece76dd57bcf5d19b84d7b02.tar.gz
pidl/python: Allow import of talloc, even though it doesn't live in the
samba.dcerpc. namespace.
Diffstat (limited to 'pidl')
-rw-r--r--pidl/lib/Parse/Pidl/Samba4/Python.pm32
1 files changed, 22 insertions, 10 deletions
diff --git a/pidl/lib/Parse/Pidl/Samba4/Python.pm b/pidl/lib/Parse/Pidl/Samba4/Python.pm
index ebd2a66af38..3e9178b7e8d 100644
--- a/pidl/lib/Parse/Pidl/Samba4/Python.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/Python.pm
@@ -64,8 +64,11 @@ sub PrettifyTypeName($$)
{
my ($name, $basename) = @_;
+ $basename =~ s/^.*\.([^.]+)$/\1/;
+
$name =~ s/^$basename\_//;
+
return $name;
}
@@ -77,7 +80,7 @@ sub Import
$_ = unmake_str($_);
s/\.idl$//;
$self->pidl_hdr("#include \"librpc/gen_ndr/$_\.h\"\n");
- $self->register_module_import($_);
+ $self->register_module_import("samba.dcerpc.$_");
}
}
@@ -720,7 +723,7 @@ sub Interface($$$)
$self->pidl("");
$self->register_module_typeobject($interface->{NAME}, "&$if_typename");
- my $dcerpc_typename = $self->import_type_variable("base", "ClientConnection");
+ my $dcerpc_typename = $self->import_type_variable("samba.dcerpc.base", "ClientConnection");
$self->register_module_prereadycode(["$if_typename.tp_base = $dcerpc_typename;", ""]);
$self->register_module_postreadycode(["if (!PyInterface_AddNdrRpcMethods(&$if_typename, py_ndr_$interface->{NAME}\_methods))", "\treturn;", ""]);
}
@@ -754,9 +757,15 @@ sub check_ready_type($$)
sub register_module_import($$)
{
- my ($self, $basename) = @_;
+ my ($self, $module_path) = @_;
+
+ my $var_name = $module_path;
+ $var_name =~ s/\./_/g;
+ $var_name = "dep_$var_name";
+
+ $self->{module_imports}->{$var_name} = $module_path;
- $self->{module_imports}->{"dep_$basename"} = "samba.dcerpc.$basename";
+ return $var_name;
}
sub import_type_variable($$$)
@@ -784,7 +793,7 @@ sub use_type_variable($$)
}
# If this is an external type, make sure we do the right imports.
if (($ctype->{BASEFILE} ne $self->{BASENAME})) {
- return $self->import_type_variable($ctype->{BASEFILE}, $ctype->{NAME});
+ return $self->import_type_variable("samba.dcerpc.$ctype->{BASEFILE}", $ctype->{NAME});
}
return "&$ctype->{NAME}_Type";
}
@@ -1309,11 +1318,14 @@ sub Parse($$$$$)
}
foreach (keys %{$self->{type_imports}}) {
- my $basefile = $self->{type_imports}->{$_};
- $self->pidl_hdr("static PyTypeObject *$_\_Type;\n");
- my $pretty_name = PrettifyTypeName($_, $basefile);
- $self->pidl("$_\_Type = (PyTypeObject *)PyObject_GetAttrString(dep_$basefile, \"$pretty_name\");");
- $self->pidl("if ($_\_Type == NULL)");
+ my $type_var = "$_\_Type";
+ my $module_path = $self->{type_imports}->{$_};
+ $self->pidl_hdr("static PyTypeObject *$type_var;\n");
+ my $pretty_name = PrettifyTypeName($_, $module_path);
+ my $module_var = "dep_$module_path";
+ $module_var =~ s/\./_/g;
+ $self->pidl("$type_var = (PyTypeObject *)PyObject_GetAttrString($module_var, \"$pretty_name\");");
+ $self->pidl("if ($type_var == NULL)");
$self->pidl("\treturn;");
$self->pidl("");
}