You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When defining aliases for an enum, it is not recognized as the right type by cppyy.
Reproducer:
importcppyycppyy.cppdef("enum Enum { a,b,c };")
cppyy.cppdef("struct Track { using Type = Enum; };")
# Works!print(cppyy.gbl.Enum.a)
# Doesn'tprint(cppyy.gbl.Track.Type.a)
The output is:
0
Traceback (most recent call last):
File "/home/rembserj/spaces/master/root/src/root/tst99.py", line 10, in <module>
print(cppyy.gbl.Track.Type.a)
^^^^^^^^^^^^^^^^^^^^^^
AttributeError: type object 'int' has no attribute 'a'
In case this is a more complicated problem, any advice on how I can contribute to support this is greatly appreciated!
The type Track::Type is actually found as an enum, but it's seen as disjoint from the type Enum, not an alias of it. I'd figure it should resolve as an alias, to make Python's is work. That's a failure of ROOT/meta's type resolution.
However, even if not seen as an alias, the lookup should have worked if a if the enum was properly reflected. Looks like it's not:
import cppyy
cppyy.cppdef("enum Enum { a,b,c };")
cppyy.cppdef("struct Track { using Type = Enum; };")
print("is enum:", cppyy.gbl.gInterpreter.ClassInfo_IsEnum("Track::Type"))
c = cppyy.gbl.CppyyLegacy.TClass.GetClass("Track")
e = c.GetListOfEnums(1).FindObject("Type")
print("is valid:", not not e)
which yields:
is enum: True
is valid: False
In general, ROOT/meta lacks support for using and friend.
When defining aliases for an enum, it is not recognized as the right type by cppyy.
Reproducer:
The output is:
0 Traceback (most recent call last): File "/home/rembserj/spaces/master/root/src/root/tst99.py", line 10, in <module> print(cppyy.gbl.Track.Type.a) ^^^^^^^^^^^^^^^^^^^^^^ AttributeError: type object 'int' has no attribute 'a'
In case this is a more complicated problem, any advice on how I can contribute to support this is greatly appreciated!
Originally reported in the ROOT issue tracker:
root-project/root#9246
The text was updated successfully, but these errors were encountered: