aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/py/source/pysymbol.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'externals/grill/py/source/pysymbol.cpp')
-rw-r--r--externals/grill/py/source/pysymbol.cpp37
1 files changed, 21 insertions, 16 deletions
diff --git a/externals/grill/py/source/pysymbol.cpp b/externals/grill/py/source/pysymbol.cpp
index 2e0a7264..b812e134 100644
--- a/externals/grill/py/source/pysymbol.cpp
+++ b/externals/grill/py/source/pysymbol.cpp
@@ -6,7 +6,7 @@ For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution.
$LastChangedRevision: 26 $
-$LastChangedDate: 2008-01-03 17:20:03 +0100 (Thu, 03 Jan 2008) $
+$LastChangedDate: 2008-01-03 18:15:53 +0100 (Thu, 03 Jan 2008) $
$LastChangedBy: thomas $
*/
@@ -91,13 +91,15 @@ static long symbol_hash(PyObject *self)
}
-static int symbol_length(pySymbol *self)
+static Py_ssize_t symbol_length(PyObject *s)
{
+ pySymbol *self = reinterpret_cast<pySymbol *>(s);
return strlen(flext::GetString(self->sym));
}
-static PyObject *symbol_item(pySymbol *self, int i)
+static PyObject *symbol_item(PyObject *s,Py_ssize_t i)
{
+ pySymbol *self = reinterpret_cast<pySymbol *>(s);
const char *str = flext::GetString(self->sym);
int len = strlen(str);
if(i < 0) i += len;
@@ -110,8 +112,9 @@ static PyObject *symbol_item(pySymbol *self, int i)
}
}
-static PyObject *symbol_slice(pySymbol *self,int ilow = 0,int ihigh = 1<<(sizeof(int)*8-2))
+static PyObject *symbol_slice(PyObject *s,Py_ssize_t ilow = 0,Py_ssize_t ihigh = 1<<(sizeof(int)*8-2))
{
+ pySymbol *self = reinterpret_cast<pySymbol *>(s);
const char *str = flext::GetString(self->sym);
int len = strlen(str);
if(ilow < 0) {
@@ -124,9 +127,10 @@ static PyObject *symbol_slice(pySymbol *self,int ilow = 0,int ihigh = 1<<(sizeof
return PyString_FromStringAndSize(str+ilow,ilow <= ihigh?ihigh-ilow+1:0);
}
-static PyObject *symbol_concat(pySymbol *self,PyObject *op)
+static PyObject *symbol_concat(PyObject *s,PyObject *op)
{
- PyObject *nobj = symbol_slice(self); // take all
+ pySymbol *self = reinterpret_cast<pySymbol *>(s);
+ PyObject *nobj = symbol_slice(s); // take all
if(nobj) {
PyObject *ret = PySequence_Concat(nobj,op);
Py_DECREF(nobj);
@@ -136,9 +140,10 @@ static PyObject *symbol_concat(pySymbol *self,PyObject *op)
return NULL;
}
-static PyObject *symbol_repeat(pySymbol *self,int rep)
+static PyObject *symbol_repeat(PyObject *s,Py_ssize_t rep)
{
- PyObject *nobj = symbol_slice(self); // take all
+ pySymbol *self = reinterpret_cast<pySymbol *>(s);
+ PyObject *nobj = symbol_slice(s); // take all
if(nobj) {
PyObject *ret = PySequence_Repeat(nobj,rep);
Py_DECREF(nobj);
@@ -149,19 +154,19 @@ static PyObject *symbol_repeat(pySymbol *self,int rep)
}
static PySequenceMethods symbol_as_seq = {
- (inquiry)symbol_length, /* inquiry sq_length; __len__ */
- (binaryfunc)symbol_concat, /* __add__ */
- (intargfunc)symbol_repeat, /* __mul__ */
- (intargfunc)symbol_item, /* intargfunc sq_item; __getitem__ */
- (intintargfunc)symbol_slice, /* intintargfunc sq_slice; __getslice__ */
+ symbol_length, /* inquiry sq_length; __len__ */
+ symbol_concat, /* __add__ */
+ symbol_repeat, /* __mul__ */
+ symbol_item, /* intargfunc sq_item; __getitem__ */
+ symbol_slice, /* intintargfunc sq_slice; __getslice__ */
NULL, /* intobjargproc sq_ass_item; __setitem__ */
NULL, /* intintobjargproc sq_ass_slice; __setslice__ */
};
-static PyObject *symbol_iter(PyObject *obj)
+static PyObject *symbol_iter(PyObject *s)
{
- pySymbol *self = (pySymbol *)obj;
- PyObject *nobj = symbol_slice(self);
+ pySymbol *self = reinterpret_cast<pySymbol *>(s);
+ PyObject *nobj = symbol_slice(s);
if(nobj) {
PyObject *it = PyObject_GetIter(nobj);
Py_DECREF(nobj);