On Tue, 21 Jul 2009 09:26:39 +0200, "Diez B. Roggisch" <[email protected]>
wrote:
> Hi,
> 
> well, the subject pretty much says it. The below code exectutes fine in 
> the debugger until it reaches the line
> 
>         irr::video::S3DVertex *vertex = (irr::video::S3DVertex 
> *)sipConvertToInstance(py_vertex, S3DVertexType, NULL, SIP_NOT_NONE, 
> NULL, &err);
> 
> 
> where "err" then gets some seemingly random value & the program 
> terminates. The if-statement below the line doesn't work and was a 
> feeble attempt at error-handling - a subject that is given not much more 
> information in the whole
> 
> http://www.riverbankcomputing.com/static/Docs/sip4/c_api.html
> 
> page.
> 
> Any suggestions? Ah, python is 2.6 on osx, SIP is 4.7.9.
> 
> 
> Diez
> 
> 
> void append(SIP_PYLIST, SIP_PYLIST);
> %MethodCode
>        PyObject *py_vertices = a0;
>        PyObject *py_indices = a1;
>        irr::u32 numVertices = PyList_Size(py_vertices);
>        irr::video::S3DVertex *vertices = (irr::video::S3DVertex 
> *)sipMalloc(sizeof(irr::video::S3DVertex) * numVertices);
>        irr::u32 numIndices = PyList_Size(py_indices);
>        irr::u16 *indices = (irr::u16*)sipMalloc(sizeof(irr::u16) * 
> numIndices);
> 
>        sipWrapperType *S3DVertexType = 
> sipFindClass("irr::video::S3DVertex");
> 
>        int err;
> 
>        for(irr::u32 i=0; i < numVertices; i++) {
>       PyObject *py_vertex = PyList_GetItem(py_vertices, i);
>       if(sipCanConvertToInstance(py_vertex, S3DVertexType, SIP_NOT_NONE)) {
>         irr::video::S3DVertex *vertex = (irr::video::S3DVertex 
> *)sipConvertToInstance(py_vertex, S3DVertexType, NULL, SIP_NOT_NONE, 
> NULL, &err);
>         if(err) {
>           return -1;
>         }
>         vertices[i] = *vertex;
>       } // TODO: raise an exception here!
>        }
> 
>        for(irr::u32 i=0; i < numIndices; i++) {
>       PyObject *py_index = PySequence_GetItem(py_indices, i);
>       irr::u16 indices[3];
>       for(int j=0; j < 3; j++) {
>         PyObject *item = PySequence_GetItem(py_index, j);
>         if(PyLong_Check(item)) {
>           indices[j] = (irr::u16)PyLong_AsLong(item);
>         } else {
>           // TODO: raise an exception here!
>         }
>       }
>        }
>        sipCpp->append((void*)vertices, numVertices, indices, numIndices);
>        sipFree(indices);
>        sipFree(vertices);
> %End

What is S3DVertexType? I would expect it to start with 'sipClass_'.

Phil
_______________________________________________
PyQt mailing list    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to