diff options
author | Hugo Parente Lima <hugo.pl@gmail.com> | 2011-09-14 15:44:01 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:17:14 -0300 |
commit | 24206196a34b4faeb4b720efcc84747f35accf94 (patch) | |
tree | 5ebfb058a208299d6bf65dae7f90442b50ecf52d /libshiboken/sbkpython.h | |
parent | dfd3c75a8ba6bc8a1ac42909d96bc6d4c11c6bd7 (diff) |
Added sbkpython.h to deal with conflicts and missing symbols between Python2 and 3.
Diffstat (limited to 'libshiboken/sbkpython.h')
-rw-r--r-- | libshiboken/sbkpython.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/libshiboken/sbkpython.h b/libshiboken/sbkpython.h new file mode 100644 index 000000000..0b7f2a9cd --- /dev/null +++ b/libshiboken/sbkpython.h @@ -0,0 +1,44 @@ +/* + * This file is part of the Shiboken Python Bindings Generator project. + * + * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). + * + * Contact: PySide team <contact@pyside.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef SBKPYTHON_H +#define SBKPYTHON_H + +#include "Python.h" +#include "python25compat.h" + +#if PY_MAJOR_VERSION >= 3 + #define IS_PY3K + + #define PyInt_Type PyLong_Type + #define PyInt_Check PyLong_Check + #define PyInt_AS_LONG PyLong_AS_LONG + #define PyInt_FromLong PyLong_FromLong + #define PyInt_AsLong PyLong_AsLong + #define SbkNumber_Check PyNumber_Check +#else + // Note: if there wasn't for the old-style classes, only a PyNumber_Check would suffice. + #define SbkNumber_Check(X) \ + (PyNumber_Check(X) && (!PyInstance_Check(X) || PyObject_HasAttrString(X, "__trunc__"))) +#endif + +#endif |