431 if (!TPython::CPPInstance_Check(pyobj)) {
441 void *
obj = TPython::CPPInstance_AsVoidPtr(pyobj);
443 if (!strcmp(tcls->GetName(),
"string")) {
444 std::string *
str = (std::string*)
obj;
445 return PyUnicode_FromString(
str->c_str());
448 TString tstring = tcls->GetName();
449 if (tstring.BeginsWith(
"pair<") ||
450 tstring.BeginsWith(
"std::pair<")) {
452 PyObject *
v0 = PyObject_GetAttrString(pyobj,
"first");
453 PyObject *v1 = PyObject_GetAttrString(pyobj,
"second");
462 if (is_sequence(pyobj)) {
463 if (!strcmp(tcls->GetName(),
"CLHEP::Hep3Vector")) {
472 TList *members = tcls->GetListOfDataMembers();
473 const Int_t nmembers = members->GetEntries();
475 PyObject *py_members = PyList_New(nmembers+hdr);
476 #if PYROOT_INSPECTOR_DBG
477 std::cerr <<
"==[" << tcls->GetName() <<
"]== (#mbrs:"
480 <<
" #py-sz:" << PyList_Size(py_members)
486 const Py_ssize_t nelems = PySequence_Size(pyobj);
487 #if PYROOT_INSPECTOR_DBG
488 std::cerr <<
"== sequence (" << nelems <<
")...\n";
490 PyObject *py_elems = PyList_New(nelems);
491 for (Py_ssize_t
i = 0;
i < nelems; ++
i) {
492 PyObject *itr = PySequence_GetItem(pyobj,
i);
494 PyList_SET_ITEM(py_elems,
i, itr_pyroot);
499 PyList_SET_ITEM(py_members, 0, py_elems);
500 #if PYROOT_INSPECTOR_DBG
501 std::cerr <<
"== sequence (" << nelems <<
")... content:\n"
502 << ::to_str(py_elems)
504 std::cerr <<
"== sequence (" << nelems <<
")... [done]\n";
509 for (Int_t j = 0; j<nmembers; ++j) {
510 TDataMember *mbr = (TDataMember*)(members->At(j));
511 Int_t
offset = mbr->GetOffset();
514 #if PYROOT_INSPECTOR_DBG
515 TClass *mbr_cls = TClass::GetClass(mbr->GetTypeName());
516 std::cerr <<
"==[" << j <<
"] - [" << mbr->GetTypeName() <<
"] "
517 <<
"[" << mbr->GetName()
519 <<
"[" << (mbr_cls ? mbr_cls->GetName() :
"N/A") <<
"]\n";
524 if (persistentOnly && !mbr->IsPersistent())
526 if (mbr->IsaPointer())
528 if (mbr->IsBasic()) {
529 TDataType * mbr_type = mbr->GetDataType();
530 EDataType mbr_dtype = (EDataType)mbr_type->GetType();
531 py_mbr = to_pyobj(
ptr, mbr_dtype);
532 }
else if (mbr->IsEnum()) {
533 #if PYROOT_INSPECTOR_DBG
534 std::cerr <<
"==[" << mbr->GetTypeName() <<
"]["
535 << mbr->GetDataType()->GetType() <<
"][val="
536 << (*(
int*)
ptr) <<
"]["
537 << mbr->GetName() <<
"] is an enum !!\n";
539 py_mbr = to_pyobj(
ptr, kInt_t);
541 PyObject *pyroot_obj = TPython::CPPInstance_FromVoidPtr
547 Py_XDECREF(pyroot_obj);
550 std::cerr <<
"could not create py-object of type ["
551 << mbr->GetTypeName() <<
"] !\n";
552 Py_DECREF(py_members);
557 PyTuple_SET_ITEM(py_item, 0,
558 PyUnicode_FromString(mbr->GetName()));
559 PyTuple_SET_ITEM(py_item, 1, py_mbr);
560 PyList_SET_ITEM(py_members, j+hdr, py_item);
562 #if PYROOT_INSPECTOR_DBG
563 std::cerr <<
"==[" << tcls->GetName() <<
"]== (#mbrs:"
564 << nmembers <<
")... [done]\n";