<div dir="ltr">Made a bit more progress I think. The below is building but crashing when trying to convert from the Python Obj to a SiftPoint. <div><br></div><div>The %GetCode returns what I am expecting - a Python list of SiftPoint objects. The SiftPoint has been wrapped. The %SetCode is seg. faulting on sipConvertToType.</div><div><br></div><div>Within the %GetCode, I do not believe I have access to sipTransferObj or sipIsErr.</div><div><br></div><div>Two questions:</div><div><br></div><div>1) Is this the intended use of %GetCode and %SetCode? Should I be using another directive?</div><div><br></div><div>2) In the SetCode block, how does one go about converting a list of class instances into a C++ pointer? Is this code heading down the right path?</div><div><br></div><div>Thanks! </div><div><div><br></div><div><div><font face="monospace, monospace"> SiftPoint *h_data</font></div><div><font face="monospace, monospace"> {</font></div><div><font face="monospace, monospace"> %GetCode</font></div><div><font face="monospace, monospace"> size_t size = sipCpp->numPts;</font></div><div><font face="monospace, monospace"> PyObject *l = PyList_New(sipCpp->numPts);</font></div><div><font face="monospace, monospace"> for (size_t i = 0; i < size; ++i){</font></div><div><font face="monospace, monospace"> SiftPoint *sp = new SiftPoint(sipCpp->h_data[i]);</font></div><div><font face="monospace, monospace"> PyObject *p = sipConvertFromType((void*)(sp), sipType_SiftPoint, NULL);</font></div><div><font face="monospace, monospace"> PyList_SetItem(l, i, p);</font></div><div><font face="monospace, monospace"> }</font></div><div><font face="monospace, monospace"> return l;</font></div><div><font face="monospace, monospace"> %End</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"> %SetCode</font></div><div><font face="monospace, monospace"> size_t length = PyList_GET_SIZE(sipPy);</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"> for (int i=0; i < length; ++i){</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"> if (!sipCanConvertToType(PyList_GET_ITEM(sipPy, i),</font></div><div><font face="monospace, monospace"> sipType_SiftPoint, SIP_NOT_NONE))</font></div><div><font face="monospace, monospace"> return 0;</font></div><div><font face="monospace, monospace"> }</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"> printf("So far so good\n");</font></div><div><font face="monospace, monospace"> sipCpp->numPts = length;</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"> // Set the length of the h_data</font></div><div><font face="monospace, monospace"> SiftPoint h_data[length];</font></div><div><font face="monospace, monospace"> sipCpp->h_data = h_data;</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"> for (size_t i=0; i < length; ++i){</font></div><div><font face="monospace, monospace"> PyObject *sp = PyList_GetItem(sipPy, i);</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"> SiftPoint *sif = reinterpret_cast<SiftPoint *>(sipConvertToType(sp,</font></div><div><font face="monospace, monospace"> sipType_SiftPoint,</font></div><div><font face="monospace, monospace"> NULL,</font></div><div><font face="monospace, monospace"> SIP_NOT_NONE,</font></div><div><font face="monospace, monospace"> NULL, 0));</font></div><div><font face="monospace, monospace"> h_data[i] = *sif;</font></div><div><font face="monospace, monospace"> }</font></div><div><font face="monospace, monospace"> %End</font></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 25, 2016 at 6:32 AM, Jay L. <span dir="ltr"><<a href="mailto:jlaura@asu.edu" target="_blank">jlaura@asu.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Unfortunately, the sip error is non-specific. It looks like what I actually need to use is %GetCode and %SetCode.<div><br></div><div>Thanks!</div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 25, 2016 at 12:56 AM, Phil Thompson <span dir="ltr"><<a href="mailto:phil@riverbankcomputing.com" target="_blank">phil@riverbankcomputing.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>On 24 Oct 2016, at 11:25 pm, Jay L. <<a href="mailto:jlaura@asu.edu" target="_blank">jlaura@asu.edu</a>> wrote:<br>
><br>
> I have a class with an attribute that is a pointer:<br>
><br>
> public:<br>
> SiftPoint *h_data<br>
><br>
> I can write %MethodCode to expose a custom 'get_h_data()' method, How should I expose the attribute directly, e.g. my_py_class.h_data,<br>
><br>
> I tried %MappedType, but am getting sip errors...<br>
<br>
</span>...then fix the sip errors.<br>
<span class="m_-6995116761874894608HOEnZb"><font color="#888888"><br>
Phil</font></span></blockquote></div><br></div>
</div></div></blockquote></div><br></div>