From: G B. <gb...@us...> - 2006-05-08 18:24:58
|
Update of /cvsroot/playerstage/code/player/client_libs/libplayerc/bindings/python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26136/client_libs/libplayerc/bindings/python Modified Files: playerc.i Log Message: Add a typemap for sending colour info to the graphics proxy Index: playerc.i =================================================================== RCS file: /cvsroot/playerstage/code/player/client_libs/libplayerc/bindings/python/playerc.i,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** playerc.i 3 May 2006 23:34:49 -0000 1.20 --- playerc.i 8 May 2006 05:29:43 -0000 1.21 *************** *** 125,128 **** --- 125,152 ---- } + // 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]) |