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()) {
140 std::cerr <<
"in CPyCppyy::MemoryRegulater, unexpected object of type: "
141 <<
Py_TYPE(pyobj)->tp_name << std::endl;
151 PyObject_ClearWeakRefs((
PyObject*)pyobj);
152 ((
PyObject*)pyobj)->ob_refcnt = refcnt;
177 if (!(pyobj && cppobj))
181 auto res = registerHook(cppobj, pyobj->
ObjectIsA(
false));
182 if (!res.second)
return res.first;
189 CppToPyMap_t::iterator ppo = cppobjs->find(cppobj);
190 if (ppo == cppobjs->end()) {
191 cppobjs->insert(std::make_pair(cppobj, (
PyObject*)pyobj));
203 if (!(pyobj && pyclass))
210 if (unregisterHook) {
211 auto res = unregisterHook(cppobj, ((
CPPClass*)pyclass)->fCppType);
212 if (!res.second)
return res.first;
220 if (cppobjs->erase(cppobj)) {
232 if (!(cppobj && pyclass))
239 CppToPyMap_t::iterator ppo = cppobjs->find(cppobj);
240 if (ppo != cppobjs->end()) {
241 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