X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/23bed520417f9946f01bbcf2f18c26a7bc3cb2a7..8f8b0a8dfed146fec87b78b2f5cece71b4c99d31:/wxPython/src/utils.i?ds=sidebyside diff --git a/wxPython/src/utils.i b/wxPython/src/utils.i index eb04fabdb4..f90583d8af 100644 --- a/wxPython/src/utils.i +++ b/wxPython/src/utils.i @@ -14,12 +14,19 @@ %module utils %{ -#include "export.h" +#include "helpers.h" #include #include #include %} +//--------------------------------------------------------------------------- +%{ + // Put some wx default wxChar* values into wxStrings. + DECLARE_DEF_STRING2(DateFormatStr, wxT("%c")); + static const wxString wxPyEmptyString(wxT("")); + +%} //--------------------------------------------------------------------------- %include typemaps.i @@ -38,7 +45,11 @@ PyObject* ret = PyTuple_New(3); if (ret) { PyTuple_SET_ITEM(ret, 0, PyInt_FromLong(flag)); - PyTuple_SET_ITEM(ret, 1, PyString_FromString(str)); +#if wxUSE_UNICODE + PyTuple_SET_ITEM(ret, 1, PyUnicode_FromUnicode(str.c_str(), str.Len())); +#else + PyTuple_SET_ITEM(ret, 1, PyString_FromStringAndSize(str.c_str(), str.Len())); +#endif PyTuple_SET_ITEM(ret, 2, PyInt_FromLong(index)); } return ret; @@ -58,10 +69,10 @@ enum class wxConfigBase { public: -// wxConfigBase(const wxString& appName = wxEmptyString, **** An ABC -// const wxString& vendorName = wxEmptyString, -// const wxString& localFilename = wxEmptyString, -// const wxString& globalFilename = wxEmptyString, +// wxConfigBase(const wxString& appName = wxPyEmptyString, **** An ABC +// const wxString& vendorName = wxPyEmptyString, +// const wxString& localFilename = wxPyEmptyString, +// const wxString& globalFilename = wxPyEmptyString, // long style = 0); ~wxConfigBase(); @@ -146,7 +157,7 @@ public: bool IsExpandingEnvVars(); bool IsRecordingDefaults(); - wxString Read(const wxString& key, const wxString& defaultVal = wxEmptyString); + wxString Read(const wxString& key, const wxString& defaultVal = wxPyEmptyString); %addmethods { long ReadInt(const wxString& key, long defaultVal = 0) { @@ -196,10 +207,10 @@ public: // This will be a wxRegConfig on Win32 and wxFileConfig otherwise. class wxConfig : public wxConfigBase { public: - wxConfig(const wxString& appName = wxEmptyString, - const wxString& vendorName = wxEmptyString, - const wxString& localFilename = wxEmptyString, - const wxString& globalFilename = wxEmptyString, + wxConfig(const wxString& appName = wxPyEmptyString, + const wxString& vendorName = wxPyEmptyString, + const wxString& localFilename = wxPyEmptyString, + const wxString& globalFilename = wxPyEmptyString, long style = 0); ~wxConfig(); }; @@ -208,10 +219,10 @@ public: // Sometimes it's nice to explicitly have a wxFileConfig too. class wxFileConfig : public wxConfigBase { public: - wxFileConfig(const wxString& appName = wxEmptyString, - const wxString& vendorName = wxEmptyString, - const wxString& localFilename = wxEmptyString, - const wxString& globalFilename = wxEmptyString, + wxFileConfig(const wxString& appName = wxPyEmptyString, + const wxString& vendorName = wxPyEmptyString, + const wxString& localFilename = wxPyEmptyString, + const wxString& globalFilename = wxPyEmptyString, long style = 0); ~wxFileConfig(); }; @@ -736,9 +747,10 @@ public: wxDateTime __sub__TS(const wxTimeSpan& other) { return *self - other; } wxDateTime __sub__DS(const wxDateSpan& other) { return *self - other; } - int __cmp__(const wxDateTime& other) { - if (*self < other) return -1; - if (*self == other) return 0; + int __cmp__(const wxDateTime* other) { + if (! other) return -1; + if (*self < *other) return -1; + if (*self == *other) return 0; return 1; } } @@ -767,32 +779,32 @@ public: // parse a string in RFC 822 format (found e.g. in mail headers and // having the form "Wed, 10 Feb 1999 19:07:07 +0100") - const char *ParseRfc822Date(const char* date); + wxString ParseRfc822Date(const wxString& date); // parse a date/time in the given format (see strptime(3)), fill in // the missing (in the string) fields with the values of dateDef (by // default, they will not change if they had valid values or will // default to Today() otherwise) - const char *ParseFormat(const char *date, - const char *format = "%c", - const wxDateTime& dateDef = wxDefaultDateTime); + wxString ParseFormat(const wxString& date, + const wxString& format = wxPyDateFormatStr, + const wxDateTime& dateDef = wxDefaultDateTime); // parse a string containing the date/time in "free" format, this // function will try to make an educated guess at the string contents - const char *ParseDateTime(const char *datetime); + wxString ParseDateTime(const wxString& datetime); // parse a string containing the date only in "free" format (less // flexible than ParseDateTime) - const char *ParseDate(const char *date); + wxString ParseDate(const wxString& date); // parse a string containing the time only in "free" format - const char *ParseTime(const char *time); + wxString ParseTime(const wxString& time); // this function accepts strftime()-like format string (default // argument corresponds to the preferred date and time representation // for the current locale) and returns the string containing the // resulting text representation - wxString Format(const char *format = "%c", + wxString Format(const wxString& format = wxPyDateFormatStr, const wxDateTime::TimeZone& tz = LOCAL) const; // preferred date representation for the current locale @@ -883,9 +895,10 @@ public: wxTimeSpan __mul__(int n) { return *self * n; } wxTimeSpan __rmul__(int n) { return n * *self; } wxTimeSpan __neg__() { return self->Negate(); } - int __cmp__(const wxTimeSpan& other) { - if (*self < other) return -1; - if (*self == other) return 0; + int __cmp__(const wxTimeSpan* other) { + if (! other) return -1; + if (*self < *other) return -1; + if (*self == *other) return 0; return 1; } } @@ -942,7 +955,7 @@ public: // resulting text representation. Notice that only some of format // specifiers valid for wxDateTime are valid for wxTimeSpan: hours, // minutes and seconds make sense, but not "PM/AM" string for example. - wxString Format(const char *format = "%c") const; + wxString Format(const wxString& format = wxPyDateFormatStr) const; // // preferred date representation for the current locale // wxString FormatDate() const; @@ -1051,8 +1064,9 @@ wxLongLong wxGetLocalTimeMillis(); //--------------------------------------------------------------------------- %init %{ - wxClassInfo::CleanUpClasses(); - wxClassInfo::InitializeClasses(); + // These are no longer needed since utils is back in the core +// wxClassInfo::CleanUpClasses(); +// wxClassInfo::InitializeClasses(); %} //---------------------------------------------------------------------------