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