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,numinputs=0) unsigned long *nelements (unsigned long temp) {
89 %typemap(python,in) unsigned long *nelements (unsigned long temp) {
90 temp = (unsigned)PyLong_AsLong($input);
94 %typemap(python,in,numinputs=0) unsigned long **value (unsigned long *temp) {
98 %typemap(python,argout) (unsigned long *nelements, unsigned long **value) {
101 if (PyTuple_Check($result)) {
102 s = PyTuple_Size($result);
103 _PyTuple_Resize(&$result, s + 2);
106 tuple = PyTuple_New(3);
107 PyTuple_SET_ITEM(tuple, 0, $result);
114 PyTuple_SET_ITEM(tuple, s++, PyLong_FromLong(sz));
116 PyObject *r = PyList_New(sz);
117 for (int i = 0; i < sz; ++i) {
118 PyList_SET_ITEM(r, i, PyLong_FromLong((*$2)[i]));
120 PyTuple_SET_ITEM(tuple, s, r);
124 %typemap(python,in,numinputs=0) StringVect *strings (StringVect temp) {
128 %typemap(python,argout) (unsigned long *nelements, StringVect *strings) {
131 if (PyTuple_Check($result)) {
132 s = PyTuple_Size($result);
133 _PyTuple_Resize(&$result, s + 2);
136 tuple = PyTuple_New(3);
137 PyTuple_SET_ITEM(tuple, 0, $result);
144 PyTuple_SET_ITEM(tuple, s++, PyLong_FromLong(sz));
146 PyObject *r = PyList_New(sz);
147 for (int i = 0; i < sz; ++i) {
148 PyList_SET_ITEM(r, i, PyString_FromString((*$2)[i].c_str()));
150 PyTuple_SET_ITEM(tuple, s, r);
156 %immutable otk::Property::atoms;
158 %ignore Property::NUM_STRING_TYPE;
159 %ignore Property::initialize();
161 %rename(getNum) Property::get(Window, Atom, Atom, unsigned long*);
162 %rename(getNums) Property::get(Window, Atom, Atom, unsigned long*,
164 %rename(getString) Property::get(Window, Atom, StringType, ustring*);
165 %rename(getStrings) Property::get(Window, Atom, StringType, unsigned long*,
170 %include "property.hh"