#include "PyROOT.h"
#include "TPyDispatcher.h"
#include "TObject.h"
#include <stdarg.h>
ClassImp(TPyDispatcher)
TPyDispatcher::TPyDispatcher( PyObject* callable ) : fCallable( 0 )
{
Py_XINCREF( callable );
fCallable = callable;
}
TPyDispatcher::TPyDispatcher( const TPyDispatcher& other ) : TObject ( other )
{
Py_XINCREF( other.fCallable );
fCallable = other.fCallable;
}
TPyDispatcher& TPyDispatcher::operator=( const TPyDispatcher& other )
{
if ( this != &other ) {
this->TObject::operator=( other );
Py_XDECREF( fCallable );
Py_XINCREF( other.fCallable );
fCallable = other.fCallable;
}
return *this;
}
TPyDispatcher::~TPyDispatcher() {
Py_XDECREF( fCallable );
}
PyObject* TPyDispatcher::DispatchVA( const char* format, ... )
{
PyObject* args = 0;
if ( format ) {
va_list va;
va_start( va, format );
args = Py_VaBuildValue( (char*)format, va );
va_end( va );
if ( ! args ) {
PyErr_Print();
return 0;
}
if ( ! PyTuple_Check( args ) ) {
PyObject* t = PyTuple_New( 1 );
PyTuple_SET_ITEM( t, 0, args );
args = t;
}
}
PyObject* result = PyObject_CallObject( fCallable, args );
Py_XDECREF( args );
if ( ! result ) {
PyErr_Print();
return 0;
}
return result;
}
Last change: Wed Jun 25 08:51:34 2008
Last generated: 2008-06-25 08:51
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.