/* * Interface wrapper code. * * Generated by SIP 4.12-snapshot-93040d2c716c * * Copyright: (c) 2010 by Total Control Software * License: wxWindows License */ #include "sipAPI_core.h" extern "C" {static void assign_wxString(void *, SIP_SSIZE_T, const void *);} static void assign_wxString(void *sipDst, SIP_SSIZE_T sipDstIdx, const void *sipSrc) { reinterpret_cast(sipDst)[sipDstIdx] = *reinterpret_cast(sipSrc); } extern "C" {static void *array_wxString(SIP_SSIZE_T);} static void *array_wxString(SIP_SSIZE_T sipNrElem) { return new wxString[sipNrElem]; } extern "C" {static void *copy_wxString(const void *, SIP_SSIZE_T);} static void *copy_wxString(const void *sipSrc, SIP_SSIZE_T sipSrcIdx) { return new wxString(reinterpret_cast(sipSrc)[sipSrcIdx]); } /* Call the mapped type's destructor. */ extern "C" {static void release_wxString(void *, int);} static void release_wxString(void *ptr, int) { delete reinterpret_cast(ptr); } extern "C" {static int convertTo_wxString(PyObject *, void **, int *, PyObject *);} static int convertTo_wxString(PyObject *sipPy,void **sipCppPtrV,int *sipIsErr,PyObject *sipTransferObj) { wxString **sipCppPtr = reinterpret_cast(sipCppPtrV); #line 26 "src/string.sip" // just check the type? if (!sipIsErr) { if (PyString_Check(sipPy) || PyUnicode_Check(sipPy)) return 1; return 0; } // Or do the conversion #if wxUSE_UNICODE_WCHAR // wxString will contain wide chars (wchar_t) PyObject* uni = sipPy; if (PyString_Check(sipPy)) { // if it's a string object convert it to unicode first uni = PyUnicode_FromEncodedObject(sipPy, "utf-8", /*wxPyDefaultEncoding*/ "strict"); if (PyErr_Occurred()) return 0; } *sipCppPtr = new wxString(); size_t len = PyUnicode_GET_SIZE(uni); if (len) { PyUnicode_AsWideChar((PyUnicodeObject*)uni, wxStringBuffer(**sipCppPtr, len), len); } if (PyString_Check(sipPy)) Py_DECREF(uni); // release the temporary Unicode object we created return sipGetState(sipTransferObj); #else // wxString will contain a utf-8 encoded byte string. If source is // already a string then use it as-is, (assuming utf-8) otherwise // the Unicode object to utf-8 and use the converted value. char* tmpPtr; Py_ssize_t tmpSize; PyObject* str = NULL; //PyObject* uni = NULL; if (PyString_Check(sipPy) /*&& wxPyDefaultEncodingIsUTF8 */) { PyString_AsStringAndSize(sipPy, &tmpPtr, &tmpSize); } //else if (PyString_Check(sipPy)) { // uni = PyUnicode_FromEncodedObject(sipPy, wxPyDefaultEncoding, "strict"); // if (PyErr_Occurred()) return NULL; // str = PyUnicode_AsUTF8String(uni); // PyString_AsStringAndSize(sipPy, &tmpPtr, &tmpSize); //} else { str = PyUnicode_AsUTF8String(sipPy); PyString_AsStringAndSize(str, &tmpPtr, &tmpSize); } *sipCppPtr = new wxString(tmpPtr, tmpSize); Py_XDECREF(str); //Py_XDECREF(uni); return sipGetState(sipTransferObj); #endif #line 103 "sip_corewxString.cpp" } extern "C" {static PyObject *convertFrom_wxString(void *, PyObject *);} static PyObject *convertFrom_wxString(void *sipCppV,PyObject *) { wxString *sipCpp = reinterpret_cast(sipCppV); #line 82 "src/string.sip" return sipBuildResult(NULL, "G", sipCpp->c_str(), sipCpp->length()); #line 114 "sip_corewxString.cpp" } sipMappedTypeDef sipTypeDef__core_wxString = { { -1, 0, 0, SIP_TYPE_MAPPED, sipNameNr_wxString, {0} }, { -1, {0, 0, 1}, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, assign_wxString, array_wxString, copy_wxString, release_wxString, convertTo_wxString, convertFrom_wxString };