LCOV - code coverage report
Current view: top level - Modules/_sqlite/clinic - module.c.h (source / functions) Hit Total Coverage
Test: CPython 3.12 LCOV report [commit 5e6661bce9] Lines: 0 65 0.0 %
Date: 2023-03-20 08:15:36 Functions: 0 5 0.0 %
Branches: 0 46 0.0 %

           Branch data     Line data    Source code
       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                 :          0 : pysqlite_complete_statement(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
      25                 :            : {
      26                 :          0 :     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   [ #  #  #  #  :          0 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
             #  #  #  # ]
      56         [ #  # ]:          0 :     if (!args) {
      57                 :          0 :         goto exit;
      58                 :            :     }
      59         [ #  # ]:          0 :     if (!PyUnicode_Check(args[0])) {
      60                 :          0 :         _PyArg_BadArgument("complete_statement", "argument 'statement'", "str", args[0]);
      61                 :          0 :         goto exit;
      62                 :            :     }
      63                 :            :     Py_ssize_t statement_length;
      64                 :          0 :     statement = PyUnicode_AsUTF8AndSize(args[0], &statement_length);
      65         [ #  # ]:          0 :     if (statement == NULL) {
      66                 :          0 :         goto exit;
      67                 :            :     }
      68         [ #  # ]:          0 :     if (strlen(statement) != (size_t)statement_length) {
      69                 :          0 :         PyErr_SetString(PyExc_ValueError, "embedded null character");
      70                 :          0 :         goto exit;
      71                 :            :     }
      72                 :          0 :     return_value = pysqlite_complete_statement_impl(module, statement);
      73                 :            : 
      74                 :          0 : exit:
      75                 :          0 :     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                 :          0 : pysqlite_register_adapter(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
      93                 :            : {
      94                 :          0 :     PyObject *return_value = NULL;
      95                 :            :     PyTypeObject *type;
      96                 :            :     PyObject *caster;
      97                 :            : 
      98   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("register_adapter", nargs, 2, 2)) {
                   #  # ]
      99                 :          0 :         goto exit;
     100                 :            :     }
     101                 :          0 :     type = (PyTypeObject *)args[0];
     102                 :          0 :     caster = args[1];
     103                 :          0 :     return_value = pysqlite_register_adapter_impl(module, type, caster);
     104                 :            : 
     105                 :          0 : exit:
     106                 :          0 :     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                 :          0 : pysqlite_register_converter(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
     124                 :            : {
     125                 :          0 :     PyObject *return_value = NULL;
     126                 :            :     PyObject *orig_name;
     127                 :            :     PyObject *callable;
     128                 :            : 
     129   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("register_converter", nargs, 2, 2)) {
                   #  # ]
     130                 :          0 :         goto exit;
     131                 :            :     }
     132         [ #  # ]:          0 :     if (!PyUnicode_Check(args[0])) {
     133                 :          0 :         _PyArg_BadArgument("register_converter", "argument 1", "str", args[0]);
     134                 :          0 :         goto exit;
     135                 :            :     }
     136         [ #  # ]:          0 :     if (PyUnicode_READY(args[0]) == -1) {
     137                 :          0 :         goto exit;
     138                 :            :     }
     139                 :          0 :     orig_name = args[0];
     140                 :          0 :     callable = args[1];
     141                 :          0 :     return_value = pysqlite_register_converter_impl(module, orig_name, callable);
     142                 :            : 
     143                 :          0 : exit:
     144                 :          0 :     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                 :          0 : pysqlite_enable_callback_trace(PyObject *module, PyObject *arg)
     161                 :            : {
     162                 :          0 :     PyObject *return_value = NULL;
     163                 :            :     int enable;
     164                 :            : 
     165                 :          0 :     enable = _PyLong_AsInt(arg);
     166   [ #  #  #  # ]:          0 :     if (enable == -1 && PyErr_Occurred()) {
     167                 :          0 :         goto exit;
     168                 :            :     }
     169                 :          0 :     return_value = pysqlite_enable_callback_trace_impl(module, enable);
     170                 :            : 
     171                 :          0 : exit:
     172                 :          0 :     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                 :          0 : pysqlite_adapt(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
     190                 :            : {
     191                 :          0 :     PyObject *return_value = NULL;
     192                 :            :     PyObject *obj;
     193                 :          0 :     PyObject *proto = (PyObject *)clinic_state()->PrepareProtocolType;
     194                 :          0 :     PyObject *alt = NULL;
     195                 :            : 
     196   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("adapt", nargs, 1, 3)) {
                   #  # ]
     197                 :          0 :         goto exit;
     198                 :            :     }
     199                 :          0 :     obj = args[0];
     200         [ #  # ]:          0 :     if (nargs < 2) {
     201                 :          0 :         goto skip_optional;
     202                 :            :     }
     203                 :          0 :     proto = args[1];
     204         [ #  # ]:          0 :     if (nargs < 3) {
     205                 :          0 :         goto skip_optional;
     206                 :            :     }
     207                 :          0 :     alt = args[2];
     208                 :          0 : skip_optional:
     209                 :          0 :     return_value = pysqlite_adapt_impl(module, obj, proto, alt);
     210                 :            : 
     211                 :          0 : exit:
     212                 :          0 :     return return_value;
     213                 :            : }
     214                 :            : /*[clinic end generated code: output=39d38c6cfc455042 input=a9049054013a1b77]*/

Generated by: LCOV version 1.14