Update of
/cvsroot/playerstage/code/player/client_libs/libplayerc/bindings/python
In directory
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7522/client_libs/libplayerc/bindings/python
Modified Files:
Tag: release-2-0-patches
parse.py playerc.i
Log Message:
more backports from HEAD
Index: parse.py
===================================================================
RCS file:
/cvsroot/playerstage/code/player/client_libs/libplayerc/bindings/python/parse.py,v
retrieving revision 1.6
retrieving revision 1.6.2.1
diff -C2 -d -r1.6 -r1.6.2.1
*** parse.py 16 Feb 2006 21:15:53 -0000 1.6
--- parse.py 9 Jun 2006 18:13:49 -0000 1.6.2.1
***************
*** 15,23 ****
self.foot = ''
return
!
class Replace:
pass
!
--- 15,23 ----
self.foot = ''
return
!
class Replace:
pass
!
***************
*** 98,104 ****
rule = Rule()
rule.type = 'method'
! rule.patterns += [re.compile('\w*\s*%s_\w*\(.*?;' % prefix, re.DOTALL)]
! rule.patterns += [re.compile('\w*\s*\w*\s*%s_\w*\(.*?;' % prefix,
re.DOTALL)]
! rule.patterns += [re.compile('\w*\s*\*%s_\w*\(.*?;' % prefix, re.DOTALL)]
rule.head = '\n%%extend %s\n{\n' % prefix
--- 98,104 ----
rule = Rule()
rule.type = 'method'
! rule.patterns += [re.compile('\w*\s*%s_\w*\s*\(.*?;' % prefix, re.DOTALL)]
! rule.patterns += [re.compile('\w*\s*\w*\s*%s_\w*\s*\(.*?;' % prefix,
re.DOTALL)]
! rule.patterns += [re.compile('\w*\s*\*%s_\w*\s*\(.*?;' % prefix,
re.DOTALL)]
rule.head = '\n%%extend %s\n{\n' % prefix
***************
*** 149,160 ****
outstream = ''
current_struct = None
!
while instream:
line = instream
m = None
-
- for rule in rules:
# See if this line matches the rule
for pattern in rule.patterns:
--- 149,159 ----
outstream = ''
current_struct = None
!
while instream:
line = instream
m = None
+ for rule in rules:
# See if this line matches the rule
for pattern in rule.patterns:
***************
*** 166,170 ****
func = line[m.start():m.end()]
!
# Parse comment blocks
if rule.type == 'comment':
--- 165,169 ----
func = line[m.start():m.end()]
!
# Parse comment blocks
if rule.type == 'comment':
***************
*** 201,205 ****
continue
sig = sig[:mm.start()] + rep.dst + sig[mm.end():]
!
#print rval, name, sig
--- 200,204 ----
continue
sig = sig[:mm.start()] + rep.dst + sig[mm.end():]
!
#print rval, name, sig
***************
*** 207,213 ****
outstream += '%s %s %s' % (rval, name, sig)
outstream += rule.foot
!
instream = instream[m.end():]
!
break
--- 206,212 ----
outstream += '%s %s %s' % (rval, name, sig)
outstream += rule.foot
!
instream = instream[m.end():]
!
break
***************
*** 218,222 ****
return outstream
!
--- 217,221 ----
return outstream
!
Index: playerc.i
===================================================================
RCS file:
/cvsroot/playerstage/code/player/client_libs/libplayerc/bindings/python/playerc.i,v
retrieving revision 1.18
retrieving revision 1.18.2.1
diff -C2 -d -r1.18 -r1.18.2.1
*** playerc.i 22 Feb 2006 21:21:46 -0000 1.18
--- playerc.i 9 Jun 2006 18:13:49 -0000 1.18.2.1
***************
*** 26,39 ****
return NULL;
}
! for (i = 0; i < $1_dim0; i++)
{
PyObject *o = PySequence_GetItem($input,i);
! if (PyNumber_Check(o))
{
temp[i] = (float) PyFloat_AsDouble(o);
! }
! else
{
! PyErr_SetString(PyExc_ValueError,"Sequence elements must be numbers");
return NULL;
}
--- 26,39 ----
return NULL;
}
! for (i = 0; i < $1_dim0; i++)
{
PyObject *o = PySequence_GetItem($input,i);
! if (PyNumber_Check(o))
{
temp[i] = (float) PyFloat_AsDouble(o);
! }
! else
{
! PyErr_SetString(PyExc_ValueError,"Sequence elements must be numbers");
return NULL;
}
***************
*** 42,45 ****
--- 42,152 ----
}
+ // typemap for passing points into the graphics2d interface
+ %typemap(python,in) player_point_2d_t pts[]
+ {
+ // Check if is a list
+ if (PyList_Check ($input))
+ {
+ int size = PyList_Size ($input);
+ int ii = 0;
+ $1 = (player_point_2d_t*) malloc (size * sizeof
(player_point_2d_t));
+ for (ii = 0; ii < size; ii++)
+ {
+ PyObject *o = PyList_GetItem ($input, ii);
+ if (PyTuple_Check (o))
+ {
+ if (PyTuple_GET_SIZE (o) != 2)
+ {
+ PyErr_SetString (PyExc_ValueError,
"tuples must have 2 items");
+ free ($1);
+ return NULL;
+ }
+ $1[ii].px = PyFloat_AsDouble (PyTuple_GET_ITEM
(o, 0));
+ $1[ii].py = PyFloat_AsDouble (PyTuple_GET_ITEM
(o, 1));
+ }
+ else
+ {
+ PyErr_SetString (PyExc_TypeError, "list must
contain tuples");
+ free ($1);
+ return NULL;
+ }
+ }
+ }
+ else
+ {
+ PyErr_SetString (PyExc_TypeError, "not a list");
+ return NULL;
+ }
+ }
+
+ // typemap for passing 3d points into the graphics3d interface
+ %typemap(python,in) player_point_3d_t pts[]
+ {
+ // Check if is a list
+ if (PyList_Check ($input))
+ {
+ int size = PyList_Size ($input);
+ int ii = 0;
+ $1 = (player_point_3d_t*) malloc (size * sizeof
(player_point_3d_t));
+ for (ii = 0; ii < size; ii++)
+ {
+ PyObject *o = PyList_GetItem ($input, ii);
+ if (PyTuple_Check (o))
+ {
+ if (PyTuple_GET_SIZE (o) != 3)
+ {
+ PyErr_SetString (PyExc_ValueError,
"tuples must have 3 items");
+ free ($1);
+ return NULL;
+ }
+ $1[ii].px = PyFloat_AsDouble (PyTuple_GET_ITEM
(o, 0));
+ $1[ii].py = PyFloat_AsDouble (PyTuple_GET_ITEM
(o, 1));
+ $1[ii].pz = PyFloat_AsDouble (PyTuple_GET_ITEM
(o, 2));
+ }
+ else
+ {
+ PyErr_SetString (PyExc_TypeError, "list must
contain tuples");
+ free ($1);
+ return NULL;
+ }
+ }
+ }
+ else
+ {
+ PyErr_SetString (PyExc_TypeError, "not a list");
+ return NULL;
+ }
+ }
+
+ // typemap to free the array created in the previous typemap
+ %typemap(python,freearg) player_point2d_t pts[]
+ {
+ free ((player_point2d_t*) $input);
+ }
+
+ // typemap for tuples to colours
+ %typemap(python,in) player_color_t (player_color_t temp)
+ {
+ // Check it is a tuple
+ if (PyTuple_Check ($input))
+ {
+ // Check the tuple has four elements
+ if (PyTuple_GET_SIZE ($input) != 4)
+ {
+ PyErr_SetString (PyExc_ValueError, "tuple must have 4
items");
+ return NULL;
+ }
+ temp.alpha = PyInt_AsLong (PyTuple_GET_ITEM ($input, 0));
+ temp.red = PyInt_AsLong (PyTuple_GET_ITEM ($input, 1));
+ temp.green = PyInt_AsLong (PyTuple_GET_ITEM ($input, 2));
+ temp.blue = PyInt_AsLong (PyTuple_GET_ITEM ($input, 3));
+ }
+ else
+ {
+ PyErr_SetString (PyExc_TypeError, "not a tuple");
+ return NULL;
+ }
+ }
+
// Provide array (write) access
%typemap(in) double [ANY][ANY] (double temp[$1_dim0][$1_dim1])
***************
*** 55,59 ****
return NULL;
}
! for (i = 0; i < $1_dim0; i++)
{
PyObject *olist = PySequence_GetItem($input,i);
--- 162,166 ----
return NULL;
}
! for (i = 0; i < $1_dim0; i++)
{
PyObject *olist = PySequence_GetItem($input,i);
***************
*** 68,82 ****
}
! for (j = 0; j < $1_dim1; j++)
{
PyObject *o = PySequence_GetItem(olist,j);
! if (PyNumber_Check(o))
{
temp[i][j] = (float) PyFloat_AsDouble(o);
! }
! else
{
! PyErr_SetString(PyExc_ValueError,"Sequence elements must be
numbers");
return NULL;
}
--- 175,189 ----
}
! for (j = 0; j < $1_dim1; j++)
{
PyObject *o = PySequence_GetItem(olist,j);
! if (PyNumber_Check(o))
{
temp[i][j] = (float) PyFloat_AsDouble(o);
! }
! else
{
! PyErr_SetString(PyExc_ValueError,"Sequence elements must be numbers");
return NULL;
}
***************
*** 108,116 ****
// Provide array access
! %typemap(out) double [ANY]
{
int i;
$result = PyList_New($1_dim0);
! for (i = 0; i < $1_dim0; i++)
{
PyObject *o = PyFloat_FromDouble((double) $1[i]);
--- 215,223 ----
// Provide array access
! %typemap(out) double [ANY]
{
int i;
$result = PyList_New($1_dim0);
! for (i = 0; i < $1_dim0; i++)
{
PyObject *o = PyFloat_FromDouble((double) $1[i]);
***************
*** 119,127 ****
}
! %typemap(out) uint8_t [ANY]
{
int i;
$result = PyList_New($1_dim0);
! for (i = 0; i < $1_dim0; i++)
{
PyObject *o = PyInt_FromLong((long) (unsigned char) $1[i]);
--- 226,234 ----
}
! %typemap(out) uint8_t [ANY]
{
int i;
$result = PyList_New($1_dim0);
! for (i = 0; i < $1_dim0; i++)
{
PyObject *o = PyInt_FromLong((long) (unsigned char) $1[i]);
***************
*** 131,139 ****
// Provide array access doubly-dimensioned arrays
! %typemap(out) double [ANY][ANY]
{
int i, j;
$result = PyList_New($1_dim0);
! for (i = 0; i < $1_dim0; i++)
{
PyObject *l = PyList_New($1_dim1);
--- 238,246 ----
// Provide array access doubly-dimensioned arrays
! %typemap(out) double [ANY][ANY]
{
int i, j;
$result = PyList_New($1_dim0);
! for (i = 0; i < $1_dim0; i++)
{
PyObject *l = PyList_New($1_dim1);
***************
*** 153,157 ****
int i;
$result = PyTuple_New($1_dim0);
! for (i = 0; i < $1_dim0; i++)
{
PyObject *o = SWIG_NewPointerObj($1 + i, $1_descriptor, 0);
--- 260,264 ----
int i;
$result = PyTuple_New($1_dim0);
! for (i = 0; i < $1_dim0; i++)
{
PyObject *o = SWIG_NewPointerObj($1 + i, $1_descriptor, 0);
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit