Show More
@@ -0,0 +1,63 b'' | |||||
|
1 | /* | |||
|
2 | util.h - utility functions for interfacing with the various python APIs. | |||
|
3 | ||||
|
4 | This software may be used and distributed according to the terms of | |||
|
5 | the GNU General Public License, incorporated herein by reference. | |||
|
6 | */ | |||
|
7 | ||||
|
8 | #ifndef _HG_UTIL_H_ | |||
|
9 | #define _HG_UTIL_H_ | |||
|
10 | ||||
|
11 | #if PY_MAJOR_VERSION >= 3 | |||
|
12 | ||||
|
13 | #define IS_PY3K | |||
|
14 | #define PyInt_FromLong PyLong_FromLong | |||
|
15 | ||||
|
16 | #endif /* PY_MAJOR_VERSION */ | |||
|
17 | ||||
|
18 | /* Backports from 2.6 */ | |||
|
19 | #if PY_VERSION_HEX < 0x02060000 | |||
|
20 | ||||
|
21 | #define Py_TYPE(ob) (ob)->ob_type | |||
|
22 | #define Py_SIZE(ob) (ob)->ob_size | |||
|
23 | #define PyVarObject_HEAD_INIT(type, size) PyObject_HEAD_INIT(type) size, | |||
|
24 | ||||
|
25 | /* Shamelessly stolen from bytesobject.h */ | |||
|
26 | #define PyBytesObject PyStringObject | |||
|
27 | #define PyBytes_Type PyString_Type | |||
|
28 | ||||
|
29 | #define PyBytes_Check PyString_Check | |||
|
30 | #define PyBytes_CheckExact PyString_CheckExact | |||
|
31 | #define PyBytes_CHECK_INTERNED PyString_CHECK_INTERNED | |||
|
32 | #define PyBytes_AS_STRING PyString_AS_STRING | |||
|
33 | #define PyBytes_GET_SIZE PyString_GET_SIZE | |||
|
34 | #define Py_TPFLAGS_BYTES_SUBCLASS Py_TPFLAGS_STRING_SUBCLASS | |||
|
35 | ||||
|
36 | #define PyBytes_FromStringAndSize PyString_FromStringAndSize | |||
|
37 | #define PyBytes_FromString PyString_FromString | |||
|
38 | #define PyBytes_FromFormatV PyString_FromFormatV | |||
|
39 | #define PyBytes_FromFormat PyString_FromFormat | |||
|
40 | #define PyBytes_Size PyString_Size | |||
|
41 | #define PyBytes_AsString PyString_AsString | |||
|
42 | #define PyBytes_Repr PyString_Repr | |||
|
43 | #define PyBytes_Concat PyString_Concat | |||
|
44 | #define PyBytes_ConcatAndDel PyString_ConcatAndDel | |||
|
45 | #define _PyBytes_Resize _PyString_Resize | |||
|
46 | #define _PyBytes_Eq _PyString_Eq | |||
|
47 | #define PyBytes_Format PyString_Format | |||
|
48 | #define _PyBytes_FormatLong _PyString_FormatLong | |||
|
49 | #define PyBytes_DecodeEscape PyString_DecodeEscape | |||
|
50 | #define _PyBytes_Join _PyString_Join | |||
|
51 | #define PyBytes_Decode PyString_Decode | |||
|
52 | #define PyBytes_Encode PyString_Encode | |||
|
53 | #define PyBytes_AsEncodedObject PyString_AsEncodedObject | |||
|
54 | #define PyBytes_AsEncodedString PyString_AsEncodedString | |||
|
55 | #define PyBytes_AsDecodedObject PyString_AsDecodedObject | |||
|
56 | #define PyBytes_AsDecodedString PyString_AsDecodedString | |||
|
57 | #define PyBytes_AsStringAndSize PyString_AsStringAndSize | |||
|
58 | #define _PyBytes_InsertThousandsGrouping _PyString_InsertThousandsGrouping | |||
|
59 | ||||
|
60 | #endif /* PY_VERSION_HEX */ | |||
|
61 | ||||
|
62 | #endif /* _HG_UTIL_H_ */ | |||
|
63 |
General Comments 0
You need to be logged in to leave comments.
Login now