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 PyObject* GetSignature(
bool =
true)
override {
65 PyObject* GetSignatureNames()
override {
68 PyObject* GetSignatureTypes()
override {
71 PyObject* GetPrototype(
bool =
true)
override {
78 return GetPrototype();
82 int GetPriority()
override {
return 100; };
83 bool IsGreedy()
override {
return false; };
85 int GetMaxArgs()
override {
return 100; };
89 PyObject* GetArgDefault(
int ,
bool =
true)
override {
101 PyCallable* Clone()
override {
return new TPythonCallback(*
this); }
106#if PY_VERSION_HEX >= 0x03080000
163static int PriorityCmp(
const std::pair<int, PyCallable*>& left,
const std::pair<int, PyCallable*>& right)
165 return left.first > right.first;
179static inline PyObject* HandleReturn(
257 if (
pymeth->fMethodInfo->fDoc) {
259 return pymeth->fMethodInfo->fDoc;
277 for (CPPOverload::Methods_t::size_type i = 1; i <
nMethods; ++i) {
290 pymeth->fMethodInfo->fDoc = val;
349 *
pymeth->fMethodInfo->fRefCount += 1;
366 "function %s has no attribute \'im_self\'",
pymeth->fMethodInfo->fName.c_str());
368 }
else if (
pymeth->fSelf != 0) {
385 "function %s has no attribute \'im_class\'",
pymeth->fMethodInfo->fName.c_str());
400#if PY_VERSION_HEX < 0x03000000
401#define CPyCppyy_Py3_UNUSED(name) name
403#define CPyCppyy_Py3_UNUSED(name)
410#if PY_VERSION_HEX < 0x03000000
572 pymeth->fMethodInfo->fFlags &= ~CallContext::kUseStrict;
575 pymeth->fMethodInfo->fFlags &= ~CallContext::kUseHeuristics;
578 "expected kMemoryStrict or kMemoryHeuristics as value for __mempolicy__");
587#define CPPYY_BOOLEAN_PROPERTY(name, flag, label) \
588static PyObject* mp_get##name(CPPOverload* pymeth, void*) { \
589 if (pymeth->fMethodInfo->fFlags & flag) { \
595static int mp_set##name(CPPOverload* pymeth, PyObject* value, void*) { \
596 return set_flag(pymeth, value, flag, label); \
614 return methods[0]->GetTypeName();
622 {(
char*)
"__name__", (
getter)
mp_name,
nullptr,
nullptr,
nullptr},
638 {(
char*)
"func_name", (
getter)
mp_name,
nullptr,
nullptr,
nullptr},
645 (
char*)
"For ownership rules of result: if true, objects are python-owned",
nullptr},
647 (
char*)
"For argument ownership rules: like global, either heuristic or strict",
nullptr},
649 (
char*)
"If true, set a lifeline from the return value onto self",
nullptr},
651 (
char*)
"If true, releases GIL on call into C++",
nullptr},
653 (
char*)
"not implemented",
nullptr},
655 (
char*)
"If true, turn signals into Python exceptions",
nullptr},
660 {(
char*)
nullptr,
nullptr,
nullptr,
nullptr,
nullptr}
664#if PY_VERSION_HEX >= 0x03080000
671#if PY_VERSION_HEX < 0x03080000
728 ctxt.fFlags &= ~CallContext::kAllowImplicit;
738 std::vector<std::pair<int, PyCallable*>>
pm;
pm.reserve(
methods.size());
740 pm.emplace_back(ptr->GetPriority(), ptr);
742 for (CPPOverload::Methods_t::size_type i = 0; i <
methods.size(); ++i)
747 std::vector<Utility::PyError_t>
errors;
749 for (
int stage = 0; stage < 2; ++stage) {
751 for (CPPOverload::Methods_t::size_type i = 0; i <
nMethods; ++i) {
798 ctxt.fFlags &= ~CallContext::kHaveImplicit;
813 "none of the %d overloaded methods succeeded. Full details:", (
int)
nMethods);
824 std::ostringstream s;
825 s <<
"<C++ overload \"" <<
cppinst->fMethodInfo->fName <<
"\" at " << (
void*)
cppinst <<
">";
843#if PY_VERSION_HEX < 0x03080000
867 *
pymeth->fMethodInfo->fRefCount += 1;
870#if PY_VERSION_HEX >= 0x03080000
911 pymeth->fMethodInfo =
new CPPOverload::MethodInfo_t;
925 if (--(*
pymeth->fMethodInfo->fRefCount) <= 0) {
926 delete pymeth->fMethodInfo;
943#if PY_VERSION_HEX >= 0x030d0000
990 const char*
sigarg =
nullptr;
1011 TPythonCallback* cb =
new TPythonCallback(
new_overload);
1024 return pymeth->fMethodInfo->fMethods[0]->Reflex(request,
format);
1030 (
char*)
"select overload for dispatch" },
1032 (
char*)
"add a new overload" },
1034 (
char*)
"C++ overload reflection information" },
1035 {(
char*)
nullptr,
nullptr, 0,
nullptr }
1044 (
char*)
"cppyy.CPPOverload",
1071#if PY_VERSION_HEX >= 0x03080000
1075 (
char*)
"cppyy method proxy (internal)",
1100#if PY_VERSION_HEX >= 0x02030000
1103#if PY_VERSION_HEX >= 0x02060000
1106#if PY_VERSION_HEX >= 0x03040000
1109#if PY_VERSION_HEX >= 0x03080000
1112#if PY_VERSION_HEX >= 0x030c0000
1115#if PY_VERSION_HEX >= 0x030d0000
1132 if (
name ==
"__init__")
1149#if PY_VERSION_HEX >= 0x03080000
1158 fMethodInfo->fMethods.push_back(pc);
1166 fMethodInfo->fFlags =
meth->fMethodInfo->fFlags;
1167 fMethodInfo->fMethods.insert(fMethodInfo->fMethods.end(),
1170 meth->fMethodInfo->fDispatchMap.clear();
1171 meth->fMethodInfo->fMethods.clear();
1180 std::string
sig1{
"("};
1206 bool isconst =
meth->IsConst();
1221 newmeth->fMethodInfo->fFlags = fMethodInfo->fFlags;
1249 bool isconst =
meth->IsConst();
1268 for (
int i = 0; i <
n; i++) {
1292 newmeth->fMethodInfo->fFlags = fMethodInfo->fFlags;
1301 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
void SetDetailedException(std::vector< PyError_t > &&errors, PyObject *topmsg, PyObject *defexc)
size_t FetchError(std::vector< PyError_t > &, bool is_cpp=false)
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