mirror of
https://github.com/python/cpython.git
synced 2025-09-18 14:40:43 +00:00
gh-91102: Use Argument Clinic for EncodingMap (#31725)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
This commit is contained in:
parent
dbd9d75fed
commit
2f0fc521f4
3 changed files with 43 additions and 48 deletions
|
@ -0,0 +1 @@
|
||||||
|
Use Argument Clinic for :class:`EncodingMap`. Patch by Oleg Iarygin.
|
20
Objects/clinic/unicodeobject.c.h
generated
20
Objects/clinic/unicodeobject.c.h
generated
|
@ -2,6 +2,24 @@
|
||||||
preserve
|
preserve
|
||||||
[clinic start generated code]*/
|
[clinic start generated code]*/
|
||||||
|
|
||||||
|
PyDoc_STRVAR(EncodingMap_size__doc__,
|
||||||
|
"size($self, /)\n"
|
||||||
|
"--\n"
|
||||||
|
"\n"
|
||||||
|
"Return the size (in bytes) of this object.");
|
||||||
|
|
||||||
|
#define ENCODINGMAP_SIZE_METHODDEF \
|
||||||
|
{"size", (PyCFunction)EncodingMap_size, METH_NOARGS, EncodingMap_size__doc__},
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
EncodingMap_size_impl(struct encoding_map *self);
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
EncodingMap_size(struct encoding_map *self, PyObject *Py_UNUSED(ignored))
|
||||||
|
{
|
||||||
|
return EncodingMap_size_impl(self);
|
||||||
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(unicode_title__doc__,
|
PyDoc_STRVAR(unicode_title__doc__,
|
||||||
"title($self, /)\n"
|
"title($self, /)\n"
|
||||||
"--\n"
|
"--\n"
|
||||||
|
@ -1335,4 +1353,4 @@ skip_optional_pos:
|
||||||
exit:
|
exit:
|
||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
/*[clinic end generated code: output=c494bed46209961d input=a9049054013a1b77]*/
|
/*[clinic end generated code: output=e8566b060f558f72 input=a9049054013a1b77]*/
|
||||||
|
|
|
@ -397,6 +397,7 @@ static const unsigned char ascii_linebreak[] = {
|
||||||
|
|
||||||
static int convert_uc(PyObject *obj, void *addr);
|
static int convert_uc(PyObject *obj, void *addr);
|
||||||
|
|
||||||
|
struct encoding_map;
|
||||||
#include "clinic/unicodeobject.c.h"
|
#include "clinic/unicodeobject.c.h"
|
||||||
|
|
||||||
_Py_error_handler
|
_Py_error_handler
|
||||||
|
@ -8331,6 +8332,11 @@ PyUnicode_DecodeCharmap(const char *s,
|
||||||
|
|
||||||
/* Charmap encoding: the lookup table */
|
/* Charmap encoding: the lookup table */
|
||||||
|
|
||||||
|
/*[clinic input]
|
||||||
|
class EncodingMap "struct encoding_map *" "&EncodingMapType"
|
||||||
|
[clinic start generated code]*/
|
||||||
|
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=14e46bbb6c522d22]*/
|
||||||
|
|
||||||
struct encoding_map {
|
struct encoding_map {
|
||||||
PyObject_HEAD
|
PyObject_HEAD
|
||||||
unsigned char level1[32];
|
unsigned char level1[32];
|
||||||
|
@ -8338,62 +8344,32 @@ struct encoding_map {
|
||||||
unsigned char level23[1];
|
unsigned char level23[1];
|
||||||
};
|
};
|
||||||
|
|
||||||
static PyObject*
|
/*[clinic input]
|
||||||
encoding_map_size(PyObject *obj, PyObject* args)
|
EncodingMap.size
|
||||||
|
|
||||||
|
Return the size (in bytes) of this object.
|
||||||
|
[clinic start generated code]*/
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
EncodingMap_size_impl(struct encoding_map *self)
|
||||||
|
/*[clinic end generated code: output=c4c969e4c99342a4 input=004ff13f26bb5366]*/
|
||||||
{
|
{
|
||||||
struct encoding_map *map = (struct encoding_map*)obj;
|
return PyLong_FromLong((sizeof(*self) - 1) + 16*self->count2 +
|
||||||
return PyLong_FromLong(sizeof(*map) - 1 + 16*map->count2 +
|
128*self->count3);
|
||||||
128*map->count3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyMethodDef encoding_map_methods[] = {
|
static PyMethodDef encoding_map_methods[] = {
|
||||||
{"size", encoding_map_size, METH_NOARGS,
|
ENCODINGMAP_SIZE_METHODDEF
|
||||||
PyDoc_STR("Return the size (in bytes) of this object") },
|
{NULL, NULL}
|
||||||
{ 0 }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static PyTypeObject EncodingMapType = {
|
static PyTypeObject EncodingMapType = {
|
||||||
PyVarObject_HEAD_INIT(NULL, 0)
|
PyVarObject_HEAD_INIT(NULL, 0)
|
||||||
"EncodingMap", /*tp_name*/
|
.tp_name = "EncodingMap",
|
||||||
sizeof(struct encoding_map), /*tp_basicsize*/
|
.tp_basicsize = sizeof(struct encoding_map),
|
||||||
0, /*tp_itemsize*/
|
|
||||||
/* methods */
|
/* methods */
|
||||||
0, /*tp_dealloc*/
|
.tp_flags = Py_TPFLAGS_DEFAULT,
|
||||||
0, /*tp_vectorcall_offset*/
|
.tp_methods = encoding_map_methods,
|
||||||
0, /*tp_getattr*/
|
|
||||||
0, /*tp_setattr*/
|
|
||||||
0, /*tp_as_async*/
|
|
||||||
0, /*tp_repr*/
|
|
||||||
0, /*tp_as_number*/
|
|
||||||
0, /*tp_as_sequence*/
|
|
||||||
0, /*tp_as_mapping*/
|
|
||||||
0, /*tp_hash*/
|
|
||||||
0, /*tp_call*/
|
|
||||||
0, /*tp_str*/
|
|
||||||
0, /*tp_getattro*/
|
|
||||||
0, /*tp_setattro*/
|
|
||||||
0, /*tp_as_buffer*/
|
|
||||||
Py_TPFLAGS_DEFAULT, /*tp_flags*/
|
|
||||||
0, /*tp_doc*/
|
|
||||||
0, /*tp_traverse*/
|
|
||||||
0, /*tp_clear*/
|
|
||||||
0, /*tp_richcompare*/
|
|
||||||
0, /*tp_weaklistoffset*/
|
|
||||||
0, /*tp_iter*/
|
|
||||||
0, /*tp_iternext*/
|
|
||||||
encoding_map_methods, /*tp_methods*/
|
|
||||||
0, /*tp_members*/
|
|
||||||
0, /*tp_getset*/
|
|
||||||
0, /*tp_base*/
|
|
||||||
0, /*tp_dict*/
|
|
||||||
0, /*tp_descr_get*/
|
|
||||||
0, /*tp_descr_set*/
|
|
||||||
0, /*tp_dictoffset*/
|
|
||||||
0, /*tp_init*/
|
|
||||||
0, /*tp_alloc*/
|
|
||||||
0, /*tp_new*/
|
|
||||||
0, /*tp_free*/
|
|
||||||
0, /*tp_is_gc*/
|
|
||||||
};
|
};
|
||||||
|
|
||||||
PyObject*
|
PyObject*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue