[PySide] Shiboken not generating right code for member pointers?
Luiz Vitor Martinez Cardoso
grabber at gmail.com
Sun Oct 14 20:54:57 CEST 2012
Dear,
I'm new to PySide/Shiboken but I'm enjoying it!
To be honest I don't like the lack of good and reasonable documentation and
examples.
I decided to create a git repo (
https://github.com/Grabber/shiboken-binding-examples) together my friend *Yann
Lanthony *to archive all the solutions we get to work in our lab. At the
end we plan to write a very detailed and extensive article including
everything from the installation (Win, OSX and Linux) to the binding
process itself.
Today the master's help to solve a little trouble.
I'm trying to wrap the following code:
class LIBFOO_EXPORT CustomType
> {
>
> public:
> CustomType() {}
> virtual ~CustomType() {}
> CustomType(const CustomType&) {}
> int a;
> int * b;
> };
Using the following TypeSystem:
<?xml version="1.0"?>
> <typesystem package="foo">
> <primitive-type name="int"/>
> <load-typesystem name="typesystem_core.xml" generate="no"/>
> <object-type name="CustomType" />
> </typesystem>
But I'm getting some pointers erros in the generated wrapping code:
/home/lmvc/Projects/shiboken-binding-examples/build/foo/foo/customtype_wrapper.cpp:
> In function ‘PyObject* Sbk_CustomType_get_b(PyObject*, void*)’:
> /home/lmvc/Projects/shiboken-binding-examples/build/foo/foo/customtype_wrapper.cpp:166:33:
> error: invalid conversion from ‘int*’ to ‘int’ [-fpermissive]
> /home/lmvc/Projects/shiboken-binding-examples/build/foo/foo/customtype_wrapper.cpp:
> In function ‘int Sbk_CustomType_set_b(PyObject*, PyObject*, void*)’:
> /home/lmvc/Projects/shiboken-binding-examples/build/foo/foo/customtype_wrapper.cpp:187:33:
> error: invalid conversion from ‘int*’ to ‘int’ [-fpermissive]
> /home/lmvc/Projects/shiboken-binding-examples/build/foo/foo/customtype_wrapper.cpp:189:18:
> error: invalid conversion from ‘int’ to ‘int*’ [-fpermissive]
> make[2]: *** [foo/CMakeFiles/foo.dir/foo/customtype_wrapper.cpp.o] Error 1
The generated wrapping code was:
static PyObject* Sbk_CustomType_get_b(PyObject* self, void*)
> {
> ::CustomType* cppSelf = 0;
> SBK_UNUSED(cppSelf)
> if (!Shiboken::Object::isValid(self))
> return 0;
> cppSelf =
> ((::CustomType*)Shiboken::Conversions::cppPointer(SbkfooTypes[SBK_CUSTOMTYPE_IDX],
> (SbkObject*)self));
> int cppOut_local = cppSelf->b;
> PyObject* pyOut =
> Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter<int>(),
> &cppOut_local);
> return pyOut;
> }
> static int Sbk_CustomType_set_b(PyObject* self, PyObject* pyIn, void*)
> {
> ::CustomType* cppSelf = 0;
> SBK_UNUSED(cppSelf)
> if (!Shiboken::Object::isValid(self))
> return 0;
> cppSelf =
> ((::CustomType*)Shiboken::Conversions::cppPointer(SbkfooTypes[SBK_CUSTOMTYPE_IDX],
> (SbkObject*)self));
> if (pyIn == 0) {
> PyErr_SetString(PyExc_TypeError, "'b' may not be deleted");
> return -1;
> }
> PythonToCppFunc pythonToCpp;
> if (!(pythonToCpp =
> Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter<int>(),
> (pyIn)))) {
> PyErr_SetString(PyExc_TypeError, "wrong type attributed to 'b',
> 'int' or convertible type expected");
> return -1;
> }
> int cppOut_local = cppSelf->b;
> pythonToCpp(pyIn, &cppOut_local);
> cppSelf->b = cppOut_local;
> return 0;
> }
Could someone tell me what is going on? I feel I have to inject some code
in TypeSystem but I don't know well...
I appreciate your help!
Best regards,
Luiz Vitor.
--
Regards,
Luiz Vitor Martinez Cardoso
Celular: (11) 7351-7097 | Skype: grabberbr
engineer student at maua.br
<http://maua.br>intern marketing engineer at geindustrial.com.br
entrepreneur at adboxnetwork.com
"If you wanna be successful, you need total dedication, go for your last
limit, give your best and love your love infinitely!"
"The only limits are the ones you place upon yourself"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/pyside/attachments/20121014/9d782def/attachment.html>
More information about the PySide
mailing list