John,<div><br></div><div>Thank you!</div><div><br></div><div>I read both your answer and your response... are you saying me to use "value-type" instead of "primitive-type"?</div><div><br></div><div>I'm really confused because I can't find any documentation explaining specific cases like it.</div>
<div><br></div><div>Could you help me a little more?</div><div><br></div><div>I appreciate! </div><div><br></div><div>Best regards,</div><div>Luiz Vitor.<br><br><div class="gmail_quote">On Tue, Oct 23, 2012 at 11:35 AM, John Cummings <span dir="ltr"><<a href="mailto:jcummings2@users.sf.net" target="_blank">jcummings2@users.sf.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000"><div><div class="h5">
    On 10/22/2012 09:19 AM, Luiz Vitor Martinez Cardoso wrote:
    <blockquote type="cite">Anyone?<br>
      <br>
      <div class="gmail_quote">On Sun, Oct 14, 2012 at 3:54 PM, Luiz
        Vitor Martinez Cardoso <span dir="ltr"><<a href="mailto:grabber@gmail.com" target="_blank">grabber@gmail.com</a>></span> wrote:<br>
        <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
          Dear,
          <div><br>
          </div>
          <div>I'm new to PySide/Shiboken but I'm enjoying it!</div>
          <div><br>
          </div>
          <div>To be honest I don't like the lack of good and reasonable
            documentation and examples.</div>
          <div><br>
          </div>
          <div>
            I decided to create a git repo (<a href="https://github.com/Grabber/shiboken-binding-examples" target="_blank">https://github.com/Grabber/shiboken-binding-examples</a>)
            together my friend <i>Yann Lanthony </i>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.</div>
          <div><br>
          </div>
          <div>Today the master's help to solve a little trouble.</div>
          <div><br>
          </div>
          <div>I'm trying to wrap the following code:</div>
          <div><br>
          </div>
          <div>
            <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">class
              LIBFOO_EXPORT CustomType<br>
              {<br>
            </blockquote>
            <div> </div>
            <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">public:<br>
                      CustomType() {}<br>
                      virtual ~CustomType() {}<br>
                      CustomType(const CustomType&) {}<br>
                      int a;<br>
                      int * b;<br>
              };</blockquote>
            <div><br>
            </div>
            <div>Using the following TypeSystem:</div>
            <div><br>
            </div>
            <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><?xml
              version="1.0"?><br>
              <typesystem package="foo"><br>
              <span style="white-space:pre-wrap"> </span><primitive-type
              name="int"/><br>
              <span style="white-space:pre-wrap"> </span><load-typesystem
              name="typesystem_core.xml" generate="no"/><br>
                  <object-type name="CustomType" /><br>
              </typesystem> </blockquote>
          </div>
          <div><br>
          </div>
          <div>But I'm getting some pointers erros in the generated
            wrapping code:</div>
          <div><br>
          </div>
          <div>
            <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">/home/lmvc/Projects/shiboken-binding-examples/build/foo/foo/customtype_wrapper.cpp:
              In function ‘PyObject* Sbk_CustomType_get_b(PyObject*,
              void*)’:<br>
              /home/lmvc/Projects/shiboken-binding-examples/build/foo/foo/customtype_wrapper.cpp:166:33:
              error: invalid conversion from ‘int*’ to ‘int’
              [-fpermissive]<br>
              /home/lmvc/Projects/shiboken-binding-examples/build/foo/foo/customtype_wrapper.cpp:
              In function ‘int Sbk_CustomType_set_b(PyObject*,
              PyObject*, void*)’:<br>
              /home/lmvc/Projects/shiboken-binding-examples/build/foo/foo/customtype_wrapper.cpp:187:33:
              error: invalid conversion from ‘int*’ to ‘int’
              [-fpermissive]<br>
              /home/lmvc/Projects/shiboken-binding-examples/build/foo/foo/customtype_wrapper.cpp:189:18:
              error: invalid conversion from ‘int’ to ‘int*’
              [-fpermissive]<br>
              make[2]: ***
              [foo/CMakeFiles/foo.dir/foo/customtype_wrapper.cpp.o]
              Error 1</blockquote>
          </div>
          <div><br>
          </div>
          <div><br>
          </div>
          <div>The generated wrapping code was:</div>
          <div><br>
          </div>
          <div>
            <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">static
              PyObject* Sbk_CustomType_get_b(PyObject* self, void*)<br>
              {<br>
                  ::CustomType* cppSelf = 0;<br>
                  SBK_UNUSED(cppSelf)<br>
                  if (!Shiboken::Object::isValid(self))<br>
                      return 0;<br>
                  cppSelf =
              ((::CustomType*)Shiboken::Conversions::cppPointer(SbkfooTypes[SBK_CUSTOMTYPE_IDX],
              (SbkObject*)self));<br>
                  int cppOut_local = cppSelf->b;<br>
                  PyObject* pyOut =
              Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter<int>(),
              &cppOut_local);<br>
                  return pyOut;<br>
              }<br>
              static int Sbk_CustomType_set_b(PyObject* self, PyObject*
              pyIn, void*)<br>
              {<br>
                  ::CustomType* cppSelf = 0;<br>
                  SBK_UNUSED(cppSelf)<br>
                  if (!Shiboken::Object::isValid(self))<br>
                      return 0;<br>
                  cppSelf =
              ((::CustomType*)Shiboken::Conversions::cppPointer(SbkfooTypes[SBK_CUSTOMTYPE_IDX],
              (SbkObject*)self));<br>
                  if (pyIn == 0) {<br>
                      PyErr_SetString(PyExc_TypeError, "'b' may not be
              deleted");<br>
                      return -1;<br>
                  }<br>
                  PythonToCppFunc pythonToCpp;<br>
                  if (!(pythonToCpp =
              Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter<int>(),
              (pyIn)))) {<br>
                      PyErr_SetString(PyExc_TypeError, "wrong type
              attributed to 'b', 'int' or convertible type expected");<br>
                      return -1;<br>
                  }<br>
                  int cppOut_local = cppSelf->b;<br>
                  pythonToCpp(pyIn, &cppOut_local);<br>
                  cppSelf->b = cppOut_local;<br>
                  return 0;<br>
              }</blockquote>
            <div><br>
            </div>
            <div><br>
            </div>
            <div>Could someone tell me what is going on? I feel I have
              to inject some code in TypeSystem but I don't know well...</div>
            <div><br>
            </div>
            <div>I appreciate your help!</div>
            <div> </div>
          </div>
          <div>Best regards,</div>
          <div>Luiz Vitor.<span><font color="#888888"></font></span></div>
        </blockquote>
      </div>
    </blockquote>
    <br></div></div>
    Luiz,<br>
    <br>
    I'm not certain, but since no one else jumped in, I believe it
    relates to int being a primitive type. That is, it maps the types
    directly instead of using an opaque pointer. I seem to recall there
    being similar issues [1] for me when I tried to have a member array
    of primitives (which in C/C++ can be thought of as a glorified
    pointer). The summary of the answer had to do with not being able to
    keep track of updates to the pointer, or something like that.<br>
    <br>
    I believe types specified as "value-type" are similar in that they
    are passed by value.<br>
    <br>
    Perhaps someone more knowledgeable can correct my simplistic
    answers.<br>
    <br>
    Hope that helps<br>
    John Cummings<br>
    <br>
    [1] <a href="http://thread.gmane.org/gmane.comp.lib.qt.pyside/2331/focus=2332" target="_blank">http://thread.gmane.org/gmane.comp.lib.qt.pyside/2331/focus=2332</a><br>
  </div>

<br>_______________________________________________<br>
PySide mailing list<br>
<a href="mailto:PySide@qt-project.org">PySide@qt-project.org</a><br>
<a href="http://lists.qt-project.org/mailman/listinfo/pyside" target="_blank">http://lists.qt-project.org/mailman/listinfo/pyside</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>Regards, <br><br>Luiz Vitor Martinez Cardoso<div>Celular: (11) 7351-7097 | Skype: grabberbr <br>engineer student at <a href="http://maua.br" target="_blank">maua.br</a><div>
<a href="http://maua.br" target="_blank"></a>intern marketing engineer at <a href="http://geindustrial.com.br" target="_blank">geindustrial.com.br</a><br>entrepreneur at <a href="http://adboxnetwork.com" target="_blank">adboxnetwork.com</a></div>
<div><br>"If you wanna be successful, you need total dedication, go for your last limit, give your best and love your love infinitely!"</div></div><div><br></div><div>"T<span style="background-color:rgb(255,255,255);color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">he only limits are the ones you place upon yourself</span>"</div>
<br>
</div>