Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix IsEnum check in cppyy/metacling #17775

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions bindings/pyroot/cppyy/cppyy-backend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ target_link_libraries(${libname} Core ${CMAKE_DL_LIBS})
# cppyy uses ROOT headers from binary directory
add_dependencies(${libname} move_headers)

# Allows us to use CppInterOp's API
add_dependencies(${libname} clangCppInterOp)
target_include_directories(${libname} SYSTEM PRIVATE ${CPPINTEROP_INCLUDE_DIRS})

set_property(GLOBAL APPEND PROPERTY ROOT_EXPORTED_TARGETS ${libname})

# Install library
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
#include "TROOT.h"
#include "TSystem.h"

// CppInterOp
#include "clang/Interpreter/CppInterOp.h"

// Standard
#include <assert.h>
#include <algorithm> // for std::count, std::remove
Expand Down Expand Up @@ -1078,9 +1081,13 @@ bool Cppyy::IsAbstract(TCppType_t klass)
bool Cppyy::IsEnum(const std::string& type_name)
{
if (type_name.empty()) return false;
std::string tn_short = TClassEdit::ShortType(type_name.c_str(), 1);
if (tn_short.empty()) return false;
return gInterpreter->ClassInfo_IsEnum(tn_short.c_str());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: this solve the problem 'only' for Python. It would be even better to fix TCling::ClassInfo_IsEnum.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed! The initial fix was in TCling(https://github.com/root-project/root/actions/runs/13424841558), that caused a certain set of test failures. I was curious to know which of them happened only via the python interface leading me to temporarily patch clingwrapper instead

// std::string tn_short = TClassEdit::ShortType(type_name.c_str(), 1);
// if (tn_short.empty()) return false;
// return gInterpreter->ClassInfo_IsEnum(tn_short.c_str());
if (auto type = Cpp::GetType(type_name))
return Cpp::IsEnumType(type);
else
return false;
}

bool Cppyy::IsAggregate(TCppType_t klass)
Expand Down
Loading