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
553 "The __mempolicy__ attribute can't be used, because in the past it was reserved to manage the local memory policy. "
554 "If you want to do that now, please implement a pythonization for your class that uses SetOwnership() to manage the "
555 "ownership of arguments according to your needs.";
572#define CPPYY_BOOLEAN_PROPERTY(name, flag, label) \
573static PyObject* mp_get##name(CPPOverload* pymeth, void*) { \
574 if (pymeth->fMethodInfo->fFlags & flag) { \
580static int mp_set##name(CPPOverload* pymeth, PyObject* value, void*) { \
581 return set_flag(pymeth, value, flag, label); \
599 return methods[0]->GetTypeName();
607 {(
char*)
"__name__", (
getter)
mp_name,
nullptr,
nullptr,
nullptr},
623 {(
char*)
"func_name", (
getter)
mp_name,
nullptr,
nullptr,
nullptr},
630 (
char*)
"For ownership rules of result: if true, objects are python-owned",
nullptr},
632 (
char*)
"Unused",
nullptr},
634 (
char*)
"If true, set a lifeline from the return value onto self",
nullptr},
636 (
char*)
"If true, releases GIL on call into C++",
nullptr},
638 (
char*)
"not implemented",
nullptr},
640 (
char*)
"If true, turn signals into Python exceptions",
nullptr},
645 {(
char*)
nullptr,
nullptr,
nullptr,
nullptr,
nullptr}
649#if PY_VERSION_HEX >= 0x03080000
656#if PY_VERSION_HEX < 0x03080000
711 ctxt.fFlags &= ~CallContext::kAllowImplicit;
721 std::vector<std::pair<int, PyCallable*>>
pm;
pm.reserve(
methods.size());
723 pm.emplace_back(ptr->GetPriority(), ptr);
725 for (CPPOverload::Methods_t::size_type i = 0; i <
methods.size(); ++i)
730 std::vector<Utility::PyError_t>
errors;
732 for (
int stage = 0; stage < 2; ++stage) {
734 for (CPPOverload::Methods_t::size_type i = 0; i <
nMethods; ++i) {
781 ctxt.fFlags &= ~CallContext::kHaveImplicit;
796 "none of the %d overloaded methods succeeded. Full details:", (
int)
nMethods);
807 std::ostringstream s;
808 s <<
"<C++ overload \"" <<
cppinst->fMethodInfo->fName <<
"\" at " << (
void*)
cppinst <<
">";
826#if PY_VERSION_HEX < 0x03080000
850 *
pymeth->fMethodInfo->fRefCount += 1;
853#if PY_VERSION_HEX >= 0x03080000
894 pymeth->fMethodInfo =
new CPPOverload::MethodInfo_t;
908 if (--(*
pymeth->fMethodInfo->fRefCount) <= 0) {
909 delete pymeth->fMethodInfo;
926#if PY_VERSION_HEX >= 0x030d0000
973 const char*
sigarg =
nullptr;
994 TPythonCallback* cb =
new TPythonCallback(
new_overload);
1007 return pymeth->fMethodInfo->fMethods[0]->Reflex(request,
format);
1013 (
char*)
"select overload for dispatch" },
1015 (
char*)
"add a new overload" },
1017 (
char*)
"C++ overload reflection information" },
1018 {(
char*)
nullptr,
nullptr, 0,
nullptr }
1027 (
char*)
"cppyy.CPPOverload",
1054#if PY_VERSION_HEX >= 0x03080000
1058 (
char*)
"cppyy method proxy (internal)",
1083#if PY_VERSION_HEX >= 0x02030000
1086#if PY_VERSION_HEX >= 0x02060000
1089#if PY_VERSION_HEX >= 0x03040000
1092#if PY_VERSION_HEX >= 0x03080000
1095#if PY_VERSION_HEX >= 0x030c0000
1098#if PY_VERSION_HEX >= 0x030d0000
1115 if (
name ==
"__init__")
1132#if PY_VERSION_HEX >= 0x03080000
1141 fMethodInfo->fMethods.push_back(pc);
1149 fMethodInfo->fFlags =
meth->fMethodInfo->fFlags;
1150 fMethodInfo->fMethods.insert(fMethodInfo->fMethods.end(),
1153 meth->fMethodInfo->fDispatchMap.clear();
1154 meth->fMethodInfo->fMethods.clear();
1163 std::string
sig1{
"("};
1204 newmeth->fMethodInfo->fFlags = fMethodInfo->fFlags;
1251 for (
int i = 0; i <
n; i++) {
1275 newmeth->fMethodInfo->fFlags = fMethodInfo->fFlags;
1284 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 uint32_t & GlobalPolicyFlags()