Fixes to allow compilation in Unicode mode on wxGTK2. Python's
internal Unicode representation may or may not match wchar_t. Previously I was using the optimized APIs that assumed they were the same, but they aren't on Linux so this checkin switches to the more general Python APIs. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@18518 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -407,7 +407,7 @@ public:
|
||||
|
||||
for (int i=0; i<count; i++) {
|
||||
#if wxUSE_UNICODE
|
||||
PyList_SetItem(list, i, PyUnicode_FromUnicode(files[i], files[i].Len()));
|
||||
PyList_SetItem(list, i, PyUnicode_FromWideChar(files[i], files[i].Len()));
|
||||
#else
|
||||
PyList_SetItem(list, i, PyString_FromString((const char*)files[i]));
|
||||
#endif
|
||||
|
@@ -361,6 +361,9 @@ public:
|
||||
wxString GetStyleString() const;
|
||||
wxString GetWeightString() const;
|
||||
|
||||
void SetNoAntiAliasing( bool no = TRUE );
|
||||
bool GetNoAntiAliasing();
|
||||
|
||||
static wxFontEncoding GetDefaultEncoding();
|
||||
static void SetDefaultEncoding(wxFontEncoding encoding);
|
||||
|
||||
|
@@ -302,12 +302,7 @@ void __wxPreStart(PyObject* moduleDict)
|
||||
int x;
|
||||
for(x=0; x<argc; x++) {
|
||||
PyObject *item = PyList_GetItem(sysargv, x);
|
||||
#if wxUSE_UNICODE
|
||||
if (PyUnicode_Check(item))
|
||||
argv[x] = wxPyCopyCString(PyUnicode_AS_UNICODE(item));
|
||||
else
|
||||
#endif
|
||||
argv[x] = wxPyCopyCString(PyString_AsString(item));
|
||||
argv[x] = wxPyCopyCString(Py2wxString(item));
|
||||
}
|
||||
argv[argc] = NULL;
|
||||
}
|
||||
@@ -338,12 +333,7 @@ PyObject* __wxStart(PyObject* /* self */, PyObject* args)
|
||||
int x;
|
||||
for(x=0; x<argc; x++) {
|
||||
PyObject *pyArg = PyList_GetItem(sysargv, x);
|
||||
#if wxUSE_UNICODE
|
||||
if (PyUnicode_Check(pyArg))
|
||||
argv[x] = wxPyCopyWString(PyUnicode_AS_UNICODE(pyArg));
|
||||
else
|
||||
#endif
|
||||
argv[x] = wxPyCopyWString(PyString_AsString(pyArg));
|
||||
argv[x] = wxPyCopyWString(Py2wxString(pyArg));
|
||||
}
|
||||
argv[argc] = NULL;
|
||||
}
|
||||
@@ -522,7 +512,7 @@ PyObject* wxPyClassExists(const wxString& className) {
|
||||
|
||||
char buff[64]; // should always be big enough...
|
||||
|
||||
sprintf(buff, "%sPtr", className.mbc_str());
|
||||
sprintf(buff, "%sPtr", (const char*)className.mbc_str());
|
||||
PyObject* classobj = PyDict_GetItemString(wxPython_dict, buff);
|
||||
|
||||
return classobj; // returns NULL if not found
|
||||
@@ -1474,7 +1464,10 @@ wxString* wxString_in_helper(PyObject* source) {
|
||||
}
|
||||
#if wxUSE_UNICODE
|
||||
if (PyUnicode_Check(source)) {
|
||||
target = new wxString(PyUnicode_AS_UNICODE(source));
|
||||
target = new wxString();
|
||||
size_t len = PyUnicode_GET_SIZE(source);
|
||||
PyUnicode_AsWideChar((PyUnicodeObject*)source, target->GetWriteBuf(len), len);
|
||||
target->UngetWriteBuf();
|
||||
} else {
|
||||
// It is a string, get pointers to it and transform to unicode
|
||||
char* tmpPtr; int tmpSize;
|
||||
@@ -1516,7 +1509,9 @@ wxString Py2wxString(PyObject* source)
|
||||
|
||||
#if wxUSE_UNICODE
|
||||
if (PyUnicode_Check(source)) {
|
||||
target = PyUnicode_AS_UNICODE(source);
|
||||
size_t len = PyUnicode_GET_SIZE(source);
|
||||
PyUnicode_AsWideChar((PyUnicodeObject*)source, target.GetWriteBuf(len), len);
|
||||
target.UngetWriteBuf();
|
||||
} else {
|
||||
// It is a string, get pointers to it and transform to unicode
|
||||
char* tmpPtr; int tmpSize;
|
||||
@@ -1549,7 +1544,7 @@ PyObject* wx2PyString(const wxString& src)
|
||||
{
|
||||
PyObject* str;
|
||||
#if wxUSE_UNICODE
|
||||
str = PyUnicode_FromUnicode(src.c_str(), src.Len());
|
||||
str = PyUnicode_FromWideChar(src.c_str(), src.Len());
|
||||
#else
|
||||
str = PyString_FromStringAndSize(src.c_str(), src.Len());
|
||||
#endif
|
||||
@@ -2170,7 +2165,7 @@ PyObject* wxArrayString2PyList_helper(const wxArrayString& arr) {
|
||||
PyObject* list = PyList_New(0);
|
||||
for (size_t i=0; i < arr.GetCount(); i++) {
|
||||
#if wxUSE_UNICODE
|
||||
PyObject* str = PyUnicode_FromUnicode(arr[i].c_str(), arr[i].Len());
|
||||
PyObject* str = PyUnicode_FromWideChar(arr[i].c_str(), arr[i].Len());
|
||||
#else
|
||||
PyObject* str = PyString_FromStringAndSize(arr[i].c_str(), arr[i].Len());
|
||||
#endif
|
||||
|
@@ -1212,7 +1212,7 @@ public:
|
||||
wxString str;
|
||||
if (self->GetMimeType(&str)) {
|
||||
#if wxUSE_UNICODE
|
||||
return PyUnicode_FromUnicode(str.c_str(), str.Len());
|
||||
return PyUnicode_FromWideChar(str.c_str(), str.Len());
|
||||
#else
|
||||
return PyString_FromStringAndSize(str.c_str(), str.Len());
|
||||
#endif
|
||||
@@ -1264,7 +1264,7 @@ public:
|
||||
PyTuple_SetItem(tuple, 0, wxPyConstructObject(new wxIcon(icon),
|
||||
wxT("wxIcon"), TRUE));
|
||||
#if wxUSE_UNICODE
|
||||
PyTuple_SetItem(tuple, 1, PyUnicode_FromUnicode(iconFile.c_str(), iconFile.Len()));
|
||||
PyTuple_SetItem(tuple, 1, PyUnicode_FromWideChar(iconFile.c_str(), iconFile.Len()));
|
||||
#else
|
||||
PyTuple_SetItem(tuple, 1, PyString_FromStringAndSize(iconFile.c_str(), iconFile.Len()));
|
||||
#endif
|
||||
@@ -1283,7 +1283,7 @@ public:
|
||||
wxString str;
|
||||
if (self->GetDescription(&str)) {
|
||||
#if wxUSE_UNICODE
|
||||
return PyUnicode_FromUnicode(str.c_str(), str.Len());
|
||||
return PyUnicode_FromWideChar(str.c_str(), str.Len());
|
||||
#else
|
||||
return PyString_FromStringAndSize(str.c_str(), str.Len());
|
||||
#endif
|
||||
@@ -1300,7 +1300,7 @@ public:
|
||||
wxString str;
|
||||
if (self->GetOpenCommand(&str, wxFileType::MessageParameters(filename, mimetype))) {
|
||||
#if wxUSE_UNICODE
|
||||
return PyUnicode_FromUnicode(str.c_str(), str.Len());
|
||||
return PyUnicode_FromWideChar(str.c_str(), str.Len());
|
||||
#else
|
||||
return PyString_FromStringAndSize(str.c_str(), str.Len());
|
||||
#endif
|
||||
@@ -1317,7 +1317,7 @@ public:
|
||||
wxString str;
|
||||
if (self->GetPrintCommand(&str, wxFileType::MessageParameters(filename, mimetype))) {
|
||||
#if wxUSE_UNICODE
|
||||
return PyUnicode_FromUnicode(str.c_str(), str.Len());
|
||||
return PyUnicode_FromWideChar(str.c_str(), str.Len());
|
||||
#else
|
||||
return PyString_FromStringAndSize(str.c_str(), str.Len());
|
||||
#endif
|
||||
@@ -1696,7 +1696,7 @@ public:
|
||||
// #define ADD_STRING(dict, str) \
|
||||
// wxString tmp##str(str); \
|
||||
// PyDict_SetItemString(dict, #str, \
|
||||
// PyUnicode_FromUnicode(tmp##str.c_str(), tmp##str.Len()))
|
||||
// PyUnicode_FromWideChar(tmp##str.c_str(), tmp##str.Len()))
|
||||
// #else
|
||||
// #define ADD_STRING(dict, str) \
|
||||
// PyDict_SetItemString(d, #str, PyString_FromString(str))
|
||||
|
@@ -168,7 +168,7 @@ $function
|
||||
|
||||
%typemap(python, out) wxString {
|
||||
#if wxUSE_UNICODE
|
||||
$target = PyUnicode_FromUnicode($source->c_str(), $source->Len());
|
||||
$target = PyUnicode_FromWideChar($source->c_str(), $source->Len());
|
||||
#else
|
||||
$target = PyString_FromStringAndSize($source->c_str(), $source->Len());
|
||||
#endif
|
||||
@@ -180,7 +180,7 @@ $function
|
||||
|
||||
%typemap(python, out) wxString* {
|
||||
#if wxUSE_UNICODE
|
||||
$target = PyUnicode_FromUnicode($source->c_str(), $source->Len());
|
||||
$target = PyUnicode_FromWideChar($source->c_str(), $source->Len());
|
||||
#else
|
||||
$target = PyString_FromStringAndSize($source->c_str(), $source->Len());
|
||||
#endif
|
||||
@@ -274,11 +274,10 @@ $function
|
||||
PyObject* item = PySequence_GetItem($source, i);
|
||||
#if wxUSE_UNICODE
|
||||
PyObject* str = PyObject_Unicode(item);
|
||||
$target->Add(PyUnicode_AsUnicode(str));
|
||||
#else
|
||||
PyObject* str = PyObject_Str(item);
|
||||
$target->Add(PyString_AsString(str));
|
||||
#endif
|
||||
$target->Add(Py2wxString(str));
|
||||
Py_DECREF(item);
|
||||
Py_DECREF(str);
|
||||
}
|
||||
|
@@ -46,7 +46,7 @@
|
||||
if (ret) {
|
||||
PyTuple_SET_ITEM(ret, 0, PyInt_FromLong(flag));
|
||||
#if wxUSE_UNICODE
|
||||
PyTuple_SET_ITEM(ret, 1, PyUnicode_FromUnicode(str.c_str(), str.Len()));
|
||||
PyTuple_SET_ITEM(ret, 1, PyUnicode_FromWideChar(str.c_str(), str.Len()));
|
||||
#else
|
||||
PyTuple_SET_ITEM(ret, 1, PyString_FromStringAndSize(str.c_str(), str.Len()));
|
||||
#endif
|
||||
|
@@ -277,7 +277,7 @@ static wxPyCoreAPI API = {
|
||||
PyDict_SetItemString(d,"wxVERSION_NUMBER", PyInt_FromLong((long)wxVERSION_NUMBER ));
|
||||
#if wxUSE_UNICODE
|
||||
wxString tempStr(wxVERSION_STRING);
|
||||
PyDict_SetItemString(d,"wxVERSION_STRING", PyUnicode_FromUnicode(tempStr.c_str(), tempStr.Len()));
|
||||
PyDict_SetItemString(d,"wxVERSION_STRING", PyUnicode_FromWideChar(tempStr.c_str(), tempStr.Len()));
|
||||
#else
|
||||
PyDict_SetItemString(d,"wxVERSION_STRING", PyString_FromString(wxVERSION_STRING));
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user