4#include "structmember.h"
5#if PY_VERSION_HEX >= 0x02050000
6#if PY_VERSION_HEX < 0x030b0000
14#define CO_NOFREE 0x0040
66#if PY_VERSION_HEX >= 0x030e0000
83#ifndef CPPOverload_MAXFREELIST
84#define CPPOverload_MAXFREELIST 32
90class TPythonCallback :
public PyCallable {
109 PyObject* GetSignature(
bool =
true)
override {
112 PyObject* GetSignatureNames()
override {
115 PyObject* GetSignatureTypes()
override {
118 PyObject* GetPrototype(
bool =
true)
override {
125 return GetPrototype();
129 int GetPriority()
override {
return 100; };
130 bool IsGreedy()
override {
return false; };
132 int GetMaxArgs()
override {
return 100; };
133 PyObject* GetCoVarNames()
override {
136 PyObject* GetArgDefault(
int ,
bool =
true)
override {
148 PyCallable* Clone()
override {
return new TPythonCallback(*
this); }
153#if PY_VERSION_HEX >= 0x03080000
210static int PriorityCmp(
const std::pair<int, PyCallable*>& left,
const std::pair<int, PyCallable*>& right)
212 return left.first > right.first;
226static inline PyObject* HandleReturn(
304 if (
pymeth->fMethodInfo->fDoc) {
306 return pymeth->fMethodInfo->fDoc;
324 for (CPPOverload::Methods_t::size_type i = 1; i <
nMethods; ++i) {
337 pymeth->fMethodInfo->fDoc = val;
396 *
pymeth->fMethodInfo->fRefCount += 1;
413 "function %s has no attribute \'im_self\'",
pymeth->fMethodInfo->fName.c_str());
415 }
else if (
pymeth->fSelf != 0) {
432 "function %s has no attribute \'im_class\'",
pymeth->fMethodInfo->fName.c_str());
447#if PY_VERSION_HEX < 0x03000000
448#define CPyCppyy_Py3_UNUSED(name) name
450#define CPyCppyy_Py3_UNUSED(name)
457#if PY_VERSION_HEX < 0x03000000
600 "The __mempolicy__ attribute can't be used, because in the past it was reserved to manage the local memory policy. "
601 "If you want to do that now, please implement a pythonization for your class that uses SetOwnership() to manage the "
602 "ownership of arguments according to your needs.";
619#define CPPYY_BOOLEAN_PROPERTY(name, flag, label) \
620static PyObject* mp_get##name(CPPOverload* pymeth, void*) { \
621 if (pymeth->fMethodInfo->fFlags & flag) { \
627static int mp_set##name(CPPOverload* pymeth, PyObject* value, void*) { \
628 return set_flag(pymeth, value, flag, label); \
646 return methods[0]->GetTypeName();
654 {(
char*)
"__name__", (
getter)
mp_name,
nullptr,
nullptr,
nullptr},
670 {(
char*)
"func_name", (
getter)
mp_name,
nullptr,
nullptr,
nullptr},
677 (
char*)
"For ownership rules of result: if true, objects are python-owned",
nullptr},
679 (
char*)
"Unused",
nullptr},
681 (
char*)
"If true, set a lifeline from the return value onto self",
nullptr},
683 (
char*)
"If true, releases GIL on call into C++",
nullptr},
685 (
char*)
"not implemented",
nullptr},
687 (
char*)
"If true, turn signals into Python exceptions",
nullptr},
692 {(
char*)
nullptr,
nullptr,
nullptr,
nullptr,
nullptr}
696#if PY_VERSION_HEX >= 0x03080000
703#if PY_VERSION_HEX < 0x03080000
758 ctxt.fFlags &= ~CallContext::kAllowImplicit;
768 std::vector<std::pair<int, PyCallable*>>
pm;
pm.reserve(
methods.size());
770 pm.emplace_back(ptr->GetPriority(), ptr);
772 for (CPPOverload::Methods_t::size_type i = 0; i <
methods.size(); ++i)
777 std::vector<Utility::PyError_t>
errors;
779 for (
int stage = 0; stage < 2; ++stage) {
781 for (CPPOverload::Methods_t::size_type i = 0; i <
nMethods; ++i) {
828 ctxt.fFlags &= ~CallContext::kHaveImplicit;
843 "none of the %d overloaded methods succeeded. Full details:", (
int)
nMethods);
854 std::ostringstream s;
855 s <<
"<C++ overload \"" <<
cppinst->fMethodInfo->fName <<
"\" at " << (
void*)
cppinst <<
">";
873#if PY_VERSION_HEX < 0x03080000
897 *
pymeth->fMethodInfo->fRefCount += 1;
900#if PY_VERSION_HEX >= 0x03080000
941 pymeth->fMethodInfo =
new CPPOverload::MethodInfo_t;
955 if (--(*
pymeth->fMethodInfo->fRefCount) <= 0) {
956 delete pymeth->fMethodInfo;
973#if PY_VERSION_HEX >= 0x030d0000
1020 const char*
sigarg =
nullptr;
1054 return pymeth->fMethodInfo->fMethods[0]->Reflex(request,
format);
1060 (
char*)
"select overload for dispatch" },
1062 (
char*)
"add a new overload" },
1064 (
char*)
"C++ overload reflection information" },
1065 {(
char*)
nullptr,
nullptr, 0,
nullptr }
1074 (
char*)
"cppyy.CPPOverload",
1101#if PY_VERSION_HEX >= 0x03080000
1105 (
char*)
"cppyy method proxy (internal)",
1130#if PY_VERSION_HEX >= 0x02030000
1133#if PY_VERSION_HEX >= 0x02060000
1136#if PY_VERSION_HEX >= 0x03040000
1139#if PY_VERSION_HEX >= 0x03080000
1142#if PY_VERSION_HEX >= 0x030c0000
1145#if PY_VERSION_HEX >= 0x030d0000
1162 if (
name ==
"__init__")
1179#if PY_VERSION_HEX >= 0x03080000
1188 fMethodInfo->fMethods.push_back(pc);
1196 fMethodInfo->fFlags =
meth->fMethodInfo->fFlags;
1197 fMethodInfo->fMethods.insert(fMethodInfo->fMethods.end(),
1200 meth->fMethodInfo->fDispatchMap.clear();
1201 meth->fMethodInfo->fMethods.clear();
1210 std::string
sig1{
"("};
1251 newmeth->fMethodInfo->fFlags = fMethodInfo->fFlags;
1298 for (
int i = 0; i <
n; i++) {
1322 newmeth->fMethodInfo->fFlags = fMethodInfo->fFlags;
1331 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
static Py_ssize_t CPyCppyy_PyArgs_GET_SIZE(CPyCppyy_PyArgs_t args, size_t)
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
static PyObject * CPyCppyy_PyArgs_GET_ITEM(CPyCppyy_PyArgs_t args, Py_ssize_t i)
#define CPyCppyy_PyText_Check
#define PyVarObject_HEAD_INIT(type, size)
bool PyUnstable_Object_IsUniqueReferencedTemporary(PyObject *pyobject)
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 CPPOverload_Check(T *object)
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 TemplateProxy_Check(T *object)
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 uint32_t & GlobalPolicyFlags()