1 %typemap(in,numinputs=0) (SbVec2s & size, int & nc) (int temp) {
2    $1 = new SbVec2s();
3    $2 = &temp;
4 }
5 
6 %typemap(argout) (SbVec2s & 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] * (*$2),
11                           SWIG_NewPointerObj((void *)$1, SWIGTYPE_p_SbVec2s, 1),
12                           *$2);
13 }
14 
15 %extend SoSFImage {
setValue(const SbVec2s & size,const int nc,PyObject * pixels)16   void setValue(const SbVec2s & size, const int nc, PyObject * pixels)
17   {
18     Py_ssize_t len = size[0] * size[1] * 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   }
31 
setValue(const SoSFImage * other)32   void setValue(const SoSFImage * other) { *self = *other; }
33 }
34