summaryrefslogtreecommitdiff
path: root/source4/pidl/lib
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-01-13 03:15:55 +0100
committerJelmer Vernooij <jelmer@samba.org>2008-01-14 19:53:04 +0100
commitd814f3ce1c58be53886deab31a815e444ca6c5d5 (patch)
treeb559f79ce8fb7a6abb6c7ec5f7860a80a0a4ff43 /source4/pidl/lib
parent4ba71079272b1231c457112ac2d90f1f920cf5c8 (diff)
downloadsamba-d814f3ce1c58be53886deab31a815e444ca6c5d5.tar.gz
samba-d814f3ce1c58be53886deab31a815e444ca6c5d5.tar.bz2
samba-d814f3ce1c58be53886deab31a815e444ca6c5d5.zip
pidl/python: Fix const type wrapping.
(This used to be commit 35a4843f9c75a59ab98e785520114809903575cf)
Diffstat (limited to 'source4/pidl/lib')
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4/Python.pm25
1 files changed, 20 insertions, 5 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm
index 4ae647aa0a..ae4931571a 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm
@@ -65,7 +65,7 @@ sub Import
sub Const($$)
{
my ($self, $const) = @_;
- $self->register_constant($const->{NAME}, $const->{DATA}->{TYPE}, $const->{VALUE});
+ $self->register_constant($const->{NAME}, $const->{DTYPE}, $const->{VALUE});
}
sub register_constant($$$$)
@@ -258,7 +258,7 @@ sub PythonFunction($$$)
}
}
- if ($fn->{RETURN_TYPE}) {
+ if (defined($fn->{RETURN_TYPE})) {
$self->pidl("PyTuple_SetItem(result, $i, " . $self->ConvertObjectToPython($fn->{RETURN_TYPE}, "r.out.result") . ");");
}
@@ -460,10 +460,16 @@ sub ConvertObjectFromPython($$$)
{
my ($self, $ctype, $cvar) = @_;
+ die("undef type for $cvar") unless(defined($ctype));
+
if (ref($ctype) ne "HASH") {
$ctype = getType($ctype);
}
+ if (ref($ctype) ne "HASH") {
+ return "FIXME($cvar)";
+ }
+
my $actual_ctype = $ctype;
if ($ctype->{TYPE} eq "TYPEDEF") {
$actual_ctype = $ctype->{DATA};
@@ -482,13 +488,23 @@ sub ConvertObjectToPython($$$)
{
my ($self, $ctype, $cvar) = @_;
+ if ($cvar =~ /^[0-9]+$/ or $cvar =~ /^0x[0-9a-fA-F]+$/) {
+ return "PyInt_FromLong($cvar)";
+ }
+
+ die("undef type for $cvar") unless(defined($ctype));
+
if ($cvar =~ /^".*"$/) {
return "PyString_FromString($cvar)";
}
if (ref($ctype) ne "HASH") {
if (not hasType($ctype)) {
- return "py_import_$ctype($cvar)"; # best bet
+ if (ref($ctype) eq "HASH") {
+ return "py_import_$ctype->{TYPE}_$ctype->{NAME}($cvar)";
+ } else {
+ return "py_import_$ctype($cvar)"; # best bet
+ }
}
$ctype = getType($ctype);
@@ -499,8 +515,7 @@ sub ConvertObjectToPython($$$)
$actual_ctype = $ctype->{DATA};
}
- if ($cvar =~ /^[0-9]+$/ or
- $actual_ctype->{TYPE} eq "ENUM" or $actual_ctype->{TYPE} eq "BITMAP" or
+ if ($actual_ctype->{TYPE} eq "ENUM" or $actual_ctype->{TYPE} eq "BITMAP" or
($actual_ctype->{TYPE} eq "SCALAR" and
expandAlias($actual_ctype->{NAME}) =~ /^(int|long|char|u?int[0-9]+|hyper|dlong|udlong|udlongr|time_t|NTTIME_hyper|NTTIME|NTTIME_1sec)$/)) {
return "PyInt_FromLong($cvar)";