From aa0be2719e8d2577a6b6857660c97bc73ecc8111 Mon Sep 17 00:00:00 2001 From: Scott Talbert Date: Sat, 27 Feb 2016 21:41:54 -0500 Subject: [PATCH] Fix extraction for #define's when not an integer or string Some #define values fall outside the range of int, so we need to override the types. --- etg/_stc.py | 3 +++ etg/defs.py | 9 +++++++++ etg/richtextbuffer.py | 5 ++++- etgtools/sip_generator.py | 2 ++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/etg/_stc.py b/etg/_stc.py index 27560f55..242daec6 100644 --- a/etg/_stc.py +++ b/etg/_stc.py @@ -120,6 +120,9 @@ 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 9b19d0fc..28929d43 100644 --- a/etg/defs.py +++ b/etg/defs.py @@ -47,6 +47,15 @@ def run(): module.find('wxIntPtr').type = 'long' #'ssize_t' 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('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 module.find('wxByte').pyInt = True diff --git a/etg/richtextbuffer.py b/etg/richtextbuffer.py index 946f2ed4..946344bf 100644 --- a/etg/richtextbuffer.py +++ b/etg/richtextbuffer.py @@ -394,7 +394,10 @@ def run(): m.ignore() - + + # Correct the type for this define as it is a float + module.find('wxSCRIPT_MUL_FACTOR').type = 'float' + #----------------------------------------------------------------- tools.doCommonTweaks(module) tools.runGenerators(module) diff --git a/etgtools/sip_generator.py b/etgtools/sip_generator.py index 7965022a..4a4f9f63 100644 --- a/etgtools/sip_generator.py +++ b/etgtools/sip_generator.py @@ -268,6 +268,8 @@ from .%s import * # so tell sip that's what it is. if '"' in define.value: stream.write('const char* %s;\n' % define.name) + elif hasattr(define, 'type'): + stream.write('const %s %s;\n' % (define.type, define.name)) else: stream.write('const int %s;\n' % define.name)