Show More
@@ -1,64 +1,105 | |||
|
1 | 1 | /* |
|
2 | 2 | util.h - utility functions for interfacing with the various python APIs. |
|
3 | 3 | |
|
4 | 4 | This software may be used and distributed according to the terms of |
|
5 | 5 | the GNU General Public License, incorporated herein by reference. |
|
6 | 6 | */ |
|
7 | 7 | |
|
8 | 8 | #ifndef _HG_UTIL_H_ |
|
9 | 9 | #define _HG_UTIL_H_ |
|
10 | 10 | |
|
11 | 11 | #if PY_MAJOR_VERSION >= 3 |
|
12 | 12 | |
|
13 | 13 | #define IS_PY3K |
|
14 | 14 | #define PyInt_FromLong PyLong_FromLong |
|
15 | 15 | #define PyInt_AsLong PyLong_AsLong |
|
16 | 16 | |
|
17 | /* | |
|
18 | Mapping of some of the python < 2.x PyString* functions to py3k's PyUnicode. | |
|
19 | ||
|
20 | The commented names below represent those that are present in the PyBytes | |
|
21 | definitions for python < 2.6 (below in this file) that don't have a direct | |
|
22 | implementation. | |
|
23 | */ | |
|
24 | ||
|
25 | #define PyStringObject PyUnicodeObject | |
|
26 | #define PyString_Type PyUnicode_Type | |
|
27 | ||
|
28 | #define PyString_Check PyUnicode_Check | |
|
29 | #define PyString_CheckExact PyUnicode_CheckExact | |
|
30 | #define PyString_CHECK_INTERNED PyUnicode_CHECK_INTERNED | |
|
31 | #define PyString_AS_STRING PyUnicode_AsLatin1String | |
|
32 | #define PyString_GET_SIZE PyUnicode_GET_SIZE | |
|
33 | ||
|
34 | #define PyString_FromStringAndSize PyUnicode_FromStringAndSize | |
|
35 | #define PyString_FromString PyUnicode_FromString | |
|
36 | #define PyString_FromFormatV PyUnicode_FromFormatV | |
|
37 | #define PyString_FromFormat PyUnicode_FromFormat | |
|
38 | /* #define PyString_Size PyUnicode_GET_SIZE */ | |
|
39 | /* #define PyString_AsString */ | |
|
40 | /* #define PyString_Repr */ | |
|
41 | #define PyString_Concat PyUnicode_Concat | |
|
42 | #define PyString_ConcatAndDel PyUnicode_AppendAndDel | |
|
43 | #define _PyString_Resize PyUnicode_Resize | |
|
44 | /* #define _PyString_Eq */ | |
|
45 | #define PyString_Format PyUnicode_Format | |
|
46 | /* #define _PyString_FormatLong */ | |
|
47 | /* #define PyString_DecodeEscape */ | |
|
48 | #define _PyString_Join PyUnicode_Join | |
|
49 | #define PyString_Decode PyUnicode_Decode | |
|
50 | #define PyString_Encode PyUnicode_Encode | |
|
51 | #define PyString_AsEncodedObject PyUnicode_AsEncodedObject | |
|
52 | #define PyString_AsEncodedString PyUnicode_AsEncodedString | |
|
53 | #define PyString_AsDecodedObject PyUnicode_AsDecodedObject | |
|
54 | #define PyString_AsDecodedString PyUnicode_AsDecodedUnicode | |
|
55 | /* #define PyString_AsStringAndSize */ | |
|
56 | #define _PyString_InsertThousandsGrouping _PyUnicode_InsertThousandsGrouping | |
|
57 | ||
|
17 | 58 | #endif /* PY_MAJOR_VERSION */ |
|
18 | 59 | |
|
19 | 60 | /* Backports from 2.6 */ |
|
20 | 61 | #if PY_VERSION_HEX < 0x02060000 |
|
21 | 62 | |
|
22 | 63 | #define Py_TYPE(ob) (ob)->ob_type |
|
23 | 64 | #define Py_SIZE(ob) (ob)->ob_size |
|
24 | 65 | #define PyVarObject_HEAD_INIT(type, size) PyObject_HEAD_INIT(type) size, |
|
25 | 66 | |
|
26 | 67 | /* Shamelessly stolen from bytesobject.h */ |
|
27 | 68 | #define PyBytesObject PyStringObject |
|
28 | 69 | #define PyBytes_Type PyString_Type |
|
29 | 70 | |
|
30 | 71 | #define PyBytes_Check PyString_Check |
|
31 | 72 | #define PyBytes_CheckExact PyString_CheckExact |
|
32 | 73 | #define PyBytes_CHECK_INTERNED PyString_CHECK_INTERNED |
|
33 | 74 | #define PyBytes_AS_STRING PyString_AS_STRING |
|
34 | 75 | #define PyBytes_GET_SIZE PyString_GET_SIZE |
|
35 | 76 | #define Py_TPFLAGS_BYTES_SUBCLASS Py_TPFLAGS_STRING_SUBCLASS |
|
36 | 77 | |
|
37 | 78 | #define PyBytes_FromStringAndSize PyString_FromStringAndSize |
|
38 | 79 | #define PyBytes_FromString PyString_FromString |
|
39 | 80 | #define PyBytes_FromFormatV PyString_FromFormatV |
|
40 | 81 | #define PyBytes_FromFormat PyString_FromFormat |
|
41 | 82 | #define PyBytes_Size PyString_Size |
|
42 | 83 | #define PyBytes_AsString PyString_AsString |
|
43 | 84 | #define PyBytes_Repr PyString_Repr |
|
44 | 85 | #define PyBytes_Concat PyString_Concat |
|
45 | 86 | #define PyBytes_ConcatAndDel PyString_ConcatAndDel |
|
46 | 87 | #define _PyBytes_Resize _PyString_Resize |
|
47 | 88 | #define _PyBytes_Eq _PyString_Eq |
|
48 | 89 | #define PyBytes_Format PyString_Format |
|
49 | 90 | #define _PyBytes_FormatLong _PyString_FormatLong |
|
50 | 91 | #define PyBytes_DecodeEscape PyString_DecodeEscape |
|
51 | 92 | #define _PyBytes_Join _PyString_Join |
|
52 | 93 | #define PyBytes_Decode PyString_Decode |
|
53 | 94 | #define PyBytes_Encode PyString_Encode |
|
54 | 95 | #define PyBytes_AsEncodedObject PyString_AsEncodedObject |
|
55 | 96 | #define PyBytes_AsEncodedString PyString_AsEncodedString |
|
56 | 97 | #define PyBytes_AsDecodedObject PyString_AsDecodedObject |
|
57 | 98 | #define PyBytes_AsDecodedString PyString_AsDecodedString |
|
58 | 99 | #define PyBytes_AsStringAndSize PyString_AsStringAndSize |
|
59 | 100 | #define _PyBytes_InsertThousandsGrouping _PyString_InsertThousandsGrouping |
|
60 | 101 | |
|
61 | 102 | #endif /* PY_VERSION_HEX */ |
|
62 | 103 | |
|
63 | 104 | #endif /* _HG_UTIL_H_ */ |
|
64 | 105 |
General Comments 0
You need to be logged in to leave comments.
Login now