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 " PyGILState_STATE state = PyGILState_Ensure();\n"
45 " PyErr_Warn(PyExc_RuntimeWarning, (char*)\"Call attempted on deleted python-side proxy\");\n"
46 " PyGILState_Release(state);\n"
60 code <<
" Py_INCREF(iself);\n";
63#if PY_VERSION_HEX < 0x03000000
64 code <<
" PyObject* mtPyName = PyString_FromString(\"" <<
mtCppName <<
"\");\n"
66 code <<
" PyObject* mtPyName = PyUnicode_FromString(\"" <<
mtCppName <<
"\");\n"
68 " PyObject* pyresult = PyObject_CallMethodObjArgs(iself, mtPyName";
70 code <<
", pyargs[" << i <<
"]";
71 code <<
", NULL);\n Py_DECREF(mtPyName);\n Py_DECREF(iself);\n";
74 Utility::ConstructCallbackReturn(
retType, (
int)
nArgs, code);
81 btype(t), bname(
bn), bname_scoped(
bns) {}
84 std::string bname_scoped;
88 typedef std::vector<Cppyy::TCppMethod_t>
Ctors_t;
90 typedef std::vector<std::pair<Cppyy::TCppMethod_t, size_t>>
CtorInfos_t;
97 if (idx <
ctors.size()) {
113 for (Ctors_t::size_type i = 0; i <
methods.size(); ++i) {
119 if (i != 0) code <<
"__cppyy_internal::Sep*";
121 for (
size_t j = 0;
j <
nArgs; ++
j) {
122 if (i != 0 ||
j != 0) code <<
", ";
129 for (BaseInfos_t::size_type i = 0; i <
base_infos.size(); ++i) {
130 if (i != 0) code <<
", ";
132 size_t first = (i != 0 ?
arg_tots[i-1] : 0);
134 if (
j != first) code <<
", ";
149using namespace Cppyy;
155 std::vector<TCppIndex_t>
result;
176 err <<
"internal error: expected tuple of bases and proper dictionary";
180 if (!Utility::IncludePython()) {
181 err <<
"failed to include Python.h";
195 err <<
"base class is incomplete";
218 static int counter = 0;
219 std::ostringstream
osname;
220 osname <<
"Dispatcher" << ++counter;
224 std::ostringstream code;
227 code <<
"namespace __cppyy_internal {\n"
230 if (
ibase != 0) code <<
", ";
235 code <<
"protected:\n CPyCppyy::DispatchPtr _internal_self;\n";
244 "PyGILState_STATE state = PyGILState_Ensure();\n"
245 " PyObject* iself = (PyObject*)_internal_self;\n"
246 " if (!iself || iself == Py_None)\n"
248 " Py_INCREF(iself);\n"
249 " PyObject* mtPyName = PyUnicode_FromString(\"__destruct__\");\n"
250 " PyObject* pyresult = PyObject_CallMethodObjArgs(iself, mtPyName, NULL);\n"
251 " Py_DECREF(mtPyName);\n Py_DECREF(iself);\n";
255 code <<
" if (!pyresult) PyErr_Print();\n"
256 " else { Py_DECREF(pyresult); }\n"
257 " PyGILState_Release(state);\n"
297 if (TypeManip::compound(
argtype) ==
"&" && TypeManip::clean_type(
argtype,
false) ==
binfo.bname_scoped)
320 if (i != 0) code <<
", ";
327 if (i != 0) code <<
", ";
400 if (
ibase != 0) code <<
", ";
404 code <<
", _internal_self(other._internal_self, this)";
409 code <<
" template<typename ...Args>\n " <<
derivedName <<
"(Args... args) : "
422 if (
dm_name !=
"_internal_self") {
429 code <<
" using " <<
binfo.bname <<
"::" <<
dname <<
";\n";
437 code <<
"public:\n static void _init_dispatchptr(" <<
derivedName <<
"* inst, PyObject* self) {\n";
441 code <<
" " <<
binfo.bname <<
"::_init_dispatchptr(inst, self);\n";
453 code <<
" new ((void*)&inst->_internal_self) CPyCppyy::DispatchPtr{self, true};\n";
457 code <<
"\n static PyObject* _get_dispatch(" <<
derivedName <<
"* inst) {\n"
458 " PyGILState_STATE state = PyGILState_Ensure();\n"
459 " PyObject* res = (PyObject*)inst->_internal_self;\n"
460 " Py_XINCREF(res);\n"
461 " PyGILState_Release(state);\n"
469 err <<
"failed to compile the dispatcher code";
477 err <<
"failed to retrieve the internal dispatcher";
485 unsigned int flags = (
unsigned int)(
klass->fFlags & CPPScope::kIsMultiCross);
495#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)