return(pid);
}
+DEFINE_REF(eConsoleAppContainer);
+
eConsoleAppContainer::eConsoleAppContainer()
-:pid(-1), killstate(0), in(0), out(0), err(0)
+:pid(-1), killstate(0)
{
for (int i=0; i < 3; ++i)
{
::fcntl(fd[1], F_SETFL, O_NONBLOCK);
::fcntl(fd[2], F_SETFL, O_NONBLOCK);
- in = new eSocketNotifier(eApp, fd[0], eSocketNotifier::Read|eSocketNotifier::Priority|eSocketNotifier::Hungup );
- out = new eSocketNotifier(eApp, fd[1], eSocketNotifier::Write, false);
- err = new eSocketNotifier(eApp, fd[2], eSocketNotifier::Read|eSocketNotifier::Priority );
+ in = eSocketNotifier::create(eApp, fd[0], eSocketNotifier::Read|eSocketNotifier::Priority|eSocketNotifier::Hungup );
+ out = eSocketNotifier::create(eApp, fd[1], eSocketNotifier::Write, false);
+ err = eSocketNotifier::create(eApp, fd[2], eSocketNotifier::Read|eSocketNotifier::Priority );
CONNECT(in->activated, eConsoleAppContainer::readyRead);
CONNECT(out->activated, eConsoleAppContainer::readyWrite);
CONNECT(err->activated, eConsoleAppContainer::readyErrRead);
+ in->m_clients.push_back(this);
+ out->m_clients.push_back(this);
+ err->m_clients.push_back(this);
return 0;
}
outbuf.pop();
delete [] d.data;
}
- delete in;
- delete out;
- delete err;
- in=out=err=0;
+ in = 0;
+ out = 0;
+ err = 0;
for (int i=0; i < 3; ++i)
{
outbuf.pop();
delete [] d.data;
}
+ in = 0; out = 0; err = 0;
pid = -1;
}
static int
eConsolePy_traverse(eConsolePy *self, visitproc visit, void *arg)
{
- PyObject *obj = self->cont->dataAvail.get(true);
+ PyObject *obj = self->cont->dataAvail.getSteal();
if (obj) {
Py_VISIT(obj);
}
- obj = self->cont->stdoutAvail.get(true);
+ obj = self->cont->stdoutAvail.getSteal();
if (obj) {
Py_VISIT(obj);
}
- obj = self->cont->stderrAvail.get(true);
+ obj = self->cont->stderrAvail.getSteal();
if (obj) {
Py_VISIT(obj);
}
- obj = self->cont->dataSent.get(true);
+ obj = self->cont->dataSent.getSteal();
if (obj) {
Py_VISIT(obj);
}
- obj = self->cont->appClosed.get(true);
+ obj = self->cont->appClosed.getSteal();
if (obj) {
Py_VISIT(obj);
}
static int
eConsolePy_clear(eConsolePy *self)
{
- PyObject *obj = self->cont->dataAvail.get(true);
+ PyObject *obj = self->cont->dataAvail.getSteal(true);
if (obj) {
Py_CLEAR(obj);
}
- obj = self->cont->stdoutAvail.get(true);
+ obj = self->cont->stdoutAvail.getSteal(true);
if (obj) {
Py_CLEAR(obj);
}
- obj = self->cont->stderrAvail.get(true);
+ obj = self->cont->stderrAvail.getSteal(true);
if (obj) {
Py_CLEAR(obj);
}
- obj = self->cont->dataSent.get(true);
+ obj = self->cont->dataSent.getSteal(true);
if (obj) {
Py_CLEAR(obj);
}
- obj = self->cont->appClosed.get(true);
+ obj = self->cont->appClosed.getSteal(true);
if (obj) {
Py_CLEAR(obj);
}
if (self->in_weakreflist != NULL)
PyObject_ClearWeakRefs((PyObject *) self);
eConsolePy_clear(self);
- delete self->cont;
+ self->cont->Release();
self->ob_type->tp_free((PyObject*)self);
}
{
eConsolePy *self = (eConsolePy *)type->tp_alloc(type, 0);
self->cont = new eConsoleAppContainer();
+ self->cont->AddRef();
self->in_weakreflist = NULL;
return (PyObject *)self;
}
int dataSent;
};
-class eConsoleAppContainer: public Object
+class eConsoleAppContainer: public Object, public iObject
{
+ DECLARE_REF(eConsoleAppContainer);
int fd[3];
int filefd[3];
int pid;
int killstate;
std::string m_cwd;
std::queue<struct queue_data> outbuf;
- eSocketNotifier *in, *out, *err;
+ ePtr<eSocketNotifier> in, out, err;
void readyRead(int what);
void readyErrRead(int what);
void readyWrite(int what);
#include <lib/base/elock.h>
#include <lib/gdi/grc.h>
+DEFINE_REF(eSocketNotifier);
+
eSocketNotifier::eSocketNotifier(eMainloop *context, int fd, int requested, bool startnow): context(*context), fd(fd), state(0), requested(requested)
{
- if (startnow)
+ if (startnow)
start();
}
void eSocketNotifier::stop()
{
if (state)
+ {
+ state=0;
context.removeSocketNotifier(this);
-
- state=0;
+ }
}
// timer
int fd = sn->getFD();
std::map<int,eSocketNotifier*>::iterator i(notifiers.find(fd));
if (i != notifiers.end())
- return notifiers.erase(i);
- eFatal("removed socket notifier which is not present");
+ {
+ notifiers.erase(i);
+ return;
+ }
+ for (i = notifiers.begin(); i != notifiers.end(); ++i)
+ eDebug("fd=%d, sn=%d", i->second->getFD(), (void*)i->second);
+ eFatal("removed socket notifier which is not present, fd=%d", fd);
}
int eMainloop::processOneEvent(unsigned int twisted_timeout, PyObject **res, ePyObject additional)
// build the poll aray
pollfd pfd[fdcount]; // make new pollfd array
std::map<int,eSocketNotifier*>::iterator it = notifiers.begin();
+
int i=0;
for (; i < nativecount; ++i, ++it)
{
if (it != notifiers.end()
&& it->second->state == 1) // added and in poll
{
- int req = it->second->getRequested();
- if (pfd[i].revents & req)
- it->second->activate(pfd[i].revents & req);
+ eSocketNotifier *sn = it->second;
+ int req = sn->getRequested();
+ if (pfd[i].revents & req) {
+ sn->AddRef();
+ sn->activate(pfd[i].revents & req);
+ sn->Release();
+ }
pfd[i].revents &= ~req;
}
if (pfd[i].revents & (POLLERR|POLLHUP|POLLNVAL))
static int
eTimerPy_traverse(eTimerPy *self, visitproc visit, void *arg)
{
- PyObject *obj = self->tm->timeout.get(true);
+ PyObject *obj = self->tm->timeout.getSteal();
if (obj) {
Py_VISIT(obj);
}
static int
eTimerPy_clear(eTimerPy *self)
{
- PyObject *obj = self->tm->timeout.get(true);
+ PyObject *obj = self->tm->timeout.getSteal(true);
if (obj)
Py_CLEAR(obj);
return 0;
static int
eSocketNotifierPy_traverse(eSocketNotifierPy *self, visitproc visit, void *arg)
{
- PyObject *obj = self->sn->activated.get(true);
+ PyObject *obj = self->sn->activated.getSteal();
if (obj)
Py_VISIT(obj);
return 0;
static int
eSocketNotifierPy_clear(eSocketNotifierPy *self)
{
- PyObject *obj = self->sn->activated.get(true);
+ PyObject *obj = self->sn->activated.getSteal(true);
if (obj)
Py_CLEAR(obj);
return 0;
if (self->in_weakreflist != NULL)
PyObject_ClearWeakRefs((PyObject *) self);
eSocketNotifierPy_clear(self);
- delete self->sn;
+ self->sn->Release();
self->ob_type->tp_free((PyObject*)self);
}
}
else if (size < 2 || !PyArg_ParseTuple(args, "ii", &fd, &req))
return NULL;
- self->sn = new eSocketNotifier(eApp, fd, req, immediate_start);
+ self->sn = eSocketNotifier::create(eApp, fd, req, immediate_start);
+ self->sn->AddRef();
self->in_weakreflist = NULL;
return (PyObject *)self;
}
* This class emits the signal \c eSocketNotifier::activate whenever the
* event specified by \c req is available.
*/
-class eSocketNotifier
+class eSocketNotifier: iObject
{
+ DECLARE_REF(eSocketNotifier);
friend class eMainloop;
public:
enum { Read=POLLIN, Write=POLLOUT, Priority=POLLPRI, Error=POLLERR, Hungup=POLLHUP };
int state;
int requested; // requested events (POLLIN, ...)
void activate(int what) { /*emit*/ activated(what); }
+ eSocketNotifier(eMainloop *context, int fd, int req, bool startnow);
public:
/**
* \brief Constructs a eSocketNotifier.
* \param req The events to watch to, normally either \c Read or \c Write. You can specify any events that \c poll supports.
* \param startnow Specifies if the socketnotifier should start immediately.
*/
- eSocketNotifier(eMainloop *context, int fd, int req, bool startnow=true);
+ static eSocketNotifier* create(eMainloop *context, int fd, int req, bool startnow=true) { return new eSocketNotifier(context, fd, req, startnow); }
~eSocketNotifier();
PSignal1<void, int> activated;
int getFD() { return fd; }
int getRequested() { return requested; }
void setRequested(int req) { requested=req; }
+
+ eSmartPtrList<iObject> m_clients;
};
#endif
template<class T>
class eFixedMessagePump: private eMessagePump, public Object
{
- eSocketNotifier *sn;
+ ePtr<eSocketNotifier> sn;
void do_recv(int)
{
T msg;
}
eFixedMessagePump(eMainloop *context, int mt): eMessagePump(mt)
{
- sn=new eSocketNotifier(context, getOutputFD(), eSocketNotifier::Read);
+ sn=eSocketNotifier::create(context, getOutputFD(), eSocketNotifier::Read);
CONNECT(sn->activated, eFixedMessagePump<T>::do_recv);
sn->start();
}
- ~eFixedMessagePump()
- {
- delete sn;
- sn=0;
- }
void start() { if (sn) sn->start(); }
void stop() { if (sn) sn->stop(); }
};
class ePythonMessagePump: public eMessagePump, public Object
{
- eSocketNotifier *sn;
+ ePtr<eSocketNotifier> sn;
void do_recv(int)
{
int msg;
ePythonMessagePump()
:eMessagePump(1)
{
- eDebug("add python messagepump %p", this);
- sn=new eSocketNotifier(eApp, getOutputFD(), eSocketNotifier::Read);
+ sn=eSocketNotifier::create(eApp, getOutputFD(), eSocketNotifier::Read);
CONNECT(sn->activated, ePythonMessagePump::do_recv);
sn->start();
}
- ~ePythonMessagePump()
- {
- eDebug("remove python messagepump %p", this);
- delete sn;
- sn=0;
- }
void start() { if (sn) sn->start(); }
void stop() { if (sn) sn->stop(); }
};
}
else
{
- m_fp_notifier = new eSocketNotifier(eApp, m_fp_fd, eSocketNotifier::Read|POLLERR);
+ m_fp_notifier = eSocketNotifier::create(eApp, m_fp_fd, eSocketNotifier::Read|POLLERR);
CONNECT(m_fp_notifier->activated, eAVSwitch::fp_event);
}
}
{
if ( m_fp_fd >= 0 )
close(m_fp_fd);
- if (m_fp_notifier)
- delete m_fp_notifier;
}
eAVSwitch *eAVSwitch::getInstance()
{
static eAVSwitch *instance;
int m_video_mode;
- eSocketNotifier *m_fp_notifier;
+ ePtr<eSocketNotifier> m_fp_notifier;
void fp_event(int what);
int m_fp_fd;
#ifdef SWIG
sn=0;
} else
{
- sn=new eSocketNotifier(eApp, handle, eSocketNotifier::Read);
+ sn=eSocketNotifier::create(eApp, handle, eSocketNotifier::Read);
CONNECT(sn->activated, eRCShortDriver::keyPressed);
eRCInput::getInstance()->setFile(handle);
}
{
if (handle>=0)
close(handle);
- if (sn)
- delete sn;
}
void eRCInputEventDriver::keyPressed(int)
sn=0;
} else
{
- sn=new eSocketNotifier(eApp, handle, eSocketNotifier::Read);
+ sn=eSocketNotifier::create(eApp, handle, eSocketNotifier::Read);
CONNECT(sn->activated, eRCInputEventDriver::keyPressed);
eRCInput::getInstance()->setFile(handle);
}
{
if (handle>=0)
close(handle);
- if (sn)
- delete sn;
}
eRCConfig::eRCConfig()
{
protected:
int handle;
- eSocketNotifier *sn;
+ ePtr<eSocketNotifier> sn;
void keyPressed(int);
public:
eRCShortDriver(const char *filename);
{
protected:
int handle;
- eSocketNotifier *sn;
+ ePtr<eSocketNotifier> sn;
void keyPressed(int);
public:
std::string getDeviceName();
sn=0;
} else
{
- sn=new eSocketNotifier(eApp, handle, eSocketNotifier::Read);
+ sn=eSocketNotifier::create(eApp, handle, eSocketNotifier::Read);
CONNECT(sn->activated, eRCConsoleDriver::keyPressed);
eRCInput::getInstance()->setFile(handle);
}
tcsetattr(handle,TCSANOW, &ot);
if (handle>=0)
close(handle);
- if (sn)
- delete sn;
}
void eRCConsoleDriver::keyPressed(int)
struct termios ot;
protected:
int handle;
- eSocketNotifier *sn;
+ ePtr<eSocketNotifier> sn;
void keyPressed(int);
public:
eRCConsoleDriver(const char *filename);
eWarning("%s: %m", filename);
else
{
- m_sn = new eSocketNotifier(eApp, m_fd, eSocketNotifier::Priority);
+ m_sn = eSocketNotifier::create(eApp, m_fd, eSocketNotifier::Priority);
CONNECT(m_sn->activated, eDVBVideo::video_event);
}
eDebug("Video Device: %s", filename);
eDVBVideo::~eDVBVideo()
{
- if (m_sn)
- delete m_sn;
if (m_is_slow_motion)
setSlowMotion(0);
if (m_is_fast_forward)
m_fd_video;
#endif
int m_is_slow_motion, m_is_fast_forward, m_is_freezed;
- eSocketNotifier *m_sn;
+ ePtr<eSocketNotifier> m_sn;
void video_event(int what);
Signal1<void, struct iTSMPEGDecoder::videoEvent> m_event;
public:
if (fd >= 0)
{
- notifier=new eSocketNotifier(context, fd, eSocketNotifier::Read, false);
+ notifier=eSocketNotifier::create(context, fd, eSocketNotifier::Read, false);
CONNECT(notifier->activated, eDVBSectionReader::data);
res = 0;
} else
eDVBSectionReader::~eDVBSectionReader()
{
- if (notifier)
- delete notifier;
if (fd >= 0)
::close(fd);
}
{
::ioctl(m_fd, DMX_SET_BUFFER_SIZE, 64*1024);
::fcntl(m_fd, F_SETFL, O_NONBLOCK);
- m_notifier = new eSocketNotifier(context, m_fd, eSocketNotifier::Read, false);
+ m_notifier = eSocketNotifier::create(context, m_fd, eSocketNotifier::Read, false);
CONNECT(m_notifier->activated, eDVBPESReader::data);
res = 0;
} else
eDVBPESReader::~eDVBPESReader()
{
- if (m_notifier)
- delete m_notifier;
if (m_fd >= 0)
::close(m_fd);
}
int active;
int checkcrc;
void data(int);
- eSocketNotifier *notifier;
+ ePtr<eSocketNotifier> notifier;
public:
eDVBSectionReader(eDVBDemux *demux, eMainloop *context, RESULT &res);
ePtr<eDVBDemux> m_demux;
int m_active;
void data(int);
- eSocketNotifier *m_notifier;
+ ePtr<eSocketNotifier> m_notifier;
public:
eDVBPESReader(eDVBDemux *demux, eMainloop *context, RESULT &res);
virtual ~eDVBPESReader();
eDVBFrontend::eDVBFrontend(int adap, int fe, int &ok, bool simulate)
:m_simulate(simulate), m_enabled(false), m_type(-1), m_dvbid(fe), m_slotid(fe)
,m_fd(-1), m_need_rotor_workaround(false), m_can_handle_dvbs2(false)
- ,m_sn(0), m_timeout(0), m_tuneTimer(0)
+ , m_timeout(0), m_tuneTimer(0)
#if HAVE_DVB_API_VERSION < 3
,m_secfd(-1)
#endif
if (!m_simulate)
{
- m_sn = new eSocketNotifier(eApp, m_fd, eSocketNotifier::Read, false);
+ m_sn = eSocketNotifier::create(eApp, m_fd, eSocketNotifier::Read, false);
CONNECT(m_sn->activated, eDVBFrontend::feEvent);
}
eWarning("couldnt close sec %d", m_dvbid);
}
#endif
- delete m_sn;
m_sn=0;
m_state = stateClosed;
FRONTENDPARAMETERS parm;
int m_state;
ePtr<iDVBSatelliteEquipmentControl> m_sec;
- eSocketNotifier *m_sn;
+ ePtr<eSocketNotifier> m_sn;
int m_tuning;
eTimer *m_timeout;
eTimer *m_tuneTimer;
ePtr<eConnection> eDVBCAService::m_chanAddedConn;
eDVBCAService::eDVBCAService()
- :m_sn(0), m_prev_build_hash(0), m_sendstate(0), m_retryTimer(eApp)
+ : m_prev_build_hash(0), m_sendstate(0), m_retryTimer(eApp)
{
memset(m_used_demux, 0xFF, sizeof(m_used_demux));
CONNECT(m_retryTimer.timeout, eDVBCAService::sendCAPMT);
{
eDebug("[eDVBCAService] free service %s", m_service.toString().c_str());
::close(m_sock);
- delete m_sn;
}
// begin static methods
void eDVBCAService::Connect()
{
- if (m_sn) {
- delete m_sn;
- m_sn=0;
- }
+ m_sn=0;
memset(&m_servaddr, 0, sizeof(struct sockaddr_un));
m_servaddr.sun_family = AF_UNIX;
strcpy(m_servaddr.sun_path, "/tmp/camd.socket");
int val=1;
fcntl(m_sock, F_SETFL, O_NONBLOCK);
setsockopt(m_sock, SOL_SOCKET, SO_REUSEADDR, &val, 4);
- m_sn = new eSocketNotifier(eApp, m_sock,
+ m_sn = eSocketNotifier::create(eApp, m_sock,
eSocketNotifier::Read|eSocketNotifier::Priority|eSocketNotifier::Error|eSocketNotifier::Hungup);
CONNECT(m_sn->activated, eDVBCAService::socketCB);
class eDVBCAService: public Object
{
- eSocketNotifier *m_sn;
+ ePtr<eSocketNotifier> m_sn;
eServiceReferenceDVB m_service;
uint8_t m_used_demux[32];
unsigned int m_prev_build_hash;
if (fd >= 0)
{
- notifier = new eSocketNotifier(context, fd, eSocketNotifier::Read | eSocketNotifier::Priority | eSocketNotifier::Write);
+ notifier = eSocketNotifier::create(context, fd, eSocketNotifier::Read | eSocketNotifier::Priority | eSocketNotifier::Write);
CONNECT(notifier->activated, eDVBCISlot::data);
} else
{
eDVBCISlot::~eDVBCISlot()
{
- delete notifier;
}
void eDVBCISlot::setAppManager( eDVBCIApplicationManagerSession *session )
DECLARE_REF(eDVBCISlot);
int slotid;
int fd;
- eSocketNotifier *notifier;
+ ePtr<eSocketNotifier> notifier;
int state;
std::map<uint16_t, uint8_t> running_services;
eDVBCIApplicationManagerSession *application_manager;
if (writebuffer.empty())
{
int wasconnected=(mystate==Connection) || (mystate==Closing);
- delete rsn;
rsn=0;
::close(socketdesc);
socketdesc=-1;
fcntl(socketdesc, F_SETFL, O_NONBLOCK);
last_break = 0xFFFFFFFF;
- if (rsn)
- delete rsn;
- rsn=new eSocketNotifier(ml, getDescriptor(),
+ rsn = 0;
+ rsn=eSocketNotifier::create(ml, getDescriptor(),
eSocketNotifier::Read|eSocketNotifier::Hungup);
CONNECT(rsn->activated, eSocket::notifier);
return 0;
setSocket(s, 1, ml);
}
-eSocket::eSocket(int socket, int issocket, eMainloop *ml): readbuffer(32768), writebuffer(32768), rsn(0)
+eSocket::eSocket(int socket, int issocket, eMainloop *ml): readbuffer(32768), writebuffer(32768)
{
setSocket(socket, issocket, ml);
mystate=Connection;
eSocket::~eSocket()
{
- if (rsn)
- delete rsn;
if(socketdesc>=0)
{
::close(socketdesc);
int writebusy;
sockaddr_in serv_addr;
protected:
- eSocketNotifier *rsn;
+ ePtr<eSocketNotifier> rsn;
virtual void notifier(int);
public:
eSocket(eMainloop *ml);
m_subtitle_widget(0),
m_state(stIdle),
m_current_trick(0),
- m_sn(eApp, ddvd_get_messagepipe_fd(m_ddvdconfig), eSocketNotifier::Read|eSocketNotifier::Priority|eSocketNotifier::Error|eSocketNotifier::Hungup),
m_pump(eApp, 1)
{
+ m_sn = eSocketNotifier::create(eApp, ddvd_get_messagepipe_fd(m_ddvdconfig), eSocketNotifier::Read|eSocketNotifier::Priority|eSocketNotifier::Error|eSocketNotifier::Hungup);
std::string aspect;
eDebug("SERVICEDVD construct!");
// create handle
ddvd_set_video(m_ddvdconfig, DDVD_16_9, DDVD_PAL);
ddvd_set_lfb(m_ddvdconfig, (unsigned char *)m_pixmap->surface->data, 720, 576, 4, 720*4);
- CONNECT(m_sn.activated, eServiceDVD::gotMessage);
+ CONNECT(m_sn->activated, eServiceDVD::gotMessage);
CONNECT(m_pump.recv_msg, eServiceDVD::gotThreadMessage);
strcpy(m_ddvd_titlestring,"");
m_cue_pts = 0;
char m_ddvd_titlestring[96];
- eSocketNotifier m_sn;
+ ePtr<eSocketNotifier> m_sn;
eFixedMessagePump<int> m_pump;
pts_t m_cue_pts;
}
eSocketMMIHandler::eSocketMMIHandler()
- :buffer(512), connfd(-1), connsn(0), sockname("/tmp/mmi.socket"), name(0)
+ :buffer(512), connfd(-1), sockname("/tmp/mmi.socket"), name(0)
{
memset(&servaddr, 0, sizeof(struct sockaddr_un));
servaddr.sun_family = AF_UNIX;
else if (listen(listenfd, 0) == -1)
eDebug("[eSocketMMIHandler] listen (%m)");
else {
- listensn = new eSocketNotifier( eApp, listenfd, POLLIN );
+ listensn = eSocketNotifier::create( eApp, listenfd, POLLIN );
listensn->start();
CONNECT( listensn->activated, eSocketMMIHandler::listenDataAvail );
eDebug("[eSocketMMIHandler] created successfully");
else if (fcntl(connfd, F_SETFL, val | O_NONBLOCK) == -1)
eDebug("[eSocketMMIHandler] F_SETFL (%m)");
else {
- connsn = new eSocketNotifier( eApp, connfd, POLLIN|POLLHUP|POLLERR );
+ connsn = eSocketNotifier::create( eApp, connfd, POLLIN|POLLHUP|POLLERR );
CONNECT( connsn->activated, eSocketMMIHandler::connDataAvail );
return;
}
close(connfd);
connfd=-1;
}
- if ( connsn )
- {
- delete connsn;
- connsn=0;
- }
+ connsn=0;
if ( name )
{
delete [] name;
eSocketMMIHandler::~eSocketMMIHandler()
{
closeConn();
- delete listensn;
unlink(sockname);
}
eIOBuffer buffer;
int listenfd, connfd, clilen;
struct sockaddr_un servaddr;
- eSocketNotifier *listensn, *connsn;
+ ePtr<eSocketNotifier> listensn, connsn;
void listenDataAvail(int what);
void connDataAvail(int what);
void closeConn();
#include <lib/python/connections.h>
PSignal::PSignal()
- :m_destroyed(0)
{
}
PSignal::~PSignal()
{
- if (m_destroyed)
- *m_destroyed = true;
Py_XDECREF(m_list);
}
}
}
-PyObject *PSignal::get(bool steal)
+PyObject *PSignal::get()
{
- if (!steal) {
- if (!m_list)
- m_list = PyList_New(0);
- Py_INCREF(m_list);
+ if (!m_list)
+ m_list = PyList_New(0);
+ Py_INCREF(m_list);
+ return m_list;
+}
+
+PyObject *PSignal::getSteal(bool clear)
+{
+ if (clear)
+ {
+ ePyObject ret = m_list;
+ m_list = (PyObject*)0;
+ return ret;
}
return m_list;
}
{
protected:
ePyObject m_list;
- bool *m_destroyed;
public:
PSignal();
~PSignal();
void callPython(SWIG_PYOBJECT(ePyObject) tuple);
- PyObject *get(bool steal=false);
+#ifndef SWIG
+ PyObject *getSteal(bool clear=false);
+#endif
+ PyObject *get();
};
inline PyObject *PyFrom(int v)
public:
R operator()()
{
- bool destroyed=false;
- m_destroyed = &destroyed;
if (m_list)
{
PyObject *pArgs = PyTuple_New(0);
callPython(pArgs);
Org_Py_DECREF(pArgs);
}
- if (!destroyed) {
- m_destroyed = 0;
- return Signal0<R>::operator()();
- }
+ return Signal0<R>::operator()();
}
};
public:
R operator()(V0 a0)
{
- bool destroyed=false;
- m_destroyed = &destroyed;
if (m_list)
{
PyObject *pArgs = PyTuple_New(1);
callPython(pArgs);
Org_Py_DECREF(pArgs);
}
- if (!destroyed) {
- m_destroyed = 0;
- return Signal1<R,V0>::operator()(a0);
- }
+ return Signal1<R,V0>::operator()(a0);
}
};
public:
R operator()(V0 a0, V1 a1)
{
- bool destroyed=false;
- m_destroyed = &destroyed;
if (m_list)
{
PyObject *pArgs = PyTuple_New(2);
callPython(pArgs);
Org_Py_DECREF(pArgs);
}
- if (!destroyed) {
- m_destroyed = 0;
- return Signal2<R,V0,V1>::operator()(a0, a1);
- }
+ return Signal2<R,V0,V1>::operator()(a0, a1);
}
};