29 const std::string&
name, std::vector<PyCallable*>* overloads =
nullptr)
61 for (
auto clb : *overloads) pytmpl->
AdoptMethod(clb);
75 PyErr_SetString(PyExc_TypeError,
"enum values are read-only");
84 return PyType_Type.tp_alloc(meta,
nitems);
92 for (
auto pyobj : *scope->
fImp.
fUsing) Py_DECREF(pyobj);
100 return PyType_Type.tp_dealloc((
PyObject*)scope);
121 std::string modname =
157 PyErr_SetString(PyExc_AttributeError,
158 "attribute \'__module__\' of 'cppyy.CPPScope\' objects is not writable");
181 const_cast<char*
>(
"<class cppyy.CPPInstance at %p>"), scope);
185 return PyType_Type.tp_repr((
PyObject*)scope);
224 result->fOperators =
nullptr;
225 result->fModuleName =
nullptr;
234 const char* mp = strstr(subtype->tp_name,
"_meta");
252 if (3 <= PyTuple_GET_SIZE(args)) {
253 PyObject* dct = PyTuple_GET_ITEM(args, 2);
257 std::ostringstream errmsg;
259 PyErr_Format(PyExc_TypeError,
"no python-side overrides supported (%s)", errmsg.str().c_str());
266 if (PyObject_SetAttrString((
PyObject*)
result,
"__cpp_cross__", bname) == -1)
289 result->fImp.fCppObjects =
nullptr;
292 result->fImp.fUsing =
nullptr;
296 if (PyErr_Occurred()) {
317 if (
name.size() >= 2 &&
name.compare(0, 2,
"__") == 0 &&
322 std::vector<Utility::PyError_t> errors;
339 const std::vector<Cppyy::TCppIndex_t> methods =
341 if (!methods.empty()) {
343 std::vector<PyCallable*> overloads;
344 for (
auto idx : methods) {
370 if (resolved != lookup) {
391 PyErr_Format(PyExc_TypeError,
"\'%s\' is not a known C++ template",
name.c_str());
405 PyObject* pymetabases = PyTuple_New(1);
408 PyTuple_SET_ITEM(pymetabases, 0, btype);
410 PyObject* args = Py_BuildValue((
char*)
"sO{}", (
name+
"_meta").c_str(), pymetabases);
411 Py_DECREF(pymetabases);
412 PyObject* pymeta = PyType_Type.tp_new(
Py_TYPE(&PyInt_Type), args,
nullptr);
418 Py_INCREF(&PyInt_Type);
419 PyTuple_SET_ITEM(pybases, 0, (
PyObject*)&PyInt_Type);
441 args = Py_BuildValue((
char*)
"sOO",
name.c_str(), pybases, dct);
444 attr = ((PyTypeObject*)pymeta)->tp_new((PyTypeObject*)pymeta, args,
nullptr);
452 Py_INCREF(&PyInt_Type);
457 PyErr_Format(PyExc_TypeError,
"\'%s\' is not a known C++ enum",
name.c_str());
467 attr = PyType_Type.tp_getattro(pyclass,
pyname);
469 PyType_Type.tp_setattro(pyclass,
pyname,
attr);
481 for (
auto pyref : *klass->
fImp.
fUsing) Py_DECREF(pyref);
484 klass->
fImp.
fUsing =
new std::vector<PyObject*>;
487 for (
auto uid : uv) {
491 klass->
fImp.
fUsing->push_back(PyWeakref_NewRef(pyuscope,
nullptr));
494 PyType_Type.tp_setattro(pyclass, llname, pyuscope);
504 PyObject* pyuscope = PyWeakref_GetObject(pyref);
519 PyObject* sklass = PyObject_Str(pyclass);
528 SetDetailedException(errors, topmsg , PyExc_AttributeError );
552 return PyType_Type.tp_setattro(pyclass,
pyname, pyval);
566 using namespace Cppyy;
569 return PyList_New(0);
572 PyErr_SetString(PyExc_TypeError,
"C++ proxy scope expected");
580 std::set<std::string> cppnames;
584 for (
Py_ssize_t i = 0; i < PyList_GET_SIZE(dirlist); ++i)
588 dirlist = PyList_New(cppnames.size());
592 for (
const auto&
name : cppnames) {
600 {(
char*)
"__dir__", (PyCFunction)
meta_dir, METH_NOARGS,
nullptr},
601 {(
char*)
nullptr,
nullptr, 0,
nullptr}
607 {(
char*)
"__cpp_name__", (getter)
meta_getcppname,
nullptr,
nullptr,
nullptr},
609 {(
char*)
nullptr,
nullptr,
nullptr,
nullptr,
nullptr}
616 (
char*)
"cppyy.CPPScope",
634 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE
635#
if PY_VERSION_HEX >= 0x03040000
636 | Py_TPFLAGS_TYPE_SUBCLASS
639 (
char*)
"CPyCppyy metatype (internal)",
664#
if PY_VERSION_HEX >= 0x02030000
667#
if PY_VERSION_HEX >= 0x02060000
670#
if PY_VERSION_HEX >= 0x03040000
#define CPyCppyy_PyText_InternFromString
#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)
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
Utility::PyOperators * fOperators
Cppyy::TCppType_t fCppType
std::vector< PyObject * > * fUsing
union CPyCppyy::CPPScope::@216 fImp
CppToPyMap_t * fCppObjects
void AdoptTemplate(PyCallable *pc)
void AdoptMethod(PyCallable *pc)
R__EXTERN PyObject * gName
R__EXTERN PyObject * gCppName
R__EXTERN PyObject * gModule
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 extract_namespace(const std::string &name)
size_t FetchError(std::vector< PyError_t > &)
const std::string Compound(const std::string &name)
Set of helper functions that are invoked from the pythonizors, on the Python side.
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,...
PyObject * GetScopeProxy(Cppyy::TCppScope_t)
static int meta_setmodule(CPPScope *scope, PyObject *value, void *)
static PyObject * meta_dir(CPPScope *klass)
static PyObject * meta_alloc(PyTypeObject *meta, Py_ssize_t nitems)
PyTypeObject TypedefPointerToClass_Type
static int enum_setattro(PyObject *, PyObject *, PyObject *)
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)
PyObject * CreateScopeProxy(Cppyy::TCppScope_t)
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)
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 long long GetEnumDataValue(TCppEnum_t, TCppIndex_t idata)
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 GetEnumDataName(TCppEnum_t, TCppIndex_t idata)
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 std::vector< TCppScope_t > GetUsingNamespaces(TCppScope_t)
RPY_EXPORTED TCppIndex_t GetNumEnumData(TCppEnum_t)
RPY_EXPORTED std::string GetFinalName(TCppType_t type)
RPY_EXPORTED TCppEnum_t GetEnum(TCppScope_t scope, const std::string &enum_name)
static void Clear(PyError_t &e)
PyObject_HEAD Cppyy::TCppType_t fType