forked from wxWidgets/Phoenix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlonglong.sip
60 lines (51 loc) · 1.78 KB
/
longlong.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//--------------------------------------------------------------------------
// Name: datetime.sip
// Purpose: Implements a %MappedType for wxLongLong
//
// Author: Robin Dunn
//
// Created: 29-Feb-2012
// Copyright: (c) 2013 by Total Control Software
// Licence: wxWindows license
//--------------------------------------------------------------------------
typedef long long wxLongLong_t;
typedef unsigned long long wxULongLong_t;
%MappedType wxLongLong {
%TypeHeaderCode
#include <wx/longlong.h>
%End
%ConvertToTypeCode
// Code to test a PyObject for compatibility
if (!sipIsErr) {
if (PyNumber_Check(sipPy))
return TRUE;
return FALSE;
}
// Code to convert from a compatible PyObject
#if wxUSE_LONGLONG_NATIVE
*sipCppPtr = new wxLongLong(PyLong_AsLongLong(sipPy));
#else
#error TODO. Get the hi/lo 32-bit dwords to construct the wxLongLong
#endif
return sipGetState(sipTransferObj);
%End
%ConvertFromTypeCode
#if wxUSE_LONGLONG_NATIVE
return PyLong_FromLongLong(sipCpp->GetValue());
#else
// Convert a wxLongLong to a Python Long by getting the hi/lo
// dwords, then shifting and or-ing them together
PyObject *hi, *lo, *shifter, *shifted, *result;
hi = PyLong_FromLong( sipCpp->GetHi() );
lo = PyLong_FromLong( sipCpp->GetLo() );
shifter = PyLong_FromLong(32);
shifted = PyNumber_Lshift(hi, shifter);
result = PyNumber_Or(shifted, lo);
Py_DECREF(hi);
Py_DECREF(lo);
Py_DECREF(shifter);
Py_DECREF(shifted);
return result;
#endif
%End
};