123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548 |
- /*[clinic input]
- preserve
- [clinic start generated code]*/
- #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
- # include "pycore_gc.h" // PyGC_Head
- # include "pycore_runtime.h" // _Py_ID()
- #endif
- PyDoc_STRVAR(pyexpat_xmlparser_SetReparseDeferralEnabled__doc__,
- "SetReparseDeferralEnabled($self, enabled, /)\n"
- "--\n"
- "\n"
- "Enable/Disable reparse deferral; enabled by default with Expat >=2.6.0.");
- #define PYEXPAT_XMLPARSER_SETREPARSEDEFERRALENABLED_METHODDEF \
- {"SetReparseDeferralEnabled", (PyCFunction)pyexpat_xmlparser_SetReparseDeferralEnabled, METH_O, pyexpat_xmlparser_SetReparseDeferralEnabled__doc__},
- static PyObject *
- pyexpat_xmlparser_SetReparseDeferralEnabled_impl(xmlparseobject *self,
- int enabled);
- static PyObject *
- pyexpat_xmlparser_SetReparseDeferralEnabled(xmlparseobject *self, PyObject *arg)
- {
- PyObject *return_value = NULL;
- int enabled;
- enabled = PyObject_IsTrue(arg);
- if (enabled < 0) {
- goto exit;
- }
- return_value = pyexpat_xmlparser_SetReparseDeferralEnabled_impl(self, enabled);
- exit:
- return return_value;
- }
- PyDoc_STRVAR(pyexpat_xmlparser_GetReparseDeferralEnabled__doc__,
- "GetReparseDeferralEnabled($self, /)\n"
- "--\n"
- "\n"
- "Retrieve reparse deferral enabled status; always returns false with Expat <2.6.0.");
- #define PYEXPAT_XMLPARSER_GETREPARSEDEFERRALENABLED_METHODDEF \
- {"GetReparseDeferralEnabled", (PyCFunction)pyexpat_xmlparser_GetReparseDeferralEnabled, METH_NOARGS, pyexpat_xmlparser_GetReparseDeferralEnabled__doc__},
- static PyObject *
- pyexpat_xmlparser_GetReparseDeferralEnabled_impl(xmlparseobject *self);
- static PyObject *
- pyexpat_xmlparser_GetReparseDeferralEnabled(xmlparseobject *self, PyObject *Py_UNUSED(ignored))
- {
- return pyexpat_xmlparser_GetReparseDeferralEnabled_impl(self);
- }
- PyDoc_STRVAR(pyexpat_xmlparser_Parse__doc__,
- "Parse($self, data, isfinal=False, /)\n"
- "--\n"
- "\n"
- "Parse XML data.\n"
- "\n"
- "`isfinal\' should be true at end of input.");
- #define PYEXPAT_XMLPARSER_PARSE_METHODDEF \
- {"Parse", _PyCFunction_CAST(pyexpat_xmlparser_Parse), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pyexpat_xmlparser_Parse__doc__},
- static PyObject *
- pyexpat_xmlparser_Parse_impl(xmlparseobject *self, PyTypeObject *cls,
- PyObject *data, int isfinal);
- static PyObject *
- pyexpat_xmlparser_Parse(xmlparseobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
- {
- PyObject *return_value = NULL;
- #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
- # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
- #else
- # define KWTUPLE NULL
- #endif
- static const char * const _keywords[] = {"", "", NULL};
- static _PyArg_Parser _parser = {
- .keywords = _keywords,
- .fname = "Parse",
- .kwtuple = KWTUPLE,
- };
- #undef KWTUPLE
- PyObject *argsbuf[2];
- PyObject *data;
- int isfinal = 0;
- args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
- if (!args) {
- goto exit;
- }
- data = args[0];
- if (nargs < 2) {
- goto skip_optional_posonly;
- }
- isfinal = PyObject_IsTrue(args[1]);
- if (isfinal < 0) {
- goto exit;
- }
- skip_optional_posonly:
- return_value = pyexpat_xmlparser_Parse_impl(self, cls, data, isfinal);
- exit:
- return return_value;
- }
- PyDoc_STRVAR(pyexpat_xmlparser_ParseFile__doc__,
- "ParseFile($self, file, /)\n"
- "--\n"
- "\n"
- "Parse XML data from file-like object.");
- #define PYEXPAT_XMLPARSER_PARSEFILE_METHODDEF \
- {"ParseFile", _PyCFunction_CAST(pyexpat_xmlparser_ParseFile), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pyexpat_xmlparser_ParseFile__doc__},
- static PyObject *
- pyexpat_xmlparser_ParseFile_impl(xmlparseobject *self, PyTypeObject *cls,
- PyObject *file);
- static PyObject *
- pyexpat_xmlparser_ParseFile(xmlparseobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
- {
- PyObject *return_value = NULL;
- #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
- # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
- #else
- # define KWTUPLE NULL
- #endif
- static const char * const _keywords[] = {"", NULL};
- static _PyArg_Parser _parser = {
- .keywords = _keywords,
- .fname = "ParseFile",
- .kwtuple = KWTUPLE,
- };
- #undef KWTUPLE
- PyObject *argsbuf[1];
- PyObject *file;
- args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
- if (!args) {
- goto exit;
- }
- file = args[0];
- return_value = pyexpat_xmlparser_ParseFile_impl(self, cls, file);
- exit:
- return return_value;
- }
- PyDoc_STRVAR(pyexpat_xmlparser_SetBase__doc__,
- "SetBase($self, base, /)\n"
- "--\n"
- "\n"
- "Set the base URL for the parser.");
- #define PYEXPAT_XMLPARSER_SETBASE_METHODDEF \
- {"SetBase", (PyCFunction)pyexpat_xmlparser_SetBase, METH_O, pyexpat_xmlparser_SetBase__doc__},
- static PyObject *
- pyexpat_xmlparser_SetBase_impl(xmlparseobject *self, const char *base);
- static PyObject *
- pyexpat_xmlparser_SetBase(xmlparseobject *self, PyObject *arg)
- {
- PyObject *return_value = NULL;
- const char *base;
- if (!PyUnicode_Check(arg)) {
- _PyArg_BadArgument("SetBase", "argument", "str", arg);
- goto exit;
- }
- Py_ssize_t base_length;
- base = PyUnicode_AsUTF8AndSize(arg, &base_length);
- if (base == NULL) {
- goto exit;
- }
- if (strlen(base) != (size_t)base_length) {
- PyErr_SetString(PyExc_ValueError, "embedded null character");
- goto exit;
- }
- return_value = pyexpat_xmlparser_SetBase_impl(self, base);
- exit:
- return return_value;
- }
- PyDoc_STRVAR(pyexpat_xmlparser_GetBase__doc__,
- "GetBase($self, /)\n"
- "--\n"
- "\n"
- "Return base URL string for the parser.");
- #define PYEXPAT_XMLPARSER_GETBASE_METHODDEF \
- {"GetBase", (PyCFunction)pyexpat_xmlparser_GetBase, METH_NOARGS, pyexpat_xmlparser_GetBase__doc__},
- static PyObject *
- pyexpat_xmlparser_GetBase_impl(xmlparseobject *self);
- static PyObject *
- pyexpat_xmlparser_GetBase(xmlparseobject *self, PyObject *Py_UNUSED(ignored))
- {
- return pyexpat_xmlparser_GetBase_impl(self);
- }
- PyDoc_STRVAR(pyexpat_xmlparser_GetInputContext__doc__,
- "GetInputContext($self, /)\n"
- "--\n"
- "\n"
- "Return the untranslated text of the input that caused the current event.\n"
- "\n"
- "If the event was generated by a large amount of text (such as a start tag\n"
- "for an element with many attributes), not all of the text may be available.");
- #define PYEXPAT_XMLPARSER_GETINPUTCONTEXT_METHODDEF \
- {"GetInputContext", (PyCFunction)pyexpat_xmlparser_GetInputContext, METH_NOARGS, pyexpat_xmlparser_GetInputContext__doc__},
- static PyObject *
- pyexpat_xmlparser_GetInputContext_impl(xmlparseobject *self);
- static PyObject *
- pyexpat_xmlparser_GetInputContext(xmlparseobject *self, PyObject *Py_UNUSED(ignored))
- {
- return pyexpat_xmlparser_GetInputContext_impl(self);
- }
- PyDoc_STRVAR(pyexpat_xmlparser_ExternalEntityParserCreate__doc__,
- "ExternalEntityParserCreate($self, context, encoding=<unrepresentable>,\n"
- " /)\n"
- "--\n"
- "\n"
- "Create a parser for parsing an external entity based on the information passed to the ExternalEntityRefHandler.");
- #define PYEXPAT_XMLPARSER_EXTERNALENTITYPARSERCREATE_METHODDEF \
- {"ExternalEntityParserCreate", _PyCFunction_CAST(pyexpat_xmlparser_ExternalEntityParserCreate), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pyexpat_xmlparser_ExternalEntityParserCreate__doc__},
- static PyObject *
- pyexpat_xmlparser_ExternalEntityParserCreate_impl(xmlparseobject *self,
- PyTypeObject *cls,
- const char *context,
- const char *encoding);
- static PyObject *
- pyexpat_xmlparser_ExternalEntityParserCreate(xmlparseobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
- {
- PyObject *return_value = NULL;
- #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
- # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
- #else
- # define KWTUPLE NULL
- #endif
- static const char * const _keywords[] = {"", "", NULL};
- static _PyArg_Parser _parser = {
- .keywords = _keywords,
- .fname = "ExternalEntityParserCreate",
- .kwtuple = KWTUPLE,
- };
- #undef KWTUPLE
- PyObject *argsbuf[2];
- const char *context;
- const char *encoding = NULL;
- args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
- if (!args) {
- goto exit;
- }
- if (args[0] == Py_None) {
- context = NULL;
- }
- else if (PyUnicode_Check(args[0])) {
- Py_ssize_t context_length;
- context = PyUnicode_AsUTF8AndSize(args[0], &context_length);
- if (context == NULL) {
- goto exit;
- }
- if (strlen(context) != (size_t)context_length) {
- PyErr_SetString(PyExc_ValueError, "embedded null character");
- goto exit;
- }
- }
- else {
- _PyArg_BadArgument("ExternalEntityParserCreate", "argument 1", "str or None", args[0]);
- goto exit;
- }
- if (nargs < 2) {
- goto skip_optional_posonly;
- }
- if (!PyUnicode_Check(args[1])) {
- _PyArg_BadArgument("ExternalEntityParserCreate", "argument 2", "str", args[1]);
- goto exit;
- }
- Py_ssize_t encoding_length;
- encoding = PyUnicode_AsUTF8AndSize(args[1], &encoding_length);
- if (encoding == NULL) {
- goto exit;
- }
- if (strlen(encoding) != (size_t)encoding_length) {
- PyErr_SetString(PyExc_ValueError, "embedded null character");
- goto exit;
- }
- skip_optional_posonly:
- return_value = pyexpat_xmlparser_ExternalEntityParserCreate_impl(self, cls, context, encoding);
- exit:
- return return_value;
- }
- PyDoc_STRVAR(pyexpat_xmlparser_SetParamEntityParsing__doc__,
- "SetParamEntityParsing($self, flag, /)\n"
- "--\n"
- "\n"
- "Controls parsing of parameter entities (including the external DTD subset).\n"
- "\n"
- "Possible flag values are XML_PARAM_ENTITY_PARSING_NEVER,\n"
- "XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE and\n"
- "XML_PARAM_ENTITY_PARSING_ALWAYS. Returns true if setting the flag\n"
- "was successful.");
- #define PYEXPAT_XMLPARSER_SETPARAMENTITYPARSING_METHODDEF \
- {"SetParamEntityParsing", (PyCFunction)pyexpat_xmlparser_SetParamEntityParsing, METH_O, pyexpat_xmlparser_SetParamEntityParsing__doc__},
- static PyObject *
- pyexpat_xmlparser_SetParamEntityParsing_impl(xmlparseobject *self, int flag);
- static PyObject *
- pyexpat_xmlparser_SetParamEntityParsing(xmlparseobject *self, PyObject *arg)
- {
- PyObject *return_value = NULL;
- int flag;
- flag = _PyLong_AsInt(arg);
- if (flag == -1 && PyErr_Occurred()) {
- goto exit;
- }
- return_value = pyexpat_xmlparser_SetParamEntityParsing_impl(self, flag);
- exit:
- return return_value;
- }
- #if (XML_COMBINED_VERSION >= 19505)
- PyDoc_STRVAR(pyexpat_xmlparser_UseForeignDTD__doc__,
- "UseForeignDTD($self, flag=True, /)\n"
- "--\n"
- "\n"
- "Allows the application to provide an artificial external subset if one is not specified as part of the document instance.\n"
- "\n"
- "This readily allows the use of a \'default\' document type controlled by the\n"
- "application, while still getting the advantage of providing document type\n"
- "information to the parser. \'flag\' defaults to True if not provided.");
- #define PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF \
- {"UseForeignDTD", _PyCFunction_CAST(pyexpat_xmlparser_UseForeignDTD), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pyexpat_xmlparser_UseForeignDTD__doc__},
- static PyObject *
- pyexpat_xmlparser_UseForeignDTD_impl(xmlparseobject *self, PyTypeObject *cls,
- int flag);
- static PyObject *
- pyexpat_xmlparser_UseForeignDTD(xmlparseobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
- {
- PyObject *return_value = NULL;
- #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
- # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
- #else
- # define KWTUPLE NULL
- #endif
- static const char * const _keywords[] = {"", NULL};
- static _PyArg_Parser _parser = {
- .keywords = _keywords,
- .fname = "UseForeignDTD",
- .kwtuple = KWTUPLE,
- };
- #undef KWTUPLE
- PyObject *argsbuf[1];
- int flag = 1;
- args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
- if (!args) {
- goto exit;
- }
- if (nargs < 1) {
- goto skip_optional_posonly;
- }
- flag = PyObject_IsTrue(args[0]);
- if (flag < 0) {
- goto exit;
- }
- skip_optional_posonly:
- return_value = pyexpat_xmlparser_UseForeignDTD_impl(self, cls, flag);
- exit:
- return return_value;
- }
- #endif /* (XML_COMBINED_VERSION >= 19505) */
- PyDoc_STRVAR(pyexpat_ParserCreate__doc__,
- "ParserCreate($module, /, encoding=None, namespace_separator=None,\n"
- " intern=<unrepresentable>)\n"
- "--\n"
- "\n"
- "Return a new XML parser object.");
- #define PYEXPAT_PARSERCREATE_METHODDEF \
- {"ParserCreate", _PyCFunction_CAST(pyexpat_ParserCreate), METH_FASTCALL|METH_KEYWORDS, pyexpat_ParserCreate__doc__},
- static PyObject *
- pyexpat_ParserCreate_impl(PyObject *module, const char *encoding,
- const char *namespace_separator, PyObject *intern);
- static PyObject *
- pyexpat_ParserCreate(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
- {
- PyObject *return_value = NULL;
- #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
- #define NUM_KEYWORDS 3
- static struct {
- PyGC_Head _this_is_not_used;
- PyObject_VAR_HEAD
- PyObject *ob_item[NUM_KEYWORDS];
- } _kwtuple = {
- .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
- .ob_item = { &_Py_ID(encoding), &_Py_ID(namespace_separator), &_Py_ID(intern), },
- };
- #undef NUM_KEYWORDS
- #define KWTUPLE (&_kwtuple.ob_base.ob_base)
- #else // !Py_BUILD_CORE
- # define KWTUPLE NULL
- #endif // !Py_BUILD_CORE
- static const char * const _keywords[] = {"encoding", "namespace_separator", "intern", NULL};
- static _PyArg_Parser _parser = {
- .keywords = _keywords,
- .fname = "ParserCreate",
- .kwtuple = KWTUPLE,
- };
- #undef KWTUPLE
- PyObject *argsbuf[3];
- Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
- const char *encoding = NULL;
- const char *namespace_separator = NULL;
- PyObject *intern = NULL;
- args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 3, 0, argsbuf);
- if (!args) {
- goto exit;
- }
- if (!noptargs) {
- goto skip_optional_pos;
- }
- if (args[0]) {
- if (args[0] == Py_None) {
- encoding = NULL;
- }
- else if (PyUnicode_Check(args[0])) {
- Py_ssize_t encoding_length;
- encoding = PyUnicode_AsUTF8AndSize(args[0], &encoding_length);
- if (encoding == NULL) {
- goto exit;
- }
- if (strlen(encoding) != (size_t)encoding_length) {
- PyErr_SetString(PyExc_ValueError, "embedded null character");
- goto exit;
- }
- }
- else {
- _PyArg_BadArgument("ParserCreate", "argument 'encoding'", "str or None", args[0]);
- goto exit;
- }
- if (!--noptargs) {
- goto skip_optional_pos;
- }
- }
- if (args[1]) {
- if (args[1] == Py_None) {
- namespace_separator = NULL;
- }
- else if (PyUnicode_Check(args[1])) {
- Py_ssize_t namespace_separator_length;
- namespace_separator = PyUnicode_AsUTF8AndSize(args[1], &namespace_separator_length);
- if (namespace_separator == NULL) {
- goto exit;
- }
- if (strlen(namespace_separator) != (size_t)namespace_separator_length) {
- PyErr_SetString(PyExc_ValueError, "embedded null character");
- goto exit;
- }
- }
- else {
- _PyArg_BadArgument("ParserCreate", "argument 'namespace_separator'", "str or None", args[1]);
- goto exit;
- }
- if (!--noptargs) {
- goto skip_optional_pos;
- }
- }
- intern = args[2];
- skip_optional_pos:
- return_value = pyexpat_ParserCreate_impl(module, encoding, namespace_separator, intern);
- exit:
- return return_value;
- }
- PyDoc_STRVAR(pyexpat_ErrorString__doc__,
- "ErrorString($module, code, /)\n"
- "--\n"
- "\n"
- "Returns string error for given number.");
- #define PYEXPAT_ERRORSTRING_METHODDEF \
- {"ErrorString", (PyCFunction)pyexpat_ErrorString, METH_O, pyexpat_ErrorString__doc__},
- static PyObject *
- pyexpat_ErrorString_impl(PyObject *module, long code);
- static PyObject *
- pyexpat_ErrorString(PyObject *module, PyObject *arg)
- {
- PyObject *return_value = NULL;
- long code;
- code = PyLong_AsLong(arg);
- if (code == -1 && PyErr_Occurred()) {
- goto exit;
- }
- return_value = pyexpat_ErrorString_impl(module, code);
- exit:
- return return_value;
- }
- #ifndef PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF
- #define PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF
- #endif /* !defined(PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF) */
- /*[clinic end generated code: output=8625852bb44a5e56 input=a9049054013a1b77]*/
|