diff --git a/Engine/AppManager.h b/Engine/AppManager.h index 14ac18a198..e10cbf97d1 100644 --- a/Engine/AppManager.h +++ b/Engine/AppManager.h @@ -44,7 +44,7 @@ CLANG_DIAG_ON(deprecated) #include #include -#if !defined(Q_MOC_RUN) && !defined(SBK_RUN) +#if (!defined(Q_MOC_RUN) && !defined(SBK_RUN)) || defined(SBK2_GEN) #include #include #include diff --git a/Engine/Engine.pro b/Engine/Engine.pro index 721f49d67f..95c763fb91 100644 --- a/Engine/Engine.pro +++ b/Engine/Engine.pro @@ -238,7 +238,6 @@ SOURCES += \ NatronEngine/intparam_wrapper.cpp \ NatronEngine/itembase_wrapper.cpp \ NatronEngine/layer_wrapper.cpp \ - NatronEngine/natron_namespace_wrapper.cpp \ NatronEngine/natronengine_module_wrapper.cpp \ NatronEngine/nodecreationproperty_wrapper.cpp \ NatronEngine/outputfileparam_wrapper.cpp \ @@ -383,7 +382,6 @@ HEADERS += \ PyParameter.h \ PyRoto.h \ PyTracker.h \ - Pyside_Engine_Python.h \ ReadNode.h \ RectD.h \ RectDSerialization.h \ diff --git a/Engine/ImagePlaneDesc.h b/Engine/ImagePlaneDesc.h index 559207970f..d5747f2637 100644 --- a/Engine/ImagePlaneDesc.h +++ b/Engine/ImagePlaneDesc.h @@ -31,7 +31,7 @@ #include #include -#if !defined(Q_MOC_RUN) && !defined(SBK_RUN) +#if (!defined(Q_MOC_RUN) && !defined(SBK_RUN)) || defined(SBK2_GEN) GCC_DIAG_UNUSED_LOCAL_TYPEDEFS_OFF GCC_DIAG_OFF(unused-parameter) // /opt/local/include/boost/serialization/smart_cast.hpp:254:25: warning: unused parameter 'u' [-Wunused-parameter] diff --git a/Engine/Knob.h b/Engine/Knob.h index a90fa3c088..131afa9235 100644 --- a/Engine/Knob.h +++ b/Engine/Knob.h @@ -33,7 +33,7 @@ #include #include -#if !defined(Q_MOC_RUN) && !defined(SBK_RUN) +#if (!defined(Q_MOC_RUN) && !defined(SBK_RUN)) || defined(SBK2_GEN) #include #include #endif diff --git a/Engine/PySideCompat.cpp b/Engine/PySideCompat.cpp index 0877733ebe..c56c9807aa 100644 --- a/Engine/PySideCompat.cpp +++ b/Engine/PySideCompat.cpp @@ -38,11 +38,17 @@ CLANG_DIAG_OFF(mismatched-tags) GCC_DIAG_OFF(unused-parameter) GCC_DIAG_OFF(missing-field-initializers) +#ifdef SBK2_GEN +#include +#include +#include +#else #include #include #include #include #include +#endif #include CLANG_DIAG_ON(mismatched-tags) GCC_DIAG_ON(unused-parameter) diff --git a/Engine/Pyside_Engine_Python.h b/Engine/Pyside_Engine_Python.h index 2193eea4a2..432aea27bd 100644 --- a/Engine/Pyside_Engine_Python.h +++ b/Engine/Pyside_Engine_Python.h @@ -17,6 +17,9 @@ * along with Natron. If not, see * ***** END LICENSE BLOCK ***** */ +//Defined to avoid including some headers when running shiboken which may crash shiboken (particularly boost headers) +#define SBK_RUN + #ifndef PYSIDE_ENGINE_PYTHON_H #define PYSIDE_ENGINE_PYTHON_H @@ -33,10 +36,11 @@ * Do not include it when compiling Natron. **/ -//Defined to avoid including some headers when running shiboken which may crash shiboken (particularly boost headers) -#define SBK_RUN - +#ifdef SBK2_GEN +#include +#else #include +#endif #include //Global #include diff --git a/Engine/typesystem_engine.xml b/Engine/typesystem_engine.xml index 43f853b411..669c9d76f3 100644 --- a/Engine/typesystem_engine.xml +++ b/Engine/typesystem_engine.xml @@ -18,10 +18,13 @@ - along with Natron. If not, see - ***** END LICENSE BLOCK ***** --> - + + + NATRON_NAMESPACE_USING NATRON_PYTHON_NAMESPACE_USING + + - @@ -209,8 +212,8 @@ - - + @@ -225,7 +228,7 @@ - + @@ -1506,6 +1509,7 @@ for (int j = 0; j < subSize; ++j) { PyObject* pyString = PyList_GET_ITEM(subList,j); + #if PY_VERSION_MAJOR < 3 if ( PyString_Check(pyString) ) { char* buf = PyString_AsString(pyString); if (buf) { @@ -1514,6 +1518,9 @@ rowVec[j] = ret; } } else if (PyUnicode_Check(pyString) ) { + #else + if (PyUnicode_Check(pyString) ) { + #endif PyObject* utf8pyobj = PyUnicode_AsUTF8String(pyString); // newRef if (utf8pyobj) { char* cstr = PyBytes_AS_STRING(utf8pyobj); // Borrowed pointer diff --git a/Global/Enums.h b/Global/Enums.h index 7e76a8c6a1..3ec34bb7f8 100644 --- a/Global/Enums.h +++ b/Global/Enums.h @@ -28,7 +28,7 @@ CLANG_DIAG_OFF(deprecated) CLANG_DIAG_ON(deprecated) NATRON_NAMESPACE_ENTER -#ifdef SBK_RUN +#if defined(SBK_RUN) && !defined(SBK2_GEN) // shiboken doesn't generate SbkNatronEngine_StandardButtonEnum_as_number unless it is put in a class or namespace NATRON_NAMESPACE_EXIT namespace NATRON_NAMESPACE { @@ -684,7 +684,7 @@ enum MergingFunctionEnum //typedef QFlags StandardButtons; Q_DECLARE_FLAGS(StandardButtons, StandardButtonEnum) -#ifdef SBK_RUN +#if defined(SBK_RUN) && !defined(SBK2_GEN) } NATRON_NAMESPACE_ENTER #endif diff --git a/Global/GlobalDefines.h b/Global/GlobalDefines.h index 4929728224..30397bcc30 100644 --- a/Global/GlobalDefines.h +++ b/Global/GlobalDefines.h @@ -66,10 +66,10 @@ CLANG_DIAG_ON(deprecated) //#define foreach Q_FOREACH -typedef boost::uint32_t U32; -typedef boost::uint64_t U64; -typedef boost::uint8_t U8; -typedef boost::uint16_t U16; +typedef std::uint32_t U32; +typedef std::uint64_t U64; +typedef std::uint8_t U8; +typedef std::uint16_t U16; NATRON_NAMESPACE_ENTER diff --git a/Global/Pyside_Shiboken2_Macros.h b/Global/Pyside_Shiboken2_Macros.h new file mode 100644 index 0000000000..5c5d34b076 --- /dev/null +++ b/Global/Pyside_Shiboken2_Macros.h @@ -0,0 +1 @@ +#define SBK2_GEN diff --git a/global.pri b/global.pri index 96208f97e3..9d3a4d339f 100644 --- a/global.pri +++ b/global.pri @@ -41,8 +41,6 @@ run-without-python { # from : # "Since Python may define some pre-processor definitions which affect the standard headers on some systems, you must include Python.h before any standard headers are included." CONFIG += python - QMAKE_CFLAGS += -include Python.h - QMAKE_CXXFLAGS += -include Python.h python3 { PYV=3 PY_PKG_SUFFIX=-embed diff --git a/tools/utils/runPostShiboken2.sh b/tools/utils/runPostShiboken2.sh new file mode 100755 index 0000000000..b692d65243 --- /dev/null +++ b/tools/utils/runPostShiboken2.sh @@ -0,0 +1,88 @@ +#!/bin/sh +# ***** BEGIN LICENSE BLOCK ***** +# This file is part of Natron , +# Copyright (C) 2016 INRIA and Alexandre Gauthier +# +# Natron is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# Natron 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Natron. If not, see +# ***** END LICENSE BLOCK ***** + +# exit if a command returns an error status +set -e + +# PySide version override, add 2 for Qt5/PySide2 +PYV="${1:-2}" + +# To be run after shiboken to fix errors + +sed -e '//d' -i'.bak' Engine/NatronEngine/*.cpp +sed -e '//d' -i'.bak' Gui/NatronGui/*.cpp +sed -e "/SbkPySide${PYV}_QtCoreTypes;/d" -i'.bak' Gui/NatronGui/natrongui_module_wrapper.cpp +sed -e "/SbkPySide${PYV}_QtCoreTypeConverters;/d" -i'.bak' Gui/NatronGui/natrongui_module_wrapper.cpp +sed -e '/SbkNatronEngineTypes;/d' -i'.bak' Gui/NatronGui/natrongui_module_wrapper.cpp +sed -e '/SbkNatronEngineTypeConverters;/d' -i'.bak' Gui/NatronGui/natrongui_module_wrapper.cpp +sed -e 's/cleanTypesAttributes/cleanGuiTypesAttributes/g' -i'.bak' Gui/NatronGui/natrongui_module_wrapper.cpp +sed -e '/Py_BEGIN_ALLOW_THREADS/d' -i'.bak' Engine/NatronEngine/*.cpp +sed -e '/Py_BEGIN_ALLOW_THREADS/d' -i'.bak' Gui/NatronGui/*.cpp +sed -e '/Py_END_ALLOW_THREADS/d' -i'.bak' Engine/NatronEngine/*.cpp +sed -e '/Py_END_ALLOW_THREADS/d' -i'.bak' Gui/NatronGui/*.cpp + +# fix warnings +sed -e 's@^#include $@#include "Global/Macros.h"\ +CLANG_DIAG_OFF(mismatched-tags)\ +GCC_DIAG_OFF(unused-parameter)\ +GCC_DIAG_OFF(missing-field-initializers)\ +GCC_DIAG_OFF(missing-declarations)\ +GCC_DIAG_OFF(uninitialized)\ +GCC_DIAG_UNUSED_LOCAL_TYPEDEFS_OFF\ +#include // produces many warnings@' -i'.bak' Engine/NatronEngine/*.cpp Gui/NatronGui/*.cpp + +sed -e 's@// inner classes@// inner classes\ +NATRON_NAMESPACE_USING NATRON_PYTHON_NAMESPACE_USING@' -i'.bak' Engine/NatronEngine/*.cpp Gui/NatronGui/*.cpp + +# replace NATRON_NAMESPACE with Natron for enums with flags (e.g. StandardButtonEnum) +sed -e 's@"NatronEngine\.NATRON_NAMESPACE@"NatronEngine.Natron@g' -e 's@, NatronEngine\.NATRON_NAMESPACE@, NatronEngine.Natron@g' -e 's@"NatronGui\.NATRON_NAMESPACE@"NatronGui.Natron@g' -e 's@"NATRON_NAMESPACE@"Natron@g' -i'.bak' Engine/NatronEngine/*_wrapper.cpp + +# re-add the Natron namespace +#sed -e 's@" ::\([^s][^t][^d]\)@ NATRON_NAMESPACE::\1@g' -i'.bak' Engine/NatronEngine/*.cpp Engine/NatronEngine/*.h Gui/NatronGui/*.cpp Gui/NatronGui/*.h + +sed -e '/AnimatedParam/ {:y;n;by};s@SbkType< ::\(.*\) >@SbkType@g' -i Engine/NatronEngine/natronengine_python.h +sed -e 's@SbkType< ::@SbkType$@CLANG_DIAG_OFF(header-guard)\ +#include // has wrong header guards in pyside 1.2.2@' -i'.bak' Engine/NatronEngine/*.cpp Gui/NatronGui/*.cpp + +sed -e 's@^#include $@CLANG_DIAG_OFF(deprecated)\ +CLANG_DIAG_OFF(uninitialized)\ +CLANG_DIAG_OFF(keyword-macro)\ +#include // produces warnings\ +CLANG_DIAG_ON(deprecated)\ +CLANG_DIAG_ON(uninitialized)\ +CLANG_DIAG_ON(keyword-macro)@' -i'.bak' Engine/NatronEngine/*.cpp Gui/NatronGui/*.cpp Engine/NatronEngine/*.h Gui/NatronGui/*.h + +sed -e 's@^#include $@CLANG_DIAG_OFF(deprecated)\ +CLANG_DIAG_OFF(uninitialized)\ +CLANG_DIAG_OFF(keyword-macro)\ +#include // produces warnings\ +CLANG_DIAG_ON(deprecated)\ +CLANG_DIAG_ON(uninitialized)\ +CLANG_DIAG_ON(keyword-macro)@' -i'.bak' Engine/NatronEngine/*.cpp Gui/NatronGui/*.cpp Engine/NatronEngine/*.h Gui/NatronGui/*.h + +# clean up +rm Gui/NatronGui/*.bak Engine/NatronEngine/*.bak