diff --git a/etg/_core.py b/etg/_core.py index 6e7287c5..f247f02c 100644 --- a/etg/_core.py +++ b/etg/_core.py @@ -4,7 +4,7 @@ # # Created: 8-Nove-2010 # Copyright: (c) 2010 by Total Control Software -# Licence: wxWindows license +# License: wxWindows License #--------------------------------------------------------------------------- PACKAGE = "wx" @@ -22,6 +22,8 @@ ITEMS = [ # Parse the XML file(s) building a collection of Extractor objects import etgtools +import etgtools.tweaker_tools as tools + module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING) etgtools.parseDoxyXML(module, ITEMS) @@ -29,9 +31,8 @@ etgtools.parseDoxyXML(module, ITEMS) # Tweak the parsed meta objects in the module object as needed for customizing # the generated code and docstrings. -import etgtools.tweaker_tools as tools -tools.ignoreAssignmentOperators(module) -tools.removeWxPrefixes(module) + +module.addHeaderCode('#include ') # These items are in their own etg scripts for easier maintainability, @@ -42,9 +43,18 @@ tools.removeWxPrefixes(module) # the promoted script to be the same as its NAME. module.addInclude(['string', + 'clntdata', + 'windowid', 'object', + + 'tracker', + 'kbdstate', + 'mousestate', + 'event', + 'gdicmn', 'geometry', + ]) @@ -66,7 +76,10 @@ module.insertItemAfter(td, etgtools.TypedefDef(type='wchar_t', name='wxUChar')) module.insertItemAfter(td, etgtools.TypedefDef(type='wchar_t', name='wxChar')) + #--------------------------------------------------------------------------- +tools.ignoreAssignmentOperators(module) +tools.removeWxPrefixes(module) #--------------------------------------------------------------------------- # Run the generators diff --git a/etg/event.py b/etg/event.py new file mode 100644 index 00000000..52ada4ae --- /dev/null +++ b/etg/event.py @@ -0,0 +1,341 @@ +#--------------------------------------------------------------------------- +# Name: etg/event.py +# Author: Robin Dunn +# +# Created: 15-Nov-2010 +# Copyright: (c) 2010 by Total Control Software +# License: wxWindows License +#--------------------------------------------------------------------------- + +PACKAGE = "wx" +MODULE = "_core" +NAME = "event" # 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 = [ + 'wxEvtHandler', + 'wxEventBlocker', + + 'wxEvent', + 'wxCommandEvent', + + 'wxActivateEvent', + 'wxChildFocusEvent', + 'wxClipboardTextEvent', + 'wxCloseEvent', + 'wxContextMenuEvent', + 'wxDisplayChangedEvent', + 'wxDropFilesEvent', + 'wxEraseEvent', + 'wxFocusEvent', + 'wxHelpEvent', + 'wxIconizeEvent', + 'wxIdleEvent', + 'wxInitDialogEvent', + 'wxJoystickEvent', + 'wxKeyEvent', + 'wxMaximizeEvent', + 'wxMenuEvent', + 'wxMouseCaptureChangedEvent', + 'wxMouseCaptureLostEvent', + 'wxMouseEvent', + 'wxMoveEvent', + 'wxNavigationKeyEvent', + 'wxNotifyEvent', + 'wxPaintEvent', + 'wxPaletteChangedEvent', + 'wxQueryNewPaletteEvent', + 'wxScrollEvent', + 'wxScrollWinEvent', + 'wxSetCursorEvent', + 'wxShowEvent', + 'wxSizeEvent', + 'wxSysColourChangedEvent', + 'wxUpdateUIEvent', + 'wxWindowCreateEvent', + 'wxWindowDestroyEvent', + + #'wxThreadEvent', +] + +#--------------------------------------------------------------------------- +# Parse the XML file(s) building a collection of Extractor objects + +import etgtools +import etgtools.tweaker_tools as tools + +module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING) +etgtools.parseDoxyXML(module, ITEMS) + +#--------------------------------------------------------------------------- +# Tweak the parsed meta objects in the module object as needed for customizing +# the generated code and docstrings. + +module.addCppCode(""" +#if !wxUSE_HOTKEY +#define wxEVT_HOTKEY 0 +#endif +""") + +module.insertItem(0, etgtools.WigCode("class wxWindow; // forward declaration")) +module.insertItem(0, etgtools.WigCode("class wxDC; // forward declaration")) +module.insertItem(0, etgtools.WigCode("class wxMenu; // forward declaration")) +module.insertItem(0, etgtools.WigCode("class wxCursor; // forward declaration")) + +# TODO: +# * PyEventBinder class +# * event binder instances for all the event types implemented here +# * Connect, Bind etc. methods for EvtHandler + + +#--------------------------------------- +# wxEvtHandler +c = module.find('wxEvtHandler') +c.addPrivateCopyCtor() + +# Ignore the Connect/Disconnect and Bind/Unbind methods for now. +for item in c.allItems(): + if item.name in ['Connect', 'Disconnect', 'Bind', 'Unbind']: + item.ignore() + + +# wxEventTable is not documented so we have to ignore SearchEventTable. +# TODO: Should wxEventTable be available to language bindings? +c.find('SearchEventTable').ignore() + +# TODO: If we don't need to use the wxEvtHandler's client data for our own +# tracking then enable these.... +c.find('GetClientObject').ignore() +c.find('SetClientObject').ignore() +c.find('GetClientData').ignore() +c.find('SetClientData').ignore() + + +#--------------------------------------- +# wxEvent +c = module.find('wxEvent') +c.abstract = True +c.find('Clone').factory = True + +# Clone is not declared in the derived classes where it is implemented so we +# need to pretend that it is not pure-virtual so the derived classes will not +# be marked as abstract. Although perhaps it would be better to go ahead and +# add the declaration to the derived classes? TODO: decide this +c.find('Clone').isPureVirtual = False + +c.addProperty('EventObject GetEventObject SetEventObject') +c.addProperty('EventType GetEventType SetEventType') +c.addProperty('Id GetId SetId') +c.addProperty('Skipped GetSkipped') +c.addProperty('Timestamp GetTimestamp SetTimestamp') + + + +#--------------------------------------- +# wxCommandEvent +c = module.find('wxCommandEvent') +assert isinstance(c, etgtools.ClassDef) + +c.find('GetClientObject').ignore() +c.find('SetClientObject').ignore() +c.find('GetClientData').ignore() +c.find('SetClientData').ignore() + +c.addCppMethod('SIP_PYOBJECT', 'GetClientData', '()', """\ + wxPyClientData* data = (wxPyClientData*)sipCpp->GetClientObject(); + if (data) { + Py_INCREF(data->m_obj); + sipRes = data->m_obj; + } else { + Py_INCREF(Py_None); + sipRes = Py_None; + } +""") + +c.addCppMethod('void', 'SetClientData', '(SIP_PYOBJECT clientData)', """\ + wxPyClientData* data = new wxPyClientData(clientData); + sipCpp->SetClientObject(data); +""") + + +c.addProperty('ClientData GetClientData SetClientData') +c.addProperty('ExtraLong GetExtraLong SetExtraLong') +c.addProperty('Int GetInt SetInt') +c.addProperty('Selection GetSelection') +c.addProperty('String GetString SetString') + + +#--------------------------------------- +# wxKeyEvent +c = module.find('wxKeyEvent') + +c.find('GetPosition').findOverload('long').ignore() + +c.addProperty('X GetX') +c.addProperty('Y GetY') +c.addProperty('KeyCode GetKeyCode') +c.addProperty('Position GetPosition') +c.addProperty('RawKeyCode GetRawKeyCode') +c.addProperty('RawKeyFlags GetRawKeyFlags') +c.addProperty('UnicodeKey GetUnicodeKey') + +#--------------------------------------- +# wxScrollEvent +c = module.find('wxScrollEvent') +c.addProperty('Orientation GetOrientation SetOrientation') +c.addProperty('Position GetPosition SetPosition') + +#--------------------------------------- +# wxScrollWinEvent +c = module.find('wxScrollWinEvent') +c.addProperty('Orientation GetOrientation SetOrientation') +c.addProperty('Position GetPosition SetPosition') + +#--------------------------------------- +# wxMouseEvent +c = module.find('wxMouseEvent') +c.addProperty('LinesPerAction GetLinesPerAction') +c.addProperty('LogicalPosition GetLogicalPosition') +c.addProperty('WheelDelta GetWheelDelta') +c.addProperty('WheelRotation GetWheelRotation') + +#--------------------------------------- +# wxSetCursorEvent +c = module.find('wxSetCursorEvent') +c.addProperty('Cursor GetCursor SetCursor') +c.addProperty('X GetX') +c.addProperty('Y GetY') + +#--------------------------------------- +# wxSizeEvent +c = module.find('wxSizeEvent') +c.addProperty('Rect GetRect SetRect') +c.addProperty('Size GetSize SetSize') + +#--------------------------------------- +# wxMoveEvent +c = module.find('wxMoveEvent') +c.addProperty('Rect GetRect SetRect') +c.addProperty('Position GetPosition SetPosition') + +#--------------------------------------- +# wxEraseEvent +c = module.find('wxEraseEvent') +c.addProperty('DC GetDC') + +#--------------------------------------- +# wxFocusEvent +c = module.find('wxFocusEvent') +c.addProperty('Window GetWindow SetWindow') + +#--------------------------------------- +# wxChildFocusEvent +c = module.find('wxChildFocusEvent') +c.addProperty('Window GetWindow') + + +#--------------------------------------- +# wxActivateEvent +c = module.find('wxActivateEvent') +c.addProperty('Active GetActive') + +#--------------------------------------- +# wxMenuEvent +c = module.find('wxMenuEvent') +c.addProperty('Menu GetMenu') +c.addProperty('MenuId GetMenuId') + +#--------------------------------------- +# wxShowEvent +c = module.find('wxShowEvent') +c.addProperty('Show IsShown SetShow') + +#--------------------------------------- +# wxDropFilesEvent +c = module.find('wxDropFilesEvent') +c.addProperty('Files GetFiles') +c.addProperty('NumberOfFiles GetNumberOfFiles') +c.addProperty('Position GetPosition') + +#--------------------------------------- +# wxUpdateUIEvent +c = module.find('wxUpdateUIEvent') +c.addProperty('Checked GetChecked Check') +c.addProperty('Enabled GetEnabled Enable') +c.addProperty('Shown GetShown Show') +c.addProperty('Text GetText SetText') + +#--------------------------------------- +# wxMouseCaptureChangedEvent +c = module.find('wxMouseCaptureChangedEvent') +c.addProperty('CapturedWindow GetCapturedWindow') + +#--------------------------------------- +# wxPaletteChangedEvent +c = module.find('wxPaletteChangedEvent') +c.addProperty('ChangedWindow GetChangedWindow SetChangedWindow') + +#--------------------------------------- +# wxQueryNewPaletteEvent +c = module.find('wxQueryNewPaletteEvent') +c.addProperty('PaletteRealized GetPaletteRealized SetPaletteRealized') + +#--------------------------------------- +# wxNavigationKeyEvent +c = module.find('wxNavigationKeyEvent') +c.addProperty('CurrentFocus GetCurrentFocus SetCurrentFocus') +c.addProperty('Direction GetDirection SetDirection') +#c.addProperty('FromTab IsFromTab SetFromTab') +#c.addProperty('WindowChange IsWindowChange SetWindowChange') + +# ignore the copy ctor because we'll be adding a private one below +c.find('wxNavigationKeyEvent').findOverload('const wxNavigationKeyEvent').ignore() + + +#--------------------------------------- +# wxWindowCreateEvent +c = module.find('wxWindowCreateEvent') +c.addProperty('Window GetWindow') + +#--------------------------------------- +# wxWindowDestroyEvent +c = module.find('wxWindowDestroyEvent') +c.addProperty('Window GetWindow') + +#--------------------------------------- +# wxContextMenuEvent +c = module.find('wxContextMenuEvent') +c.addProperty('Position GetPosition SetPosition') + + + + + +#--------------------------------------- +# Supress the automatic use of an assignment operator for these classes, by +# the back-end generator, assuming they are smart enough to do that if they +# see a private assignment operator in the class declaration. + +for name in [n for n in ITEMS if n.endswith('Event')]: + c = module.find(name) + c.addPrivateAssignOp() + + + +#--------------------------------------------------------------------------- +tools.ignoreAssignmentOperators(module) +tools.removeWxPrefixes(module) +#--------------------------------------------------------------------------- +# Run the generators + +# Create the code generator and make the wrapper code +wg = etgtools.getWrapperGenerator() +wg.generate(module) + +# Create a documentation generator and let it do its thing +dg = etgtools.getDocsGenerator() +dg.generate(module) + +#--------------------------------------------------------------------------- diff --git a/etg/gdicmn.py b/etg/gdicmn.py index d377480d..0f8523d6 100644 --- a/etg/gdicmn.py +++ b/etg/gdicmn.py @@ -4,7 +4,7 @@ # # Created: 4-Nov-2010 # Copyright: (c) 2010 by Total Control Software -# Licence: wxWindows license +# License: wxWindows License #--------------------------------------------------------------------------- PACKAGE = "wx" @@ -25,6 +25,8 @@ ITEMS = [ # Parse the XML file(s) building a collection of Extractor objects import etgtools +import etgtools.tweaker_tools as tools + module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING) etgtools.parseDoxyXML(module, ITEMS) @@ -32,12 +34,6 @@ etgtools.parseDoxyXML(module, ITEMS) # Tweak the parsed meta objects in the module object as needed for customizing # the generated code and docstrings. -import etgtools.tweaker_tools as tools -tools.ignoreAssignmentOperators(module) -tools.removeWxPrefixes(module) - - -module.addHeaderCode('#include ') # ignore some of these enum values e = module.find('wxBitmapType') @@ -45,8 +41,13 @@ for i in e: if i.name.endswith('_RESOURCE'): i.ignore() -# TODO: We need an ETG way to indicate that an item is only available -# on certain platofmrs. +module.addCppCode("""\ +#if !defined(__WXMAC__) +#define wxCURSOR_COPY_ARROW wxCURSOR_ARROW +#endif +""") + +# these are X11 only e = module.find('wxStockCursor') e.find('wxCURSOR_BASED_ARROW_DOWN').ignore() e.find('wxCURSOR_BASED_ARROW_UP').ignore() @@ -205,6 +206,17 @@ wxRect operator*(const wxRect& r1, const wxRect& r2); """) module.insertItemAfter(c, wc) +# Because of our add-ons that make wx.Point and wx.Size act like 2-element +# sequences, and also the typecheck code that allows 2-element sequences, then +# we end up with a bit of confusion about the (Point,Point) and the +# (Point,Size) overloads of the wx.Rect constructor. The confusion can be +# dealt with by using keyword args, but I think that the (Point,Size) version +# will be used more, so reorder the overloads so it is found first. +m = module.find('wxRect.wxRect') +mo = m.findOverload('topLeft') +del m.overloads[m.overloads.index(mo)] +m.overloads.append(mo) + # These methods have some overloads that will end up with the same signature # in Python, so we have to remove one. module.find('wxRect.Deflate').findOverload(') const').ignore() @@ -288,7 +300,10 @@ c.addPyMethod('__setitem__', '(self, idx, val)', c.addPyCode('RealPoint.__safe_for_unpickling__ = True') + #--------------------------------------------------------------------------- +tools.ignoreAssignmentOperators(module) +tools.removeWxPrefixes(module) #--------------------------------------------------------------------------- # Run the generators diff --git a/etg/geometry.py b/etg/geometry.py index cbdf6576..8e3717dc 100644 --- a/etg/geometry.py +++ b/etg/geometry.py @@ -4,7 +4,7 @@ # # Created: 4-Nov-2010 # Copyright: (c) 2010 by Total Control Software -# Licence: wxWindows license +# License: wxWindows License #--------------------------------------------------------------------------- PACKAGE = "wx" @@ -23,6 +23,8 @@ ITEMS = [ # Parse the XML file(s) building a collection of Extractor objects import etgtools +import etgtools.tweaker_tools as tools + module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING) etgtools.parseDoxyXML(module, ITEMS) @@ -30,10 +32,6 @@ etgtools.parseDoxyXML(module, ITEMS) # Tweak the parsed meta objects in the module object as needed for customizing # the generated code and docstrings. -import etgtools.tweaker_tools as tools -tools.ignoreAssignmentOperators(module) -tools.removeWxPrefixes(module) - module.addHeaderCode('#include ') @@ -58,6 +56,30 @@ c.find('operator/=').findOverload('wxDouble').ignore() c.find('operator*=').findOverload('wxDouble').ignore() +c.convertFromPyObject = tools.convertTwoDoublesTemplate('wxPoint2DDouble') + +c.addCppMethod('SIP_PYOBJECT', 'Get', '()', """\ + sipRes = sipBuildResult(&sipIsErr, "(dd)", sipCpp->m_x, sipCpp->m_y); +""", briefDoc="""\ + Get() -> (x,y)\n + Return the x and y properties as a tuple.""") + +# Add sequence protocol methods and other goodies +c.addPyMethod('__str__', '(self)', 'return str(self.Get())') +c.addPyMethod('__repr__', '(self)', 'return "wx.Point2D"+str(self.Get())') +c.addPyMethod('__len__', '(self)', 'return len(self.Get())') +c.addPyMethod('__nonzero__', '(self)', 'return self.Get() != (0,0)') +c.addPyMethod('__reduce__', '(self)', 'return (Point2D, self.Get())') +c.addPyMethod('__getitem__', '(self, idx)', 'return self.Get()[idx]') +c.addPyMethod('__setitem__', '(self, idx, val)', + """\ + if idx == 0: self.x = val + elif idx == 1: self.y = val + else: raise IndexError + """) +c.addPyCode('Point2D.__safe_for_unpickling__ = True') + + # ignore these operator methods, since we are not wrapping the Int version c.find('operator*=').findOverload('wxInt32').ignore() c.find('operator/=').findOverload('wxInt32').ignore() @@ -70,6 +92,7 @@ for item in module: item.ignore() + c = module.find('wxRect2DDouble') c.pyName = 'Rect2D' c.find('m_x').pyName = 'x' @@ -77,8 +100,36 @@ c.find('m_y').pyName = 'y' c.find('m_width').pyName = 'width' c.find('m_height').pyName = 'height' +c.convertFromPyObject = tools.convertFourDoublesTemplate('wxRect2DDouble') + +c.addCppMethod('SIP_PYOBJECT', 'Get', '()', """\ + sipRes = sipBuildResult(&sipIsErr, "(dddd)", + sipCpp->m_x, sipCpp->m_y, sipCpp->m_width, sipCpp->m_height); +""", briefDoc="""\ + Get() -> (x, y, width, height)\n + Return the rectangle's properties as a tuple.""") + +# Add sequence protocol methods and other goodies +c.addPyMethod('__str__', '(self)', 'return str(self.Get())') +c.addPyMethod('__repr__', '(self)', 'return "wx.Rect2D"+str(self.Get())') +c.addPyMethod('__len__', '(self)', 'return len(self.Get())') +c.addPyMethod('__nonzero__', '(self)', 'return self.Get() != (0,0,0,0)') +c.addPyMethod('__reduce__', '(self)', 'return (Rect2D, self.Get())') +c.addPyMethod('__getitem__', '(self, idx)', 'return self.Get()[idx]') +c.addPyMethod('__setitem__', '(self, idx, val)', + """\ + if idx == 0: self.x = val + elif idx == 1: self.y = val + elif idx == 2: self.width = val + elif idx == 3: self.height = val + else: raise IndexError + """) +c.addPyCode('Rect2D.__safe_for_unpickling__ = True') + #--------------------------------------------------------------------------- +tools.ignoreAssignmentOperators(module) +tools.removeWxPrefixes(module) #--------------------------------------------------------------------------- # Run the generators diff --git a/etg/kbdstate.py b/etg/kbdstate.py new file mode 100644 index 00000000..0cd9662a --- /dev/null +++ b/etg/kbdstate.py @@ -0,0 +1,56 @@ +#--------------------------------------------------------------------------- +# Name: etg/kbdstate.py +# Author: Robin Dunn +# +# Created: 15-Nov-2010 +# Copyright: (c) 2010 by Total Control Software +# License: wxWindows License +#--------------------------------------------------------------------------- + +PACKAGE = "wx" +MODULE = "_core" +NAME = "kbdstate" # 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 = [ 'wxKeyboardState' ] + +#--------------------------------------------------------------------------- +# Parse the XML file(s) building a collection of Extractor objects + +import etgtools +import etgtools.tweaker_tools as tools + +module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING) +etgtools.parseDoxyXML(module, ITEMS) + +#--------------------------------------------------------------------------- +# Tweak the parsed meta objects in the module object as needed for customizing +# the generated code and docstrings. + + +c = module.find('wxKeyboardState') + +c.addProperty("controlDown ControlDown SetControlDown") +c.addProperty("shiftDown ShiftDown SetShiftDown") +c.addProperty("altDown AltDown SetAltDown") +c.addProperty("metaDown MetaDown SetMetaDown") +c.addProperty("cmdDown CmdDown") + + +#--------------------------------------------------------------------------- +tools.ignoreAssignmentOperators(module) +tools.removeWxPrefixes(module) +#--------------------------------------------------------------------------- +# Run the generators + +# Create the code generator and make the wrapper code +wg = etgtools.getWrapperGenerator() +wg.generate(module) + +# Create a documentation generator and let it do its thing +dg = etgtools.getDocsGenerator() +dg.generate(module) + +#--------------------------------------------------------------------------- diff --git a/etg/mousestate.py b/etg/mousestate.py new file mode 100644 index 00000000..337e12e6 --- /dev/null +++ b/etg/mousestate.py @@ -0,0 +1,60 @@ +#--------------------------------------------------------------------------- +# Name: etg/mousestate.py +# Author: Robin Dunn +# +# Created: 15-Nov-2010 +# Copyright: (c) 2010 by Total Control Software +# License: wxWindows License +#--------------------------------------------------------------------------- + +PACKAGE = "wx" +MODULE = "_core" +NAME = "mousestate" # 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 = [ 'wxMouseState' ] + +#--------------------------------------------------------------------------- +# Parse the XML file(s) building a collection of Extractor objects + +import etgtools +import etgtools.tweaker_tools as tools + +module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING) +etgtools.parseDoxyXML(module, ITEMS) + +#--------------------------------------------------------------------------- +# Tweak the parsed meta objects in the module object as needed for customizing +# the generated code and docstrings. + + +c = module.find('wxMouseState') +c.find('GetPosition').findOverload('int *x').ignore() + +c.addProperty("x GetX SetX") +c.addProperty("y GetY SetY") +c.addProperty("leftIsDown LeftIsDown SetLeftDown") +c.addProperty("middleIsDown MiddleIsDown SetMiddleDown") +c.addProperty("rightIsDown RightIsDown SetRightDown") +c.addProperty("aux1IsDown Aux1IsDown SetAux1Down") +c.addProperty("aux2IsDown Aux2IsDown SetAux2Down") +c.addProperty("Position GetPosition SetPosition") + + +#--------------------------------------------------------------------------- +tools.ignoreAssignmentOperators(module) +tools.removeWxPrefixes(module) +#--------------------------------------------------------------------------- +# Run the generators + +# Create the code generator and make the wrapper code +wg = etgtools.getWrapperGenerator() +wg.generate(module) + +# Create a documentation generator and let it do its thing +dg = etgtools.getDocsGenerator() +dg.generate(module) + +#--------------------------------------------------------------------------- diff --git a/etg/object.py b/etg/object.py index b83e97f0..511d802c 100644 --- a/etg/object.py +++ b/etg/object.py @@ -4,7 +4,7 @@ # # Created: 9-Nov-2010 # Copyright: (c) 2010 by Total Control Software -# Licence: wxWindows license +# License: wxWindows License #--------------------------------------------------------------------------- PACKAGE = "wx" @@ -24,6 +24,8 @@ ITEMS = [ # Parse the XML file(s) building a collection of Extractor objects import etgtools +import etgtools.tweaker_tools as tools + module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING) etgtools.parseDoxyXML(module, ITEMS) @@ -31,10 +33,6 @@ etgtools.parseDoxyXML(module, ITEMS) # Tweak the parsed meta objects in the module object as needed for customizing # the generated code and docstrings. -import etgtools.tweaker_tools as tools -tools.ignoreAssignmentOperators(module) -tools.removeWxPrefixes(module) - module.find('wxObject.operator delete').ignore() module.find('wxObject.operator new').ignore() @@ -47,6 +45,8 @@ module.find('wxClassInfo.wxClassInfo').ignore() module.find('wxRefCounter.~wxRefCounter').ignore(False) #--------------------------------------------------------------------------- +tools.ignoreAssignmentOperators(module) +tools.removeWxPrefixes(module) #--------------------------------------------------------------------------- # Run the generators diff --git a/etg/template.py b/etg/template.py index fddfcbb6..2056ab86 100644 --- a/etg/template.py +++ b/etg/template.py @@ -4,7 +4,7 @@ # # Created: # Copyright: (c) 2010 by Total Control Software -# Licence: wxWindows license +# License: wxWindows License #--------------------------------------------------------------------------- PACKAGE = "" @@ -20,6 +20,8 @@ ITEMS = [ ] # Parse the XML file(s) building a collection of Extractor objects import etgtools +import etgtools.tweaker_tools as tools + module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING) etgtools.parseDoxyXML(module, ITEMS) @@ -27,14 +29,14 @@ etgtools.parseDoxyXML(module, ITEMS) # Tweak the parsed meta objects in the module object as needed for customizing # the generated code and docstrings. -import etgtools.tweaker_tools as tools -tools.ignoreAssignmentOperators(module) -tools.removeWxPrefixes(module) + #--------------------------------------------------------------------------- +tools.ignoreAssignmentOperators(module) +tools.removeWxPrefixes(module) #--------------------------------------------------------------------------- # Run the generators diff --git a/etg/tracker.py b/etg/tracker.py new file mode 100644 index 00000000..db746e02 --- /dev/null +++ b/etg/tracker.py @@ -0,0 +1,52 @@ +#--------------------------------------------------------------------------- +# Name: etc/tracker.py +# Author: Robin Dunn +# +# Created: 15-Nov-2010 +# Copyright: (c) 2010 by Total Control Software +# License: wxWindows License +#--------------------------------------------------------------------------- + +PACKAGE = "wx" +MODULE = "_core" +NAME = "tracker" # 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 = [ 'wxTrackable' ] + +#--------------------------------------------------------------------------- +# Parse the XML file(s) building a collection of Extractor objects + +import etgtools +import etgtools.tweaker_tools as tools + +module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING) +etgtools.parseDoxyXML(module, ITEMS) + +#--------------------------------------------------------------------------- +# Tweak the parsed meta objects in the module object as needed for customizing +# the generated code and docstrings. + + +c = module.find('wxTrackable') +c.abstract = True +c.addDtor('private') + + +#--------------------------------------------------------------------------- +tools.ignoreAssignmentOperators(module) +tools.removeWxPrefixes(module) +#--------------------------------------------------------------------------- +# Run the generators + +# Create the code generator and make the wrapper code +wg = etgtools.getWrapperGenerator() +wg.generate(module) + +# Create a documentation generator and let it do its thing +dg = etgtools.getDocsGenerator() +dg.generate(module) + +#--------------------------------------------------------------------------- diff --git a/etg/windowid.py b/etg/windowid.py new file mode 100644 index 00000000..5bc51086 --- /dev/null +++ b/etg/windowid.py @@ -0,0 +1,51 @@ +#--------------------------------------------------------------------------- +# Name: etg/windowid.py +# Author: Robin Dunn +# +# Created: 15-Nov-2010 +# Copyright: (c) 2010 by Total Control Software +# License: wxWindows License +#--------------------------------------------------------------------------- + +PACKAGE = "wx" +MODULE = "_core" +NAME = "windowid" # 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 = [ 'wxIdManager' ] + +#--------------------------------------------------------------------------- +# Parse the XML file(s) building a collection of Extractor objects + +import etgtools +import etgtools.tweaker_tools as tools + +module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING) +etgtools.parseDoxyXML(module, ITEMS) + +#--------------------------------------------------------------------------- +# Tweak the parsed meta objects in the module object as needed for customizing +# the generated code and docstrings. + + + + + + +#--------------------------------------------------------------------------- +tools.ignoreAssignmentOperators(module) +tools.removeWxPrefixes(module) +#--------------------------------------------------------------------------- +# Run the generators + +# Create the code generator and make the wrapper code +wg = etgtools.getWrapperGenerator() +wg.generate(module) + +# Create a documentation generator and let it do its thing +dg = etgtools.getDocsGenerator() +dg.generate(module) + +#--------------------------------------------------------------------------- diff --git a/src/clntdata.sip b/src/clntdata.sip new file mode 100644 index 00000000..1cf8ba68 --- /dev/null +++ b/src/clntdata.sip @@ -0,0 +1,43 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: clntdata.sip +// Purpose: +// +// Author: Robin Dunn +// +// Created: 16-Nov-2010 +// Copyright: (c) 2010 by Total Control Software +// Licence: wxWindows license +///////////////////////////////////////////////////////////////////////////// + + +%ModuleHeaderCode + + // A wxClientData that holds a refernece to a Python object + class wxPyClientData : public wxClientData + { + public: + wxPyClientData(PyObject* obj, bool incref=true) + { + m_obj = obj; + m_incRef = incref; + if (incref) + Py_INCREF(m_obj); + } + ~wxPyClientData() + { + if (m_incRef) { + //wxPyBlock_t blocked = wxPyBeginBlockThreads(); + Py_DECREF(m_obj); + //wxPyEndBlockThreads(blocked); + } + m_obj = NULL; + } + PyObject* m_obj; + bool m_incRef; + }; + +%End + + +// TODO: Can we just use a MappedType for wxClientData instead of writing +// CppMethods where it needs to be used?