Details
-
Bug
-
Resolution: Cannot Reproduce
-
Not Evaluated
-
None
-
1.2.x
-
None
-
64-bit Linux with gcc 4.6.2
Description
Newer versions of Shiboken do not handle passing an enum by reference. I noticed the issue with the 1.1.1 release and it still exists in HEAD. I know shiboken properly handled passing an enum by reference in version 1.0.7. I am not sure about versions in between 1.0.7 and 1.1.1.
To recreate the error, I changed the Val::oneOrTheOtherEnumValue method in the libminimal test case to pass the enum by value like so:
ValEnum oneOrTheOtherEnumValue(ValEnum& enumValue) { return enumValue == One ? Other : One; }
This change results in the following error:
[ 60%] Building CXX object tests/minimalbinding/CMakeFiles/minimal.dir/minimal/val_wrapper.cpp.o /home/john.cummings/packages/python/pyside/git/shiboken/build/tests/minimalbinding/minimal/val_wrapper.cpp: In function 'PyObject* Sbk_ValFunc_oneOrTheOtherEnumValue(PyObject*, PyObject*)': /home/john.cummings/packages/python/pyside/git/shiboken/build/tests/minimalbinding/minimal/val_wrapper.cpp:400:77: error: no matching function for call to 'Val::oneOrTheOtherEnumValue(Val::ValEnum*&)' /home/john.cummings/packages/python/pyside/git/shiboken/build/tests/minimalbinding/minimal/val_wrapper.cpp:400:77: note: candidate is: /home/john.cummings/packages/python/pyside/git/shiboken/tests/libminimal/val.h:47:13: note: Val::ValEnum Val::oneOrTheOtherEnumValue(Val::ValEnum&) /home/john.cummings/packages/python/pyside/git/shiboken/tests/libminimal/val.h:47:13: note: no known conversion for argument 1 from 'Val::ValEnum*' to 'Val::ValEnum&' make[2]: *** [tests/minimalbinding/CMakeFiles/minimal.dir/minimal/val_wrapper.cpp.o] Error 1 make[1]: *** [tests/minimalbinding/CMakeFiles/minimal.dir/all] Error 2
The relevant portion of the auto-generated code is as follows:
// Call function/method { ::Val::ValEnum* cppArg0; pythonToCpp(pyArg, &cppArg0); if (!PyErr_Occurred()) { // oneOrTheOtherEnumValue(Val::ValEnum&) PyThreadState* _save = PyEval_SaveThread(); // Py_BEGIN_ALLOW_THREADS Val::ValEnum cppResult = cppSelf->oneOrTheOtherEnumValue(cppArg0); PyEval_RestoreThread(_save); // Py_END_ALLOW_THREADS pyResult = Shiboken::Conversions::copyToPython(SBK_CONVERTER(SbkminimalTypes[SBK_VAL_VALENUM_IDX]), &cppResult); } }
Released version 1.0.7 produced the following code that compiled and ran just fine:
// Call function/method { Val::ValEnum & cppArg0 = Shiboken::Converter< ::Val::ValEnum & >::toCpp(pyArg); if(!PyErr_Occurred()) { // oneOrTheOtherEnumValue(Val::ValEnum&) PyThreadState* _save = PyEval_SaveThread(); // Py_BEGIN_ALLOW_THREADS Val::ValEnum cppResult = cppSelf->oneOrTheOtherEnumValue(cppArg0); PyEval_RestoreThread(_save); // Py_END_ALLOW_THREADS pyResult = Shiboken::Converter< ::Val::ValEnum >::toPython(cppResult); } }