Files
Phoenix/src/userdata.sip
Robin Dunn 35fd2e16bf Update copyright year
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@73416 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2013-01-21 02:13:03 +00:00

53 lines
1.5 KiB
Plaintext

//--------------------------------------------------------------------------
// Name: userdata.sip
// Purpose:
//
// Author: Kevin Ollivier
//
// Created: 06-Sept-2011
// Copyright: (c) 2013 by Wide Open Technologies
// Licence: wxWindows license
//--------------------------------------------------------------------------
%ModuleHeaderCode
// A wxObject object that holds a reference to a Python object
class wxPyUserData : public wxPyUserDataHelper<wxObject>
{
public:
wxPyUserData(PyObject* obj = NULL)
: wxPyUserDataHelper<wxObject>(obj)
{ }
};
%End
// We'll use the wxPyUserData defined above wherever a wxObject parameter or
// return value is specified in the API. This MappedType code will convert to/from a
// PyObject so it will be totally transparent to the programmer and from their
// perspective any python object is being stored as the client data.
%MappedType wxPyUserData
{
%ConvertToTypeCode
// Code to test a PyObject for compatibility
if (!sipIsErr) {
return TRUE; // any python object is valid
}
// Code to create a new wxPyUserData from the PyObject
wxPyUserData* data = new wxPyUserData(sipPy);
*sipCppPtr = data;
return sipGetState(sipTransferObj);
%End
%ConvertFromTypeCode
// Code to convert a wxPyUserData back to the PyObject.
PyObject* obj;
obj = wxPyUserData::SafeGetData(static_cast<wxPyUserData*>(sipCpp));
return obj;
%End
};