patches/pygame-03-pgcompat.diff
author jurikm
Sun, 12 Feb 2012 14:04:10 +0000
changeset 8245 383896da4129
parent 2331 bb50963a5336
permissions -rw-r--r--
SFEsauerbraten.spec: add IPS package name
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2331
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
     1
--- pygame-1.9.1release/src/pgcompat.h-orig	2010-02-03 07:53:46.178657442 -0600
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
     2
+++ pygame-1.9.1release/src/pgcompat.h	2010-02-03 07:53:57.263344034 -0600
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
     3
@@ -1,118 +1,118 @@
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
     4
-/* Python 2.x/3.x compitibility tools
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
     5
- */
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
     6
-
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
     7
-#if !defined(PGCOMPAT_H)
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
     8
-#define PGCOMPAT_H
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
     9
-
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    10
-#if PY_MAJOR_VERSION >= 3
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    11
-
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    12
-#define PY3 1
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    13
-
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    14
-/* Define some aliases for the removed PyInt_* functions */
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    15
-#define PyInt_Check(op) PyLong_Check(op)
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    16
-#define PyInt_FromString PyLong_FromString
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    17
-#define PyInt_FromUnicode PyLong_FromUnicode
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    18
-#define PyInt_FromLong PyLong_FromLong
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    19
-#define PyInt_FromSize_t PyLong_FromSize_t
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    20
-#define PyInt_FromSsize_t PyLong_FromSsize_t
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    21
-#define PyInt_AsLong PyLong_AsLong
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    22
-#define PyInt_AsSsize_t PyLong_AsSsize_t
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    23
-#define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    24
-#define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    25
-#define PyInt_AS_LONG PyLong_AS_LONG
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    26
-#define PyNumber_Int PyNumber_Long
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    27
-
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    28
-/* Weakrefs flags changed in 3.x */
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    29
-#define Py_TPFLAGS_HAVE_WEAKREFS 0
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    30
-
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    31
-/* Module init function returns new module instance. */
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    32
-#define MODINIT_RETURN(x) return x
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    33
-#define MODINIT_DEFINE(mod_name) PyMODINIT_FUNC PyInit_##mod_name (void)
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    34
-#define DECREF_MOD(mod) Py_DECREF (mod)
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    35
-
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    36
-/* Type header differs. */
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    37
-#define TYPE_HEAD(x,y) PyVarObject_HEAD_INIT(x,y)
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    38
-
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    39
-/* Text interface. Use unicode strings. */
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    40
-#define Text_Type PyUnicode_Type
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    41
-#define Text_Check PyUnicode_Check
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    42
-#define Text_FromUTF8 PyUnicode_FromString
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    43
-#define Text_FromUTF8AndSize PyUnicode_FromStringAndSize
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    44
-#define Text_FromFormat PyUnicode_FromFormat
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    45
-#define Text_GetSize PyUnicode_GetSize
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    46
-#define Text_GET_SIZE PyUnicode_GET_SIZE
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    47
-
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    48
-/* Binary interface. Use bytes. */
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    49
-#define Bytes_Type PyBytes_Type
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    50
-#define Bytes_Check PyBytes_Check
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    51
-#define Bytes_Size PyBytes_Size
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    52
-#define Bytes_AsString PyBytes_AsString
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    53
-#define Bytes_AsStringAndSize PyBytes_AsStringAndSize
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    54
-#define Bytes_FromStringAndSize PyBytes_FromStringAndSize
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    55
-#define Bytes_AS_STRING PyBytes_AS_STRING
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    56
-#define Bytes_GET_SIZE PyBytes_GET_SIZE
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    57
-
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    58
-#define IsTextObj(x) (PyUnicode_Check(x) || PyBytes_Check(x))
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    59
-
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    60
-/* Renamed builtins */
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    61
-#define BUILTINS_MODULE "builtins"
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    62
-#define BUILTINS_UNICODE "str"
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    63
-#define BUILTINS_UNICHR "chr"
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    64
-
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    65
-#else /* PY_VERSION_HEX >= 0x03000000 */
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    66
-
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    67
-#define PY3 0
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    68
-
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    69
-/* Module init function returns nothing. */
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    70
-#define MODINIT_RETURN(x) return
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    71
-#define MODINIT_DEFINE(mod_name) PyMODINIT_FUNC init##mod_name (void)
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    72
-#define DECREF_MOD(mod)
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    73
-
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    74
-/* Type header differs. */
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    75
-#define TYPE_HEAD(x,y)                          \
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    76
-    PyObject_HEAD_INIT(x)                       \
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    77
-    0,
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    78
-
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    79
-/* Text interface. Use ascii strings. */
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    80
-#define Text_Type PyString_Type
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    81
-#define Text_Check PyString_Check
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    82
-#define Text_FromUTF8 PyString_FromString
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    83
-#define Text_FromUTF8AndSize PyString_FromStringAndSize
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    84
-#define Text_FromFormat PyString_FromFormat
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    85
-#define Text_GetSize PyString_GetSize
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    86
-#define Text_GET_SIZE PyString_GET_SIZE
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    87
-
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    88
-/* Binary interface. Use ascii strings. */
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    89
-#define Bytes_Type PyString_Type
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    90
-#define Bytes_Check PyString_Check
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    91
-#define Bytes_Size PyString_Size
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    92
-#define Bytes_AsString PyString_AsString
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    93
-#define Bytes_AsStringAndSize PyString_AsStringAndSize
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    94
-#define Bytes_FromStringAndSize PyString_FromStringAndSize
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    95
-#define Bytes_AS_STRING PyString_AS_STRING
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    96
-#define Bytes_GET_SIZE PyString_GET_SIZE
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    97
-
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    98
-/* Renamed builtins */
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    99
-#define BUILTINS_MODULE "__builtin__"
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   100
-#define BUILTINS_UNICODE "unicode"
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   101
-#define BUILTINS_UNICHR "unichr"
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   102
-
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   103
-#endif /* PY_VERSION_HEX >= 0x03000000 */
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   104
-
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   105
-#define MODINIT_ERROR MODINIT_RETURN (NULL)
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   106
-
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   107
-/* Module state. These macros are used to define per-module macros. 
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   108
- * v - global state variable (Python 2.x)
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   109
- * s - global state structure (Python 3.x)
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   110
- */
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   111
-#define PY2_GETSTATE(v) (&(v))
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   112
-#define PY3_GETSTATE(s, m) ((struct s *) PyModule_GetState (m))
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   113
-
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   114
-/* Pep 3123: Making PyObject_HEAD conform to standard C */
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   115
-#if !defined(Py_TYPE)
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   116
-#define Py_TYPE(o)    (((PyObject*)(o))->ob_type)
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   117
-#define Py_REFCNT(o)  (((PyObject*)(o))->ob_refcnt)
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   118
-#define Py_SIZE(o)    (((PyVarObject*)(o))->ob_size)
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   119
-#endif
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   120
-
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   121
-#endif /* !defined(PGCOMPAT_H) */
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   122
+/* Python 2.x/3.x compitibility tools
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   123
+ */
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   124
+
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   125
+#if !defined(PGCOMPAT_H)
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   126
+#define PGCOMPAT_H
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   127
+
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   128
+#if PY_MAJOR_VERSION >= 3
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   129
+
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   130
+#define PY3 1
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   131
+
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   132
+/* Define some aliases for the removed PyInt_* functions */
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   133
+#define PyInt_Check(op) PyLong_Check(op)
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   134
+#define PyInt_FromString PyLong_FromString
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   135
+#define PyInt_FromUnicode PyLong_FromUnicode
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   136
+#define PyInt_FromLong PyLong_FromLong
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   137
+#define PyInt_FromSize_t PyLong_FromSize_t
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   138
+#define PyInt_FromSsize_t PyLong_FromSsize_t
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   139
+#define PyInt_AsLong PyLong_AsLong
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   140
+#define PyInt_AsSsize_t PyLong_AsSsize_t
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   141
+#define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   142
+#define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   143
+#define PyInt_AS_LONG PyLong_AS_LONG
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   144
+#define PyNumber_Int PyNumber_Long
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   145
+
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   146
+/* Weakrefs flags changed in 3.x */
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   147
+#define Py_TPFLAGS_HAVE_WEAKREFS 0
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   148
+
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   149
+/* Module init function returns new module instance. */
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   150
+#define MODINIT_RETURN(x) return x
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   151
+#define MODINIT_DEFINE(mod_name) PyMODINIT_FUNC PyInit_##mod_name (void)
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   152
+#define DECREF_MOD(mod) Py_DECREF (mod)
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   153
+
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   154
+/* Type header differs. */
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   155
+#define TYPE_HEAD(x,y) PyVarObject_HEAD_INIT(x,y)
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   156
+
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   157
+/* Text interface. Use unicode strings. */
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   158
+#define Text_Type PyUnicode_Type
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   159
+#define Text_Check PyUnicode_Check
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   160
+#define Text_FromUTF8 PyUnicode_FromString
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   161
+#define Text_FromUTF8AndSize PyUnicode_FromStringAndSize
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   162
+#define Text_FromFormat PyUnicode_FromFormat
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   163
+#define Text_GetSize PyUnicode_GetSize
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   164
+#define Text_GET_SIZE PyUnicode_GET_SIZE
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   165
+
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   166
+/* Binary interface. Use bytes. */
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   167
+#define Bytes_Type PyBytes_Type
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   168
+#define Bytes_Check PyBytes_Check
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   169
+#define Bytes_Size PyBytes_Size
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   170
+#define Bytes_AsString PyBytes_AsString
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   171
+#define Bytes_AsStringAndSize PyBytes_AsStringAndSize
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   172
+#define Bytes_FromStringAndSize PyBytes_FromStringAndSize
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   173
+#define Bytes_AS_STRING PyBytes_AS_STRING
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   174
+#define Bytes_GET_SIZE PyBytes_GET_SIZE
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   175
+
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   176
+#define IsTextObj(x) (PyUnicode_Check(x) || PyBytes_Check(x))
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   177
+
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   178
+/* Renamed builtins */
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   179
+#define BUILTINS_MODULE "builtins"
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   180
+#define BUILTINS_UNICODE "str"
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   181
+#define BUILTINS_UNICHR "chr"
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   182
+
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   183
+#else /* PY_VERSION_HEX >= 0x03000000 */
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   184
+
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   185
+#define PY3 0
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   186
+
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   187
+/* Module init function returns nothing. */
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   188
+#define MODINIT_RETURN(x) return
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   189
+#define MODINIT_DEFINE(mod_name) PyMODINIT_FUNC init##mod_name (void)
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   190
+#define DECREF_MOD(mod)
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   191
+
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   192
+/* Type header differs. */
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   193
+#define TYPE_HEAD(x,y)                          \
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   194
+    PyObject_HEAD_INIT(x)                       \
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   195
+    0,
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   196
+
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   197
+/* Text interface. Use ascii strings. */
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   198
+#define Text_Type PyString_Type
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   199
+#define Text_Check PyString_Check
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   200
+#define Text_FromUTF8 PyString_FromString
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   201
+#define Text_FromUTF8AndSize PyString_FromStringAndSize
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   202
+#define Text_FromFormat PyString_FromFormat
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   203
+#define Text_GetSize PyString_GetSize
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   204
+#define Text_GET_SIZE PyString_GET_SIZE
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   205
+
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   206
+/* Binary interface. Use ascii strings. */
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   207
+#define Bytes_Type PyString_Type
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   208
+#define Bytes_Check PyString_Check
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   209
+#define Bytes_Size PyString_Size
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   210
+#define Bytes_AsString PyString_AsString
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   211
+#define Bytes_AsStringAndSize PyString_AsStringAndSize
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   212
+#define Bytes_FromStringAndSize PyString_FromStringAndSize
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   213
+#define Bytes_AS_STRING PyString_AS_STRING
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   214
+#define Bytes_GET_SIZE PyString_GET_SIZE
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   215
+
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   216
+/* Renamed builtins */
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   217
+#define BUILTINS_MODULE "__builtin__"
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   218
+#define BUILTINS_UNICODE "unicode"
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   219
+#define BUILTINS_UNICHR "unichr"
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   220
+
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   221
+#endif /* PY_VERSION_HEX >= 0x03000000 */
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   222
+
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   223
+#define MODINIT_ERROR MODINIT_RETURN (NULL)
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   224
+
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   225
+/* Module state. These macros are used to define per-module macros. 
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   226
+ * v - global state variable (Python 2.x)
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   227
+ * s - global state structure (Python 3.x)
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   228
+ */
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   229
+#define PY2_GETSTATE(v) (&(v))
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   230
+#define PY3_GETSTATE(s, m) ((struct s *) PyModule_GetState (m))
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   231
+
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   232
+/* Pep 3123: Making PyObject_HEAD conform to standard C */
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   233
+#if !defined(Py_TYPE)
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   234
+#define Py_TYPE(o)    (((PyObject*)(o))->ob_type)
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   235
+#define Py_REFCNT(o)  (((PyObject*)(o))->ob_refcnt)
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   236
+#define Py_SIZE(o)    (((PyVarObject*)(o))->ob_size)
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   237
+#endif
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   238
+
bb50963a5336 2010-02-03 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   239
+#endif /* !defined(PGCOMPAT_H) */