return a Python list of Client*'s when a std::list<Client*> is returned

This commit is contained in:
Dana Jansens 2003-02-17 11:49:35 +00:00
parent 5fc7db1c16
commit a7d17188a4

View file

@ -16,8 +16,6 @@
%} %}
%include "stl.i" %include "stl.i"
//%include std_list.i
//%template(ClientList) std::list<Client*>;
%include "callback.i" %include "callback.i"
%immutable ob::openbox; %immutable ob::openbox;
@ -28,22 +26,18 @@
%}; %};
*/ */
%ignore ob::Screen::clients; %typemap(python,out) std::list<ob::Client*> {
%{ unsigned int s = $1.size();
#include <iterator> PyObject *l = PyList_New(s);
%}
%extend ob::Screen { std::list<ob::Client*>::const_iterator it = $1.begin(), end = $1.end();
Client *client(int i) { for (unsigned int i = 0; i < s; ++i, ++it) {
if (i < 0 || i >= (int)self->clients.size()) PyObject *pdata = SWIG_NewPointerObj((void *) *it,
return NULL; SWIGTYPE_p_ob__Client, 0);
ob::Client::List::iterator it = self->clients.begin(); PyList_SET_ITEM(l, i, pdata);
std::advance(it,i);
return *it;
} }
int clientCount() const { $result = l;
return (int) self->clients.size();
} }
};
// do this through events // do this through events
%ignore ob::Screen::showDesktop(bool); %ignore ob::Screen::showDesktop(bool);