[PySide] Python bindings generation
Alexandre
alexandre.gauthier-foichat at inria.fr
Thu Oct 23 08:12:07 CEST 2014
Somehow putting the templates in the same type system.xml solved the
> insert-template referring to non-existing template 'stdListToPyList'
Now when calling my function getPluginIDs() from Python, I get a crash in the call to convertToPython of std::string, any clue about the crash ?
// C++ to Python conversion for type 'std::list<std::string >'.
static PyObject* std_list_std_string__CppToPython_std_list_std_string_(const void* cppIn) {
::std::list<std::string >& cppInRef = *((::std::list<std::string >*)cppIn);
// TEMPLATE - stdListToPyList - START
PyObject* pyOut = PyList_New((int) cppInRef.size());
::std::list<std::string >::const_iterator it = cppInRef.begin();
for (int idx = 0; it != cppInRef.end(); ++it, ++idx) {
::std::string cppItem(*it);
PyList_SET_ITEM(pyOut, idx,
// CRASHING IN THE FOLLOWING LINE
Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter<std::string>(), &cppItem));
}
return pyOut;
// TEMPLATE - stdListToPyList - END
}
> On 22 Oct 2014, at 14:29, Alexandre <alexandre.gauthier-foichat at inria.fr> wrote:
>
> Hi Tom,
>
> Thank you for your quick answer.
> Indeed with the wrapper around global functions I could make it work!;)
>
> However I still don’t understand one thing:
>
> If I supplied the a conversion for std::list and for std::string, do I need to also provide a conversion for std::list<std::string> ?
>
> My function signature is the following:
>
> inline std::list<std::string>
> getPluginIDs()
> {
> // Code logic
> }
>
>
> I’m declaring it in the type system this way:
> <function signature="getPluginIDs()"/>
>
>
> std::list and std::string conversion are declared as told in the previous mail.
> The generated code by Shiboken looks like this, with empty functions:
>
> // C++ to Python conversion for type 'std::list<std::string >'.
> static PyObject* std_list_std_string__CppToPython_std_list_std_string_(const void* cppIn) {
> ::std::list<std::string >& cppInRef = *((::std::list<std::string >*)cppIn);
>
>
>
> }
> static void std_list_std_string__PythonToCpp_std_list_std_string_(PyObject* pyIn, void* cppOut) {
> ::std::list<std::string >& cppOutRef = *((::std::list<std::string >*)cppOut);
>
>
>
> }
>
>
> And I get the following warning:
> insert-template referring to non-existing template 'stdListToPyList'
> Any clue on what might cause this ?
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/pyside/attachments/20141023/f56fe4e2/attachment.html>
More information about the PySide
mailing list