mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-06 03:50:06 +01:00
Add a MappedType for wxFileName to convert to/from strings
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@72272 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -43,16 +43,6 @@ def run():
|
||||
c.find('AddHandler.handler').transfer = True
|
||||
c.find('RemoveHandler').transferBack = True
|
||||
|
||||
m = c.find('URLToFileName')
|
||||
m.type = 'wxString'
|
||||
m.setCppCode("""\
|
||||
wxFileName fname = wxFileSystem::URLToFileName(*url);
|
||||
return new wxString(fname.GetFullPath());
|
||||
""")
|
||||
|
||||
fileNameTypedef = etgtools.TypedefDef(type='wxString', name='wxFileName', noTypeName=True)
|
||||
module.insertItemBefore(c, fileNameTypedef)
|
||||
|
||||
c = module.find('wxArchiveFSHandler')
|
||||
c.addPrivateCopyCtor();
|
||||
module.addPyCode('ZipFSHandler = wx.deprecated(ArchiveFSHandler, "Use ArchiveFSHandler instead.")')
|
||||
|
||||
39
src/filename.sip
Normal file
39
src/filename.sip
Normal file
@@ -0,0 +1,39 @@
|
||||
//--------------------------------------------------------------------------
|
||||
// Name: filename.sip
|
||||
// Purpose: Implements a %MappedType for wxFileName
|
||||
//
|
||||
// Author: Robin Dunn
|
||||
//
|
||||
// Created: 30-July-2012
|
||||
// Copyright: (c) 2012 by Total Control Software
|
||||
// Licence: wxWindows license
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
|
||||
// wxFileNames are mapped to/from Unicode string objects
|
||||
|
||||
%MappedType wxFileName
|
||||
{
|
||||
%ConvertToTypeCode
|
||||
// Code to test a PyObject for compatibility with wxFileName
|
||||
if (!sipIsErr) {
|
||||
if (PyBytes_Check(sipPy) || PyUnicode_Check(sipPy))
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Code to convert a compatible PyObject to a wxFileName
|
||||
*sipCppPtr = new wxFileName(Py2wxString(sipPy));
|
||||
return sipGetState(sipTransferObj);
|
||||
%End
|
||||
|
||||
|
||||
%ConvertFromTypeCode
|
||||
// Convert a wxString to a Python Unicode object. See wxpy_api.sip
|
||||
return wx2PyString(sipCpp->GetFullPath());
|
||||
%End
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user