53 ExtendedData() : fObject(nullptr), fSmartClass(nullptr), fDispatchPtr(nullptr), fArraySize(0) {}
55 for (
auto& pc : fDatamemberCache)
57 fDatamemberCache.clear();
79#define EXT_OBJECT(pyobj) ((ExtendedData*)((pyobj)->fObject))->fObject
80#define DATA_CACHE(pyobj) ((ExtendedData*)((pyobj)->fObject))->fDatamemberCache
81#define SMART_CLS(pyobj) ((ExtendedData*)((pyobj)->fObject))->fSmartClass
82#define SMART_TYPE(pyobj) SMART_CLS(pyobj)->fCppType
83#define DISPATCHPTR(pyobj) ((ExtendedData*)((pyobj)->fObject))->fDispatchPtr
84#define ARRAY_SIZE(pyobj) ((ExtendedData*)((pyobj)->fObject))->fArraySize
90 fObject = (
void*)
new ExtendedData{};
226 if (
pyobj->IsExtended())
delete (ExtendedData*)
pyobj->fObject;
244 if (!
self->GetObject())
308 if (!
self->IsSmart()) {
376 unsigned flags = 0;
size_t sz =
sizeof(
void*);
422 (
char*)
"call the C++ destructor"},
424 (
char*)
"dispatch to selected overload"},
426 (
char*)
"get associated smart pointer, if any"},
428 (
char*)
"reduce method for serialization"},
430 (
char*)
"cast pointer to 1D array type"},
431 {(
char*)
nullptr,
nullptr, 0,
nullptr}
440 pyobj->fObject =
nullptr;
469 using namespace Utility;
486 if (!
klass->fOperators)
487 klass->fOperators =
new PyOperators{};
545 if (
offset != -1) address = (
void*)((intptr_t)address +
offset);
552#define CPYCPPYY_ORDERED_OPERATOR_STUB(op, ometh, label) \
554 PyCallable* pyfunc = Utility::FindBinaryOperator((PyObject*)self, other, #op);\
556 ometh = (PyObject*)CPPOverload_New(#label, pyfunc); \
658 if (
self->IsSmart()) {
661 const_cast<char*
>(
"<%s.%s object at %p held by %s at %p>"),
678 if (
sizeof(
unsigned long) >=
sizeof(
size_t))
687 if (
klass->fOperators &&
klass->fOperators->fHash) {
729 std::ostringstream s;
732#if PY_VERSION_HEX >= 0x03000000
744#if PY_VERSION_HEX >= 0x03000000
776 if (!
self->GetObject())
826 static PyObject* printValue =
nullptr;
836 printValue =
nullptr;
866 if (!
pv.empty() &&
pv.find(
"@0x") == std::string::npos)
908 (
char*)
"If true, python manages the life time of this object",
nullptr},
909 {(
char*)
nullptr,
nullptr,
nullptr,
nullptr,
nullptr}
914#define CPYCPPYY_STUB_BODY(name, op) \
915 bool previously_resolved_overload = (bool)meth; \
918 PyCallable* pyfunc = Utility::FindBinaryOperator(left, right, #op); \
919 if (pyfunc) meth = (PyObject*)CPPOverload_New(#name, pyfunc); \
921 PyErr_SetString(PyExc_NotImplementedError, ""); \
925 PyObject* res = PyObject_CallFunctionObjArgs(meth, cppobj, other, nullptr);\
926 if (!res && previously_resolved_overload) { \
929 PyCallable* pyfunc = Utility::FindBinaryOperator(left, right, #op); \
930 if (pyfunc) ((CPPOverload*&)meth)->AdoptMethod(pyfunc); \
932 PyErr_SetString(PyExc_NotImplementedError, ""); \
936 res = PyObject_CallFunctionObjArgs(meth, cppobj, other, nullptr); \
941#define CPYCPPYY_OPERATOR_STUB(name, op, ometh) \
942static PyObject* op_##name##_stub(PyObject* left, PyObject* right) \
945 CPPClass* klass = (CPPClass*)Py_TYPE(left); \
946 if (!klass->fOperators) klass->fOperators = new Utility::PyOperators{}; \
947 PyObject*& meth = ometh; \
948 PyObject *cppobj = left, *other = right; \
949 CPYCPPYY_STUB_BODY(name, op) \
952#define CPYCPPYY_ASSOCIATIVE_OPERATOR_STUB(name, op, lmeth, rmeth) \
953static PyObject* op_##name##_stub(PyObject* left, PyObject* right) \
956 CPPClass* klass; PyObject** pmeth; \
957 PyObject *cppobj, *other; \
958 if (CPPInstance_Check(left)) { \
959 klass = (CPPClass*)Py_TYPE(left); \
960 if (!klass->fOperators) klass->fOperators = new Utility::PyOperators{};\
961 pmeth = &lmeth; cppobj = left; other = right; \
962 } else if (CPPInstance_Check(right)) { \
963 klass = (CPPClass*)Py_TYPE(right); \
964 if (!klass->fOperators) klass->fOperators = new Utility::PyOperators{};\
965 pmeth = &rmeth; cppobj = right; other = left; \
967 PyErr_SetString(PyExc_NotImplementedError, ""); \
970 PyObject*& meth = *pmeth; \
971 CPYCPPYY_STUB_BODY(name, op) \
974#define CPYCPPYY_UNARY_OPERATOR(name, op, label) \
975static PyObject* op_##name##_stub(PyObject* pyobj) \
978 PyCallable* pyfunc = Utility::FindUnaryOperator((PyObject*)Py_TYPE(pyobj), #op);\
979 if (pyfunc && Utility::AddToClass((PyObject*)Py_TYPE(pyobj), #label, pyfunc))\
980 return PyObject_CallMethod(pyobj, (char*)#label, nullptr); \
981 PyErr_SetString(PyExc_NotImplementedError, ""); \
1014#if PY_VERSION_HEX < 0x03000000
1020#if PY_VERSION_HEX < 0x03000000
1027#if PY_VERSION_HEX < 0x03000000
1037#if PY_VERSION_HEX >= 0x02020000
1039#if PY_VERSION_HEX < 0x03000000
1060 (
char*)
"cppyy.CPPInstance",
1082 (
char*)
"cppyy object proxy (internal)",
#define CPYCPPYY_UNARY_OPERATOR(name, op, label)
#define EXT_OBJECT(pyobj)
#define SMART_TYPE(pyobj)
#define CPYCPPYY_OPERATOR_STUB(name, op, ometh)
#define DATA_CACHE(pyobj)
#define DISPATCHPTR(pyobj)
#define CPYCPPYY_ORDERED_OPERATOR_STUB(op, ometh, label)
#define CPYCPPYY_ASSOCIATIVE_OPERATOR_STUB(name, op, lmeth, rmeth)
#define CPyCppyy_PyText_AsString
#define CPyCppyy_PyText_FromFormat
#define CPyCppyy_PyText_Type
#define CPyCppyy_PyText_FromString
#define PyVarObject_HEAD_INIT(type, size)
std::ios_base::fmtflags fFlags
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t target
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
#define ARRAY_SIZE(array)
static std::function< PyObject *(PyObject *)> ReduceMethod)()
Cppyy::TCppType_t GetSmartIsA() const
void CastToArray(Py_ssize_t sz)
CPPInstance * Copy(void *cppinst, PyTypeObject *target=nullptr)
CI_DatamemberCache_t & GetDatamemberCache()
void SetSmart(PyObject *smart_type)
PyObject_HEAD void * fObject
void * GetExtendedObject()
void SetDispatchPtr(void *)
static bool RegisterPyObject(CPPInstance *pyobj, void *cppobj)
static bool UnregisterPyObject(CPPInstance *pyobj, PyObject *pyclass)
std::string extract_namespace(const std::string &name)
PyCallable * FindBinaryOperator(PyObject *left, PyObject *right, const char *op, Cppyy::TCppScope_t scope=0)
bool AddToClass(PyObject *pyclass, const char *label, PyCFunction cfunc, int flags=METH_VARARGS)
std::string ClassName(PyObject *pyobj)
CPPOverload * CPPOverload_New(const std::string &name, std::vector< PyCallable * > &methods)
PyTypeObject CPPInstance_Type
static PyObject * op_str_internal(PyObject *pyobj, PyObject *lshift, bool isBound)
static PyObject * op_div_stub(PyObject *left, PyObject *right)
static void ScopeFlagSet(CPPInstance *self, CPPScope::EFlags flag)
static Py_hash_t CPyCppyy_PyLong_AsHash_t(PyObject *obj)
PyObject * CreateScopeProxy(Cppyy::TCppScope_t, const unsigned flags=0)
static int op_nonzero(CPPInstance *self)
static PyObject * op_mul_stub(PyObject *left, PyObject *right)
static PySequenceMethods op_as_sequence
static PyMethodDef op_methods[]
static PyObject * op_repr(CPPInstance *self)
static PyObject * op_item(CPPInstance *self, Py_ssize_t idx)
PyObject * BindCppObjectNoCast(Cppyy::TCppObject_t object, Cppyy::TCppType_t klass, const unsigned flags=0)
static PyObject * op_richcompare(CPPInstance *self, PyObject *other, int op)
std::vector< std::pair< ptrdiff_t, PyObject * > > CI_DatamemberCache_t
static int op_setownership(CPPInstance *pyobj, PyObject *value, void *)
bool CPPScope_Check(T *object)
static PyObject * eqneq_binop(CPPClass *klass, PyObject *self, PyObject *obj, int op)
static PyObject * op_getownership(CPPInstance *pyobj, void *)
static PyObject * op_neg_stub(PyObject *pyobj)
static int op_clear(CPPInstance *pyobj)
static PyObject * op_sub_stub(PyObject *left, PyObject *right)
void op_dealloc_nofree(CPPInstance *)
bool CPPInstance_Check(T *object)
static PyObject * op_reshape(CPPInstance *self, PyObject *shape)
static PyGetSetDef op_getset[]
PyObject * gNullPtrObject
PyTypeObject CPPOverload_Type
static PyNumberMethods op_as_number
static void * cast_actual(void *obj)
static PyObject * op_str(CPPInstance *self)
static void op_dealloc(CPPInstance *pyobj)
static PyObject * op_pos_stub(PyObject *pyobj)
static PyObject * op_add_stub(PyObject *left, PyObject *right)
static Py_hash_t op_hash(CPPInstance *self)
static PyObject * op_dispatch(PyObject *self, PyObject *args, PyObject *)
static PyObject * op_invert_stub(PyObject *pyobj)
PyTypeObject CPPScope_Type
PyObject * op_reduce(PyObject *self, PyObject *)
static bool ScopeFlagCheck(CPPInstance *self, CPPScope::EFlags flag)
static PyObject * op_get_smartptr(CPPInstance *self)
static CPPInstance * op_new(PyTypeObject *subtype, PyObject *, PyObject *)
static int op_traverse(CPPInstance *, visitproc, void *)
static PyObject * op_destruct(CPPInstance *self)
RPY_EXPORTED ptrdiff_t GetBaseOffset(TCppType_t derived, TCppType_t base, TCppObject_t address, int direction, bool rerror=false)
RPY_EXPORTED size_t SizeOf(TCppType_t klass)
RPY_EXPORTED std::string ToString(TCppType_t klass, TCppObject_t obj)
RPY_EXPORTED void CallDestructor(TCppType_t type, TCppObject_t self)
RPY_EXPORTED void Destruct(TCppType_t type, TCppObject_t instance)
RPY_EXPORTED TCppType_t GetActualClass(TCppType_t klass, TCppObject_t obj)
RPY_EXPORTED std::string GetScopedFinalName(TCppType_t type)
RPY_EXPORTED void Deallocate(TCppType_t type, TCppObject_t instance)
RPY_EXPORTED void * CallR(TCppMethod_t method, TCppObject_t self, size_t nargs, void *args)
RPY_EXPORTED TCppScope_t GetScope(const std::string &scope_name)
RPY_EXPORTED std::string GetFinalName(TCppType_t type)