30#if defined(__GNUC__) && (__GNUC__ >= 5 || (__GNUC__ >= 4 && ((__GNUC_MINOR__ == 2 && __GNUC_PATCHLEVEL__ >= 1) || (__GNUC_MINOR__ >= 3)))) && !__INTEL_COMPILER
31#pragma GCC diagnostic ignored "-Wstrict-aliasing"
38struct InitCPyCppyy_NoneType_t {
39 InitCPyCppyy_NoneType_t() {
54 CPyCppyy_NoneType.tp_richcompare = (richcmpfunc)&InitCPyCppyy_NoneType_t::RichCompare;
55#if PY_VERSION_HEX < 0x03000000
66 static void DeAlloc(
PyObject* pyobj) {
Py_TYPE(pyobj)->tp_free(pyobj); }
67 static int PtrHash(
PyObject* pyobj) {
return (
int)ptrdiff_t(pyobj); }
70 return PyObject_RichCompare(other, Py_None, opid);
74#if PY_VERSION_HEX < 0x03000000
75 return PyObject_Compare(other, Py_None);
78 return !PyObject_RichCompareBool(other, Py_None, Py_EQ);
94 static InitCPyCppyy_NoneType_t initCPyCppyy_NoneType;
119 CppToPyMap_t::iterator ppo = cppobjs->find(cppobj);
121 if (ppo != cppobjs->end()) {
138#ifdef Py_TPFLAGS_MANAGED_DICT
144 std::cerr <<
"in CPyCppyy::MemoryRegulater, unexpected object of type: "
145 <<
Py_TYPE(pyobj)->tp_name << std::endl;
155 PyObject_ClearWeakRefs((
PyObject*)pyobj);
156 ((
PyObject*)pyobj)->ob_refcnt = refcnt;
181 if (!(pyobj && cppobj))
185 auto res = registerHook(cppobj, pyobj->
ObjectIsA(
false));
186 if (!res.second)
return res.first;
193 CppToPyMap_t::iterator ppo = cppobjs->find(cppobj);
194 if (ppo == cppobjs->end()) {
195 cppobjs->insert(std::make_pair(cppobj, (
PyObject*)pyobj));
207 if (!(pyobj && pyclass))
214 if (unregisterHook) {
215 auto res = unregisterHook(cppobj, ((
CPPClass*)pyclass)->fCppType);
216 if (!res.second)
return res.first;
224 if (cppobjs->erase(cppobj)) {
236 if (!(cppobj && pyclass))
243 CppToPyMap_t::iterator ppo = cppobjs->find(cppobj);
244 if (ppo != cppobjs->end()) {
245 Py_INCREF(ppo->second);
static Py_ssize_t AlwaysNullLength(PyObject *)
static PyMappingMethods CPyCppyy_NoneType_mapping
static PyTypeObject CPyCppyy_NoneType
Int_t Compare(const void *item1, const void *item2)
Cppyy::TCppType_t ObjectIsA(bool check_smart=true) const
static MemHook_t unregisterHook
static bool RecursiveRemove(Cppyy::TCppObject_t cppobj, Cppyy::TCppType_t klass)
static PyObject * RetrievePyObject(Cppyy::TCppObject_t cppobj, PyObject *pyclass)
static bool RegisterPyObject(CPPInstance *pyobj, void *cppobj)
static MemHook_t registerHook
static void SetUnregisterHook(MemHook_t h)
static void SetRegisterHook(MemHook_t h)
static bool UnregisterPyObject(CPPInstance *pyobj, PyObject *pyclass)
std::map< Cppyy::TCppObject_t, PyObject * > CppToPyMap_t
Type object to hold class reference (this is only semantically a presentation of CPPScope instances,...
PyObject * GetScopeProxy(Cppyy::TCppScope_t)
bool CPPScope_Check(T *object)
void op_dealloc_nofree(CPPInstance *)
std::function< std::pair< bool, bool >(Cppyy::TCppObject_t, Cppyy::TCppType_t)> MemHook_t