From 3634414c506c20a7dcfe7d9c2a9953c4ba3d9ab6 Mon Sep 17 00:00:00 2001 From: Scott Talbert Date: Tue, 8 Mar 2016 00:07:55 -0500 Subject: [PATCH] Rework fix for #define type extraction A user running 32-bit Windows reported a problem with wx.VSCROLL after my changes in aa0be27. It is likely some integer conversion is not happening correctly between C++ and Python. To resolve this, convert the #defines that are using standard WX 32-bit values back to int and instead insert casts into the SIP generated cpp code to resolve the C++11 compilation errors. --- build.py | 12 ++++++++++++ etg/_stc.py | 3 --- etg/defs.py | 5 +---- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/build.py b/build.py index ea8fe910..ea4b6f6d 100755 --- a/build.py +++ b/build.py @@ -1023,6 +1023,18 @@ def cmd_sip(options, args): # ...or totally remove them by replacing those lines with '' import re srcTxt = re.sub(r'^#line.*\n', '', srcTxt, flags=re.MULTILINE) + # Perform a couple of manual modifications to the generated cpp + # to fix C++11 compilation errors. + if os.path.basename(src) == 'sip_corecmodule.cpp': + srcTxt = srcTxt.replace('wxCANCEL_DEFAULT},', + 'static_cast(wxCANCEL_DEFAULT)},') + srcTxt = srcTxt.replace('wxVSCROLL},', + 'static_cast(wxVSCROLL)},') + srcTxt = srcTxt.replace('wxWINDOW_STYLE_MASK},', + 'static_cast(wxWINDOW_STYLE_MASK)},') + if os.path.basename(src) == 'sip_stccmodule.cpp': + srcTxt = srcTxt.replace('wxSTC_MASK_FOLDERS},', + 'static_cast(wxSTC_MASK_FOLDERS)},') return srcTxt # Check each file in tmpdir to see if it is different than the same file diff --git a/etg/_stc.py b/etg/_stc.py index d9e1a9ee..8f3f02c9 100644 --- a/etg/_stc.py +++ b/etg/_stc.py @@ -123,9 +123,6 @@ def run(): return rv; """) - # Correct the type for this define as its value is outside the range of int - module.find('wxSTC_MASK_FOLDERS').type = 'unsigned long' - # TODO: Add the UTF8 PyMethods from classic (see _stc_utf8_methods.py) diff --git a/etg/defs.py b/etg/defs.py index 28929d43..8e82d632 100644 --- a/etg/defs.py +++ b/etg/defs.py @@ -48,13 +48,10 @@ def run(): module.find('wxUIntPtr').type = 'unsigned long' #'size_t' # Correct the types for these as their values are outside the range of int - module.find('wxUINT32_MAX').type = 'long' + module.find('wxUINT32_MAX').type = 'unsigned long' module.find('wxINT64_MIN').type = 'long long' module.find('wxINT64_MAX').type = 'long long' module.find('wxUINT64_MAX').type = 'unsigned long long' - module.find('wxCANCEL_DEFAULT').type = 'unsigned long' - module.find('wxWINDOW_STYLE_MASK').type = 'unsigned long' - module.find('wxVSCROLL').type = 'unsigned long' module.find('wxInt8').pyInt = True module.find('wxUint8').pyInt = True