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. 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 wxUSE_FSWATCHER && !defined(wxHAS_INOTIFY) && !defined(wxHAVE_FSEVENTS_FILE_NOTIFICATIONS) const int wxFSW_EVENT_UNMOUNT = 0x2000; #endif """) c = module.find('wxFileSystemWatcher') assert isinstance(c, etgtools.ClassDef) c = module.find('wxFileSystemWatcherEvent') tools.fixEventClass(c) module.addPyCode("""\ EVT_FSWATCHER = wx.PyEventBinder(wxEVT_FSWATCHER) """) #----------------------------------------------------------------- tools.doCommonTweaks(module) tools.runGenerators(module)
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. c = module.find('wxJoystick') assert isinstance(c, etgtools.ClassDef) c.mustHaveApp() c.addItem(MethodDef(name='GetMaxButtons', type='int', isConst=True)) c.addItem(MethodDef(name='GetMaxAxes', type='int', isConst=True)) tools.generateStubs('wxUSE_JOYSTICK', module) #----------------------------------------------------------------- tools.doCommonTweaks(module) tools.runGenerators(module)
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/access.h>') tools.generateStubs('wxUSE_ACCESSIBILITY', module, typeValMap={'wxAccStatus':'wxACC_NOT_IMPLEMENTED'}) c = module.find('wxAccessible') assert isinstance(c, etgtools.ClassDef) c.addPrivateCopyCtor() c.find('GetChild.child').out = True c.find('GetChildCount.childCount').out = True c.find('GetDefaultAction.actionName').out = True c.find('GetDescription.description').out = True c.find('GetFocus.child').out = True c.find('GetHelpText.helpText').out = True c.find('GetKeyboardShortcut.shortcut').out = True c.find('GetName.name').out = True c.find('GetParent.parent').out = True c.find('GetRole.role').out = True c.find('GetSelections.selections').out = True c.find('GetState.state').out = True c.find('GetValue.strValue').out = True #TODO: double-check this one c.find('GetLocation.rect').out = True #----------------------------------------------------------------- tools.doCommonTweaks(module) tools.runGenerators(module)
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/webview.h> #if wxUSE_WEBVIEW_IE && defined(__WXMSW__) #include <wx/msw/webview_ie.h> #endif """) module.addHeaderCode('#include <wx/filesys.h>') module.addGlobalStr('wxWebViewBackendDefault', 0) module.addGlobalStr('wxWebViewBackendIE', 0) module.addGlobalStr('wxWebViewBackendWebKit', 0) module.addGlobalStr('wxWebViewNameStr', 0) module.addGlobalStr('wxWebViewDefaultURLStr', 0) # This tweak is needed only for the stub code module.find('wxWebViewHandler.wxWebViewHandler').argsString = '(const wxString& scheme="")' tools.generateStubs('wxUSE_WEBVIEW', module, typeValMap={'wxWebViewNavigationActionFlags': 'wxWEBVIEW_NAV_ACTION_NONE'}) c = module.find('wxWebView') assert isinstance(c, etgtools.ClassDef) tools.fixWindowClass(c) c.abstract = True for m in c.find('New').all(): m.factory = True c.find('New.id').default = 'wxID_ANY' c.find('New.parent').transferThis = True c.find('RegisterHandler.handler').type = 'wxWebViewHandler*' c.find('RegisterHandler.handler').transfer = True c.find('RegisterHandler').setCppCode_sip( "sipCpp->RegisterHandler(wxSharedPtr<wxWebViewHandler>(handler));") c.find('RegisterFactory.factory').type = 'wxWebViewFactory*' c.find('RegisterFactory.factory').transfer = True c.find('RegisterFactory').setCppCode_sip( "wxWebView::RegisterFactory(*backend, wxSharedPtr<wxWebViewFactory>(factory));") c.find('RunScript.output').out = True # Custom code to deal with the # wxVector<wxSharedPtr<wxWebViewHistoryItem>> return type of these two # methods. We'll just convert them to a Python list of history items. code = """\ wxPyThreadBlocker blocker; PyObject* result = PyList_New(0); wxVector<wxSharedPtr<wxWebViewHistoryItem> > vector = self->{method}(); for (size_t idx=0; idx < vector.size(); idx++) {{ PyObject* obj; wxWebViewHistoryItem* item = new wxWebViewHistoryItem(*vector[idx].get()); obj = wxPyConstructObject((void*)item, "wxWebViewHistoryItem", true); PyList_Append(result, obj); Py_DECREF(obj); }} return result; """ c.find('GetBackwardHistory').type = 'PyObject*' c.find('GetBackwardHistory').setCppCode(code.format(method='GetBackwardHistory')) c.find('GetForwardHistory').type = 'PyObject*' c.find('GetForwardHistory').setCppCode(code.format(method='GetForwardHistory')) # Since LoadHistoryItem expects to get an actual item in the history # list, and since we make copies of the items in the cppCode above, then # this won't be possible to do from the Python wrappers. However, it's # just as easy to use LoadURL to reload a history item so it's not a # great loss. c.find('LoadHistoryItem').ignore() ##c.find('LoadHistoryItem.item').type = 'wxWebViewHistoryItem*' ##c.find('LoadHistoryItem.item').transfer = True ##c.find('LoadHistoryItem').setCppCode_sip( ## "sipCpp->LoadHistoryItem(wxSharedPtr<wxWebViewHistoryItem>(item));") c.find('MSWSetModernEmulationLevel').setCppCode("""\ #if wxUSE_WEBVIEW_IE && defined(__WXMSW__) return wxWebViewIE::MSWSetModernEmulationLevel(modernLevel); #else return false; #endif """) c = module.find('wxWebViewEvent') tools.fixEventClass(c) module.addPyCode("""\ EVT_WEBVIEW_NAVIGATING = wx.PyEventBinder( wxEVT_WEBVIEW_NAVIGATING, 1 ) EVT_WEBVIEW_NAVIGATED = wx.PyEventBinder( wxEVT_WEBVIEW_NAVIGATED, 1 ) EVT_WEBVIEW_LOADED = wx.PyEventBinder( wxEVT_WEBVIEW_LOADED, 1 ) EVT_WEBVIEW_ERROR = wx.PyEventBinder( wxEVT_WEBVIEW_ERROR, 1 ) EVT_WEBVIEW_NEWWINDOW = wx.PyEventBinder( wxEVT_WEBVIEW_NEWWINDOW, 1 ) EVT_WEBVIEW_TITLE_CHANGED = wx.PyEventBinder( wxEVT_WEBVIEW_TITLE_CHANGED, 1 ) # deprecated wxEVT aliases wxEVT_COMMAND_WEBVIEW_NAVIGATING = wxEVT_WEBVIEW_NAVIGATING wxEVT_COMMAND_WEBVIEW_NAVIGATED = wxEVT_WEBVIEW_NAVIGATED wxEVT_COMMAND_WEBVIEW_LOADED = wxEVT_WEBVIEW_LOADED wxEVT_COMMAND_WEBVIEW_ERROR = wxEVT_WEBVIEW_ERROR wxEVT_COMMAND_WEBVIEW_NEWWINDOW = wxEVT_WEBVIEW_NEWWINDOW wxEVT_COMMAND_WEBVIEW_TITLE_CHANGED = wxEVT_WEBVIEW_TITLE_CHANGED """) c = module.find('wxWebViewHistoryItem') tools.addAutoProperties(c) for name in [ 'wxWebViewHandler', 'wxWebViewArchiveHandler', 'wxWebViewFSHandler' ]: c = module.find(name) c.find('GetFile').factory = True #----------------------------------------------------------------- tools.doCommonTweaks(module) tools.runGenerators(module)
def run(): # Parse the XML file(s) building a collection of Extractor objects module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING) 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 <wxPython/wxpy_api.h>') module.addImport('_core') module.addPyCode('import wx', order=10) module.addInclude(INCLUDES) #----------------------------------------------------------------- module.addHeaderCode('#include <wx/glcanvas.h>') tools.generateStubs('wxUSE_GLCANVAS', module, extraHdrCode=('static wxGLAttributes _NullGLAttributes;\n' 'static wxGLContextAttrs _NULLGLContextAttrs;\n'), typeValMap={'wxGLAttributes &': '_NullGLAttributes', 'wxGLContextAttrs &': '_NULLGLContextAttrs', }) c = module.find('wxGLContext') assert isinstance(c, etgtools.ClassDef) c.mustHaveApp() c.addPrivateCopyCtor() c = module.find('wxGLAttribsBase') assert isinstance(c, etgtools.ClassDef) c.find('GetGLAttrs').ignore() c = module.find('wxGLCanvas') tools.fixWindowClass(c) # We already have a MappedType for wxArrayInt, so just tweak the # interfaces to use that instead of a const int pointer. c.find('wxGLCanvas').findOverload('const int *attribList').ignore() m = c.addCppCtor_sip( argsString="""( wxWindow* parent /TransferThis/, wxWindowID id=wxID_ANY, wxArrayInt* attribList=NULL, const wxPoint& pos=wxDefaultPosition, const wxSize& size=wxDefaultSize, long style=0, const wxString& name="GLCanvas", const wxPalette& palette=wxNullPalette) """, cppSignature="""( wxWindow* parent, wxWindowID id=wxID_ANY, const int* attribList=NULL, const wxPoint& pos=wxDefaultPosition, const wxSize& size=wxDefaultSize, long style=0, const wxString& name="GLCanvas", const wxPalette& palette=wxNullPalette)""", pyArgsString="(parent, id=wx.ID_ANY, attribList=None, pos=wx.DefaultPosition, size=wx.DefaultSize, style=0, name='GLCanvas', palette=wx.NullPalette)", body="""\ const int* attribPtr = NULL; if (attribList) { attribList->push_back(0); // ensure it is zero-terminated attribPtr = &attribList->front(); } sipCpp = new sipwxGLCanvas(parent, id, attribPtr, *pos, *size, style, *name, *palette); """, noDerivedCtor=False, ) m = c.find('IsDisplaySupported').findOverload('attribList') m.find('attribList').type = 'wxArrayInt*' m.setCppCode_sip("""\ const int* attribPtr = NULL; if (attribList) { attribList->push_back(0); // ensure it is zero-terminated attribPtr = &attribList->front(); } sipRes = wxGLCanvas::IsDisplaySupported(attribPtr); """) #----------------------------------------------------------------- tools.doCommonTweaks(module) tools.runGenerators(module)
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/mediactrl.h>') module.addHeaderCode('#include <wx/uri.h>') tools.generateStubs('wxUSE_MEDIACTRL', module, typeValMap={'wxMediaState': 'wxMEDIASTATE_STOPPED'}) c = module.find('wxMediaCtrl') c.addPrivateCopyCtor() c.find('wxMediaCtrl.id').default = '-1' c.find('Create.id').default = '-1' # the C++ class has three overloaded Load(...) methods # for now we ignore all than the first one for loading a filename for item in c.findAll("Load"): if not "fileName" in item.argsString: # ignore e.g. the Load with args '(const wxURI &uri)' # keep e.g. '(const wxString &fileName)' item.ignore() # Transplant the docstrings from the ignored Load methods into the # appropriate compatibility method if 'proxy' in item.argsString: m = c.find('LoadURIWithProxy') else: m = c.find('LoadURI') m.briefDoc = item.briefDoc m.detailedDoc = item.detailedDoc c = module.find('wxMediaEvent') tools.fixEventClass(c) module.addPyCode("""\ EVT_MEDIA_LOADED = wx.PyEventBinder( wxEVT_MEDIA_LOADED ) EVT_MEDIA_STOP = wx.PyEventBinder( wxEVT_MEDIA_STOP ) EVT_MEDIA_FINISHED = wx.PyEventBinder( wxEVT_MEDIA_FINISHED ) EVT_MEDIA_STATECHANGED = wx.PyEventBinder( wxEVT_MEDIA_STATECHANGED ) EVT_MEDIA_PLAY = wx.PyEventBinder( wxEVT_MEDIA_PLAY ) EVT_MEDIA_PAUSE = wx.PyEventBinder( wxEVT_MEDIA_PAUSE ) """) # See mediactrl.h: module.addPyCode("""\ MEDIABACKEND_DIRECTSHOW = "wxAMMediaBackend" MEDIABACKEND_MCI = "wxMCIMediaBackend" MEDIABACKEND_QUICKTIME = "wxQTMediaBackend" MEDIABACKEND_GSTREAMER = "wxGStreamerMediaBackend" MEDIABACKEND_REALPLAYER = "wxRealPlayerMediaBackend" MEDIABACKEND_WMP10 = "wxWMP10MediaBackend" """) #----------------------------------------------------------------- tools.doCommonTweaks(module) tools.runGenerators(module)