Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
CPPInstance.cxx File Reference
#include "cpyrt.h"
#include "CPPInstance.h"
#include "CPPOverload.h"
#include "CPPScope.h"
#include "Compatibility.h"
#include "MemoryRegulator.h"
#include "ProxyWrappers.h"
#include "PyStrings.h"
#include "TypeManip.h"
#include "Utility.h"
#include "cppjit_interop.h"
#include "cpyrt/DispatchPtr.h"
#include <algorithm>
#include <sstream>
Include dependency graph for CPPInstance.cxx:

Namespaces

namespace  cppjit
 
namespace  cppjit::cpyrt
 

Macros

#define ARRAY_SIZE(pyobj)   ((ExtendedData*)((pyobj)->fObject))->fArraySize
 
#define CPYRT_ASSOCIATIVE_OPERATOR_STUB(name, op, lmeth, rmeth)
 
#define CPYRT_OPERATOR_STUB(name, op, ometh)
 
#define CPYRT_ORDERED_OPERATOR_STUB(op, ometh, label)
 
#define CPYRT_STUB_BODY(name, op)
 
#define CPYRT_UNARY_OPERATOR(name, op, label)
 
#define DATA_CACHE(pyobj)   ((ExtendedData*)((pyobj)->fObject))->fDatamemberCache
 
#define DISPATCHPTR(pyobj)   ((ExtendedData*)((pyobj)->fObject))->fDispatchPtr
 
#define EXT_OBJECT(pyobj)   ((ExtendedData*)((pyobj)->fObject))->fObject
 
#define SMART_CLS(pyobj)   ((ExtendedData*)((pyobj)->fObject))->fSmartClass
 
#define SMART_TYPE(pyobj)   SMART_CLS(pyobj)->fCppType
 

Functions

static void * cppjit::cpyrt::cast_actual (void *obj)
 
static Py_hash_t cppjit::cpyrt::cpyrt_PyLong_AsHash_t (PyObject *obj)
 
static PyObject * cppjit::cpyrt::eqneq_binop (CPPClass *klass, PyObject *self, PyObject *obj, int op)
 
static PyObject * cppjit::cpyrt::op_add_stub (PyObject *left, PyObject *right)
 
static int cppjit::cpyrt::op_clear (CPPInstance *pyobj)
 
static void cppjit::cpyrt::op_dealloc (CPPInstance *pyobj)
 
static PyObject * cppjit::cpyrt::op_destruct (CPPInstance *self)
 
static PyObject * cppjit::cpyrt::op_dispatch (PyObject *self, PyObject *args, PyObject *)
 
static PyObject * cppjit::cpyrt::op_div_stub (PyObject *left, PyObject *right)
 
static PyObject * cppjit::cpyrt::op_get_smartptr (CPPInstance *self)
 
static PyObject * cppjit::cpyrt::op_getownership (CPPInstance *pyobj, void *)
 
static Py_hash_t cppjit::cpyrt::op_hash (CPPInstance *self)
 
static PyObject * cppjit::cpyrt::op_invert_stub (PyObject *pyobj)
 
static PyObject * cppjit::cpyrt::op_item (CPPInstance *self, Py_ssize_t idx)
 
static PyObject * cppjit::cpyrt::op_mul_stub (PyObject *left, PyObject *right)
 
static PyObject * cppjit::cpyrt::op_neg_stub (PyObject *pyobj)
 
static CPPInstance * cppjit::cpyrt::op_new (PyTypeObject *subtype, PyObject *, PyObject *)
 
static int cppjit::cpyrt::op_nonzero (CPPInstance *self)
 
static PyObject * cppjit::cpyrt::op_pos_stub (PyObject *pyobj)
 
PyObject * cppjit::cpyrt::op_reduce (PyObject *self, PyObject *args)
 
static PyObject * cppjit::cpyrt::op_repr (CPPInstance *self)
 
static PyObject * cppjit::cpyrt::op_reshape (CPPInstance *self, PyObject *shape)
 
static PyObject * cppjit::cpyrt::op_richcompare (CPPInstance *self, PyObject *other, int op)
 
static int cppjit::cpyrt::op_setownership (CPPInstance *pyobj, PyObject *value, void *)
 
static PyObject * cppjit::cpyrt::op_str (CPPInstance *self)
 
static PyObject * cppjit::cpyrt::op_str_internal (PyObject *pyobj, PyObject *lshift, bool isBound)
 
static PyObject * cppjit::cpyrt::op_sub_stub (PyObject *left, PyObject *right)
 
static int cppjit::cpyrt::op_traverse (CPPInstance *, visitproc, void *)
 
static bool cppjit::cpyrt::ScopeFlagCheck (CPPInstance *self, CPPScope::EFlags flag)
 
static void cppjit::cpyrt::ScopeFlagSet (CPPInstance *self, CPPScope::EFlags flag)
 

Variables

PyTypeObject cppjit::cpyrt::CPPInstance_Type
 
static PyNumberMethods cppjit::cpyrt::op_as_number
 
static PySequenceMethods cppjit::cpyrt::op_as_sequence
 
static PyGetSetDef cppjit::cpyrt::op_getset []
 
static PyMethodDef cppjit::cpyrt::op_methods []
 

Macro Definition Documentation

◆ ARRAY_SIZE

#define ARRAY_SIZE ( pyobj)    ((ExtendedData*)((pyobj)->fObject))->fArraySize

Definition at line 88 of file CPPInstance.cxx.

◆ CPYRT_ASSOCIATIVE_OPERATOR_STUB

#define CPYRT_ASSOCIATIVE_OPERATOR_STUB ( name,
op,
lmeth,
rmeth )
Value:
static PyObject* op_##name##_stub(PyObject* left, PyObject* right) { \
/* placeholder to lazily install and forward do '(l/r)meth' if available \
*/ \
CPPClass* klass; \
PyObject** pmeth; \
PyObject *cppobj, *other; \
if (CPPInstance_Check(left)) { \
klass = (CPPClass*)Py_TYPE(left); \
if (!klass->fOperators) \
klass->fOperators = new Utility::PyOperators{}; \
pmeth = &lmeth; \
cppobj = left; \
other = right; \
} else if (CPPInstance_Check(right)) { \
klass = (CPPClass*)Py_TYPE(right); \
if (!klass->fOperators) \
klass->fOperators = new Utility::PyOperators{}; \
pmeth = &rmeth; \
cppobj = right; \
other = left; \
} else { \
PyErr_SetString(PyExc_NotImplementedError, ""); \
return nullptr; \
} \
PyObject*& meth = *pmeth; \
CPYRT_STUB_BODY(name, op) \
}
_object PyObject
char name[80]
Definition TGX11.cxx:142
Utility::PyOperators * fOperators
Definition CPPScope.h:68
CPPScope CPPClass
Definition CPPScope.h:75
bool CPPInstance_Check(T *object)

Definition at line 1041 of file CPPInstance.cxx.

◆ CPYRT_OPERATOR_STUB

#define CPYRT_OPERATOR_STUB ( name,
op,
ometh )
Value:
static PyObject* op_##name##_stub(PyObject* left, PyObject* right) { \
/* placeholder to lazily install and forward to 'ometh' if available */ \
CPPClass* klass = (CPPClass*)Py_TYPE(left); \
if (!klass->fOperators) \
klass->fOperators = new Utility::PyOperators{}; \
PyObject*& meth = ometh; \
PyObject *cppobj = left, *other = right; \
CPYRT_STUB_BODY(name, op) \
}

Definition at line 1030 of file CPPInstance.cxx.

◆ CPYRT_ORDERED_OPERATOR_STUB

#define CPYRT_ORDERED_OPERATOR_STUB ( op,
ometh,
label )
Value:
if (!ometh) { \
PyCallable* pyfunc = \
Utility::FindBinaryOperator((PyObject*)self, other, #op); \
if (pyfunc) \
ometh = (PyObject*)CPPOverload_New(#label, pyfunc); \
} \
meth = ometh;

Definition at line 611 of file CPPInstance.cxx.

◆ CPYRT_STUB_BODY

#define CPYRT_STUB_BODY ( name,
op )
Value:
bool previously_resolved_overload = (bool)meth; \
if (!meth) { \
PyErr_Clear(); \
PyCallable* pyfunc = Utility::FindBinaryOperator(left, right, #op); \
if (pyfunc) \
meth = (PyObject*)CPPOverload_New(#name, pyfunc); \
else { \
PyErr_SetString(PyExc_NotImplementedError, ""); \
return nullptr; \
} \
} \
PyObject* res = PyObject_CallFunctionObjArgs(meth, cppobj, other, nullptr); \
if (!res && previously_resolved_overload) { \
/* try again, in case (left, right) are different types than before */ \
PyErr_Clear(); \
PyCallable* pyfunc = Utility::FindBinaryOperator(left, right, #op); \
if (pyfunc) \
((CPPOverload*&)meth)->AdoptMethod(pyfunc); \
else { \
PyErr_SetString(PyExc_NotImplementedError, ""); \
return nullptr; \
} \
/* use same overload with newly added function */ \
res = PyObject_CallFunctionObjArgs(meth, cppobj, other, nullptr); \
} \
return res;

Definition at line 1002 of file CPPInstance.cxx.

◆ CPYRT_UNARY_OPERATOR

#define CPYRT_UNARY_OPERATOR ( name,
op,
label )
Value:
static PyObject* op_##name##_stub(PyObject* pyobj) { \
/* placeholder to lazily install unary operators */ \
PyCallable* pyfunc = \
Utility::FindUnaryOperator((PyObject*)Py_TYPE(pyobj), #op); \
if (pyfunc && \
Utility::AddToClass((PyObject*)Py_TYPE(pyobj), #label, pyfunc)) \
return PyObject_CallMethod(pyobj, (char*)#label, nullptr); \
PyErr_SetString(PyExc_NotImplementedError, ""); \
return nullptr; \
}

Definition at line 1069 of file CPPInstance.cxx.

◆ DATA_CACHE

#define DATA_CACHE ( pyobj)    ((ExtendedData*)((pyobj)->fObject))->fDatamemberCache

Definition at line 84 of file CPPInstance.cxx.

◆ DISPATCHPTR

#define DISPATCHPTR ( pyobj)    ((ExtendedData*)((pyobj)->fObject))->fDispatchPtr

Definition at line 87 of file CPPInstance.cxx.

◆ EXT_OBJECT

#define EXT_OBJECT ( pyobj)    ((ExtendedData*)((pyobj)->fObject))->fObject

Definition at line 83 of file CPPInstance.cxx.

◆ SMART_CLS

#define SMART_CLS ( pyobj)    ((ExtendedData*)((pyobj)->fObject))->fSmartClass

Definition at line 85 of file CPPInstance.cxx.

◆ SMART_TYPE

#define SMART_TYPE ( pyobj)    SMART_CLS(pyobj)->fCppType

Definition at line 86 of file CPPInstance.cxx.