My favorites | Sign in
Project Home Downloads Wiki
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions

Issue 201 attachment: diff (3.6 KB)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
diff --git a/src/row.cpp b/src/row.cpp
index 37b9016..194aec0 100644
--- a/src/row.cpp
+++ b/src/row.cpp
@@ -104,17 +104,18 @@ static PyObject* Row_getattro(PyObject* o, PyObject* name)
return PyObject_GenericGetAttr(o, name);
}

-static Py_ssize_t Row_length(PyObject* self)
+static Py_ssize_t Row_length(PyObject* o)
{
- return ((Row*)self)->cValues;
+ Row* self = (Row*)o;
+ return (self)->cValues;
}


-static int Row_contains(Row *self, PyObject *el)
+static int Row_contains(PyObject* o, PyObject *el)
{
// Implementation of contains. The documentation is not good (non-existent?), so I copied the following from the
// PySequence_Contains documentation: Return -1 if error; 1 if ob in seq; 0 if ob not in seq.
-
+ Row* self = (Row*)o;
int cmp = 0;

for (Py_ssize_t i = 0, c = self->cValues ; cmp == 0 && i < c; ++i)
@@ -124,10 +125,10 @@ static int Row_contains(Row *self, PyObject *el)
}


-static PyObject* Row_item(Row* self, Py_ssize_t i)
+static PyObject* Row_item(PyObject* o, Py_ssize_t i)
{
// Apparently, negative indexes are handled by magic ;) -- they never make it here.
-
+ Row* self = (Row*)o;
if (i < 0 || i >= self->cValues)
{
PyErr_SetString(PyExc_IndexError, "tuple index out of range");
@@ -139,10 +140,11 @@ static PyObject* Row_item(Row* self, Py_ssize_t i)
}


-static int Row_ass_item(Row* self, Py_ssize_t i, PyObject* v)
+static int Row_ass_item(PyObject* o, Py_ssize_t i, PyObject* v)
{
// Implements row[i] = value.
-
+ Row* self = (Row*)o;
+
if (i < 0 || i >= self->cValues)
{
PyErr_SetString(PyExc_IndexError, "Row assignment index out of range");
@@ -164,13 +166,13 @@ static int Row_setattro(PyObject* o, PyObject *name, PyObject* v)
PyObject* index = PyDict_GetItem(self->map_name_to_index, name);

if (index)
- return Row_ass_item(self, PyNumber_AsSsize_t(index, 0), v);
+ return Row_ass_item((PyObject*)self, PyNumber_AsSsize_t(index, 0), v);

return PyObject_GenericSetAttr(o, name, v);
}


-static PyObject* Row_slice(PyObject* o, Py_ssize_t iFirst, Py_ssize_t iMax)
+static void Row_slice(PyObject* o, Py_ssize_t iFirst, Py_ssize_t iMax)
{
// Note: Negative indexes will have already been converted to positive ones before this is called. It is possible
// for the iMax value to be too high if row[:] or row[1:] is used.
@@ -189,13 +191,13 @@ static PyObject* Row_slice(PyObject* o, Py_ssize_t iFirst, Py_ssize_t iMax)
if (iFirst == 0 && iMax == self->cValues)
{
Py_INCREF(o);
- return o;
+ return;
}

Py_ssize_t len = iMax - iFirst;
PyObject* result = PyTuple_New(len);
if (!result)
- return 0;
+ return;

for (Py_ssize_t i = 0; i < len; i++)
{
@@ -203,8 +205,6 @@ static PyObject* Row_slice(PyObject* o, Py_ssize_t iFirst, Py_ssize_t iMax)
PyTuple_SET_ITEM(result, i, item);
Py_INCREF(item);
}
-
- return result;
}


@@ -379,11 +379,15 @@ static PySequenceMethods row_as_sequence =
0, // sq_concat
0, // sq_repeat
(ssizeargfunc)Row_item, // sq_item
- Row_slice, // sq_slice
+ 0, // sq_slice
(ssizeobjargproc)Row_ass_item, // sq_ass_item
- 0, // sq_ass_slice
+ (void*)Row_slice, // sq_ass_slice
(objobjproc)Row_contains, // sq_contains
+ 0,0
};
+// 0, // sq_slice
+//
+


static PyMappingMethods row_as_mapping =
Powered by Google Project Hosting