Commit 58c1fddf authored by Marius Wachtler's avatar Marius Wachtler

capi: add the direct access macros back

parent 20cb1ccb
......@@ -56,9 +56,8 @@ PyAPI_FUNC(PyObject *) PyFloat_FromDouble(double) PYSTON_NOEXCEPT;
/* Extract C double from Python float. The macro version trades safety for
speed. */
PyAPI_FUNC(double) PyFloat_AsDouble(PyObject *) PYSTON_NOEXCEPT;
// Pyston changes: these aren't direct macros any more [they potentially could be though]
#define PyFloat_AS_DOUBLE(op) PyFloat_AsDouble((PyObject*)op)
//#define PyFloat_AS_DOUBLE(op) (((PyFloatObject *)(op))->ob_fval)
#define PyFloat_AS_DOUBLE(op) (((PyFloatObject *)(op))->ob_fval)
/* Write repr(v) into the char buffer argument, followed by null byte. The
buffer must be "big enough"; >= 100 is very safe.
......
......@@ -55,9 +55,7 @@ PyAPI_FUNC(unsigned PY_LONG_LONG) PyInt_AsUnsignedLongLongMask(PyObject *) PYSTO
PyAPI_FUNC(long) PyInt_GetMax(void) PYSTON_NOEXCEPT;
/* Macro, trading safety for speed */
// Pyston changes: these aren't direct macros any more [they potentially could be though]
#define PyInt_AS_LONG(op) PyInt_AsLong((PyObject*)op)
//#define PyInt_AS_LONG(op) (((PyIntObject *)(op))->ob_ival)
#define PyInt_AS_LONG(op) (((PyIntObject *)(op))->ob_ival)
/* These aren't really part of the Int object, but they're handy; the protos
* are necessary for systems that need the magic of PyAPI_FUNC and that want
......
......@@ -93,21 +93,16 @@ PyAPI_FUNC(void) _Py_ReleaseInternedStrings(void) PYSTON_NOEXCEPT;
PyAPI_FUNC(char) PyString_GetItem(PyObject *, Py_ssize_t) PYSTON_NOEXCEPT;
/* Use only if you know it's a string */
// Pyston changes: these aren't direct macros any more [they potentially could be though]
//#define PyString_CHECK_INTERNED(op) (((PyStringObject *)(op))->ob_sstate)
PyAPI_FUNC(int) _PyString_CheckInterned(PyObject *) PYSTON_NOEXCEPT;
#define PyString_CHECK_INTERNED(op) _PyString_CheckInterned((PyObject*)op)
#define PyString_CHECK_INTERNED(op) (((PyStringObject *)(op))->ob_sstate)
/* Macro, trading safety for speed */
// Pyston changes: these aren't direct macros any more [they potentially could be though]
#define PyString_AS_STRING(op) PyString_AsString((PyObject*)op)
// Note: there are buggy extension modules (unicodedata.c) that rely on the fact that
// PyString_GET_SIZE does *not* have the same behavior as PyString_Size. In particular,
// you can get away with calling PyString_GET_SIZE on a unicode object and getting the
// length of the unicode string, not the length of the bytes it encodes to in the default
// encoding.
// So, set up a different function for those callers to use.
//#define PyString_AS_STRING(op) (((PyStringObject *)(op))->ob_sval)
#define PyString_AS_STRING(op) (((PyStringObject *)(op))->ob_sval)
#define PyString_GET_SIZE(op) Py_SIZE(op)
/* _PyString_Join(sep, x) is like sep.join(x). sep must be PyStringObject*,
......
......@@ -423,12 +423,6 @@ extern "C" void _Py_ReleaseInternedStrings() noexcept {
interned_strings.clear();
}
extern "C" int _PyString_CheckInterned(PyObject* p) noexcept {
RELEASE_ASSERT(PyString_Check(p), "");
BoxedString* s = (BoxedString*)p;
return s->interned_state;
}
/* Format codes
* F_LJUST '-'
* F_SIGN '+'
......
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