Merge pull request #1124 from RobinD42/fix-issue1123

Generate optional stubs for the wxFileSystemWatcher* classes
(cherry picked from commit 792d32a1c4)
This commit is contained in:
Robin Dunn
2019-01-03 22:13:44 -08:00
parent 1d427573b3
commit 94ce8fc74a
4 changed files with 22 additions and 3 deletions

View File

@@ -141,7 +141,7 @@ Changes in this release include the following:
* Added the ability to generate stub classes for use when optional wxWidgets
features are not part of the build. So far, stubs are available for
wx.Accessible, wx.glcanvas, wx.media and wx.html2.
wx.Accessible, wx.FileSystemWatcher, wx.glcanvas, wx.media and wx.html2.
* Moved the wxpy_api.h file into the wx package at wx/include/wxPython so it
will be included in the wheel file. (#961)

View File

@@ -6516,6 +6516,7 @@
"USER_ATTENTION_ERROR":"wx.",
"USER_ATTENTION_INFO":"wx.",
"USE_ACCESSIBILITY":"wx.",
"USE_FSWATCHER":"wx.",
"USE_GLCANVAS":"wx.glcanvas.",
"USE_JOYSTICK":"wx.adv.",
"USE_MEDIACTRL":"wx.media.",

View File

@@ -32,11 +32,22 @@ def run():
# Tweak the parsed meta objects in the module object as needed for
# customizing the generated code and docstrings.
c = module.find('wxFileSystemWatcherEvent')
assert isinstance(c, etgtools.ClassDef)
c.addItem(etgtools.MethodDef(name='Clone', type='wxEvent*', argsString='() const',
isConst=True, isVirtual=True))
tools.generateStubs('wxUSE_FSWATCHER', module,
extraHdrCode='static wxFileName _NullFileName;\n',
typeValMap={'const wxFileName &': '_NullFileName',
'wxFSWWarningType': 'wxFSW_WARNING_NONE'}
)
# In the C++ code the wxFSW_EVENT_UNMOUNT item is only part of the enum
# for platforms that have INOTIFY so we need to fake it elsewhere.
module.addHeaderCode("""
#include <wx/fswatcher.h>
#if !defined(wxHAS_INOTIFY) && !defined(wxHAVE_FSEVENTS_FILE_NOTIFICATIONS)
#if wxUSE_FSWATCHER && !defined(wxHAS_INOTIFY) && !defined(wxHAVE_FSEVENTS_FILE_NOTIFICATIONS)
const int wxFSW_EVENT_UNMOUNT = 0x2000;
#endif
""")

View File

@@ -1270,7 +1270,8 @@ def guessTypeStr(v):
# generating stubs then we can still provide the wrapper classes but simply
# have them raise NotImplemented errors or whatnot.
def generateStubs(cppFlag, module, excludes=[], typeValMap={}):
def generateStubs(cppFlag, module, excludes=[], typeValMap={},
extraHdrCode=None, extraCppCode=None):
"""
Generate C++ stubs for all items in the module, except those that are
in the optional excludes list.
@@ -1306,6 +1307,12 @@ def generateStubs(cppFlag, module, excludes=[], typeValMap={}):
if isinstance(item, extractors.ClassDef):
code.hdr.append('class {};'.format(item.name))
if extraHdrCode:
code.hdr.append(extraHdrCode)
if extraCppCode:
code.cpp.append(extraCppCode)
# Now write code for all the items in the module.
for item in module:
if item.name in excludes: