forked from wxWidgets/Phoenix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuserdata.sip
40 lines (34 loc) · 1.3 KB
/
userdata.sip
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//--------------------------------------------------------------------------
// Name: userdata.sip
// Purpose:
//
// Author: Kevin Ollivier
//
// Created: 06-Sept-2011
// Copyright: (c) 2011 by Wide Open Technologies
// Copyright: (c) 2011-2020 by Total Control Software
// Licence: wxWindows license
//--------------------------------------------------------------------------
// 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
};