1 %typemap(in,numinputs=0) (SbVec3s & size, int & nc) (int temp) { 2 $1 = new SbVec3s(); 3 $2 = &temp; 4 } 5 6 %typemap(argout) (SbVec3s & size, int & nc) { 7 Py_XDECREF($result); /* free up any previous result */ 8 $result = Py_BuildValue("(s#Oi)", 9 (const char *)result, 10 (*$1)[0] * (*$1)[1] * (*$1)[2] * (*$2), 11 SWIG_NewPointerObj((void *)$1, SWIGTYPE_p_SbVec3s, 1), 12 *$2); 13 } 14 15 %extend SoSFImage3 { setValue(const SbVec3s & size,const int nc,PyObject * pixels)16 void setValue(const SbVec3s & size, const int nc, PyObject * pixels) 17 { 18 Py_ssize_t len = size[0] * size[1] * size[2] * nc; 19 unsigned char * image; 20 #ifdef PY_2 21 PyString_AsStringAndSize(pixels, (char **)&image, &len); 22 #else 23 PyObject * b_pixels = pixels; 24 if (PyUnicode_Check(pixels)){ 25 b_pixels = PyUnicode_AsEncodedString(pixels, "utf-8", "Error ~"); 26 } 27 PyBytes_AsStringAndSize(b_pixels, (char **)&image, &len); 28 #endif 29 self->setValue(size, nc, image); 30 } setValue(const SoSFImage3 * other)31 void setValue(const SoSFImage3 * other) { *self = *other; } 32 } 33