Commit 308f7b23 authored by Stefan Behnel's avatar Stefan Behnel

replace plain '#define CYTHON_PEP393_ENABLED' by flag #define as 1 or 0 to...

replace plain '#define CYTHON_PEP393_ENABLED' by flag #define as 1 or 0 to make it usable from Cython code

--HG--
extra : transplant_source : %98%A3s%16%85%D7%5C%18%AC%C4%EFe%A624ZcU%EC%A8
parent 03e0fdb8
......@@ -1544,7 +1544,7 @@ static CYTHON_INLINE Py_UCS4 __Pyx_PyObject_AsPy_UCS4(PyObject* x) {
long ival;
if (PyUnicode_Check(x)) {
Py_ssize_t length;
#ifdef CYTHON_PEP393_ENABLED
#if CYTHON_PEP393_ENABLED
length = PyUnicode_GET_LENGTH(x);
if (likely(length == 1)) {
return PyUnicode_READ_CHAR(x, 0);
......@@ -1614,7 +1614,7 @@ static CYTHON_INLINE Py_UNICODE __Pyx_PyObject_AsPy_UNICODE(PyObject*);
impl='''
static CYTHON_INLINE Py_UNICODE __Pyx_PyObject_AsPy_UNICODE(PyObject* x) {
long ival;
#ifdef CYTHON_PEP393_ENABLED
#if CYTHON_PEP393_ENABLED
const long maxval = 1114111;
#else
static long maxval = 0;
......@@ -1626,13 +1626,13 @@ static CYTHON_INLINE Py_UNICODE __Pyx_PyObject_AsPy_UNICODE(PyObject* x) {
"got length %"PY_FORMAT_SIZE_T"d", __Pyx_PyUnicode_GET_LENGTH(x));
return (Py_UNICODE)-1;
}
#ifdef CYTHON_PEP393_ENABLED
#if CYTHON_PEP393_ENABLED
ival = PyUnicode_READ_CHAR(x, 0);
#else
return PyUnicode_AS_UNICODE(x)[0];
#endif
} else {
#ifndef CYTHON_PEP393_ENABLED
#if CYTHON_PEP393_ENABLED
if (unlikely(!maxval))
maxval = (long)PyUnicode_GetMax();
#endif
......
......@@ -124,10 +124,11 @@
/* new Py3.3 unicode representation (PEP 393) */
#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_GET_LENGTH)
#define CYTHON_PEP393_ENABLED
#define CYTHON_PEP393_ENABLED 1
#define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
#define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
#else
#define CYTHON_PEP393_ENABLED 0
#define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
#define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
#endif
......
......@@ -28,7 +28,7 @@ static CYTHON_INLINE int __Pyx_PyUnicodeBufferContainsUCS4(Py_UNICODE* buffer, P
//////////////////// PyUCS4InUnicode ////////////////////
static CYTHON_INLINE int __Pyx_UnicodeContainsUCS4(PyObject* unicode, Py_UCS4 character) {
#ifdef CYTHON_PEP393_ENABLED
#if CYTHON_PEP393_ENABLED
Py_ssize_t i;
int kind;
void* udata;
......@@ -94,7 +94,7 @@ static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int
/* as done by PyObject_RichCompareBool(); also catches the (interned) empty string */
return (equals == Py_EQ);
} else if (PyUnicode_CheckExact(s1) & PyUnicode_CheckExact(s2)) {
#ifdef CYTHON_PEP393_ENABLED
#if CYTHON_PEP393_ENABLED
if ((PyUnicode_READY(s1) < 0) || (PyUnicode_READY(s2) < 0))
return -1;
if (PyUnicode_GET_LENGTH(s1) != PyUnicode_GET_LENGTH(s2)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment