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*);
407 (
char*)
"call the C++ destructor"},
409 (
char*)
"dispatch to selected overload"},
411 (
char*)
"get associated smart pointer, if any"},
413 (
char*)
"cast pointer to 1D array type"},
414 {(
char*)
nullptr,
nullptr, 0,
nullptr}
423 pyobj->fObject =
nullptr;
452 using namespace Utility;
469 if (!
klass->fOperators)
470 klass->fOperators =
new PyOperators{};
528 if (
offset != -1) address = (
void*)((intptr_t)address +
offset);
535#define CPYCPPYY_ORDERED_OPERATOR_STUB(op, ometh, label) \
537 PyCallable* pyfunc = Utility::FindBinaryOperator((PyObject*)self, other, #op);\
539 ometh = (PyObject*)CPPOverload_New(#label, pyfunc); \
641 if (
self->IsSmart()) {
644 const_cast<char*
>(
"<%s.%s object at %p held by %s at %p>"),
661 if (
sizeof(
unsigned long) >=
sizeof(
size_t))
670 if (
klass->fOperators &&
klass->fOperators->fHash) {
712 std::ostringstream s;
715#if PY_VERSION_HEX >= 0x03000000
727#if PY_VERSION_HEX >= 0x03000000
759 if (!
self->GetObject())
809 static PyObject* printValue =
nullptr;
819 printValue =
nullptr;
849 if (!
pv.empty() &&
pv.find(
"@0x") == std::string::npos)
891 (
char*)
"If true, python manages the life time of this object",
nullptr},
892 {(
char*)
nullptr,
nullptr,
nullptr,
nullptr,
nullptr}
897#define CPYCPPYY_STUB_BODY(name, op) \
898 bool previously_resolved_overload = (bool)meth; \
901 PyCallable* pyfunc = Utility::FindBinaryOperator(left, right, #op); \
902 if (pyfunc) meth = (PyObject*)CPPOverload_New(#name, pyfunc); \
904 PyErr_SetString(PyExc_NotImplementedError, ""); \
908 PyObject* res = PyObject_CallFunctionObjArgs(meth, cppobj, other, nullptr);\
909 if (!res && previously_resolved_overload) { \
912 PyCallable* pyfunc = Utility::FindBinaryOperator(left, right, #op); \
913 if (pyfunc) ((CPPOverload*&)meth)->AdoptMethod(pyfunc); \
915 PyErr_SetString(PyExc_NotImplementedError, ""); \
919 res = PyObject_CallFunctionObjArgs(meth, cppobj, other, nullptr); \
924#define CPYCPPYY_OPERATOR_STUB(name, op, ometh) \
925static PyObject* op_##name##_stub(PyObject* left, PyObject* right) \
928 CPPClass* klass = (CPPClass*)Py_TYPE(left); \
929 if (!klass->fOperators) klass->fOperators = new Utility::PyOperators{}; \
930 PyObject*& meth = ometh; \
931 PyObject *cppobj = left, *other = right; \
932 CPYCPPYY_STUB_BODY(name, op) \
935#define CPYCPPYY_ASSOCIATIVE_OPERATOR_STUB(name, op, lmeth, rmeth) \
936static PyObject* op_##name##_stub(PyObject* left, PyObject* right) \
939 CPPClass* klass; PyObject** pmeth; \
940 PyObject *cppobj, *other; \
941 if (CPPInstance_Check(left)) { \
942 klass = (CPPClass*)Py_TYPE(left); \
943 if (!klass->fOperators) klass->fOperators = new Utility::PyOperators{};\
944 pmeth = &lmeth; cppobj = left; other = right; \
945 } else if (CPPInstance_Check(right)) { \
946 klass = (CPPClass*)Py_TYPE(right); \
947 if (!klass->fOperators) klass->fOperators = new Utility::PyOperators{};\
948 pmeth = &rmeth; cppobj = right; other = left; \
950 PyErr_SetString(PyExc_NotImplementedError, ""); \
953 PyObject*& meth = *pmeth; \
954 CPYCPPYY_STUB_BODY(name, op) \
957#define CPYCPPYY_UNARY_OPERATOR(name, op, label) \
958static PyObject* op_##name##_stub(PyObject* pyobj) \
961 PyCallable* pyfunc = Utility::FindUnaryOperator((PyObject*)Py_TYPE(pyobj), #op);\
962 if (pyfunc && Utility::AddToClass((PyObject*)Py_TYPE(pyobj), #label, pyfunc))\
963 return PyObject_CallMethod(pyobj, (char*)#label, nullptr); \
964 PyErr_SetString(PyExc_NotImplementedError, ""); \
997#if PY_VERSION_HEX < 0x03000000
1003#if PY_VERSION_HEX < 0x03000000
1010#if PY_VERSION_HEX < 0x03000000
1020#if PY_VERSION_HEX >= 0x02020000
1022#if PY_VERSION_HEX < 0x03000000
1043 (
char*)
"cppyy.CPPInstance",
1065 (
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)
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
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)