Skip to content

Commit

Permalink
Merge pull request wxWidgets#1124 from RobinD42/fix-issue1123
Browse files Browse the repository at this point in the history
Generate optional stubs for the wxFileSystemWatcher* classes
(cherry picked from commit 792d32a)
  • Loading branch information
RobinD42 committed Jan 4, 2019
1 parent 1d42757 commit 94ce8fc
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions docs/sphinx/itemToModuleMap.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
13 changes: 12 additions & 1 deletion etg/fswatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
""")
Expand Down
9 changes: 8 additions & 1 deletion etgtools/tweaker_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 94ce8fc

Please sign in to comment.