diff options
author | Matthieu Patou <mat@matws.net> | 2010-06-21 10:48:58 +0400 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2010-06-25 11:33:16 +0200 |
commit | 7703b89ae57d76a3246db7489c77c9de848ea832 (patch) | |
tree | 7b476d670eb09c6c152bdea7300a3148577b3499 /pidl | |
parent | 0802f354ea837b8884c861d6d98f20aa746e4445 (diff) | |
download | samba-7703b89ae57d76a3246db7489c77c9de848ea832.tar.gz samba-7703b89ae57d76a3246db7489c77c9de848ea832.tar.bz2 samba-7703b89ae57d76a3246db7489c77c9de848ea832.zip |
pidl: Finish to fix the python generated code for 64bit integers
Signed-off-by: Jelmer Vernooij <jelmer@samba.org>
Diffstat (limited to 'pidl')
-rw-r--r-- | pidl/lib/Parse/Pidl/Samba4/Python.pm | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/pidl/lib/Parse/Pidl/Samba4/Python.pm b/pidl/lib/Parse/Pidl/Samba4/Python.pm index 4687a535c4..4c5cc1b378 100644 --- a/pidl/lib/Parse/Pidl/Samba4/Python.pm +++ b/pidl/lib/Parse/Pidl/Samba4/Python.pm @@ -820,13 +820,40 @@ sub ConvertObjectFromPythonData($$$$$$;$) $actual_ctype = $actual_ctype->{DATA}; } - if ($actual_ctype->{TYPE} eq "ENUM" or $actual_ctype->{TYPE} eq "BITMAP" or - $actual_ctype->{TYPE} eq "SCALAR" and ( - expandAlias($actual_ctype->{NAME}) =~ /^(u?int[0-9]*|hyper|NTTIME|time_t|NTTIME_hyper|NTTIME_1sec|dlong|udlong|udlongr)$/)) { + if ($actual_ctype->{TYPE} eq "ENUM" or $actual_ctype->{TYPE} eq "BITMAP") { $self->pidl("PY_CHECK_TYPE(&PyInt_Type, $cvar, $fail);"); $self->pidl("$target = PyInt_AsLong($cvar);"); return; } + if ($actual_ctype->{TYPE} eq "SCALAR" ) { + if (expandAlias($actual_ctype->{NAME}) =~ /^(u?int64|hyper|dlong|udlong|udlongr|NTTIME_hyper|NTTIME|NTTIME_1sec)$/) { + $self->pidl("if (PyObject_TypeCheck($cvar, &PyLong_Type)) {"); + $self->indent; + $self->pidl("$target = PyLong_AsLongLong($cvar);"); + $self->deindent; + $self->pidl("} else {"); + $self->indent; + $self->pidl("if (PyObject_TypeCheck($cvar, &PyInt_Type)) {"); + $self->indent; + $self->pidl("$target = PyInt_AsLong($cvar);"); + $self->deindent; + $self->pidl("} else {"); + $self->indent; + $self->pidl("PyErr_Format(PyExc_TypeError, \"Expected type %s or %s\",\\"); + $self->pidl(" PyInt_Type.tp_name, PyLong_Type.tp_name);"); + $self->pidl($fail); + $self->deindent; + $self->pidl("}"); + $self->deindent; + $self->pidl("}"); + return; + } + if (expandAlias($actual_ctype->{NAME}) =~ /^(char|u?int[0-9]*|time_t)$/) { + $self->pidl("PY_CHECK_TYPE(&PyInt_Type, $cvar, $fail);"); + $self->pidl("$target = PyInt_AsLong($cvar);"); + return; + } + } if ($actual_ctype->{TYPE} eq "STRUCT" or $actual_ctype->{TYPE} eq "INTERFACE") { my $ctype_name = $self->use_type_variable($ctype); |