git.samba.org
/
samba.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
36bdb3b
)
pidl: Allow more flexibility importing modules using convenience function.
author
Jelmer Vernooij
<jelmer@samba.org>
Tue, 30 Nov 2010 22:06:32 +0000
(23:06 +0100)
committer
Jelmer Vernooij
<jelmer@samba.org>
Wed, 1 Dec 2010 00:48:24 +0000
(
01:48
+0100)
pidl/lib/Parse/Pidl/Samba4/Python.pm
patch
|
blob
|
history
diff --git
a/pidl/lib/Parse/Pidl/Samba4/Python.pm
b/pidl/lib/Parse/Pidl/Samba4/Python.pm
index b0b8e53f44f68a22fad9cce4effc9ac208b1eb71..ebd2a66af38dda29abf1202ad7ceb3ec6e8bd267 100644
(file)
--- a/
pidl/lib/Parse/Pidl/Samba4/Python.pm
+++ b/
pidl/lib/Parse/Pidl/Samba4/Python.pm
@@
-24,7
+24,7
@@
sub new($) {
my ($class) = @_;
my $self = { res => "", res_hdr => "", tabs => "", constants => {},
module_methods => [], module_objects => [], ready_types => [],
my ($class) = @_;
my $self = { res => "", res_hdr => "", tabs => "", constants => {},
module_methods => [], module_objects => [], ready_types => [],
- module_imports =>
[]
, type_imports => {},
+ module_imports =>
{}
, type_imports => {},
patch_type_calls => [], prereadycode => [],
postreadycode => []};
bless($self, $class);
patch_type_calls => [], prereadycode => [],
postreadycode => []};
bless($self, $class);
@@
-756,7
+756,7
@@
sub register_module_import($$)
{
my ($self, $basename) = @_;
{
my ($self, $basename) = @_;
-
push (@{$self->{module_imports}}, $basename) unless (grep(/^$basename$/,@{$self->{module_imports}}))
;
+
$self->{module_imports}->{"dep_$basename"} = "samba.dcerpc.$basename"
;
}
sub import_type_variable($$$)
}
sub import_type_variable($$$)
@@
-1294,14
+1294,16
@@
sub Parse($$$$$)
$self->pidl("{");
$self->indent;
$self->pidl("PyObject *m;");
$self->pidl("{");
$self->indent;
$self->pidl("PyObject *m;");
- foreach (
@
{$self->{module_imports}}) {
- $self->pidl("PyObject *
dep_
$_;");
+ foreach (
keys %
{$self->{module_imports}}) {
+ $self->pidl("PyObject *$_;");
}
$self->pidl("");
}
$self->pidl("");
- foreach (@{$self->{module_imports}}) {
- $self->pidl("dep_$_ = PyImport_ImportModule(\"samba.dcerpc.$_\");");
- $self->pidl("if (dep_$_ == NULL)");
+ foreach (keys %{$self->{module_imports}}) {
+ my $var_name = $_;
+ my $module_path = $self->{module_imports}->{$var_name};
+ $self->pidl("$var_name = PyImport_ImportModule(\"$module_path\");");
+ $self->pidl("if ($var_name == NULL)");
$self->pidl("\treturn;");
$self->pidl("");
}
$self->pidl("\treturn;");
$self->pidl("");
}