Skip to content

Commit 4353581

Browse files
committed
Rename PyUnstable_LongExport to PyUnstable_Long_DigitArray
1 parent 660acec commit 4353581

File tree

4 files changed

+31
-30
lines changed

4 files changed

+31
-30
lines changed

Doc/c-api/long.rst

+8-7
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ Import/Export API
552552
A single unsigned digit.
553553
554554
It is usually used in an *array of digits*, such as the
555-
:c:member:`PyUnstable_LongExport.digits` array.
555+
:c:member:`PyUnstable_Long_DigitArray.digits` array.
556556
557557
Its size depend on the :c:macro:`!PYLONG_BITS_IN_DIGIT` macro:
558558
see the ``configure`` :option:`--enable-big-digits` option.
@@ -607,11 +607,12 @@ Import/Export API
607607
See :c:struct:`PyUnstable_Long_LAYOUT` for the internal layout of an integer.
608608
609609
610-
.. c:struct:: PyUnstable_LongExport
610+
.. c:struct:: PyUnstable_Long_DigitArray
611611
612612
A Python :class:`int` object exported as an array of digits.
613613
614-
See :c:struct:`PyUnstable_Long_LAYOUT` for the internal layout of an integer.
614+
See :c:struct:`PyUnstable_Long_LAYOUT` for the internal layout of an
615+
integer.
615616
616617
.. c:member:: PyLongObject *obj
617618
@@ -630,11 +631,11 @@ Import/Export API
630631
Array of unsigned digits.
631632
632633
633-
.. c:function:: int PyUnstable_Long_Export(PyObject *obj, PyUnstable_LongExport *export)
634+
.. c:function:: int PyUnstable_Long_Export(PyObject *obj, PyUnstable_Long_DigitArray *array)
634635
635636
Export a Python :class:`int` object as an array of digits.
636637
637-
* Set *\*export* and return 0 on success.
638+
* Set *\*array* and return 0 on success.
638639
* Set an exception and return -1 on error.
639640
640641
This function always succeeds if *obj* is a Python :class:`int` object or a
@@ -644,6 +645,6 @@ Import/Export API
644645
*export*.
645646
646647
647-
.. c:function:: void PyUnstable_Long_ReleaseExport(PyUnstable_LongExport *export)
648+
.. c:function:: void PyUnstable_Long_ReleaseExport(PyUnstable_Long_DigitArray *array)
648649
649-
Release an export created by :c:func:`PyUnstable_Long_Export`.
650+
Release the export *array* created by :c:func:`PyUnstable_Long_Export`.

Include/cpython/longintrepr.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -168,18 +168,18 @@ PyAPI_FUNC(PyObject*) PyUnstable_Long_Import(
168168
size_t ndigits,
169169
Py_digit *digits);
170170

171-
typedef struct PyUnstable_LongExport {
171+
typedef struct PyUnstable_Long_DigitArray {
172172
PyLongObject *obj;
173173
int negative;
174174
size_t ndigits;
175175
Py_digit *digits;
176-
} PyUnstable_LongExport;
176+
} PyUnstable_Long_DigitArray;
177177

178178
PyAPI_FUNC(int) PyUnstable_Long_Export(
179179
PyObject *obj,
180-
PyUnstable_LongExport *long_export);
180+
PyUnstable_Long_DigitArray *array);
181181
PyAPI_FUNC(void) PyUnstable_Long_ReleaseExport(
182-
PyUnstable_LongExport *long_export);
182+
PyUnstable_Long_DigitArray *array);
183183

184184
#ifdef __cplusplus
185185
}

Modules/_testcapi/long.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,14 @@ pylong_import(PyObject *module, PyObject *args)
163163
static PyObject *
164164
pylong_export(PyObject *module, PyObject *obj)
165165
{
166-
PyUnstable_LongExport long_export;
167-
if (PyUnstable_Long_Export(obj, &long_export) < 0) {
166+
PyUnstable_Long_DigitArray array;
167+
if (PyUnstable_Long_Export(obj, &array) < 0) {
168168
return NULL;
169169
}
170170

171171
PyObject *digits = PyList_New(0);
172-
for (size_t i=0; i < long_export.ndigits; i++) {
173-
PyObject *digit = PyLong_FromUnsignedLong(long_export.digits[i]);
172+
for (size_t i=0; i < array.ndigits; i++) {
173+
PyObject *digit = PyLong_FromUnsignedLong(array.digits[i]);
174174
if (digit == NULL) {
175175
Py_DECREF(digits);
176176
goto error;
@@ -184,12 +184,12 @@ pylong_export(PyObject *module, PyObject *obj)
184184
Py_DECREF(digit);
185185
}
186186

187-
PyObject *res = Py_BuildValue("(iN)", long_export.negative, digits);
188-
PyUnstable_Long_ReleaseExport(&long_export);
187+
PyObject *res = Py_BuildValue("(iN)", array.negative, digits);
188+
PyUnstable_Long_ReleaseExport(&array);
189189
return res;
190190

191191
error:
192-
PyUnstable_Long_ReleaseExport(&long_export);
192+
PyUnstable_Long_ReleaseExport(&array);
193193
return NULL;
194194
}
195195

Objects/longobject.c

+12-12
Original file line numberDiff line numberDiff line change
@@ -6702,30 +6702,30 @@ PyUnstable_Long_Import(int negative, size_t ndigits, Py_digit *digits)
67026702

67036703

67046704
int
6705-
PyUnstable_Long_Export(PyObject *obj, PyUnstable_LongExport *long_export)
6705+
PyUnstable_Long_Export(PyObject *obj, PyUnstable_Long_DigitArray *array)
67066706
{
67076707
if (!PyLong_Check(obj)) {
67086708
PyErr_Format(PyExc_TypeError, "expect int, got %T", obj);
67096709
return -1;
67106710
}
67116711
PyLongObject *self = (PyLongObject*)obj;
67126712

6713-
long_export->obj = (PyLongObject*)Py_NewRef(obj);
6714-
long_export->negative = _PyLong_IsNegative(self);
6715-
long_export->ndigits = _PyLong_DigitCount(self);
6716-
if (long_export->ndigits == 0) {
6717-
long_export->ndigits = 1;
6713+
array->obj = (PyLongObject*)Py_NewRef(obj);
6714+
array->negative = _PyLong_IsNegative(self);
6715+
array->ndigits = _PyLong_DigitCount(self);
6716+
if (array->ndigits == 0) {
6717+
array->ndigits = 1;
67186718
}
6719-
long_export->digits = self->long_value.ob_digit;
6719+
array->digits = self->long_value.ob_digit;
67206720
return 0;
67216721
}
67226722

67236723

67246724
void
6725-
PyUnstable_Long_ReleaseExport(PyUnstable_LongExport *long_export)
6725+
PyUnstable_Long_ReleaseExport(PyUnstable_Long_DigitArray *array)
67266726
{
6727-
Py_CLEAR(long_export->obj);
6728-
long_export->negative = 0;
6729-
long_export->ndigits = 0;
6730-
long_export->digits = NULL;
6727+
Py_CLEAR(array->obj);
6728+
array->negative = 0;
6729+
array->ndigits = 0;
6730+
array->digits = NULL;
67316731
}

0 commit comments

Comments
 (0)