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 | |
parent | dfd3c75a8ba6bc8a1ac42909d96bc6d4c11c6bd7 (diff) |
Added sbkpython.h to deal with conflicts and missing symbols between Python2 and 3.
Diffstat (limited to 'libshiboken')
-rw-r--r-- | libshiboken/CMakeLists.txt | 1 | ||||
-rw-r--r-- | libshiboken/autodecref.h | 2 | ||||
-rw-r--r-- | libshiboken/basewrapper.h | 3 | ||||
-rw-r--r-- | libshiboken/basewrapper_p.h | 2 | ||||
-rw-r--r-- | libshiboken/bindingmanager.h | 2 | ||||
-rw-r--r-- | libshiboken/conversions.h | 2 | ||||
-rw-r--r-- | libshiboken/gilstate.h | 2 | ||||
-rw-r--r-- | libshiboken/helper.h | 2 | ||||
-rw-r--r-- | libshiboken/sbkdbg.h | 2 | ||||
-rw-r--r-- | libshiboken/sbkenum.h | 2 | ||||
-rw-r--r-- | libshiboken/sbkmodule.h | 2 | ||||
-rw-r--r-- | libshiboken/sbkpython.h | 44 | ||||
-rw-r--r-- | libshiboken/shiboken.h | 2 | ||||
-rw-r--r-- | libshiboken/shibokenbuffer.h | 2 | ||||
-rw-r--r-- | libshiboken/threadstatesaver.h | 2 |
15 files changed, 58 insertions, 14 deletions
diff --git a/libshiboken/CMakeLists.txt b/libshiboken/CMakeLists.txt index 81812e9aa..487f0e243 100644 --- a/libshiboken/CMakeLists.txt +++ b/libshiboken/CMakeLists.txt @@ -59,6 +59,7 @@ install(FILES threadstatesaver.h typeresolver.h shibokenbuffer.h + sbkpython.h DESTINATION include/shiboken${shiboken_SUFFIX}) install(TARGETS libshiboken EXPORT shiboken LIBRARY DESTINATION "${LIB_INSTALL_DIR}" diff --git a/libshiboken/autodecref.h b/libshiboken/autodecref.h index 85445951f..da496f6e1 100644 --- a/libshiboken/autodecref.h +++ b/libshiboken/autodecref.h @@ -23,7 +23,7 @@ #ifndef AUTODECREF_H #define AUTODECREF_H -#include <Python.h> +#include "sbkpython.h" #include "shibokenmacros.h" namespace Shiboken diff --git a/libshiboken/basewrapper.h b/libshiboken/basewrapper.h index 0ad4a9eed..835b1d1d6 100644 --- a/libshiboken/basewrapper.h +++ b/libshiboken/basewrapper.h @@ -23,8 +23,7 @@ #ifndef BASEWRAPPER_H #define BASEWRAPPER_H -#include <Python.h> -#include "python25compat.h" +#include "sbkpython.h" #include "bindingmanager.h" #include <list> #include <map> diff --git a/libshiboken/basewrapper_p.h b/libshiboken/basewrapper_p.h index e1fbf67c8..e553d8e68 100644 --- a/libshiboken/basewrapper_p.h +++ b/libshiboken/basewrapper_p.h @@ -23,7 +23,7 @@ #ifndef BASEWRAPPER_P_H #define BASEWRAPPER_P_H -#include <Python.h> +#include "sbkpython.h" #include <list> #include <map> diff --git a/libshiboken/bindingmanager.h b/libshiboken/bindingmanager.h index b43bd77b2..8f8c301cd 100644 --- a/libshiboken/bindingmanager.h +++ b/libshiboken/bindingmanager.h @@ -23,7 +23,7 @@ #ifndef BINDINGMANAGER_H #define BINDINGMANAGER_H -#include <Python.h> +#include "sbkpython.h" #include <set> #include "shibokenmacros.h" diff --git a/libshiboken/conversions.h b/libshiboken/conversions.h index 350ab9541..ebe5c6c56 100644 --- a/libshiboken/conversions.h +++ b/libshiboken/conversions.h @@ -23,7 +23,7 @@ #ifndef CONVERSIONS_H #define CONVERSIONS_H -#include <Python.h> +#include "sbkpython.h" #include <limits> #include <memory> #include <typeinfo> diff --git a/libshiboken/gilstate.h b/libshiboken/gilstate.h index f67e69594..65273aca1 100644 --- a/libshiboken/gilstate.h +++ b/libshiboken/gilstate.h @@ -24,7 +24,7 @@ #define GILSTATE_H #include <shibokenmacros.h> -#include <Python.h> +#include "sbkpython.h" namespace Shiboken { diff --git a/libshiboken/helper.h b/libshiboken/helper.h index 13c119afc..a76511d12 100644 --- a/libshiboken/helper.h +++ b/libshiboken/helper.h @@ -23,7 +23,7 @@ #ifndef HELPER_H #define HELPER_H -#include <Python.h> +#include "sbkpython.h" #include "shibokenmacros.h" #include "conversions.h" #include "autodecref.h" diff --git a/libshiboken/sbkdbg.h b/libshiboken/sbkdbg.h index 44d57baf4..b671caeab 100644 --- a/libshiboken/sbkdbg.h +++ b/libshiboken/sbkdbg.h @@ -23,7 +23,7 @@ #ifndef SBKDBG_H #define SBKDBG_H -#include <Python.h> +#include "sbkpython.h" #include "basewrapper.h" #include <iostream> diff --git a/libshiboken/sbkenum.h b/libshiboken/sbkenum.h index f205302ef..4fffd1bad 100644 --- a/libshiboken/sbkenum.h +++ b/libshiboken/sbkenum.h @@ -23,7 +23,7 @@ #ifndef SBKENUM_H #define SBKENUM_H -#include <Python.h> +#include "sbkpython.h" #include "shibokenmacros.h" extern "C" diff --git a/libshiboken/sbkmodule.h b/libshiboken/sbkmodule.h index 028afec72..784cb201d 100644 --- a/libshiboken/sbkmodule.h +++ b/libshiboken/sbkmodule.h @@ -23,7 +23,7 @@ #ifndef SBK_MODULE_H #define SBK_MODULE_H -#include <Python.h> +#include "sbkpython.h" #include "shibokenmacros.h" namespace Shiboken { 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 diff --git a/libshiboken/shiboken.h b/libshiboken/shiboken.h index 724784246..d79eb84bc 100644 --- a/libshiboken/shiboken.h +++ b/libshiboken/shiboken.h @@ -23,7 +23,7 @@ #ifndef SHIBOKEN_H #define SHIBOKEN_H -#include <Python.h> +#include "sbkpython.h" #include "autodecref.h" #include "basewrapper.h" #include "bindingmanager.h" diff --git a/libshiboken/shibokenbuffer.h b/libshiboken/shibokenbuffer.h index 8f8e91dbe..2e6dea252 100644 --- a/libshiboken/shibokenbuffer.h +++ b/libshiboken/shibokenbuffer.h @@ -23,7 +23,7 @@ #ifndef SHIBOKEN_BUFFER_H #define SHIBOKEN_BUFFER_H -#include <Python.h> +#include "sbkpython.h" #include "shibokenmacros.h" namespace Shiboken diff --git a/libshiboken/threadstatesaver.h b/libshiboken/threadstatesaver.h index 5b2935114..a43ef7c7e 100644 --- a/libshiboken/threadstatesaver.h +++ b/libshiboken/threadstatesaver.h @@ -23,7 +23,7 @@ #ifndef THREADSTATESAVER_H #define THREADSTATESAVER_H -#include <Python.h> +#include "sbkpython.h" #include <shibokenmacros.h> namespace Shiboken |