-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathInt.cpp
72 lines (61 loc) · 1.35 KB
/
Int.cpp
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*****************************************************************************/
/**
* @file Int.cpp
* @author Naohisa Sakamoto
*/
/*****************************************************************************/
#include "Int.h"
namespace kvs
{
namespace python
{
bool Int::Check( const kvs::python::Object& object )
{
#ifdef KVS_PYTHON3
return PyLong_Check( object.get() );
#else
return PyInt_Check( object.get() );
#endif
}
Int::Int( const kvs::Int32 value ):
#ifdef KVS_PYTHON3
kvs::python::Object( PyLong_FromLong( value ) )
#else
kvs::python::Object( PyInt_FromLong( value ) )
#endif
{
}
Int::Int( const kvs::Int64 value ):
#ifdef KVS_PYTHON3
kvs::python::Object( PyLong_FromLong( value ) )
#else
kvs::python::Object( PyInt_FromLong( value ) )
#endif
{
}
Int::Int( const kvs::python::Object& value ):
#ifdef KVS_PYTHON3
kvs::python::Object( PyNumber_Long( value.get() ) )
#else
kvs::python::Object( PyNumber_Int( value.get() ) )
#endif
{
}
Int::operator kvs::Int32() const
{
#ifdef KVS_PYTHON3
return kvs::Int32( PyLong_AsLong( get() ) );
#else
return kvs::Int32( PyInt_AsLong( get() ) );
#endif
}
Int::operator kvs::Int64() const
{
#ifdef KVS_PYTHON3
return kvs::Int64( PyLong_AsLong( get() ) );
#else
return kvs::Int64( PyInt_AsLong( get() ) );
#endif
}
} // end of namespace python
} // end of namespace kvs