summaryrefslogtreecommitdiff
path: root/source4/pidl/lib/Parse/Pidl
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-01-11 18:27:47 +0100
committerJelmer Vernooij <jelmer@samba.org>2008-01-14 19:53:03 +0100
commit7aa0f25d7f0a8a1eac19c886477b13ab00bd76fe (patch)
tree1e64724708e4cb5b5af813f8eaedf7a1bfd20678 /source4/pidl/lib/Parse/Pidl
parent83c56f2118393e142021e232f7731e4622d2dfb3 (diff)
downloadsamba-7aa0f25d7f0a8a1eac19c886477b13ab00bd76fe.tar.gz
samba-7aa0f25d7f0a8a1eac19c886477b13ab00bd76fe.tar.bz2
samba-7aa0f25d7f0a8a1eac19c886477b13ab00bd76fe.zip
python/pidl: Handle non-string types.
(This used to be commit 02dd02c529d578ad7fa4a6b825097685555604fe)
Diffstat (limited to 'source4/pidl/lib/Parse/Pidl')
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4/Python.pm20
1 files changed, 19 insertions, 1 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm
index 7c379548ed..5077102fc7 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm
@@ -347,6 +347,24 @@ sub register_module_method($$$$$)
push (@{$self->{module_methods}}, [$fn_name, $pyfn_name, $flags, $doc])
}
+sub ConvertObjectToPython($$$)
+{
+ my ($self, $ctype, $cvar) = @_;
+
+ if ($cvar =~ /^".*"$/) {
+ return "PyString_FromString($cvar)";
+ }
+
+ if ($cvar =~ /^[0-9]+$/ or
+ $ctype->{TYPE} eq "ENUM" or $ctype->{TYPE} eq "BITMAP" or
+ $ctype->{TYPE} eq "TYPEDEF" and
+ ($ctype->{TYPE} eq "ENUM" or $ctype->{TYPE} eq "BITMAP")) {
+ return "PyInt_FromLong($cvar)";
+ }
+
+ die("Unknown type for ".mapTypeName($ctype).": $cvar");
+}
+
sub Parse($$$$)
{
my($self,$basename,$ndr,$hdr) = @_;
@@ -391,7 +409,7 @@ sub Parse($$$$)
$self->pidl("m = Py_InitModule(\"$basename\", $basename\_methods);");
foreach (keys %{$self->{constants}}) {
# FIXME: Handle non-string constants
- $self->pidl("PyModule_AddObject(m, \"$_\", PyString_FromString(" . $self->{constants}->{$_}->[1] . "));");
+ $self->pidl("PyModule_AddObject(m, \"$_\", " . $self->ConvertObjectToPython($self->{constants}->{$_}->[0], $self->{constants}->{$_}->[1]) . ");");
}
$self->deindent;
$self->pidl("}");