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()) {
141 std::cerr <<
"in CPyCppyy::MemoryRegulater, unexpected object of type: "
142 <<
Py_TYPE(pyobj)->tp_name << std::endl;
152 PyObject_ClearWeakRefs((
PyObject*)pyobj);
153 ((
PyObject*)pyobj)->ob_refcnt = refcnt;
178 if (!(pyobj && cppobj))
182 auto res = registerHook(cppobj, pyobj->
ObjectIsA(
false));
183 if (!res.second)
return res.first;
192 const auto& res = cppobjs->insert(std::make_pair(cppobj, (
PyObject*)pyobj));
195 (*cppobjs)[cppobj] = (
PyObject*)pyobj;
206 if (!(pyobj && pyclass))
213 if (unregisterHook) {
214 auto res = unregisterHook(cppobj, ((
CPPClass*)pyclass)->fCppType);
215 if (!res.second)
return res.first;
223 if (cppobjs->erase(cppobj)) {
235 if (!(cppobj && pyclass))
242 CppToPyMap_t::iterator ppo = cppobjs->find(cppobj);
243 if (ppo != cppobjs->end()) {
244 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