30 if (i != 0) code <<
", ";
31 code <<
argtypes.back() <<
" arg" << i;
42 code <<
" PyObject* iself = (PyObject*)_internal_self;\n"
43 " if (!iself || iself == Py_None) {\n"
44 " PyErr_Warn(PyExc_RuntimeWarning, (char*)\"Call attempted on deleted python-side proxy\");\n"
54 " Py_INCREF(iself);\n";
60#if PY_VERSION_HEX < 0x03000000
61 code <<
" PyObject* mtPyName = PyString_FromString(\"" <<
mtCppName <<
"\");\n"
63 code <<
" PyObject* mtPyName = PyUnicode_FromString(\"" <<
mtCppName <<
"\");\n"
65 " PyObject* pyresult = PyObject_CallMethodObjArgs(iself, mtPyName";
67 code <<
", pyargs[" << i <<
"]";
68 code <<
", NULL);\n Py_DECREF(mtPyName);\n Py_DECREF(iself);\n";
71 Utility::ConstructCallbackReturn(
retType, (
int)
nArgs, code);
78 btype(t), bname(
bn), bname_scoped(
bns) {}
81 std::string bname_scoped;
85 typedef std::vector<Cppyy::TCppMethod_t>
Ctors_t;
87 typedef std::vector<std::pair<Cppyy::TCppMethod_t, size_t>>
CtorInfos_t;
94 if (idx <
ctors.size()) {
110 for (Ctors_t::size_type i = 0; i <
methods.size(); ++i) {
116 if (i != 0) code <<
"__cppyy_internal::Sep*";
118 for (
size_t j = 0;
j <
nArgs; ++
j) {
119 if (i != 0 ||
j != 0) code <<
", ";
126 for (BaseInfos_t::size_type i = 0; i <
base_infos.size(); ++i) {
127 if (i != 0) code <<
", ";
129 size_t first = (i != 0 ?
arg_tots[i-1] : 0);
131 if (
j != first) code <<
", ";
146using namespace Cppyy;
152 std::vector<TCppIndex_t>
result;
173 err <<
"internal error: expected tuple of bases and proper dictionary";
177 if (!Utility::IncludePython()) {
178 err <<
"failed to include Python.h";
192 err <<
"base class is incomplete";
215 static int counter = 0;
216 std::ostringstream
osname;
217 osname <<
"Dispatcher" << ++counter;
221 std::ostringstream code;
224 code <<
"namespace __cppyy_internal {\n"
227 if (
ibase != 0) code <<
", ";
232 code <<
"protected:\n CPyCppyy::DispatchPtr _internal_self;\n";
241 " PyObject* iself = (PyObject*)_internal_self;\n"
242 " if (!iself || iself == Py_None)\n"
244 " Py_INCREF(iself);\n"
245 " PyObject* mtPyName = PyUnicode_FromString(\"__destruct__\");\n"
246 " PyObject* pyresult = PyObject_CallMethodObjArgs(iself, mtPyName, NULL);\n"
247 " Py_DECREF(mtPyName);\n Py_DECREF(iself);\n";
251 code <<
" if (!pyresult) PyErr_Print();\n"
252 " else { Py_DECREF(pyresult); }\n"
292 if (TypeManip::compound(
argtype) ==
"&" && TypeManip::clean_type(
argtype,
false) ==
binfo.bname_scoped)
315 if (i != 0) code <<
", ";
322 if (i != 0) code <<
", ";
395 if (
ibase != 0) code <<
", ";
399 code <<
", _internal_self(other._internal_self, this)";
404 code <<
" template<typename ...Args>\n " <<
derivedName <<
"(Args... args) : "
417 if (
dm_name !=
"_internal_self") {
424 code <<
" using " <<
binfo.bname <<
"::" <<
dname <<
";\n";
432 code <<
"public:\n static void _init_dispatchptr(" <<
derivedName <<
"* inst, PyObject* self) {\n";
436 code <<
" " <<
binfo.bname <<
"::_init_dispatchptr(inst, self);\n";
448 code <<
" new ((void*)&inst->_internal_self) CPyCppyy::DispatchPtr{self, true};\n";
452 code <<
"\n static PyObject* _get_dispatch(" <<
derivedName <<
"* inst) {\n"
453 " PyObject* res = (PyObject*)inst->_internal_self;\n"
454 " Py_XINCREF(res); return res;\n }";
461 err <<
"failed to compile the dispatcher code";
469 err <<
"failed to retrieve the internal dispatcher";
477 unsigned int flags = (
unsigned int)(
klass->fFlags & CPPScope::kIsMultiCross);
487#if PY_VERSION_HEX < 0x30d00f0
#define CPyCppyy_PyText_AsString
#define CPyCppyy_PyText_FromString
static void InjectMethod(Cppyy::TCppMethod_t method, const std::string &mtCppName, std::ostringstream &code)
static void build_constructors(const std::string &derivedName, const BaseInfos_t &base_infos, const AllCtors_t &ctors, std::ostringstream &code, const CtorInfos_t &methods=CtorInfos_t{}, size_t idx=0)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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
std::string remove_const(const std::string &cppname)
std::string compound(const std::string &name)
PyObject * CreateScopeProxy(Cppyy::TCppScope_t, const unsigned flags=0)
bool CPPScope_Check(T *object)
bool InsertDispatcher(CPPScope *klass, PyObject *bases, PyObject *dct, std::ostringstream &err)
RPY_EXPORTED TCppIndex_t GetNumTemplatedMethods(TCppScope_t scope, bool accept_namespace=false)
RPY_EXPORTED TCppIndex_t GetMethodReqArgs(TCppMethod_t)
RPY_EXPORTED std::vector< TCppIndex_t > GetMethodIndicesFromName(TCppScope_t scope, const std::string &name)
RPY_EXPORTED TCppIndex_t GetNumDatamembers(TCppScope_t scope, bool accept_namespace=false)
RPY_EXPORTED std::string GetMethodName(TCppMethod_t)
RPY_EXPORTED bool Compile(const std::string &code, bool silent=false)
RPY_EXPORTED bool IsProtectedData(TCppScope_t scope, TCppIndex_t idata)
RPY_EXPORTED bool IsConstructor(TCppMethod_t method)
RPY_EXPORTED TCppIndex_t GetNumMethods(TCppScope_t scope, bool accept_namespace=false)
RPY_EXPORTED TCppIndex_t GetMethodNumArgs(TCppMethod_t)
RPY_EXPORTED std::string GetBaseName(TCppType_t type, TCppIndex_t ibase)
RPY_EXPORTED bool IsNamespace(TCppScope_t scope)
RPY_EXPORTED std::string GetScopedFinalName(TCppType_t type)
RPY_EXPORTED std::string GetMethodArgType(TCppMethod_t, TCppIndex_t iarg)
RPY_EXPORTED TCppIndex_t GetDatamemberIndex(TCppScope_t scope, const std::string &name)
RPY_EXPORTED TCppMethod_t GetMethod(TCppScope_t scope, TCppIndex_t imeth)
RPY_EXPORTED TCppScope_t GetScope(const std::string &scope_name)
RPY_EXPORTED bool HasVirtualDestructor(TCppType_t type)
RPY_EXPORTED bool IsConstMethod(TCppMethod_t)
RPY_EXPORTED bool IsTemplatedConstructor(TCppScope_t scope, TCppIndex_t imeth)
RPY_EXPORTED TCppIndex_t GetNumBases(TCppType_t type)
RPY_EXPORTED std::string GetMethodResultType(TCppMethod_t)
RPY_EXPORTED std::string GetFinalName(TCppType_t type)
RPY_EXPORTED std::string GetDatamemberName(TCppScope_t scope, TCppIndex_t idata)
RPY_EXPORTED bool IsPublicMethod(TCppMethod_t method)
RPY_EXPORTED bool IsProtectedMethod(TCppMethod_t method)