1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
10 %include "otk_ustring.i"
12 %typemap(python,in) const otk::Property::StringVect & (otk::Property::StringVect temp) {
13 if (PyList_Check($input)) {
14 int s = PyList_Size($input);
15 temp = otk::Property::StringVect(s);
16 for (int i = 0; i < s; ++i) {
17 PyObject *o = PyList_GetItem($input, i);
18 if (PyString_Check(o)) {
19 temp[i] = PyString_AsString(o);
21 SWIG_exception(SWIG_TypeError, "list of strings expected");
26 SWIG_exception(SWIG_TypeError, "list expected");
30 %typemap(python,in) unsigned long value[] (unsigned long *temp) {
31 if (PyList_Check($input)) {
32 int s = PyList_Size($input);
33 temp = new unsigned long[s];
34 for (int i = 0; i < s; ++i) {
35 PyObject *o = PyList_GetItem($input, i);
37 temp[i] = PyInt_AsLong(o);
38 } else if (PyLong_Check(o)) {
39 temp[i] = PyLong_AsLong(o);
41 SWIG_exception(SWIG_TypeError, "list of numbers expected");
46 SWIG_exception(SWIG_TypeError, "list expected");
50 %typemap(python,freearg) unsigned long value[] {
54 %typemap(python,in,numinputs=0) otk::ustring *value (otk::ustring temp) {
58 %typemap(python,argout) otk::ustring *value {
61 if (PyTuple_Check($result)) {
62 s = PyTuple_Size($result);
63 _PyTuple_Resize(&$result, s + 1);
66 tuple = PyTuple_New(2);
67 PyTuple_SET_ITEM(tuple, 0, $result);
72 PyTuple_SET_ITEM(tuple, s, PyString_FromString($1->c_str()));
76 %typemap(python,in,numinputs=0) unsigned long *value (unsigned long temp) {
80 %typemap(python,argout) unsigned long *value {
81 PyObject *s = PyLong_FromLong(*$1);
85 %typemap(python,in) unsigned long *nelements (unsigned long temp) {
86 temp = (unsigned)PyLong_AsLong($input);
90 %typemap(python,in,numinputs=0) unsigned long **value (unsigned long *temp) {
94 %typemap(python,argout) (unsigned long *nelements, unsigned long **value) {
97 if (PyTuple_Check($result)) {
98 s = PyTuple_Size($result);
99 _PyTuple_Resize(&$result, s + 2);
102 tuple = PyTuple_New(3);
103 PyTuple_SET_ITEM(tuple, 0, $result);
110 PyTuple_SET_ITEM(tuple, s++, PyLong_FromLong(sz));
112 PyObject *r = PyList_New(sz);
113 for (int i = 0; i < sz; ++i) {
114 PyList_SET_ITEM(r, i, PyLong_FromLong((*$2)[i]));
116 PyTuple_SET_ITEM(tuple, s, r);
120 %typemap(python,in,numinputs=0) StringVect *strings (StringVect temp) {
124 %typemap(python,argout) (unsigned long *nelements, StringVect *strings) {
127 if (PyTuple_Check($result)) {
128 s = PyTuple_Size($result);
129 _PyTuple_Resize(&$result, s + 2);
132 tuple = PyTuple_New(3);
133 PyTuple_SET_ITEM(tuple, 0, $result);
140 PyTuple_SET_ITEM(tuple, s++, PyLong_FromLong(sz));
142 PyObject *r = PyList_New(sz);
143 for (int i = 0; i < sz; ++i) {
144 PyList_SET_ITEM(r, i, PyString_FromString((*$2)[i].c_str()));
146 PyTuple_SET_ITEM(tuple, s, r);
152 %ignore Property::NUM_STRING_TYPE;
153 %ignore Property::initialize();
155 %rename(getNum) Property::get(Window, Atom, Atom, unsigned long*);
156 %rename(getNums) Property::get(Window, Atom, Atom, unsigned long*,
158 %rename(getString) Property::get(Window, Atom, StringType, ustring*);
159 %rename(getStrings) Property::get(Window, Atom, StringType, unsigned long*,
164 %include "property.hh"