mirror of
https://github.com/python/cpython.git
synced 2025-11-24 12:20:42 +00:00
gh-139353: Add Objects/unicode_format.c file (#139491)
* Move PyUnicode_Format() implementation from unicodeobject.c to unicode_format.c. * Replace unicode_modifiable() with _PyUnicode_IsModifiable() * Add empty lines to have two empty lines between functions.
This commit is contained in:
parent
7cafd76a7f
commit
4c119714d5
8 changed files with 1047 additions and 973 deletions
|
|
@ -11,10 +11,14 @@ extern "C" {
|
||||||
#include "pycore_fileutils.h" // _Py_error_handler
|
#include "pycore_fileutils.h" // _Py_error_handler
|
||||||
#include "pycore_ucnhash.h" // _PyUnicode_Name_CAPI
|
#include "pycore_ucnhash.h" // _PyUnicode_Name_CAPI
|
||||||
|
|
||||||
|
|
||||||
// Maximum code point of Unicode 6.0: 0x10ffff (1,114,111).
|
// Maximum code point of Unicode 6.0: 0x10ffff (1,114,111).
|
||||||
#define _Py_MAX_UNICODE 0x10ffff
|
#define _Py_MAX_UNICODE 0x10ffff
|
||||||
|
|
||||||
|
|
||||||
|
extern int _PyUnicode_IsModifiable(PyObject *unicode);
|
||||||
|
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
_PyUnicode_Fill(int kind, void *data, Py_UCS4 value,
|
_PyUnicode_Fill(int kind, void *data, Py_UCS4 value,
|
||||||
Py_ssize_t start, Py_ssize_t length)
|
Py_ssize_t start, Py_ssize_t length)
|
||||||
|
|
@ -48,6 +52,28 @@ _PyUnicode_Fill(int kind, void *data, Py_UCS4 value,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
_PyUnicode_EnsureUnicode(PyObject *obj)
|
||||||
|
{
|
||||||
|
if (!PyUnicode_Check(obj)) {
|
||||||
|
PyErr_Format(PyExc_TypeError,
|
||||||
|
"must be str, not %T", obj);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
_PyUnicodeWriter_WriteCharInline(_PyUnicodeWriter *writer, Py_UCS4 ch)
|
||||||
|
{
|
||||||
|
assert(ch <= _Py_MAX_UNICODE);
|
||||||
|
if (_PyUnicodeWriter_Prepare(writer, 1, ch) < 0)
|
||||||
|
return -1;
|
||||||
|
PyUnicode_WRITE(writer->kind, writer->data, writer->pos, ch);
|
||||||
|
writer->pos++;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* --- Characters Type APIs ----------------------------------------------- */
|
/* --- Characters Type APIs ----------------------------------------------- */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -557,9 +557,10 @@ OBJECT_OBJS= \
|
||||||
Objects/tupleobject.o \
|
Objects/tupleobject.o \
|
||||||
Objects/typeobject.o \
|
Objects/typeobject.o \
|
||||||
Objects/typevarobject.o \
|
Objects/typevarobject.o \
|
||||||
|
Objects/unicode_format.o \
|
||||||
Objects/unicode_formatter.o \
|
Objects/unicode_formatter.o \
|
||||||
Objects/unicodeobject.o \
|
|
||||||
Objects/unicodectype.o \
|
Objects/unicodectype.o \
|
||||||
|
Objects/unicodeobject.o \
|
||||||
Objects/unionobject.o \
|
Objects/unionobject.o \
|
||||||
Objects/weakrefobject.o \
|
Objects/weakrefobject.o \
|
||||||
@PERF_TRAMPOLINE_OBJ@
|
@PERF_TRAMPOLINE_OBJ@
|
||||||
|
|
@ -2105,6 +2106,7 @@ Objects/bytes_methods.o: $(srcdir)/Objects/bytes_methods.c $(BYTESTR_DEPS)
|
||||||
Objects/bytesobject.o: $(srcdir)/Objects/bytesobject.c $(BYTESTR_DEPS)
|
Objects/bytesobject.o: $(srcdir)/Objects/bytesobject.c $(BYTESTR_DEPS)
|
||||||
Objects/bytearrayobject.o: $(srcdir)/Objects/bytearrayobject.c $(BYTESTR_DEPS)
|
Objects/bytearrayobject.o: $(srcdir)/Objects/bytearrayobject.c $(BYTESTR_DEPS)
|
||||||
|
|
||||||
|
Objects/unicode_format.o: $(srcdir)/Objects/unicode_format.c $(UNICODE_DEPS)
|
||||||
Objects/unicodeobject.o: $(srcdir)/Objects/unicodeobject.c $(UNICODE_DEPS)
|
Objects/unicodeobject.o: $(srcdir)/Objects/unicodeobject.c $(UNICODE_DEPS)
|
||||||
|
|
||||||
Objects/dictobject.o: $(srcdir)/Objects/stringlib/eq.h
|
Objects/dictobject.o: $(srcdir)/Objects/stringlib/eq.h
|
||||||
|
|
|
||||||
1002
Objects/unicode_format.c
Normal file
1002
Objects/unicode_format.c
Normal file
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -164,6 +164,7 @@
|
||||||
<ClCompile Include="..\Objects\tupleobject.c" />
|
<ClCompile Include="..\Objects\tupleobject.c" />
|
||||||
<ClCompile Include="..\Objects\typeobject.c" />
|
<ClCompile Include="..\Objects\typeobject.c" />
|
||||||
<ClCompile Include="..\Objects\typevarobject.c" />
|
<ClCompile Include="..\Objects\typevarobject.c" />
|
||||||
|
<ClCompile Include="..\Objects\unicode_format.c" />
|
||||||
<ClCompile Include="..\Objects\unicodectype.c" />
|
<ClCompile Include="..\Objects\unicodectype.c" />
|
||||||
<ClCompile Include="..\Objects\unicode_formatter.c" />
|
<ClCompile Include="..\Objects\unicode_formatter.c" />
|
||||||
<ClCompile Include="..\Objects\unicodeobject.c" />
|
<ClCompile Include="..\Objects\unicodeobject.c" />
|
||||||
|
|
|
||||||
|
|
@ -481,6 +481,9 @@
|
||||||
<ClCompile Include="..\Objects\typeobject.c">
|
<ClCompile Include="..\Objects\typeobject.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Objects\unicode_format.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="..\Objects\unicodectype.c">
|
<ClCompile Include="..\Objects\unicodectype.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|
|
||||||
|
|
@ -558,6 +558,7 @@
|
||||||
<ClCompile Include="..\Objects\tupleobject.c" />
|
<ClCompile Include="..\Objects\tupleobject.c" />
|
||||||
<ClCompile Include="..\Objects\typeobject.c" />
|
<ClCompile Include="..\Objects\typeobject.c" />
|
||||||
<ClCompile Include="..\Objects\typevarobject.c" />
|
<ClCompile Include="..\Objects\typevarobject.c" />
|
||||||
|
<ClCompile Include="..\Objects\unicode_format.c" />
|
||||||
<ClCompile Include="..\Objects\unicodectype.c" />
|
<ClCompile Include="..\Objects\unicodectype.c" />
|
||||||
<ClCompile Include="..\Objects\unicode_formatter.c" />
|
<ClCompile Include="..\Objects\unicode_formatter.c" />
|
||||||
<ClCompile Include="..\Objects\unicodeobject.c" />
|
<ClCompile Include="..\Objects\unicodeobject.c" />
|
||||||
|
|
|
||||||
|
|
@ -1271,6 +1271,9 @@
|
||||||
<ClCompile Include="..\Objects\typeobject.c">
|
<ClCompile Include="..\Objects\typeobject.c">
|
||||||
<Filter>Objects</Filter>
|
<Filter>Objects</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Objects\unicode_format.c">
|
||||||
|
<Filter>Objects</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="..\Objects\unicodectype.c">
|
<ClCompile Include="..\Objects\unicodectype.c">
|
||||||
<Filter>Objects</Filter>
|
<Filter>Objects</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue