Skip to content

Commit

Permalink
several fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbb committed Feb 9, 2016
1 parent e8bf409 commit 736aaff
Show file tree
Hide file tree
Showing 5 changed files with 180 additions and 177 deletions.
24 changes: 12 additions & 12 deletions etg/_adv.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@

import etgtools
import etgtools.tweaker_tools as tools
from etgtools import PyFunctionDef, PyCodeDef, PyPropertyDef
from etgtools import PyCodeDef, PyFunctionDef, PyPropertyDef

PACKAGE = "wx"
PACKAGE = "wx"
MODULE = "_adv"
NAME = "_adv" # 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 = [ ]
# this script.
ITEMS = [ ]


# The list of other ETG scripts and back-end generator modules that are
# included as part of this module. These should all be items that are put in
# the wxWidgets "adv" library in a multi-lib build.
INCLUDES = [
INCLUDES = [
'aboutdlg',
'helpext',
'commandlinkbutton',
Expand Down Expand Up @@ -60,7 +60,7 @@


#---------------------------------------------------------------------------

def run():
# Parse the XML file(s) building a collection of Extractor objects
module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING)
Expand All @@ -70,19 +70,19 @@ def run():
#-----------------------------------------------------------------
# Tweak the parsed meta objects in the module object as needed for
# customizing the generated code and docstrings.

module.addHeaderCode('#include <wxpy_api.h>')
module.addImport('_core')
module.addPyCode("import wx", order=10)
module.addInclude(INCLUDES)


#-----------------------------------------------------------------
tools.doCommonTweaks(module)
tools.runGenerators(module)





#---------------------------------------------------------------------------

if __name__ == '__main__':
Expand Down
32 changes: 15 additions & 17 deletions etg/taskbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,34 @@
import etgtools
import etgtools.tweaker_tools as tools

PACKAGE = "wx"
PACKAGE = "wx"
MODULE = "_adv"
NAME = "taskbar" # 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.
# this script.
ITEMS = [ "wxTaskBarIconEvent",
"wxTaskBarIcon",
]
]

#---------------------------------------------------------------------------

def run():
# Parse the XML file(s) building a collection of Extractor objects
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.addHeaderCode('#include <wx/taskbar.h>')

c = module.find('wxTaskBarIconEvent')
assert isinstance(c, etgtools.ClassDef)
tools.fixEventClass(c)

c.addPyCode("""\
EVT_TASKBAR_MOVE = wx.PyEventBinder ( wxEVT_TASKBAR_MOVE )
EVT_TASKBAR_LEFT_DOWN = wx.PyEventBinder ( wxEVT_TASKBAR_LEFT_DOWN )
Expand All @@ -50,8 +50,7 @@ def run():
EVT_TASKBAR_BALLOON_TIMEOUT = wx.PyEventBinder ( wxEVT_TASKBAR_BALLOON_TIMEOUT )
EVT_TASKBAR_BALLOON_CLICK = wx.PyEventBinder ( wxEVT_TASKBAR_BALLOON_CLICK )
""")



c = module.find('wxTaskBarIcon')
method = c.find('CreatePopupMenu')
method.ignore(False)
Expand All @@ -64,15 +63,15 @@ def run():
sipTransferTo(sipResObj, Py_None);
}
"""


c.find('Destroy').transferThis = True

c.addCppMethod('bool', 'ShowBalloon', '(const wxString& title, const wxString& text,'
'unsigned msec = 0, int flags = 0)',
doc="""\
Show a balloon notification (the icon must have been already
initialized using SetIcon). Only implemented for Windows.
initialized using SetIcon). Only implemented for Windows.
""",
body="""\
#ifdef __WXMSW__
Expand All @@ -81,13 +80,12 @@ def run():
return false;
#endif
""")

#-----------------------------------------------------------------
tools.doCommonTweaks(module)
tools.runGenerators(module)


#---------------------------------------------------------------------------
if __name__ == '__main__':
run()

38 changes: 20 additions & 18 deletions etgtools/generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,28 @@
Just some base classes and stubs for the various generators
"""


# 2.7 we'll convert any string values to unicode objects before storing them
# in the StringIO
import io
# io.StringIO reads/writes unicode objects for both Python 2.7 and 3.x. For
import sys


class WrapperGeneratorBase(object):
def __init__(self):
pass
pass
def generate(self, module, destFile=None):
raise NotImplementedError


class DocsGeneratorBase(object):
def __init__(self):
pass
pass
def generate(self, module):
raise NotImplementedError


class StubbedDocsGenerator(DocsGeneratorBase):
def generate(self, module):
pass
Expand All @@ -42,7 +48,7 @@ def generate(self, module):
def nci(text, numSpaces=0, stripLeading=True):
"""
Normalize Code Indents
First use the count of leading spaces on the first line and remove that
many spaces from the front of all lines, and then indent each line by
adding numSpaces spaces. This is used so we can convert the arbitrary
Expand All @@ -57,20 +63,20 @@ def _getLeadingSpaceCount(line):
break
count += 1
return count

def _allSpaces(text):
for c in text:
if c != ' ':
return False
return True


lines = text.rstrip().split('\n')

if stripLeading:
numStrip = _getLeadingSpaceCount(lines[0])
else:
numStrip = 0

for idx, line in enumerate(lines):
assert _allSpaces(line[:numStrip]), "Indentation inconsistent with first line"
lines[idx] = ' '*numSpaces + line[numStrip:]
Expand All @@ -90,18 +96,14 @@ def wrapText(text):

#---------------------------------------------------------------------------

# io.StringIO reads/writes unicode objects for both Python 2.7 and 3.x. For
# 2.7 we'll convert any string values to unicode objects before storing them
# in the StringIO
import io
class Utf8EncodingStream(io.StringIO):
if sys.version_info < (3,):
def write(self, text):
if isinstance(text, str):
text = text.decode('utf-8')
return io.StringIO.write(self, text)




def textfile_open(filename, mode='rt'):
Expand All @@ -117,6 +119,6 @@ def textfile_open(filename, mode='rt'):
return codecs.open(filename, mode, encoding='utf-8')
else:
return open(filename, mode, encoding='utf-8')


#---------------------------------------------------------------------------
Loading

0 comments on commit 736aaff

Please sign in to comment.