1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
|
#---------------------------------------------------------------------------
# Name: etg/defs.py
# Author: Robin Dunn
#
# Created: 19-Nov-2010
# Copyright: (c) 2010-2020 by Total Control Software
# License: wxWindows License
#---------------------------------------------------------------------------
import sys
import etgtools
import etgtools.tweaker_tools as tools
PACKAGE = "wx"
MODULE = "_core"
NAME = "defs" # Base name of the file to generate to for this script
DOCSTRING = ""
# The classes and/or the basename of the Doxygen XML files to be processed by
# this script.
ITEMS = [ 'defs_8h.xml',
'textfile_8h.xml', # Just for the wxTextFileType enum
]
#---------------------------------------------------------------------------
def run():
# Parse the XML file(s) building a collection of Extractor objects
module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING,
check4unittest=False)
etgtools.parseDoxyXML(module, ITEMS)
module.check4unittest = False
#-----------------------------------------------------------------
# Tweak the parsed meta objects in the module object as needed for
# customizing the generated code and docstrings.
module.addHeaderCode("#include <wx/textfile.h>")
# tweaks for defs.h to help SIP understand the types better
module.find('wxInt16').type = 'short'
module.find('wxInt64').type = 'long long'
module.find('wxUint64').type = 'unsigned long long'
# See src/wacky_ints.sip
module.find('wxIntPtr').ignore()
module.find('wxUIntPtr').ignore()
# Correct the types for these as their values are outside the range of int
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'
# 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
module.find('wxDELETE').ignore()
module.find('wxDELETEA').ignore()
module.find('wxSwap').ignore()
module.find('wxVaCopy').ignore()
# Add some typedefs for basic wx types and others so the backend
# generator knows what they are
td = module.find('wxUIntPtr')
module.insertItemAfter(td, etgtools.TypedefDef(type='wchar_t', name='wxUChar'))
module.insertItemAfter(td, etgtools.TypedefDef(type='wchar_t', name='wxChar'))
module.insertItemAfter(td, etgtools.TypedefDef(type='wxInt64', name='time_t'))
module.insertItemAfter(td, etgtools.TypedefDef(type='long long', name='wxFileOffset'))
module.insertItemAfter(td, etgtools.TypedefDef(type='Py_ssize_t', name='ssize_t'))
module.insertItemAfter(td, etgtools.TypedefDef(type='unsigned char', name='byte', pyInt=True))
module.insertItemAfter(td, etgtools.TypedefDef(type='unsigned long', name='ulong'))
# Forward declarations for classes that are referenced but not defined
# yet.
#
# TODO: Remove these when the classes are added for real.
# TODO: Add these classes for real :-)
module.insertItem(0, etgtools.WigCode("""\
// forward declarations
class wxExecuteEnv;
"""))
# Add some code for getting the version numbers
module.addCppCode("""
#include <wx/version.h>
const int MAJOR_VERSION = wxMAJOR_VERSION;
const int MINOR_VERSION = wxMINOR_VERSION;
const int RELEASE_NUMBER = wxRELEASE_NUMBER;
""")
module.addItem(etgtools.WigCode("""
const int MAJOR_VERSION;
const int MINOR_VERSION;
const int RELEASE_NUMBER;
"""))
# TODO: these should be removed someday
module.addPyCode("BG_STYLE_CUSTOM = BG_STYLE_PAINT")
module.addPyCode("ADJUST_MINSIZE = 0")
module.addPyCode("WS_EX_VALIDATE_RECURSIVELY = 0")
# This is only supported with C++14, so ignore it for now
module.find('wxDEPRECATED_ATTR').ignore()
#-----------------------------------------------------------------
tools.doCommonTweaks(module)
tools.runGenerators(module)
#---------------------------------------------------------------------------
if __name__ == '__main__':
run()
|