(root)/
Python-3.12.0/
Modules/
_sqlite/
clinic/
module.c.h
       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  
      10  
      11  PyDoc_STRVAR(pysqlite_complete_statement__doc__,
      12  "complete_statement($module, /, statement)\n"
      13  "--\n"
      14  "\n"
      15  "Checks if a string contains a complete SQL statement.");
      16  
      17  #define PYSQLITE_COMPLETE_STATEMENT_METHODDEF    \
      18      {"complete_statement", _PyCFunction_CAST(pysqlite_complete_statement), METH_FASTCALL|METH_KEYWORDS, pysqlite_complete_statement__doc__},
      19  
      20  static PyObject *
      21  pysqlite_complete_statement_impl(PyObject *module, const char *statement);
      22  
      23  static PyObject *
      24  pysqlite_complete_statement(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
      25  {
      26      PyObject *return_value = NULL;
      27      #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
      28  
      29      #define NUM_KEYWORDS 1
      30      static struct {
      31          PyGC_Head _this_is_not_used;
      32          PyObject_VAR_HEAD
      33          PyObject *ob_item[NUM_KEYWORDS];
      34      } _kwtuple = {
      35          .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
      36          .ob_item = { &_Py_ID(statement), },
      37      };
      38      #undef NUM_KEYWORDS
      39      #define KWTUPLE (&_kwtuple.ob_base.ob_base)
      40  
      41      #else  // !Py_BUILD_CORE
      42      #  define KWTUPLE NULL
      43      #endif  // !Py_BUILD_CORE
      44  
      45      static const char * const _keywords[] = {"statement", NULL};
      46      static _PyArg_Parser _parser = {
      47          .keywords = _keywords,
      48          .fname = "complete_statement",
      49          .kwtuple = KWTUPLE,
      50      };
      51      #undef KWTUPLE
      52      PyObject *argsbuf[1];
      53      const char *statement;
      54  
      55      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
      56      if (!args) {
      57          goto exit;
      58      }
      59      if (!PyUnicode_Check(args[0])) {
      60          _PyArg_BadArgument("complete_statement", "argument 'statement'", "str", args[0]);
      61          goto exit;
      62      }
      63      Py_ssize_t statement_length;
      64      statement = PyUnicode_AsUTF8AndSize(args[0], &statement_length);
      65      if (statement == NULL) {
      66          goto exit;
      67      }
      68      if (strlen(statement) != (size_t)statement_length) {
      69          PyErr_SetString(PyExc_ValueError, "embedded null character");
      70          goto exit;
      71      }
      72      return_value = pysqlite_complete_statement_impl(module, statement);
      73  
      74  exit:
      75      return return_value;
      76  }
      77  
      78  PyDoc_STRVAR(pysqlite_register_adapter__doc__,
      79  "register_adapter($module, type, adapter, /)\n"
      80  "--\n"
      81  "\n"
      82  "Register a function to adapt Python objects to SQLite values.");
      83  
      84  #define PYSQLITE_REGISTER_ADAPTER_METHODDEF    \
      85      {"register_adapter", _PyCFunction_CAST(pysqlite_register_adapter), METH_FASTCALL, pysqlite_register_adapter__doc__},
      86  
      87  static PyObject *
      88  pysqlite_register_adapter_impl(PyObject *module, PyTypeObject *type,
      89                                 PyObject *caster);
      90  
      91  static PyObject *
      92  pysqlite_register_adapter(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
      93  {
      94      PyObject *return_value = NULL;
      95      PyTypeObject *type;
      96      PyObject *caster;
      97  
      98      if (!_PyArg_CheckPositional("register_adapter", nargs, 2, 2)) {
      99          goto exit;
     100      }
     101      type = (PyTypeObject *)args[0];
     102      caster = args[1];
     103      return_value = pysqlite_register_adapter_impl(module, type, caster);
     104  
     105  exit:
     106      return return_value;
     107  }
     108  
     109  PyDoc_STRVAR(pysqlite_register_converter__doc__,
     110  "register_converter($module, typename, converter, /)\n"
     111  "--\n"
     112  "\n"
     113  "Register a function to convert SQLite values to Python objects.");
     114  
     115  #define PYSQLITE_REGISTER_CONVERTER_METHODDEF    \
     116      {"register_converter", _PyCFunction_CAST(pysqlite_register_converter), METH_FASTCALL, pysqlite_register_converter__doc__},
     117  
     118  static PyObject *
     119  pysqlite_register_converter_impl(PyObject *module, PyObject *orig_name,
     120                                   PyObject *callable);
     121  
     122  static PyObject *
     123  pysqlite_register_converter(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
     124  {
     125      PyObject *return_value = NULL;
     126      PyObject *orig_name;
     127      PyObject *callable;
     128  
     129      if (!_PyArg_CheckPositional("register_converter", nargs, 2, 2)) {
     130          goto exit;
     131      }
     132      if (!PyUnicode_Check(args[0])) {
     133          _PyArg_BadArgument("register_converter", "argument 1", "str", args[0]);
     134          goto exit;
     135      }
     136      if (PyUnicode_READY(args[0]) == -1) {
     137          goto exit;
     138      }
     139      orig_name = args[0];
     140      callable = args[1];
     141      return_value = pysqlite_register_converter_impl(module, orig_name, callable);
     142  
     143  exit:
     144      return return_value;
     145  }
     146  
     147  PyDoc_STRVAR(pysqlite_enable_callback_trace__doc__,
     148  "enable_callback_tracebacks($module, enable, /)\n"
     149  "--\n"
     150  "\n"
     151  "Enable or disable callback functions throwing errors to stderr.");
     152  
     153  #define PYSQLITE_ENABLE_CALLBACK_TRACE_METHODDEF    \
     154      {"enable_callback_tracebacks", (PyCFunction)pysqlite_enable_callback_trace, METH_O, pysqlite_enable_callback_trace__doc__},
     155  
     156  static PyObject *
     157  pysqlite_enable_callback_trace_impl(PyObject *module, int enable);
     158  
     159  static PyObject *
     160  pysqlite_enable_callback_trace(PyObject *module, PyObject *arg)
     161  {
     162      PyObject *return_value = NULL;
     163      int enable;
     164  
     165      enable = _PyLong_AsInt(arg);
     166      if (enable == -1 && PyErr_Occurred()) {
     167          goto exit;
     168      }
     169      return_value = pysqlite_enable_callback_trace_impl(module, enable);
     170  
     171  exit:
     172      return return_value;
     173  }
     174  
     175  PyDoc_STRVAR(pysqlite_adapt__doc__,
     176  "adapt($module, obj, proto=PrepareProtocolType, alt=<unrepresentable>, /)\n"
     177  "--\n"
     178  "\n"
     179  "Adapt given object to given protocol.");
     180  
     181  #define PYSQLITE_ADAPT_METHODDEF    \
     182      {"adapt", _PyCFunction_CAST(pysqlite_adapt), METH_FASTCALL, pysqlite_adapt__doc__},
     183  
     184  static PyObject *
     185  pysqlite_adapt_impl(PyObject *module, PyObject *obj, PyObject *proto,
     186                      PyObject *alt);
     187  
     188  static PyObject *
     189  pysqlite_adapt(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
     190  {
     191      PyObject *return_value = NULL;
     192      PyObject *obj;
     193      PyObject *proto = (PyObject *)clinic_state()->PrepareProtocolType;
     194      PyObject *alt = NULL;
     195  
     196      if (!_PyArg_CheckPositional("adapt", nargs, 1, 3)) {
     197          goto exit;
     198      }
     199      obj = args[0];
     200      if (nargs < 2) {
     201          goto skip_optional;
     202      }
     203      proto = args[1];
     204      if (nargs < 3) {
     205          goto skip_optional;
     206      }
     207      alt = args[2];
     208  skip_optional:
     209      return_value = pysqlite_adapt_impl(module, obj, proto, alt);
     210  
     211  exit:
     212      return return_value;
     213  }
     214  /*[clinic end generated code: output=39d38c6cfc455042 input=a9049054013a1b77]*/