pidl/python: also add a ndr_PyLong_FromLongLong() for symnetric reasons
authorStefan Metzmacher <metze@samba.org>
Tue, 1 Sep 2015 08:30:49 +0000 (10:30 +0200)
committerStefan Metzmacher <metze@samba.org>
Tue, 1 Sep 2015 12:01:23 +0000 (14:01 +0200)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11429

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
pidl/lib/Parse/Pidl/Samba4/Python.pm

index 056ab21..180b6b2 100644 (file)
@@ -1280,7 +1280,7 @@ sub ConvertScalarToPython($$$)
        $ctypename = expandAlias($ctypename);
 
        if ($ctypename =~ /^(int64|dlong)$/) {
-               return "($cvar > LONG_MAX || $cvar < LONG_MIN) ? PyLong_FromLongLong($cvar) : PyInt_FromLong($cvar)";
+               return "ndr_PyLong_FromLongLong($cvar)";
        }
 
        if ($ctypename =~ /^(uint64|hyper|NTTIME_hyper|NTTIME|NTTIME_1sec|udlong|udlongr|uid_t|gid_t)$/) {
@@ -1535,6 +1535,15 @@ static inline long long ndr_sizeof2intmax(size_t var_size)
        return 0;
 }
 
+static inline PyObject *ndr_PyLong_FromLongLong(long long v)
+{
+       if (v > LONG_MAX || v < LONG_MIN) {
+               return PyLong_FromLongLong(v);
+       } else {
+               return PyInt_FromLong(v);
+       }
+}
+
 static inline PyObject *ndr_PyLong_FromUnsignedLongLong(unsigned long long v)
 {
        if (v > LONG_MAX) {