mirror of
https://github.com/python/cpython.git
synced 2025-10-09 08:31:26 +00:00
bpo-45316: Move private PyCode C API to internal C API (GH-31576)
Rename private functions (no exported), add an underscore prefix: * PyLineTable_InitAddressRange() => _PyLineTable_InitAddressRange() * PyLineTable_NextAddressRange() => _PyLineTable_NextAddressRange() * PyLineTable_PreviousAddressRange() => _PyLineTable_PreviousAddressRange() Move private functions to the internal C API: * _PyCode_Addr2EndLine() * _PyCode_Addr2EndOffset() * _PyCode_Addr2Offset() * _PyCode_InitAddressRange() * _PyCode_InitEndAddressRange( * _PyLineTable_InitAddressRange() * _PyLineTable_NextAddressRange() * _PyLineTable_PreviousAddressRange() No longer export the following internal functions: * _PyCode_GetVarnames() * _PyCode_GetCellvars() * _PyCode_GetFreevars() * _Py_GetSpecializationStats() Add "extern" to pycore_code.h functions to identify them more easiliy (they are still not exported).
This commit is contained in:
parent
c579243eb6
commit
4a0c7a1aac
4 changed files with 56 additions and 49 deletions
|
@ -676,7 +676,7 @@ _PyCode_Addr2EndOffset(PyCodeObject* co, int addrq)
|
|||
}
|
||||
|
||||
void
|
||||
PyLineTable_InitAddressRange(const char *linetable, Py_ssize_t length, int firstlineno, PyCodeAddressRange *range)
|
||||
_PyLineTable_InitAddressRange(const char *linetable, Py_ssize_t length, int firstlineno, PyCodeAddressRange *range)
|
||||
{
|
||||
range->opaque.lo_next = linetable;
|
||||
range->opaque.limit = range->opaque.lo_next + length;
|
||||
|
@ -691,7 +691,7 @@ _PyCode_InitAddressRange(PyCodeObject* co, PyCodeAddressRange *bounds)
|
|||
{
|
||||
const char *linetable = PyBytes_AS_STRING(co->co_linetable);
|
||||
Py_ssize_t length = PyBytes_GET_SIZE(co->co_linetable);
|
||||
PyLineTable_InitAddressRange(linetable, length, co->co_firstlineno, bounds);
|
||||
_PyLineTable_InitAddressRange(linetable, length, co->co_firstlineno, bounds);
|
||||
return bounds->ar_line;
|
||||
}
|
||||
|
||||
|
@ -700,7 +700,7 @@ _PyCode_InitEndAddressRange(PyCodeObject* co, PyCodeAddressRange* bounds)
|
|||
{
|
||||
char* linetable = PyBytes_AS_STRING(co->co_endlinetable);
|
||||
Py_ssize_t length = PyBytes_GET_SIZE(co->co_endlinetable);
|
||||
PyLineTable_InitAddressRange(linetable, length, co->co_firstlineno, bounds);
|
||||
_PyLineTable_InitAddressRange(linetable, length, co->co_firstlineno, bounds);
|
||||
return bounds->ar_line;
|
||||
}
|
||||
|
||||
|
@ -710,12 +710,12 @@ int
|
|||
_PyCode_CheckLineNumber(int lasti, PyCodeAddressRange *bounds)
|
||||
{
|
||||
while (bounds->ar_end <= lasti) {
|
||||
if (!PyLineTable_NextAddressRange(bounds)) {
|
||||
if (!_PyLineTable_NextAddressRange(bounds)) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
while (bounds->ar_start > lasti) {
|
||||
if (!PyLineTable_PreviousAddressRange(bounds)) {
|
||||
if (!_PyLineTable_PreviousAddressRange(bounds)) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -765,7 +765,7 @@ at_end(PyCodeAddressRange *bounds) {
|
|||
}
|
||||
|
||||
int
|
||||
PyLineTable_PreviousAddressRange(PyCodeAddressRange *range)
|
||||
_PyLineTable_PreviousAddressRange(PyCodeAddressRange *range)
|
||||
{
|
||||
if (range->ar_start <= 0) {
|
||||
return 0;
|
||||
|
@ -779,7 +779,7 @@ PyLineTable_PreviousAddressRange(PyCodeAddressRange *range)
|
|||
}
|
||||
|
||||
int
|
||||
PyLineTable_NextAddressRange(PyCodeAddressRange *range)
|
||||
_PyLineTable_NextAddressRange(PyCodeAddressRange *range)
|
||||
{
|
||||
if (at_end(range)) {
|
||||
return 0;
|
||||
|
@ -847,7 +847,7 @@ decode_linetable(PyCodeObject *code)
|
|||
return NULL;
|
||||
}
|
||||
_PyCode_InitAddressRange(code, &bounds);
|
||||
while (PyLineTable_NextAddressRange(&bounds)) {
|
||||
while (_PyLineTable_NextAddressRange(&bounds)) {
|
||||
if (bounds.opaque.computed_line != line) {
|
||||
int bdelta = bounds.ar_start - code_offset;
|
||||
int ldelta = bounds.opaque.computed_line - line;
|
||||
|
@ -883,7 +883,7 @@ static PyObject *
|
|||
lineiter_next(lineiterator *li)
|
||||
{
|
||||
PyCodeAddressRange *bounds = &li->li_line;
|
||||
if (!PyLineTable_NextAddressRange(bounds)) {
|
||||
if (!_PyLineTable_NextAddressRange(bounds)) {
|
||||
return NULL;
|
||||
}
|
||||
PyObject *start = NULL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue