/src/cpython/Modules/clinic/symtablemodule.c.h
Line | Count | Source |
1 | | /*[clinic input] |
2 | | preserve |
3 | | [clinic start generated code]*/ |
4 | | |
5 | | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
6 | | # include "pycore_gc.h" // PyGC_Head |
7 | | # include "pycore_runtime.h" // _Py_ID() |
8 | | #endif |
9 | | #include "pycore_modsupport.h" // _PyArg_UnpackKeywords() |
10 | | #include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() |
11 | | |
12 | | PyDoc_STRVAR(_symtable_symtable__doc__, |
13 | | "symtable($module, source, filename, startstr, /, *, module=None)\n" |
14 | | "--\n" |
15 | | "\n" |
16 | | "Return symbol and scope dictionaries used internally by compiler.\n" |
17 | | "\n" |
18 | | "The source can be a string, a bytes object, or an AST object."); |
19 | | |
20 | | #define _SYMTABLE_SYMTABLE_METHODDEF \ |
21 | | {"symtable", _PyCFunction_CAST(_symtable_symtable), METH_FASTCALL|METH_KEYWORDS, _symtable_symtable__doc__}, |
22 | | |
23 | | static PyObject * |
24 | | _symtable_symtable_impl(PyObject *module, PyObject *source, |
25 | | PyObject *filename, const char *startstr, |
26 | | PyObject *modname); |
27 | | |
28 | | static PyObject * |
29 | | _symtable_symtable(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
30 | 0 | { |
31 | 0 | PyObject *return_value = NULL; |
32 | 0 | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
33 | |
|
34 | 0 | #define NUM_KEYWORDS 1 |
35 | 0 | static struct { |
36 | 0 | PyGC_Head _this_is_not_used; |
37 | 0 | PyObject_VAR_HEAD |
38 | 0 | Py_hash_t ob_hash; |
39 | 0 | PyObject *ob_item[NUM_KEYWORDS]; |
40 | 0 | } _kwtuple = { |
41 | 0 | .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
42 | 0 | .ob_hash = -1, |
43 | 0 | .ob_item = { &_Py_ID(module), }, |
44 | 0 | }; |
45 | 0 | #undef NUM_KEYWORDS |
46 | 0 | #define KWTUPLE (&_kwtuple.ob_base.ob_base) |
47 | |
|
48 | | #else // !Py_BUILD_CORE |
49 | | # define KWTUPLE NULL |
50 | | #endif // !Py_BUILD_CORE |
51 | |
|
52 | 0 | static const char * const _keywords[] = {"", "", "", "module", NULL}; |
53 | 0 | static _PyArg_Parser _parser = { |
54 | 0 | .keywords = _keywords, |
55 | 0 | .fname = "symtable", |
56 | 0 | .kwtuple = KWTUPLE, |
57 | 0 | }; |
58 | 0 | #undef KWTUPLE |
59 | 0 | PyObject *argsbuf[4]; |
60 | 0 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 3; |
61 | 0 | PyObject *source; |
62 | 0 | PyObject *filename = NULL; |
63 | 0 | const char *startstr; |
64 | 0 | PyObject *modname = Py_None; |
65 | |
|
66 | 0 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
67 | 0 | /*minpos*/ 3, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
68 | 0 | if (!args) { |
69 | 0 | goto exit; |
70 | 0 | } |
71 | 0 | source = args[0]; |
72 | 0 | if (!PyUnicode_FSDecoder(args[1], &filename)) { |
73 | 0 | goto exit; |
74 | 0 | } |
75 | 0 | if (!PyUnicode_Check(args[2])) { |
76 | 0 | _PyArg_BadArgument("symtable", "argument 3", "str", args[2]); |
77 | 0 | goto exit; |
78 | 0 | } |
79 | 0 | startstr = _PyUnicode_AsUTF8NoNUL(args[2]); |
80 | 0 | if (startstr == NULL) { |
81 | 0 | goto exit; |
82 | 0 | } |
83 | 0 | if (!noptargs) { |
84 | 0 | goto skip_optional_kwonly; |
85 | 0 | } |
86 | 0 | modname = args[3]; |
87 | 0 | skip_optional_kwonly: |
88 | 0 | return_value = _symtable_symtable_impl(module, source, filename, startstr, modname); |
89 | |
|
90 | 0 | exit: |
91 | | /* Cleanup for filename */ |
92 | 0 | Py_XDECREF(filename); |
93 | |
|
94 | 0 | return return_value; |
95 | 0 | } |
96 | | /*[clinic end generated code: output=910e4f6ce98ae0a1 input=a9049054013a1b77]*/ |