4#include "structmember.h"
5#if PY_VERSION_HEX >= 0x02050000
6#if PY_VERSION_HEX < 0x030b0000
14#define CO_NOFREE 0x0040
36#ifndef CPPOverload_MAXFREELIST
37#define CPPOverload_MAXFREELIST 32
43class TPythonCallback :
public PyCallable {
62 virtual PyObject* GetSignature(
bool =
true) {
65 virtual PyObject* GetPrototype(
bool =
true) {
72 return GetPrototype();
76 virtual int GetPriority() {
return 100; };
77 virtual bool IsGreedy() {
return false; };
79 virtual int GetMaxArgs() {
return 100; };
83 virtual PyObject* GetArgDefault(
int ,
bool =
true) {
95 virtual PyCallable* Clone() {
return new TPythonCallback(*
this); }
100#if PY_VERSION_HEX >= 0x03080000
157static int PriorityCmp(
const std::pair<int, PyCallable*>& left,
const std::pair<int, PyCallable*>& right)
159 return left.first > right.first;
173static inline PyObject* HandleReturn(
251 if (
pymeth->fMethodInfo->fDoc) {
253 return pymeth->fMethodInfo->fDoc;
271 for (CPPOverload::Methods_t::size_type i = 1; i <
nMethods; ++i) {
284 pymeth->fMethodInfo->fDoc = val;
295 *
pymeth->fMethodInfo->fRefCount += 1;
312 "function %s has no attribute \'im_self\'",
pymeth->fMethodInfo->fName.c_str());
314 }
else if (
pymeth->fSelf != 0) {
331 "function %s has no attribute \'im_class\'",
pymeth->fMethodInfo->fName.c_str());
346#if PY_VERSION_HEX < 0x03000000
347#define CPyCppyy_Py3_UNUSED(name) name
349#define CPyCppyy_Py3_UNUSED(name)
356#if PY_VERSION_HEX < 0x03000000
518 pymeth->fMethodInfo->fFlags &= ~CallContext::kUseStrict;
521 pymeth->fMethodInfo->fFlags &= ~CallContext::kUseHeuristics;
524 "expected kMemoryStrict or kMemoryHeuristics as value for __mempolicy__");
533#define CPPYY_BOOLEAN_PROPERTY(name, flag, label) \
534static PyObject* mp_get##name(CPPOverload* pymeth, void*) { \
535 if (pymeth->fMethodInfo->fFlags & flag) { \
541static int mp_set##name(CPPOverload* pymeth, PyObject* value, void*) { \
542 return set_flag(pymeth, value, flag, label); \
560 return methods[0]->GetTypeName();
568 {(
char*)
"__name__", (
getter)
mp_name,
nullptr,
nullptr,
nullptr},
584 {(
char*)
"func_name", (
getter)
mp_name,
nullptr,
nullptr,
nullptr},
589 (
char*)
"For ownership rules of result: if true, objects are python-owned",
nullptr},
591 (
char*)
"For argument ownership rules: like global, either heuristic or strict",
nullptr},
593 (
char*)
"If true, set a lifeline from the return value onto self",
nullptr},
595 (
char*)
"If true, releases GIL on call into C++",
nullptr},
597 (
char*)
"not implemented",
nullptr},
599 (
char*)
"If true, turn signals into Python exceptions",
nullptr},
604 {(
char*)
nullptr,
nullptr,
nullptr,
nullptr,
nullptr}
608#if PY_VERSION_HEX >= 0x03080000
615#if PY_VERSION_HEX < 0x03080000
672 ctxt.fFlags &= ~CallContext::kAllowImplicit;
682 std::vector<std::pair<int, PyCallable*>>
pm;
pm.reserve(
methods.size());
684 pm.emplace_back(ptr->GetPriority(), ptr);
686 for (CPPOverload::Methods_t::size_type i = 0; i <
methods.size(); ++i)
691 std::vector<Utility::PyError_t>
errors;
693 for (
int stage = 0; stage < 2; ++stage) {
695 for (CPPOverload::Methods_t::size_type i = 0; i <
nMethods; ++i) {
745 ctxt.fFlags &= ~CallContext::kHaveImplicit;
760 "none of the %d overloaded methods succeeded. Full details:", (
int)
nMethods);
771 std::ostringstream s;
772 s <<
"<C++ overload \"" <<
cppinst->fMethodInfo->fName <<
"\" at " << (
void*)
cppinst <<
">";
790#if PY_VERSION_HEX < 0x03080000
814 *
pymeth->fMethodInfo->fRefCount += 1;
817#if PY_VERSION_HEX >= 0x03080000
858 pymeth->fMethodInfo =
new CPPOverload::MethodInfo_t;
872 if (--(*
pymeth->fMethodInfo->fRefCount) <= 0) {
873 delete pymeth->fMethodInfo;
933 const char*
sigarg =
nullptr;
954 TPythonCallback* cb =
new TPythonCallback(
new_overload);
967 return pymeth->fMethodInfo->fMethods[0]->Reflex(request,
format);
973 (
char*)
"select overload for dispatch" },
975 (
char*)
"add a new overload" },
977 (
char*)
"C++ overload reflection information" },
978 {(
char*)
nullptr,
nullptr, 0,
nullptr }
987 (
char*)
"cppyy.CPPOverload",
1014#if PY_VERSION_HEX >= 0x03080000
1018 (
char*)
"cppyy method proxy (internal)",
1043#if PY_VERSION_HEX >= 0x02030000
1046#if PY_VERSION_HEX >= 0x02060000
1049#if PY_VERSION_HEX >= 0x03040000
1052#if PY_VERSION_HEX >= 0x03080000
1055#if PY_VERSION_HEX >= 0x030c0000
1058#if PY_VERSION_HEX >= 0x030d0000
1075 if (
name ==
"__init__")
1080 name.find(
"Clone") != std::string::npos)
1083#if PY_VERSION_HEX >= 0x03080000
1092 fMethodInfo->fMethods.push_back(pc);
1100 fMethodInfo->fFlags =
meth->fMethodInfo->fFlags;
1101 fMethodInfo->fMethods.insert(fMethodInfo->fMethods.end(),
1104 meth->fMethodInfo->fDispatchMap.clear();
1105 meth->fMethodInfo->fMethods.clear();
1114 std::string
sig1{
"("};
1140 bool isconst =
meth->IsConst();
1155 newmeth->fMethodInfo->fFlags = fMethodInfo->fFlags;
1183 bool isconst =
meth->IsConst();
1202 for (
int i = 0; i <
n; i++) {
1226 newmeth->fMethodInfo->fFlags = fMethodInfo->fFlags;
1235 for (Methods_t::iterator it = fMethods.begin(); it != fMethods.end(); ++it) {
#define CPyCppyy_Py3_UNUSED(name)
#define CPPOverload_MAXFREELIST
#define CPPYY_BOOLEAN_PROPERTY(name, flag, label)
#define CPyCppyy_PyText_Append
#define CPyCppyy_PyText_AsString
PyObject * CPyCppyy_PyArgs_t
#define CPyCppyy_PyText_AppendAndDel
PyObject * CPyCppyy_PyObject_Call(PyObject *cb, PyObject *args, size_t, PyObject *kwds)
#define CPyCppyy_PyText_FromFormat
#define CPyCppyy_PyText_FromString
#define CPyCppyy_PyText_Check
#define PyVarObject_HEAD_INIT(type, size)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t format
void MergeOverload(CPPOverload *meth)
void AdoptMethod(PyCallable *pc)
MethodInfo_t * fMethodInfo
PyObject * FindOverload(const std::string &signature, int want_const=-1)
std::vector< PyCallable * > Methods_t
void Set(const std::string &name, std::vector< PyCallable * > &methods)
const_iterator begin() const
const_iterator end() const
size_t FetchError(std::vector< PyError_t > &, bool is_cpp=false)
void SetDetailedException(std::vector< PyError_t > &errors, PyObject *topmsg, PyObject *defexc)
bool HaveImplicit(CallContext *ctxt)
PyObject * GetScopeProxy(Cppyy::TCppScope_t)
static PyMethodObject * free_list
bool NoImplicit(CallContext *ctxt)
bool IsCreator(uint64_t flags)
uint64_t HashSignature(CPyCppyy_PyArgs_t args, size_t nargsf)
bool CPPInstance_Check(T *object)
PyTypeObject CPPOverload_Type
bool IsConstructor(uint64_t flags)
bool IsSorted(uint64_t flags)
RPY_EXPORTED size_t SizeOf(TCppType_t klass)
RPY_EXPORTED TCppFuncAddr_t GetFunctionAddress(TCppMethod_t method, bool check_enabled=true)
CPPOverload::Methods_t fMethods
static ECallFlags sMemoryPolicy
static void Clear(PyError_t &e)