mirror of
https://github.com/johndoe6345789/typthon.git
synced 2026-04-30 00:25:07 +00:00
Massive automated renaming of all Py_/PyObject/etc. prefixes to Ty_/TyObject/etc. This includes: - All public API types (TyObject, TyTypeObject, etc.) - All public API functions (Ty_Initialize, Ty_BuildValue, etc.) - All internal API (_Ty_ prefixes) - Reference counting macros (Ty_INCREF, Ty_DECREF, etc.) - Type flags (Ty_TPFLAGS_*) - Debug flags (Ty_DEBUG, Ty_TRACE_REFS, etc.) - All object type APIs (TyList_, TyDict_, TyUnicode_, etc.) This changes over 60,000 occurrences across 1000+ files. Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
114 lines
3.2 KiB
C
Generated
114 lines
3.2 KiB
C
Generated
/*[clinic input]
|
|
preserve
|
|
[clinic start generated code]*/
|
|
|
|
#if defined(Ty_BUILD_CORE) && !defined(Ty_BUILD_CORE_MODULE)
|
|
# include "pycore_gc.h" // TyGC_Head
|
|
# include "pycore_runtime.h" // _Ty_ID()
|
|
#endif
|
|
#include "pycore_modsupport.h" // _TyArg_UnpackKeywords()
|
|
|
|
PyDoc_STRVAR(enum_new__doc__,
|
|
"enumerate(iterable, start=0)\n"
|
|
"--\n"
|
|
"\n"
|
|
"Return an enumerate object.\n"
|
|
"\n"
|
|
" iterable\n"
|
|
" an object supporting iteration\n"
|
|
"\n"
|
|
"The enumerate object yields pairs containing a count (from start, which\n"
|
|
"defaults to zero) and a value yielded by the iterable argument.\n"
|
|
"\n"
|
|
"enumerate is useful for obtaining an indexed list:\n"
|
|
" (0, seq[0]), (1, seq[1]), (2, seq[2]), ...");
|
|
|
|
static TyObject *
|
|
enum_new_impl(TyTypeObject *type, TyObject *iterable, TyObject *start);
|
|
|
|
static TyObject *
|
|
enum_new(TyTypeObject *type, TyObject *args, TyObject *kwargs)
|
|
{
|
|
TyObject *return_value = NULL;
|
|
#if defined(Ty_BUILD_CORE) && !defined(Ty_BUILD_CORE_MODULE)
|
|
|
|
#define NUM_KEYWORDS 2
|
|
static struct {
|
|
TyGC_Head _this_is_not_used;
|
|
PyObject_VAR_HEAD
|
|
Ty_hash_t ob_hash;
|
|
TyObject *ob_item[NUM_KEYWORDS];
|
|
} _kwtuple = {
|
|
.ob_base = PyVarObject_HEAD_INIT(&TyTuple_Type, NUM_KEYWORDS)
|
|
.ob_hash = -1,
|
|
.ob_item = { &_Ty_ID(iterable), &_Ty_ID(start), },
|
|
};
|
|
#undef NUM_KEYWORDS
|
|
#define KWTUPLE (&_kwtuple.ob_base.ob_base)
|
|
|
|
#else // !Ty_BUILD_CORE
|
|
# define KWTUPLE NULL
|
|
#endif // !Ty_BUILD_CORE
|
|
|
|
static const char * const _keywords[] = {"iterable", "start", NULL};
|
|
static _TyArg_Parser _parser = {
|
|
.keywords = _keywords,
|
|
.fname = "enumerate",
|
|
.kwtuple = KWTUPLE,
|
|
};
|
|
#undef KWTUPLE
|
|
TyObject *argsbuf[2];
|
|
TyObject * const *fastargs;
|
|
Ty_ssize_t nargs = TyTuple_GET_SIZE(args);
|
|
Ty_ssize_t noptargs = nargs + (kwargs ? TyDict_GET_SIZE(kwargs) : 0) - 1;
|
|
TyObject *iterable;
|
|
TyObject *start = 0;
|
|
|
|
fastargs = _TyArg_UnpackKeywords(_TyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser,
|
|
/*minpos*/ 1, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
|
|
if (!fastargs) {
|
|
goto exit;
|
|
}
|
|
iterable = fastargs[0];
|
|
if (!noptargs) {
|
|
goto skip_optional_pos;
|
|
}
|
|
start = fastargs[1];
|
|
skip_optional_pos:
|
|
return_value = enum_new_impl(type, iterable, start);
|
|
|
|
exit:
|
|
return return_value;
|
|
}
|
|
|
|
PyDoc_STRVAR(reversed_new__doc__,
|
|
"reversed(sequence, /)\n"
|
|
"--\n"
|
|
"\n"
|
|
"Return a reverse iterator over the values of the given sequence.");
|
|
|
|
static TyObject *
|
|
reversed_new_impl(TyTypeObject *type, TyObject *seq);
|
|
|
|
static TyObject *
|
|
reversed_new(TyTypeObject *type, TyObject *args, TyObject *kwargs)
|
|
{
|
|
TyObject *return_value = NULL;
|
|
TyTypeObject *base_tp = &PyReversed_Type;
|
|
TyObject *seq;
|
|
|
|
if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
|
|
!_TyArg_NoKeywords("reversed", kwargs)) {
|
|
goto exit;
|
|
}
|
|
if (!_TyArg_CheckPositional("reversed", TyTuple_GET_SIZE(args), 1, 1)) {
|
|
goto exit;
|
|
}
|
|
seq = TyTuple_GET_ITEM(args, 0);
|
|
return_value = reversed_new_impl(type, seq);
|
|
|
|
exit:
|
|
return return_value;
|
|
}
|
|
/*[clinic end generated code: output=3300305b351674d3 input=a9049054013a1b77]*/
|