Update of
/cvsroot/playerstage/code/player/client_libs/libplayerc/bindings/python
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12163
Modified Files:
playerc.i
Log Message:
Add some typemaps for various forms of uint8_t data
Index: playerc.i
===================================================================
RCS file:
/cvsroot/playerstage/code/player/client_libs/libplayerc/bindings/python/playerc.i,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** playerc.i 8 May 2006 05:29:43 -0000 1.21
--- playerc.i 18 Jun 2006 19:34:32 -0000 1.22
***************
*** 31,36 ****
if (PyNumber_Check(o))
{
! temp[i] = (float) PyFloat_AsDouble(o);
! }
else
{
--- 31,35 ----
if (PyNumber_Check(o))
{
! temp[i] = (float) PyFloat_AsDouble(o); }
else
{
***************
*** 42,45 ****
--- 41,78 ----
}
+ %typemap(python,in) uint8_t data[]
+ {
+ int temp = 0;
+ // Check if is a list
+ if (PyList_Check ($input))
+ {
+ int size = PyList_Size ($input);
+ int ii = 0;
+ $1 = (uint8_t*) malloc (size * sizeof (uint8_t));
+ for (ii = 0; ii < size; ii++)
+ {
+ PyObject *o = PyList_GetItem ($input, ii);
+ temp = PyInt_AsLong (o);
+ if (temp == -1 && PyErr_Occurred ())
+ {
+ free ($1);
+ return NULL;
+ }
+ $1[ii] = (uint8_t) temp;
+ }
+ }
+ else
+ {
+ PyErr_SetString (PyExc_TypeError, "not a list");
+ return NULL;
+ }
+ }
+
+ /*// typemap to free the array created in the previous typemap
+ %typemap(python,freearg) uint8_t data[]
+ {
+ if ($input) free ((uint8_t*) $input);
+ }*/
+
// typemap for passing points into the graphics2d interface
%typemap(python,in) player_point_2d_t pts[]
***************
*** 122,126 ****
%typemap(python,freearg) player_point2d_t pts[]
{
! free ((player_point2d_t*) $input);
}
--- 155,159 ----
%typemap(python,freearg) player_point2d_t pts[]
{
! if ($input) free ((player_point2d_t*) $input);
}
***************
*** 198,201 ****
--- 231,239 ----
}
+ %typemap(in) uint32_t
+ {
+ $1 = (uint32_t) PyLong_AsLong ($input);
+ }
+
// Integer types
%typemap(out) uint8_t
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit