4 #ifndef PYROOT_METHODPROXY_H
5 #define PYROOT_METHODPROXY_H
23 typedef std::map< Long_t, Int_t > DispatchMap_t;
24 typedef std::vector< PyCallable* > Methods_t;
27 MethodInfo_t() : fFlags( TCallContext::kNone ) { fRefCount =
new int(1); }
31 MethodProxy::DispatchMap_t fDispatchMap;
32 MethodProxy::Methods_t fMethods;
38 MethodInfo_t(
const MethodInfo_t& ) =
delete;
39 MethodInfo_t& operator=(
const MethodInfo_t& ) =
delete;
43 void Set(
const std::string& name, std::vector< PyCallable* >& methods );
45 const std::string& GetName()
const {
return fMethodInfo->fName; }
46 void AddMethod( PyCallable* pc );
47 void AddMethod( MethodProxy* meth );
52 MethodInfo_t* fMethodInfo;
60 R__EXTERN PyTypeObject MethodProxy_Type;
62 template<
typename T >
63 inline Bool_t MethodProxy_Check( T*
object )
65 return object && PyObject_TypeCheck(
object, &MethodProxy_Type );
68 template<
typename T >
69 inline Bool_t MethodProxy_CheckExact( T*
object )
71 return object && Py_TYPE(
object) == &MethodProxy_Type;
75 inline MethodProxy* MethodProxy_New(
76 const std::string& name, std::vector< PyCallable* >& methods )
79 MethodProxy* pymeth = (MethodProxy*)MethodProxy_Type.tp_new( &MethodProxy_Type, 0, 0 );
80 pymeth->Set( name, methods );
84 inline MethodProxy* MethodProxy_New(
const std::string& name, PyCallable* method )
87 std::vector< PyCallable* > p;
88 p.push_back( method );
89 return MethodProxy_New( name, p );
94 #endif // !PYROOT_METHODPROXY_H