Skip to content

Commit

Permalink
Python: add Effect::getInput(inputLabel) for convenience
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKepzie committed Sep 15, 2016
1 parent f1638c6 commit 98eb346
Show file tree
Hide file tree
Showing 8 changed files with 297 additions and 237 deletions.
14 changes: 11 additions & 3 deletions Documentation/source/devel/PythonReference/NatronEngine/Effect.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Functions
* def :meth:`getCurrentTime<NatronEngine.Effect.getCurrentTime>` ()
* def :meth:`getFrameRate<NatronEngine.Effect.getFrameRate>` ()
* def :meth:`getInput<NatronEngine.Effect.getInput>` (inputNumber)
* def :meth:`getInput<NatronEngine.Effect.getInput>` (inputName)
* def :meth:`getLabel<NatronEngine.Effect.getLabel>` ()
* def :meth:`getInputLabel<NatronEngine.Effect.getInputLabel>` (inputNumber)
* def :meth:`getMaxInputCount<NatronEngine.Effect.getMaxInputCount>` ()
Expand Down Expand Up @@ -258,10 +259,17 @@ thread.
:param inputNumber: :class:`int<PySide.QtCore.int>`
:rtype: :class:`Effect<NatronEngine.Effect>`

Returns the node connected at the given *inputNumber*.


Returns the node connected at the given *inputNumber*.


.. method:: NatronEngine.Effect.getInput(inputName)


:param inputName: :class:`str<PySide.QtCore.QString>`
:rtype: :class:`Effect<NatronEngine.Effect>`

Same as :func:`getInput(inputNumber)<NatronEngine.Effect.getInput>` except that the parameter in input
is the name of the input as diplayed on the node-graph. This function is made available for convenience.



Expand Down
46 changes: 34 additions & 12 deletions Engine/NatronEngine/effect_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,26 +570,48 @@ static PyObject* Sbk_EffectFunc_getInput(PyObject* self, PyObject* pyArg)
SBK_UNUSED(pythonToCpp)

// Overloaded function decisor
// 0: getInput(int)const
// 0: getInput(QString)const
// 1: getInput(int)const
if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter<int>(), (pyArg)))) {
overloadId = 0; // getInput(int)const
overloadId = 1; // getInput(int)const
} else if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArg)))) {
overloadId = 0; // getInput(QString)const
}

// Function signature not found.
if (overloadId == -1) goto Sbk_EffectFunc_getInput_TypeError;

// Call function/method
{
int cppArg0;
pythonToCpp(pyArg, &cppArg0);
switch (overloadId) {
case 0: // getInput(const QString & inputLabel) const
{
::QString cppArg0 = ::QString();
pythonToCpp(pyArg, &cppArg0);

if (!PyErr_Occurred()) {
// getInput(int)const
Effect * cppResult = const_cast<const ::Effect*>(cppSelf)->getInput(cppArg0);
pyResult = Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkNatronEngineTypes[SBK_EFFECT_IDX], cppResult);
if (!PyErr_Occurred()) {
// getInput(QString)const
Effect * cppResult = const_cast<const ::Effect*>(cppSelf)->getInput(cppArg0);
pyResult = Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkNatronEngineTypes[SBK_EFFECT_IDX], cppResult);

// Ownership transferences.
Shiboken::Object::getOwnership(pyResult);
// Ownership transferences.
Shiboken::Object::getOwnership(pyResult);
}
break;
}
case 1: // getInput(int inputNumber) const
{
int cppArg0;
pythonToCpp(pyArg, &cppArg0);

if (!PyErr_Occurred()) {
// getInput(int)const
Effect * cppResult = const_cast<const ::Effect*>(cppSelf)->getInput(cppArg0);
pyResult = Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkNatronEngineTypes[SBK_EFFECT_IDX], cppResult);

// Ownership transferences.
Shiboken::Object::getOwnership(pyResult);
}
break;
}
}

Expand All @@ -600,7 +622,7 @@ static PyObject* Sbk_EffectFunc_getInput(PyObject* self, PyObject* pyArg)
return pyResult;

Sbk_EffectFunc_getInput_TypeError:
const char* overloads[] = {"int", 0};
const char* overloads[] = {"unicode", "int", 0};
Shiboken::setErrorAboutWrongArguments(pyArg, "NatronEngine.Effect.getInput", overloads);
return 0;
}
Expand Down
Loading

0 comments on commit 98eb346

Please sign in to comment.