diff --git a/build.py b/build.py index ea4b6f6d..ea8fe910 100755 --- a/build.py +++ b/build.py @@ -1023,18 +1023,6 @@ 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 8f3f02c9..c0544ece 100644 --- a/etg/_stc.py +++ b/etg/_stc.py @@ -123,6 +123,11 @@ def run(): return rv; """) + + # Generate the code for this differently because it needs to be + # forcibly mashed into an int in the C code + module.find('wxSTC_MASK_FOLDERS').forcedInt = True + # TODO: Add the UTF8 PyMethods from classic (see _stc_utf8_methods.py) diff --git a/etg/defs.py b/etg/defs.py index 70b844a8..d2fff99b 100644 --- a/etg/defs.py +++ b/etg/defs.py @@ -49,6 +49,12 @@ def run(): module.find('wxINT64_MAX').type = 'long long' module.find('wxUINT64_MAX').type = 'unsigned long long' + # Generate the code for these differently because they need to be + # forcibly mashed into an int in the C code + module.find('wxCANCEL_DEFAULT').forcedInt = True + module.find('wxVSCROLL').forcedInt = True + module.find('wxWINDOW_STYLE_MASK').forcedInt = True + module.find('wxInt8').pyInt = True module.find('wxUint8').pyInt = True module.find('wxByte').pyInt = True diff --git a/etgtools/sip_generator.py b/etgtools/sip_generator.py index 4a4f9f63..0901e5bc 100644 --- a/etgtools/sip_generator.py +++ b/etgtools/sip_generator.py @@ -270,6 +270,14 @@ from .%s import * stream.write('const char* %s;\n' % define.name) elif hasattr(define, 'type'): stream.write('const %s %s;\n' % (define.type, define.name)) + elif getattr(define, 'forcedInt', False): + stream.write('%PostInitialisationCode\n') + #stream.write('printf("**** %s: %%d\\n", %s);\n' % (define.name, define.name)) + stream.write((' PyDict_SetItemString(sipModuleDict, "%s", ' + 'wxPyInt_FromLong(static_cast(%s)));\n') % + (define.pyName, define.name)) + stream.write('%End\n') + else: stream.write('const int %s;\n' % define.name) diff --git a/unittests/test_defs.py b/unittests/test_defs.py new file mode 100644 index 00000000..ad51c24f --- /dev/null +++ b/unittests/test_defs.py @@ -0,0 +1,29 @@ +import imp_unittest, unittest +import wtc +import wx + +#--------------------------------------------------------------------------- + +class defs_Tests(wtc.WidgetTestCase): + + + def test_constants1(self): + # These constants are not plain int's + self.assertEqual(wx.UINT32_MAX, 2**32-1) + self.assertEqual(wx.INT64_MIN, (-9223372036854775807)-1) + self.assertEqual(wx.INT64_MAX, 9223372036854775807) + self.assertEqual(wx.UINT64_MAX, 0xFFFFFFFFFFFFFFFF) + + def test_constants2(self): + # These constants needed some special tweaking. Make sure it + # was done right. + self.assertEqual(wx.VSCROLL, -2147483648) + self.assertEqual(wx.CANCEL_DEFAULT, -2147483648) + self.assertEqual(wx.WINDOW_STYLE_MASK, -65536) + + +#--------------------------------------------------------------------------- + + +if __name__ == '__main__': + unittest.main()