83 return (pos == 0 || pos == 5) &&
name.find(
"::",
name.rfind(
">")) == std::string::npos;
102 obj,
const_cast<char*
>(
meth),
const_cast<char*
>(
"O"),
arg1);
116 if (idx >=
size || (idx < 0 && idx < -
size)) {
135 if ((step > 0 && stop <= start) || (step < 0 && start <= stop))
138 if (start < 0) start = 0;
142 stop = step > 0 ? std::min(
nlen, stop) : (stop >= 0 ? stop : -1);
230#if PY_VERSION_HEX < 0x03040000
231#define PyObject_LengthHint _PyObject_LengthHint
243struct CountedItemGetter :
public ItemGetter {
248struct TupleItemGetter :
public CountedItemGetter {
249 using CountedItemGetter::CountedItemGetter;
262struct ListItemGetter :
public CountedItemGetter {
263 using CountedItemGetter::CountedItemGetter;
276struct SequenceItemGetter :
public CountedItemGetter {
277 using CountedItemGetter::CountedItemGetter;
289struct IterItemGetter :
public ItemGetter {
290 using ItemGetter::ItemGetter;
295static ItemGetter* GetGetter(
PyObject* args)
298 ItemGetter*
getter =
nullptr;
316 getter =
new SequenceItemGetter(
fi);
320 getter =
new IterItemGetter{iter};
342namespace __cppyy_internal {
349 ptr_iterator(T *c, T *e) : cur(c), end(e) {}
351 T &operator*() const { return *cur; }
352 ptr_iterator &operator++()
357 bool operator==(const ptr_iterator &other) const { return cur == other.cur; }
358 bool operator!=(const ptr_iterator &other) const { return !(*this == other); }
362ptr_iterator<T> make_iter(T *begin, T *end)
367} // namespace __cppyy_internal
369// Note: for const span<T>, T is const-qualified here
371auto __cppyy_internal_begin(T &s) noexcept
373 return __cppyy_internal::make_iter(s.data(), s.data() + s.size());
376// Note: for const span<T>, T is const-qualified here
378auto __cppyy_internal_end(T &s) noexcept
380 // end iterator = begin iterator with cur == end
381 return __cppyy_internal::make_iter(s.data() + s.size(), s.data() + s.size());
396 "'__cppyy_internal_begin' for std::span pythonization");
411 "'__cppyy_internal_end' for std::span pythonization");
469 for (
int i = 0; ; ++i) {
546 ItemGetter*
getter = GetGetter(args);
598 ItemGetter*
getter = GetGetter(args);
678 if (!
vi)
return nullptr;
680 vi->ii_container =
v;
684#if PY_VERSION_HEX >= 0x030e0000
719 vi->vi_converter =
nullptr;
721 if (value_type.back() !=
'*')
730 vi->vi_converter =
nullptr;
742 vi->vi_data =
nullptr;
744 vi->vi_converter =
nullptr;
762 if (!
self->GetObject()) {
801 "require object of type std::vector<bool>, but %s given",
806 if (!
self->GetObject()) {
841 std::vector<bool>*
vb = (std::vector<bool>*)
self->GetObject();
855 "require object of type std::vector<bool>, but %s given",
860 if (!
self->GetObject()) {
877 std::vector<bool>*
vb = (std::vector<bool>*)
self->GetObject();
985#if PY_VERSION_HEX < 0x03000000
1019#if __cplusplus <= 202002L
1065 IterItemGetter
getter{iter};
1163 if (!
ii)
return nullptr;
1166 ii->ii_container =
c;
1219 else if ((
int)idx == 1)
1252#if PY_VERSION_HEX >= 0x03000000
1276#define CPPYY_IMPL_STRING_PYTHONIZATION(type, name) \
1278PyObject* name##StringGetData(PyObject* self, bool native=true) \
1280 if (CPyCppyy::CPPInstance_Check(self)) { \
1281 type* obj = ((type*)((CPPInstance*)self)->GetObject()); \
1282 if (obj) return CPyCppyy_PyString_FromCppString(*obj, native); \
1284 PyErr_Format(PyExc_TypeError, "object mismatch (%s expected)", #type); \
1288PyObject* name##StringStr(PyObject* self) \
1290 PyObject* pyobj = name##StringGetData(self, false); \
1294 PyObject* pybytes = name##StringGetData(self, true); \
1296 pyobj = PyObject_Str(pybytes); \
1297 Py_DECREF(pybytes); \
1303PyObject* name##StringBytes(PyObject* self) \
1305 return name##StringGetData(self, true); \
1308PyObject* name##StringRepr(PyObject* self) \
1310 PyObject* data = name##StringGetData(self, true); \
1312 PyObject* repr = PyObject_Repr(data); \
1319PyObject* name##StringIsEqual(PyObject* self, PyObject* obj) \
1321 PyObject* data = name##StringGetData(self, PyBytes_Check(obj)); \
1323 PyObject* result = PyObject_RichCompare(data, obj, Py_EQ); \
1330PyObject* name##StringIsNotEqual(PyObject* self, PyObject* obj) \
1332 PyObject* data = name##StringGetData(self, PyBytes_Check(obj)); \
1334 PyObject* result = PyObject_RichCompare(data, obj, Py_NE); \
1342#define CPPYY_IMPL_STRING_PYTHONIZATION_CMP(type, name) \
1343CPPYY_IMPL_STRING_PYTHONIZATION(type, name) \
1344PyObject* name##StringCompare(PyObject* self, PyObject* obj) \
1346 PyObject* data = name##StringGetData(self, PyBytes_Check(obj)); \
1349 result = PyObject_Compare(data, obj); \
1352 if (PyErr_Occurred()) \
1354 return PyInt_FromLong(result); \
1367 std::string* obj = (std::string*)
self->GetObject();
1380 char*
keywords[] = {(
char*)
"encoding", (
char*)
"errors", (
char*)
nullptr};
1381 const char* encoding =
nullptr;
const char*
errors =
nullptr;
1389#if __cplusplus <= 202302L
1400 if (obj->find(
needle) != std::string::npos) {
1438#define CPYCPPYY_STRING_FINDMETHOD(name, cppname, pyname) \
1439PyObject* STLString##name(CPPInstance* self, PyObject* args, PyObject* ) \
1441 std::string* obj = GetSTLString(self); \
1445 PyObject* cppmeth = PyObject_GetAttrString((PyObject*)self, (char*)#cppname);\
1447 PyObject* result = PyObject_Call(cppmeth, args, nullptr); \
1448 Py_DECREF(cppmeth); \
1450 if (PyLongOrInt_AsULong64(result) == (PY_ULONG_LONG)std::string::npos) {\
1451 Py_DECREF(result); \
1452 return PyInt_FromLong(-1); \
1459 PyObject* pystr = CPyCppyy_PyText_FromStringAndSize(obj->data(), obj->size());\
1460 PyObject* pymeth = PyObject_GetAttrString(pystr, (char*)#pyname); \
1462 PyObject* result = PyObject_CallObject(pymeth, args); \
1463 Py_DECREF(pymeth); \
1569 for (
auto&
p:
dmc) {
1616#define COMPLEX_METH_GETSET(name, cppname) \
1617static PyObject* name##ComplexGet(PyObject* self, void*) { \
1618 return PyObject_CallMethodNoArgs(self, cppname); \
1620static int name##ComplexSet(PyObject* self, PyObject* value, void*) { \
1621 PyObject* result = PyObject_CallMethodOneArg(self, cppname, value); \
1623 Py_DECREF(result); \
1628PyGetSetDef name##Complex{(char*)#name, (getter)name##ComplexGet, (setter)name##ComplexSet, nullptr, nullptr};
1635 if (!
real)
return nullptr;
1642 if (!
imag)
return nullptr;
1653 if (!
real)
return nullptr;
1660 if (!
imag)
return nullptr;
1666 std::ostringstream s;
1667 s <<
'(' <<
r <<
'+' << i <<
"j)";
1681 ((std::complex<double>*)
self->GetObject())->
real(
d);
1698 ((std::complex<double>*)
self->GetObject())->
imag(
d);
1706 double r = ((std::complex<double>*)
self->GetObject())->
real();
1707 double i = ((std::complex<double>*)
self->GetObject())->
imag();
1763#if PY_VERSION_HEX >= 0x03000000
1782 if (
ol->HasMethods() &&
ol->fMethodInfo->fMethods.size() == 1) {
1819 if (
resname.find(
"iterator") == std::string::npos)
1901 name.compare(0, 6,
"tuple<", 6) != 0) {
1910 initdef <<
"namespace __cppyy_internal {\n"
1911 <<
"void init_" <<
rname <<
"(" <<
name <<
"*& self";
1924 if (
res_clean ==
"internal_enum_type_t")
1927 if (res.rfind(
']') == std::string::npos && res.rfind(
')') == std::string::npos) {
1929 else arg_types.push_back(
"const "+
res_clean+
"&");
1945 for (std::vector<std::string>::size_type i = 0; i < arg_types.size(); ++i) {
1950 for (std::vector<std::string>::size_type i = 0; i <
arg_names.size(); ++i) {
2028 if (
vtype.rfind(
"value_type") == std::string::npos) {
2053#if __cplusplus <= 202002L
2064#if __cplusplus <= 202002L
2088 else if (
name ==
"string" ||
name ==
"std::string") {
2095#if __cplusplus <= 202302L
2112 else if (
name ==
"basic_string_view<char,char_traits<char> >" ||
name ==
"std::basic_string_view<char>") {
2127 else if (
name ==
"std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> >"
2128 ||
name ==
"basic_string<wchar_t,char_traits<wchar_t>,allocator<wchar_t> >"
2129 ||
name ==
"std::basic_string<wchar_t,char_traits<wchar_t>,allocator<wchar_t> >"
2139 else if (
name ==
"complex<double>" ||
name ==
"std::complex<double>") {
#define PyInt_FromSsize_t
#define CPyCppyy_PyText_FromStringAndSize
#define CPyCppyy_PySliceCast
#define CPyCppyy_PyText_AsString
static PyObject * PyObject_CallMethodOneArg(PyObject *obj, PyObject *name, PyObject *arg)
#define PyBytes_FromStringAndSize
#define CPyCppyy_PyText_Type
static PyObject * PyObject_CallMethodNoArgs(PyObject *obj, PyObject *name)
#define CPyCppyy_PyText_FromString
#define CPyCppyy_PyText_Check
bool PyUnstable_Object_IsUniqueReferencedTemporary(PyObject *pyobject)
#define CPPYY_IMPL_STRING_PYTHONIZATION_CMP(type, name)
static bool run_pythonizors(PyObject *pyclass, PyObject *pyname, const std::vector< PyObject * > &v)
#define COMPLEX_METH_GETSET(name, cppname)
#define CPYCPPYY_STRING_FINDMETHOD(name, cppname, pyname)
#define PyObject_LengthHint
void FillVector(std::vector< double > &v, int size, T *a)
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
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 data
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 r
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 char Point_t Rectangle_t WindowAttributes_t index
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 attr
const_iterator end() const
void cppscope_to_legalname(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)
Py_ssize_t GetBuffer(PyObject *pyobject, char tc, int size, void *&buf, bool check=true)
bool AddToClass(PyObject *pyclass, const char *label, PyCFunction cfunc, int flags=METH_VARARGS)
PyTypeObject VectorIter_Type
PyObject * GetScopeProxy(Cppyy::TCppScope_t)
static PyObject * GetAttrDirect(PyObject *pyclass, PyObject *pyname)
bool Pythonize(PyObject *pyclass, const std::string &name)
bool CPPOverload_Check(T *object)
std::map< std::string, std::vector< PyObject * > > & pythonizations()
bool CPPScope_Check(T *object)
bool LowLevelView_Check(T *object)
bool CPPInstance_Check(T *object)
PyTypeObject IndexIter_Type
CPYCPPYY_EXTERN Converter * CreateConverter(const std::string &name, cdims_t=0)
std::set< std::string > gIteratorTypes
const RequestId_t RETURN_TYPE
const FormatId_t AS_STRING
RPY_EXPORTED bool IsIntegerType(const std::string &type_name)
RPY_EXPORTED size_t SizeOf(TCppType_t klass)
RPY_EXPORTED bool IsDefaultConstructable(TCppType_t type)
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 TCppIndex_t GetNumDatamembers(TCppScope_t scope, bool accept_namespace=false)
RPY_EXPORTED bool Compile(const std::string &code, bool silent=false)
RPY_EXPORTED TCppScope_t gGlobalScope
RPY_EXPORTED std::string ResolveName(const std::string &cppitem_name)
RPY_EXPORTED bool IsAggregate(TCppType_t type)
RPY_EXPORTED std::string GetScopedFinalName(TCppType_t type)
RPY_EXPORTED bool IsPublicData(TCppScope_t scope, TCppIndex_t idata)
RPY_EXPORTED bool IsBuiltin(const std::string &type_name)
RPY_EXPORTED bool IsStaticData(TCppScope_t scope, TCppIndex_t idata)
RPY_EXPORTED std::string GetDatamemberType(TCppScope_t scope, TCppIndex_t idata)
RPY_EXPORTED TCppMethod_t GetMethod(TCppScope_t scope, TCppIndex_t imeth)
RPY_EXPORTED bool IsSmartPtr(TCppType_t type)
RPY_EXPORTED TCppScope_t GetScope(const std::string &scope_name)
RPY_EXPORTED std::string GetMethodResultType(TCppMethod_t)
RPY_EXPORTED std::string GetDatamemberName(TCppScope_t scope, TCppIndex_t idata)
CoordSystem::Scalar get(DisplacementVector2D< CoordSystem, Tag > const &p)