Skip to content

Commit

Permalink
Python/shiboken: All files included by shiboken must have a namespace…
Browse files Browse the repository at this point in the history
… macro (such as NATRON_NAMESPACE_ENTER) appended with a ';' character, otherwise shiboken fails to generate code. Bug was introduced in 8b2b551
  • Loading branch information
MrKepzie committed Jul 21, 2017
1 parent fae0b52 commit bc1445a
Show file tree
Hide file tree
Showing 17 changed files with 72 additions and 55 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

# History

## Version 2.3.1

- Python: Fix the setTable() function of the PathParam class
- Windows: Fix a bug where most image formats would not read and write correctly

## Version 2.3.0

Expand Down
13 changes: 10 additions & 3 deletions Engine/NatronEngine/pathparam_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ static PyObject* Sbk_PathParamFunc_setTable(PyObject* self, PyObject* pyArg)


PyObject* subList = PyList_GET_ITEM(pyArg,i);
if (!subList) {
if (!subList || !PyList_Check(subList)) {
PyErr_SetString(PyExc_TypeError, "table must be a list of list objects.");
return 0;
}
Expand All @@ -161,8 +161,14 @@ static PyObject* Sbk_PathParamFunc_setTable(PyObject* self, PyObject* pyArg)

for (int j = 0; j < subSize; ++j) {
PyObject* pyString = PyList_GET_ITEM(subList,j);
if ( PyUnicode_Check(pyString) ) {

if ( PyString_Check(pyString) ) {
char* buf = PyString_AsString(pyString);
if (buf) {
std::string ret;
ret.append(buf);
rowVec[j] = ret;
}
} else if (PyUnicode_Check(pyString) ) {
PyObject* utf8pyobj = PyUnicode_AsUTF8String(pyString); // newRef
if (utf8pyobj) {
char* cstr = PyBytes_AS_STRING(utf8pyobj); // Borrowed pointer
Expand All @@ -173,6 +179,7 @@ static PyObject* Sbk_PathParamFunc_setTable(PyObject* self, PyObject* pyArg)
}
}
}
table.push_back(rowVec);
}

cppSelf->setTable(table);
Expand Down
8 changes: 4 additions & 4 deletions Engine/PyAppInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ CLANG_DIAG_ON(uninitialized)
#include "Engine/PyNode.h"
#include "Engine/EngineFwd.h"

NATRON_NAMESPACE_ENTER
NATRON_PYTHON_NAMESPACE_ENTER
NATRON_NAMESPACE_ENTER;
NATRON_PYTHON_NAMESPACE_ENTER;

class AppSettings
{
Expand Down Expand Up @@ -332,7 +332,7 @@ class App
boost::shared_ptr<NodeCollection> getCollectionFromGroup(Group* group) const;
};

NATRON_PYTHON_NAMESPACE_EXIT
NATRON_NAMESPACE_EXIT
NATRON_PYTHON_NAMESPACE_EXIT;
NATRON_NAMESPACE_EXIT;

#endif // Engine_AppInstanceWrapper_h
8 changes: 4 additions & 4 deletions Engine/PyExprUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@

#include "Engine/PyParameter.h"

NATRON_NAMESPACE_ENTER
NATRON_PYTHON_NAMESPACE_ENTER
NATRON_NAMESPACE_ENTER;
NATRON_PYTHON_NAMESPACE_ENTER;


class ExprUtils
Expand Down Expand Up @@ -121,8 +121,8 @@ class ExprUtils
static double pnoise(const Double3DTuple& p, const Double3DTuple& period);
};

NATRON_PYTHON_NAMESPACE_EXIT
NATRON_NAMESPACE_EXIT
NATRON_PYTHON_NAMESPACE_EXIT;
NATRON_NAMESPACE_EXIT;


#endif // PYNOISE_H
8 changes: 4 additions & 4 deletions Engine/PyGlobalFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@

#include "Engine/EngineFwd.h"

NATRON_NAMESPACE_ENTER
NATRON_PYTHON_NAMESPACE_ENTER
NATRON_NAMESPACE_ENTER;
NATRON_PYTHON_NAMESPACE_ENTER;

class PyCoreApplication
{
Expand Down Expand Up @@ -227,8 +227,8 @@ class PyCoreApplication
}
};

NATRON_PYTHON_NAMESPACE_EXIT
NATRON_NAMESPACE_EXIT
NATRON_PYTHON_NAMESPACE_EXIT;
NATRON_NAMESPACE_EXIT;

#if defined(PYSIDE_H) && defined(PYSIDE_OLD)
namespace PySide {
Expand Down
4 changes: 2 additions & 2 deletions Engine/PyNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
#include "Engine/RectD.h"
#include "Engine/EngineFwd.h"

NATRON_NAMESPACE_ENTER
NATRON_PYTHON_NAMESPACE_ENTER
NATRON_NAMESPACE_ENTER;
NATRON_PYTHON_NAMESPACE_ENTER;

class ImageLayer
{
Expand Down
4 changes: 2 additions & 2 deletions Engine/PyNodeGroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@

#include "Engine/EngineFwd.h"

NATRON_NAMESPACE_ENTER
NATRON_PYTHON_NAMESPACE_ENTER
NATRON_NAMESPACE_ENTER;
NATRON_PYTHON_NAMESPACE_ENTER;

class Group
{
Expand Down
8 changes: 4 additions & 4 deletions Engine/PyParameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
#include "Engine/KnobFile.h"
#include "Engine/EngineFwd.h"

NATRON_NAMESPACE_ENTER
NATRON_PYTHON_NAMESPACE_ENTER
NATRON_NAMESPACE_ENTER;
NATRON_PYTHON_NAMESPACE_ENTER;

class Param
{
Expand Down Expand Up @@ -1194,7 +1194,7 @@ class ParametricParam
void setDefaultCurvesFromCurrentCurves();
};

NATRON_PYTHON_NAMESPACE_EXIT
NATRON_NAMESPACE_EXIT
NATRON_PYTHON_NAMESPACE_EXIT;
NATRON_NAMESPACE_EXIT;

#endif // Engine_ParameterWrapper_h
8 changes: 4 additions & 4 deletions Engine/PyRoto.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
#include "Engine/PyParameter.h"
#include "Engine/EngineFwd.h"

NATRON_NAMESPACE_ENTER
NATRON_PYTHON_NAMESPACE_ENTER
NATRON_NAMESPACE_ENTER;
NATRON_PYTHON_NAMESPACE_ENTER;

class Layer; // defined below

Expand Down Expand Up @@ -191,7 +191,7 @@ class Roto
boost::shared_ptr<RotoContext> _ctx;
};

NATRON_PYTHON_NAMESPACE_EXIT
NATRON_NAMESPACE_EXIT
NATRON_PYTHON_NAMESPACE_EXIT;
NATRON_NAMESPACE_EXIT;

#endif // ROTOWRAPPER_H
8 changes: 4 additions & 4 deletions Engine/PyTracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
#include "Engine/PyParameter.h"
#include "Engine/EngineFwd.h"

NATRON_NAMESPACE_ENTER
NATRON_PYTHON_NAMESPACE_ENTER
NATRON_NAMESPACE_ENTER;
NATRON_PYTHON_NAMESPACE_ENTER;

class Track
{
Expand Down Expand Up @@ -100,7 +100,7 @@ class Tracker
boost::weak_ptr<TrackerContext> _ctx;
};

NATRON_PYTHON_NAMESPACE_EXIT
NATRON_NAMESPACE_EXIT
NATRON_PYTHON_NAMESPACE_EXIT;
NATRON_NAMESPACE_EXIT;

#endif // Engine_PyTracker_H
4 changes: 2 additions & 2 deletions Engine/RectD.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
GCC_DIAG_OFF(strict-overflow)
#endif

NATRON_NAMESPACE_ENTER
NATRON_NAMESPACE_ENTER;

class RectD
{
Expand Down Expand Up @@ -344,7 +344,7 @@ operator!=(const RectD & b1,
b1.top() != b2.top();
}

NATRON_NAMESPACE_EXIT
NATRON_NAMESPACE_EXIT;

Q_DECLARE_METATYPE(NATRON_NAMESPACE::RectD)

Expand Down
4 changes: 2 additions & 2 deletions Engine/RectI.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
GCC_DIAG_OFF(strict-overflow)
#endif

NATRON_NAMESPACE_ENTER
NATRON_NAMESPACE_ENTER;

/**
* @brief A rectangle where x1 < x2 and y1 < y2 such as width() == (x2 - x1) && height() == (y2 - y1)
Expand Down Expand Up @@ -469,7 +469,7 @@ operator!=(const RectI & b1,
return !(b1 == b2);
}

NATRON_NAMESPACE_EXIT
NATRON_NAMESPACE_EXIT;

Q_DECLARE_METATYPE(NATRON_NAMESPACE::RectI)

Expand Down
18 changes: 12 additions & 6 deletions Engine/typesystem_engine.xml
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@
<enum-type name="PixmapEnum"/>
<enum-type name="ValueChangedReasonEnum"/>
<enum-type name="AnimationLevelEnum"/>
<enum-type name="ImageComponentsEnum"/>
<enum-type name="ImageBitDepthEnum"/>
<enum-type name="ImagePremultiplicationEnum"/>
<enum-type name="ViewerCompositingOperatorEnum"/>
Expand Down Expand Up @@ -770,10 +769,10 @@
</modify-function>

</object-type>

<value-type name="ImageLayer" copyable="true" hash-function="ImageLayer::getHash">
</value-type>

<value-type name="ImageLayer" copyable="true" hash-function="ImageLayer::getHash">
</value-type>

<object-type name="Group" copyable="false">
<inject-documentation format="target">
This is an abstract class, it is derived by 2 different classes:
Expand Down Expand Up @@ -1506,8 +1505,14 @@

for (int j = 0; j &lt; subSize; ++j) {
PyObject* pyString = PyList_GET_ITEM(subList,j);
if ( PyString_Check(pyString) || PyUnicode_Check(pyString) ) {

if ( PyString_Check(pyString) ) {
char* buf = PyString_AsString(pyString);
if (buf) {
std::string ret;
ret.append(buf);
rowVec[j] = ret;
}
} else if (PyUnicode_Check(pyString) ) {
PyObject* utf8pyobj = PyUnicode_AsUTF8String(pyString); // newRef
if (utf8pyobj) {
char* cstr = PyBytes_AS_STRING(utf8pyobj); // Borrowed pointer
Expand All @@ -1518,6 +1523,7 @@
}
}
}
table.push_back(rowVec);
}

%CPPSELF.%FUNCTION_NAME(table);
Expand Down
4 changes: 2 additions & 2 deletions Gui/NatronGui/natrongui_module_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ void init_PyGuiApplication(PyObject* module);
void init_GuiApp(PyObject* module);
void init_PyViewer(PyObject* module);
void init_PyTabWidget(PyObject* module);
void init_PyPanel(PyObject* module);
void init_PyModalDialog(PyObject* module);
void init_PyPanel(PyObject* module);

// Required modules' type and converter arrays.
PyTypeObject** SbkPySide_QtGuiTypes;
Expand Down Expand Up @@ -508,8 +508,8 @@ SBK_MODULE_INIT_FUNCTION_BEGIN(NatronGui)
init_GuiApp(module);
init_PyViewer(module);
init_PyTabWidget(module);
init_PyPanel(module);
init_PyModalDialog(module);
init_PyPanel(module);

// Register converter for type 'const std::map<QString,NodeCreationProperty*>&'.
SbkNatronGuiTypeConverters[SBK_NATRONGUI_STD_MAP_QSTRING_NODECREATIONPROPERTYPTR_IDX] = Shiboken::Conversions::createConverter(&PyDict_Type, _conststd_map_QString_NodeCreationPropertyPTR_REF_CppToPython__conststd_map_QString_NodeCreationPropertyPTR_REF);
Expand Down
8 changes: 4 additions & 4 deletions Gui/PyGlobalGui.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ CLANG_DIAG_ON(uninitialized)
#include "Gui/GuiApplicationManager.h"
#include "Gui/GuiFwd.h"

NATRON_NAMESPACE_ENTER
NATRON_PYTHON_NAMESPACE_ENTER
NATRON_NAMESPACE_ENTER;
NATRON_PYTHON_NAMESPACE_ENTER;

class PyGuiApplication
: public PyCoreApplication
Expand Down Expand Up @@ -121,7 +121,7 @@ class PyGuiApplication
}
};

NATRON_PYTHON_NAMESPACE_EXIT
NATRON_NAMESPACE_EXIT
NATRON_PYTHON_NAMESPACE_EXIT;
NATRON_NAMESPACE_EXIT;

#endif // GLOBAL_GUI_WRAPPER_H
8 changes: 4 additions & 4 deletions Gui/PyGuiApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
#include "Gui/GuiAppInstance.h"
#include "Gui/GuiFwd.h"

NATRON_NAMESPACE_ENTER
NATRON_PYTHON_NAMESPACE_ENTER
NATRON_NAMESPACE_ENTER;
NATRON_PYTHON_NAMESPACE_ENTER;

class PyViewer
{
Expand Down Expand Up @@ -165,7 +165,7 @@ class GuiApp
void renderBlocking(const std::list<Effect*>& effects, const std::list<int>& firstFrames, const std::list<int>& lastFrames, const std::list<int>& frameSteps);
};

NATRON_PYTHON_NAMESPACE_EXIT
NATRON_NAMESPACE_EXIT
NATRON_PYTHON_NAMESPACE_EXIT;
NATRON_NAMESPACE_EXIT;

#endif // GUIAPPWRAPPER_H
8 changes: 4 additions & 4 deletions Gui/PythonPanels.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ CLANG_DIAG_ON(uninitialized)
#include "Gui/PanelWidget.h"
#include "Gui/GuiFwd.h"

NATRON_NAMESPACE_ENTER
NATRON_PYTHON_NAMESPACE_ENTER
NATRON_NAMESPACE_ENTER;
NATRON_PYTHON_NAMESPACE_ENTER;

struct DialogParamHolderPrivate;
class DialogParamHolder
Expand Down Expand Up @@ -215,7 +215,7 @@ class PyTabWidget
QString getScriptName() const;
};

NATRON_PYTHON_NAMESPACE_EXIT
NATRON_NAMESPACE_EXIT
NATRON_PYTHON_NAMESPACE_EXIT;
NATRON_NAMESPACE_EXIT;

#endif // PYTHONPANELS_H

1 comment on commit bc1445a

@devernay
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

";" was removed to avoid numerous warnings. I don't remember if it was from recent clang or GCC. These warnings have to be disabled in Global.h if removing the semicolumn doesn't work. Warnings must be fixed.

Please sign in to comment.