<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    On 10/22/2012 09:19 AM, Luiz Vitor Martinez Cardoso wrote:
    <blockquote
cite="mid:CA+ZwQ=Jm56WxZvmo2_PhJrRfeDMfEO9+f0N=MYhpceYuv_RHHQ@mail.gmail.com"
      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
            moz-do-not-send="true" 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 moz-do-not-send="true"
              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 class="HOEnZb"><font color="#888888"></font></span></div>
        </blockquote>
      </div>
    </blockquote>
    <br>
    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 class="moz-txt-link-freetext" href="http://thread.gmane.org/gmane.comp.lib.qt.pyside/2331/focus=2332">http://thread.gmane.org/gmane.comp.lib.qt.pyside/2331/focus=2332</a><br>
  </body>
</html>