Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
MemoryRegulator.h
Go to the documentation of this file.
1#ifndef CPYRT_MEMORYREGULATOR_H
2#define CPYRT_MEMORYREGULATOR_H
3
4#include "Python.h"
5#include "cppjit_interop.h"
6
7#include <functional>
8#include <utility>
9
10namespace cppjit::cpyrt {
11
12class CPPInstance;
13
14typedef std::function<std::pair<bool, bool>(interop::TCppObject_t,
17
19private:
21
22public:
24
25 // callback from C++-side frameworks
26 static bool RecursiveRemove(interop::TCppObject_t cppobj,
28
29 // called when a new python proxy object is created
30 static bool RegisterPyObject(CPPInstance* pyobj,
32
33 // called when a the python proxy object is about to be garbage collected or
34 // when it is about to delete the proxied C++ object, if owned
35 static bool UnregisterPyObject(CPPInstance* pyobj, PyObject* pyclass);
36
37 // new reference to python object matching cppobj, or 0 on failure
39 PyObject* pyclass);
40
41 // set hooks for custom memory regulation
42 static void SetRegisterHook(MemHook_t h);
43 static void SetUnregisterHook(MemHook_t h);
44};
45
46} // namespace cppjit::cpyrt
47
48#endif // !CPYRT_MEMORYREGULATOR_H
_object PyObject
#define h(i)
Definition RSha256.hxx:106
static bool RegisterPyObject(CPPInstance *pyobj, interop::TCppObject_t cppobj)
static PyObject * RetrievePyObject(interop::TCppObject_t cppobj, PyObject *pyclass)
static bool UnregisterPyObject(CPPInstance *pyobj, PyObject *pyclass)
static void SetRegisterHook(MemHook_t h)
static bool RecursiveRemove(interop::TCppObject_t cppobj, interop::TCppScope_t klass)
static void SetUnregisterHook(MemHook_t h)
std::function< std::pair< bool, bool >(interop::TCppObject_t, interop::TCppScope_t)> MemHook_t
Cpp::ObjectRef TCppObject_t
Definition API.h:43
Cpp::DeclRef TCppScope_t
Definition API.h:41