30 const std::string&
name, std::vector<PyCallable*>* overloads =
nullptr)
42 PyType_Type.tp_setattro(pyclass, pyncl, (
PyObject*)pytmpl);
54 for (
auto clb : *overloads) pytmpl->
AdoptMethod(clb);
71 return PyType_Type.tp_alloc(meta,
nitems);
79 for (
auto pyobj : *scope->
fImp.
fUsing) Py_DECREF(pyobj);
87 return PyType_Type.tp_dealloc((
PyObject*)scope);
108 std::string modname =
144 PyErr_SetString(PyExc_AttributeError,
145 "attribute \'__module__\' of 'cppyy.CPPScope\' objects is not writable");
168 const_cast<char*
>(
"<class cppyy.CPPInstance at %p>"), scope);
172 return PyType_Type.tp_repr((
PyObject*)scope);
177 return PyType_Type.tp_repr((
PyObject*)scope);
218 result->fOperators =
nullptr;
219 result->fModuleName =
nullptr;
245 if (3 <= PyTuple_GET_SIZE(args)) {
246 PyObject* dct = PyTuple_GET_ITEM(args, 2);
250 if (1 < PyTuple_GET_SIZE(PyTuple_GET_ITEM(args, 1)))
252 std::ostringstream errmsg;
254 PyErr_Format(PyExc_TypeError,
"no python-side overrides supported (%s)", errmsg.str().c_str());
261 if (PyObject_SetAttrString((
PyObject*)
result,
"__cpp_cross__", bname) == -1)
289 result->fImp.fCppObjects =
nullptr;
292 result->fImp.fUsing =
nullptr;
296 if (PyErr_Occurred()) {
309 PyObject*
attr = PyType_Type.tp_getattro(pyclass, pyname);
313 PyObject* possibly_shadowed =
nullptr;
322 PyObject* attr_from_dict = PyObject_GetItem(dct, pyname);
324 if (attr_from_dict) {
326 return attr_from_dict;
328 possibly_shadowed =
attr;
337 return possibly_shadowed;
341 if (
name.size() >= 5 &&
name.compare(0, 2,
"__") == 0 &&
343 return possibly_shadowed;
346 std::vector<Utility::PyError_t> errors;
355 bool templated_functions_checked =
false;
365 const std::vector<Cppyy::TCppIndex_t> methods =
367 if (!methods.empty()) {
369 std::vector<PyCallable*> overloads;
370 for (
auto idx : methods) {
382 templated_functions_checked =
true;
396 if (resolved != lookup) {
405 tpc->
fDict = PyDict_New();
414 if (!
attr && !templated_functions_checked) {
419 PyErr_Format(PyExc_TypeError,
"\'%s\' is not a known C++ template",
name.c_str());
433 PyErr_Format(PyExc_TypeError,
"\'%s\' is not a known C++ enum",
name.c_str());
443 attr = PyType_Type.tp_getattro(pyclass, pyname);
444 if (!
attr && PyErr_Occurred())
447 PyType_Type.tp_setattro(pyclass, pyname,
attr);
459 for (
auto pyref : *klass->
fImp.
fUsing) Py_DECREF(pyref);
462 klass->
fImp.
fUsing =
new std::vector<PyObject*>;
465 for (
auto uid : uv) {
469 klass->
fImp.
fUsing->push_back(PyWeakref_NewRef(pyuscope,
nullptr));
472 PyType_Type.tp_setattro(pyclass, llname, pyuscope);
482 PyObject* pyuscope = PyWeakref_GetObject(pyref);
484 attr = PyObject_GetAttr(pyuscope, pyname);
495 if (possibly_shadowed) {
497 Py_DECREF(possibly_shadowed);
499 attr = possibly_shadowed;
500 PyType_Type.tp_setattro(pyclass, pyname,
attr);
510 PyObject* sklass = PyObject_Str(pyclass);
519 SetDetailedException(errors, topmsg , PyExc_AttributeError );
543 return PyType_Type.tp_setattro(pyclass, pyname, pyval);
553 if (!PyArg_ParseTuple(args,
const_cast<char*
>(
"i|i:__cpp_reflex__"), &request, &
format))
572 PyErr_Format(PyExc_ValueError,
"unsupported reflex request %d or format %d", request,
format);
586 using namespace Cppyy;
589 return PyList_New(0);
592 PyErr_SetString(PyExc_TypeError,
"C++ proxy scope expected");
600 std::set<std::string> cppnames;
604 std::set<std::string> dir_cppnames;
605 for (
const std::string&
name : cppnames) {
606 if (
name.find(
"__", 0, 2) != std::string::npos || \
607 name.find(
"<") != std::string::npos || \
608 name.find(
"operator", 0, 8) != std::string::npos)
continue;
609 dir_cppnames.insert(
name);
613 for (
Py_ssize_t i = 0; i < PyList_GET_SIZE(dirlist); ++i)
617 dirlist = PyList_New(dir_cppnames.size());
621 for (
const auto&
name : dir_cppnames) {
629 {(
char*)
"__cpp_reflex__", (PyCFunction)
meta_reflex, METH_VARARGS,
630 (
char*)
"C++ datamember reflection information" },
631 {(
char*)
"__dir__", (PyCFunction)
meta_dir, METH_NOARGS,
nullptr},
632 {(
char*)
nullptr,
nullptr, 0,
nullptr}
638 {(
char*)
"__cpp_name__", (getter)
meta_getcppname,
nullptr,
nullptr,
nullptr},
640 {(
char*)
nullptr,
nullptr,
nullptr,
nullptr,
nullptr}
647 (
char*)
"cppyy.CPPScope",
665 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE
666#
if PY_VERSION_HEX >= 0x03040000
667 | Py_TPFLAGS_TYPE_SUBCLASS
670 (
char*)
"CPyCppyy metatype (internal)",
695#
if PY_VERSION_HEX >= 0x02030000
698#
if PY_VERSION_HEX >= 0x02060000
701#
if PY_VERSION_HEX >= 0x03040000
704#
if PY_VERSION_HEX >= 0x03080000
707#
if PY_VERSION_HEX >= 0x030c0000
#define CPyCppyy_PyText_AsString
#define CPyCppyy_PyText_GET_SIZE
#define CPyCppyy_PyText_AppendAndDel
#define CPyCppyy_PyText_FromFormat
#define CPyCppyy_PyText_AsStringChecked
#define CPyCppyy_PyText_CheckExact
#define CPyCppyy_PyText_FromString
#define PyVarObject_HEAD_INIT(type, size)
std::ios_base::fmtflags fFlags
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 nitems
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t attr
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
Utility::PyOperators * fOperators
union CPyCppyy::CPPScope::@206 fImp
Cppyy::TCppType_t fCppType
std::vector< PyObject * > * fUsing
CppToPyMap_t * fCppObjects
void AdoptTemplate(PyCallable *pc)
void AdoptMethod(PyCallable *pc)
void cppscope_to_pyscope(std::string &cppscope)
std::string clean_type(const std::string &cppname, bool template_strip=true, bool const_strip=true)
std::string compound(const std::string &name)
std::string extract_namespace(const std::string &name)
size_t FetchError(std::vector< PyError_t > &, bool is_cpp=false)
CPPOverload * CPPOverload_New(const std::string &name, std::vector< PyCallable * > &methods)
PyTypeObject CPPInstance_Type
static PyObject * add_template(PyObject *pyclass, const std::string &name, std::vector< PyCallable * > *overloads=nullptr)
std::map< Cppyy::TCppObject_t, PyObject * > CppToPyMap_t
Type object to hold class reference (this is only semantically a presentation of CPPScope instances,...
static PyObject * meta_reflex(CPPScope *klass, PyObject *args)
PyObject * GetScopeProxy(Cppyy::TCppScope_t)
static int meta_setmodule(CPPScope *scope, PyObject *value, void *)
CPPEnum * CPPEnum_New(const std::string &name, Cppyy::TCppScope_t scope)
static PyObject * meta_dir(CPPScope *klass)
PyObject * CreateScopeProxy(Cppyy::TCppScope_t, const unsigned flags=0)
static PyObject * meta_alloc(PyTypeObject *meta, Py_ssize_t nitems)
PyTypeObject TypedefPointerToClass_Type
static PyObject * pt_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)
bool CPPScope_Check(T *object)
bool TemplateProxy_CheckExact(T *object)
static int meta_setattro(PyObject *pyclass, PyObject *pyname, PyObject *pyval)
static PyObject * meta_getmodule(CPPScope *scope, void *)
CPPDataMember * CPPDataMember_New(Cppyy::TCppScope_t scope, Cppyy::TCppIndex_t idata)
static PyGetSetDef meta_getset[]
static void meta_dealloc(CPPScope *scope)
PyObject * CreateExcScopeProxy(PyObject *pyscope, PyObject *pyname, PyObject *parent)
bool CPPScope_CheckExact(T *object)
static PyMethodDef meta_methods[]
bool CPPDataMember_Check(T *object)
static PyObject * meta_getattro(PyObject *pyclass, PyObject *pyname)
static PyObject * meta_getcppname(CPPScope *scope, void *)
bool InsertDispatcher(CPPScope *klass, PyObject *bases, PyObject *dct, std::ostringstream &err)
PyTypeObject CPPScope_Type
static PyObject * meta_repr(CPPScope *scope)
TemplateProxy * TemplateProxy_New(const std::string &cppname, const std::string &pyname, PyObject *pyclass)
const RequestId_t IS_AGGREGATE
const RequestId_t IS_NAMESPACE
RPY_EXPORTED bool IsEnum(const std::string &type_name)
RPY_EXPORTED std::vector< TCppIndex_t > GetMethodIndicesFromName(TCppScope_t scope, const std::string &name)
RPY_EXPORTED bool ExistsMethodTemplate(TCppScope_t scope, const std::string &name)
RPY_EXPORTED TCppScope_t gGlobalScope
RPY_EXPORTED bool IsSubtype(TCppType_t derived, TCppType_t base)
RPY_EXPORTED bool GetSmartPtrInfo(const std::string &, TCppType_t *raw, TCppMethod_t *deref)
RPY_EXPORTED std::string ResolveName(const std::string &cppitem_name)
RPY_EXPORTED bool IsAggregate(TCppType_t type)
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 void GetAllCppNames(TCppScope_t scope, std::set< std::string > &cppnames)
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 std::vector< TCppScope_t > GetUsingNamespaces(TCppScope_t)
RPY_EXPORTED std::string GetFinalName(TCppType_t type)
static void Clear(PyError_t &e)
PyObject_HEAD Cppyy::TCppType_t fCppType