#include "clinic/blob.c.h"
#undef clinic_state
+#define _pysqlite_Blob_CAST(op) ((pysqlite_Blob *)(op))
+
/*[clinic input]
module _sqlite3
class _sqlite3.Blob "pysqlite_Blob *" "clinic_state()->BlobType"
}
static int
-blob_traverse(pysqlite_Blob *self, visitproc visit, void *arg)
+blob_traverse(PyObject *op, visitproc visit, void *arg)
{
+ pysqlite_Blob *self = _pysqlite_Blob_CAST(op);
Py_VISIT(Py_TYPE(self));
Py_VISIT(self->connection);
return 0;
}
static int
-blob_clear(pysqlite_Blob *self)
+blob_clear(PyObject *op)
{
+ pysqlite_Blob *self = _pysqlite_Blob_CAST(op);
Py_CLEAR(self->connection);
return 0;
}
static void
-blob_dealloc(pysqlite_Blob *self)
+blob_dealloc(PyObject *op)
{
+ pysqlite_Blob *self = _pysqlite_Blob_CAST(op);
PyTypeObject *tp = Py_TYPE(self);
PyObject_GC_UnTrack(self);
close_blob(self);
if (self->in_weakreflist != NULL) {
- PyObject_ClearWeakRefs((PyObject*)self);
+ PyObject_ClearWeakRefs(op);
}
- tp->tp_clear((PyObject *)self);
+ (void)tp->tp_clear(op);
tp->tp_free(self);
Py_DECREF(tp);
}
}
static Py_ssize_t
-blob_length(pysqlite_Blob *self)
+blob_length(PyObject *op)
{
+ pysqlite_Blob *self = _pysqlite_Blob_CAST(op);
if (!check_blob(self)) {
return -1;
}
}
static PyObject *
-blob_subscript(pysqlite_Blob *self, PyObject *item)
+blob_subscript(PyObject *op, PyObject *item)
{
+ pysqlite_Blob *self = _pysqlite_Blob_CAST(op);
if (!check_blob(self)) {
return NULL;
}
}
static int
-blob_ass_subscript(pysqlite_Blob *self, PyObject *item, PyObject *value)
+blob_ass_subscript(PyObject *op, PyObject *item, PyObject *value)
{
+ pysqlite_Blob *self = _pysqlite_Blob_CAST(op);
if (!check_blob(self)) {
return -1;
}
#include "clinic/connection.c.h"
#undef clinic_state
+#define _pysqlite_Connection_CAST(op) ((pysqlite_Connection *)(op))
+
/*[clinic input]
module _sqlite3
class _sqlite3.Connection "pysqlite_Connection *" "clinic_state()->ConnectionType"
} while (0)
static int
-connection_traverse(pysqlite_Connection *self, visitproc visit, void *arg)
+connection_traverse(PyObject *op, visitproc visit, void *arg)
{
+ pysqlite_Connection *self = _pysqlite_Connection_CAST(op);
Py_VISIT(Py_TYPE(self));
Py_VISIT(self->statement_cache);
Py_VISIT(self->cursors);
}
static int
-connection_clear(pysqlite_Connection *self)
+connection_clear(PyObject *op)
{
+ pysqlite_Connection *self = _pysqlite_Connection_CAST(op);
Py_CLEAR(self->statement_cache);
Py_CLEAR(self->cursors);
Py_CLEAR(self->blobs);
}
PyTypeObject *tp = Py_TYPE(self);
PyObject_GC_UnTrack(self);
- tp->tp_clear(self);
+ (void)tp->tp_clear(self);
tp->tp_free(self);
Py_DECREF(tp);
}
return 1;
}
-static PyObject* pysqlite_connection_get_isolation_level(pysqlite_Connection* self, void* unused)
+static PyObject *
+pysqlite_connection_get_isolation_level(PyObject *op, void *Py_UNUSED(closure))
{
+ pysqlite_Connection *self = _pysqlite_Connection_CAST(op);
if (!pysqlite_check_connection(self)) {
return NULL;
}
Py_RETURN_NONE;
}
-static PyObject* pysqlite_connection_get_total_changes(pysqlite_Connection* self, void* unused)
+static PyObject *
+pysqlite_connection_get_total_changes(PyObject *op, void *Py_UNUSED(closure))
{
+ pysqlite_Connection *self = _pysqlite_Connection_CAST(op);
if (!pysqlite_check_connection(self)) {
return NULL;
}
return PyLong_FromLong(sqlite3_total_changes(self->db));
}
-static PyObject* pysqlite_connection_get_in_transaction(pysqlite_Connection* self, void* unused)
+static PyObject *
+pysqlite_connection_get_in_transaction(PyObject *op, void *Py_UNUSED(closure))
{
+ pysqlite_Connection *self = _pysqlite_Connection_CAST(op);
if (!pysqlite_check_connection(self)) {
return NULL;
}
}
static int
-pysqlite_connection_set_isolation_level(pysqlite_Connection* self, PyObject* isolation_level, void *Py_UNUSED(ignored))
+pysqlite_connection_set_isolation_level(PyObject *op,
+ PyObject *isolation_level,
+ void *Py_UNUSED(ignored))
{
+ pysqlite_Connection *self = _pysqlite_Connection_CAST(op);
if (isolation_level == NULL) {
PyErr_SetString(PyExc_AttributeError, "cannot delete attribute");
return -1;
}
static PyObject *
-pysqlite_connection_call(pysqlite_Connection *self, PyObject *args,
- PyObject *kwargs)
+pysqlite_connection_call(PyObject *op, PyObject *args, PyObject *kwargs)
{
PyObject* sql;
pysqlite_Statement* statement;
+ pysqlite_Connection *self = _pysqlite_Connection_CAST(op);
if (!pysqlite_check_thread(self) || !pysqlite_check_connection(self)) {
return NULL;
}
static PyObject *
-get_autocommit(pysqlite_Connection *self, void *Py_UNUSED(ctx))
+get_autocommit(PyObject *op, void *Py_UNUSED(closure))
{
+ pysqlite_Connection *self = _pysqlite_Connection_CAST(op);
if (!pysqlite_check_thread(self) || !pysqlite_check_connection(self)) {
return NULL;
}
}
static int
-set_autocommit(pysqlite_Connection *self, PyObject *val, void *Py_UNUSED(ctx))
+set_autocommit(PyObject *op, PyObject *val, void *Py_UNUSED(closure))
{
+ pysqlite_Connection *self = _pysqlite_Connection_CAST(op);
if (!pysqlite_check_thread(self) || !pysqlite_check_connection(self)) {
return -1;
}
}
static PyObject *
-get_sig(PyObject *self, void *Py_UNUSED(ctx))
+get_sig(PyObject *Py_UNUSED(self), void *Py_UNUSED(closure))
{
return PyUnicode_FromString("(sql, /)");
}
PyDoc_STR("SQLite database connection object.");
static PyGetSetDef connection_getset[] = {
- {"isolation_level", (getter)pysqlite_connection_get_isolation_level, (setter)pysqlite_connection_set_isolation_level},
- {"total_changes", (getter)pysqlite_connection_get_total_changes, (setter)0},
- {"in_transaction", (getter)pysqlite_connection_get_in_transaction, (setter)0},
- {"autocommit", (getter)get_autocommit, (setter)set_autocommit},
- {"__text_signature__", get_sig, (setter)0},
+ {"isolation_level", pysqlite_connection_get_isolation_level,
+ pysqlite_connection_set_isolation_level},
+ {"total_changes", pysqlite_connection_get_total_changes, NULL},
+ {"in_transaction", pysqlite_connection_get_in_transaction, NULL},
+ {"autocommit", get_autocommit, set_autocommit},
+ {"__text_signature__", get_sig, NULL},
{NULL}
};
#include "clinic/cursor.c.h"
#undef clinic_state
+#define _pysqlite_Cursor_CAST(op) ((pysqlite_Cursor *)(op))
+
static inline int
check_cursor_locked(pysqlite_Cursor *cur)
{
}
static int
-cursor_traverse(pysqlite_Cursor *self, visitproc visit, void *arg)
+cursor_traverse(PyObject *op, visitproc visit, void *arg)
{
+ pysqlite_Cursor *self = _pysqlite_Cursor_CAST(op);
Py_VISIT(Py_TYPE(self));
Py_VISIT(self->connection);
Py_VISIT(self->description);
}
static int
-cursor_clear(pysqlite_Cursor *self)
+cursor_clear(PyObject *op)
{
+ pysqlite_Cursor *self = _pysqlite_Cursor_CAST(op);
Py_CLEAR(self->connection);
Py_CLEAR(self->description);
Py_CLEAR(self->row_cast_map);
}
static void
-cursor_dealloc(pysqlite_Cursor *self)
+cursor_dealloc(PyObject *op)
{
+ pysqlite_Cursor *self = _pysqlite_Cursor_CAST(op);
PyTypeObject *tp = Py_TYPE(self);
PyObject_GC_UnTrack(self);
if (self->in_weakreflist != NULL) {
- PyObject_ClearWeakRefs((PyObject*)self);
+ PyObject_ClearWeakRefs(op);
}
- tp->tp_clear((PyObject *)self);
+ (void)tp->tp_clear(op);
tp->tp_free(self);
Py_DECREF(tp);
}
}
static PyObject *
-pysqlite_cursor_iternext(pysqlite_Cursor *self)
+pysqlite_cursor_iternext(PyObject *op)
{
+ pysqlite_Cursor *self = _pysqlite_Cursor_CAST(op);
if (!check_cursor(self)) {
return NULL;
}
}
if (!Py_IsNone(self->row_factory)) {
PyObject *factory = self->row_factory;
- PyObject *args[] = { (PyObject *)self, row, };
+ PyObject *args[] = { op, row, };
PyObject *new_row = PyObject_Vectorcall(factory, args, 2, NULL);
Py_SETREF(row, new_row);
}
{
PyObject* row;
- row = pysqlite_cursor_iternext(self);
+ row = pysqlite_cursor_iternext((PyObject *)self);
if (!row && !PyErr_Occurred()) {
Py_RETURN_NONE;
}
return NULL;
}
- while ((row = pysqlite_cursor_iternext(self))) {
+ while ((row = pysqlite_cursor_iternext((PyObject *)self))) {
if (PyList_Append(list, row) < 0) {
Py_DECREF(row);
break;
return NULL;
}
- while ((row = pysqlite_cursor_iternext(self))) {
+ while ((row = pysqlite_cursor_iternext((PyObject *)self))) {
if (PyList_Append(list, row) < 0) {
Py_DECREF(row);
break;
static void
module_free(void *module)
{
- module_clear((PyObject *)module);
+ (void)module_clear((PyObject *)module);
}
#define ADD_TYPE(module, type) \
#include "prepare_protocol.h"
static int
-pysqlite_prepare_protocol_init(pysqlite_PrepareProtocol *self, PyObject *args,
- PyObject *kwargs)
+pysqlite_prepare_protocol_init(PyObject *self, PyObject *args, PyObject *kwargs)
{
return 0;
}
}
static void
-pysqlite_prepare_protocol_dealloc(pysqlite_PrepareProtocol *self)
+pysqlite_prepare_protocol_dealloc(PyObject *self)
{
PyTypeObject *tp = Py_TYPE(self);
PyObject_GC_UnTrack(self);
#include "clinic/row.c.h"
#undef clinic_state
+#define _pysqlite_Row_CAST(op) ((pysqlite_Row *)(op))
+
/*[clinic input]
module _sqlite3
class _sqlite3.Row "pysqlite_Row *" "clinic_state()->RowType"
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=966c53403d7f3a40]*/
static int
-row_clear(pysqlite_Row *self)
+row_clear(PyObject *op)
{
+ pysqlite_Row *self = _pysqlite_Row_CAST(op);
Py_CLEAR(self->data);
Py_CLEAR(self->description);
return 0;
}
static int
-row_traverse(pysqlite_Row *self, visitproc visit, void *arg)
+row_traverse(PyObject *op, visitproc visit, void *arg)
{
+ pysqlite_Row *self = _pysqlite_Row_CAST(op);
Py_VISIT(Py_TYPE(self));
Py_VISIT(self->data);
Py_VISIT(self->description);
{
PyTypeObject *tp = Py_TYPE(self);
PyObject_GC_UnTrack(self);
- tp->tp_clear(self);
+ (void)tp->tp_clear(self);
tp->tp_free(self);
Py_DECREF(tp);
}
return (PyObject *) self;
}
-PyObject* pysqlite_row_item(pysqlite_Row* self, Py_ssize_t idx)
+static PyObject *
+pysqlite_row_item(PyObject *op, Py_ssize_t idx)
{
- PyObject *item = PyTuple_GetItem(self->data, idx);
- return Py_XNewRef(item);
+ pysqlite_Row *self = _pysqlite_Row_CAST(op);
+ PyObject *item = PyTuple_GetItem(self->data, idx);
+ return Py_XNewRef(item);
}
static int
}
static PyObject *
-pysqlite_row_subscript(pysqlite_Row *self, PyObject *idx)
+pysqlite_row_subscript(PyObject *op, PyObject *idx)
{
Py_ssize_t _idx;
Py_ssize_t nitems, i;
+ pysqlite_Row *self = _pysqlite_Row_CAST(op);
if (PyLong_Check(idx)) {
_idx = PyNumber_AsSsize_t(idx, PyExc_IndexError);
}
static Py_ssize_t
-pysqlite_row_length(pysqlite_Row* self)
+pysqlite_row_length(PyObject *op)
{
+ pysqlite_Row *self = _pysqlite_Row_CAST(op);
return PyTuple_GET_SIZE(self->data);
}
return list;
}
-static PyObject* pysqlite_iter(pysqlite_Row* self)
+static PyObject *
+pysqlite_iter(PyObject *op)
{
+ pysqlite_Row *self = _pysqlite_Row_CAST(op);
return PyObject_GetIter(self->data);
}
-static Py_hash_t pysqlite_row_hash(pysqlite_Row *self)
+static Py_hash_t
+pysqlite_row_hash(PyObject *op)
{
+ pysqlite_Row *self = _pysqlite_Row_CAST(op);
return PyObject_Hash(self->description) ^ PyObject_Hash(self->data);
}
-static PyObject* pysqlite_row_richcompare(pysqlite_Row *self, PyObject *_other, int opid)
+static PyObject *
+pysqlite_row_richcompare(PyObject *op, PyObject *opother, int opid)
{
if (opid != Py_EQ && opid != Py_NE)
Py_RETURN_NOTIMPLEMENTED;
+ pysqlite_Row *self = _pysqlite_Row_CAST(op);
pysqlite_state *state = pysqlite_get_state_by_type(Py_TYPE(self));
- if (PyObject_TypeCheck(_other, state->RowType)) {
- pysqlite_Row *other = (pysqlite_Row *)_other;
+ if (PyObject_TypeCheck(opother, state->RowType)) {
+ pysqlite_Row *other = (pysqlite_Row *)opother;
int eq = PyObject_RichCompareBool(self->description, other->description, Py_EQ);
if (eq < 0) {
return NULL;
#include "statement.h"
#include "util.h"
+#define _pysqlite_Statement_CAST(op) ((pysqlite_Statement *)(op))
+
/* prototypes */
static const char *lstrip_sql(const char *sql);
}
static void
-stmt_dealloc(pysqlite_Statement *self)
+stmt_dealloc(PyObject *op)
{
+ pysqlite_Statement *self = _pysqlite_Statement_CAST(op);
PyTypeObject *tp = Py_TYPE(self);
- PyObject_GC_UnTrack(self);
+ PyObject_GC_UnTrack(op);
if (self->st) {
Py_BEGIN_ALLOW_THREADS
sqlite3_finalize(self->st);
}
static int
-stmt_traverse(pysqlite_Statement *self, visitproc visit, void *arg)
+stmt_traverse(PyObject *self, visitproc visit, void *arg)
{
Py_VISIT(Py_TYPE(self));
return 0;