-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Description
I guess this is a bit of a corner case. Following situation:
C++ code:
namespace NameSpaceA {
enum EnumA {
SomeValue = 1
};
};
namespace NameSpaceB {
enum EnumB {
SomeValue = 17
};
};
// use typedefs so enums in namespaces can be mapped in WebIDL
typedef NameSpaceA::EnumA NameSpaceA_EnumA;
typedef NameSpaceB::EnumB NameSpaceB_EnumB;Corresponding idl file:
enum NameSpaceA_EnumA {
"NameSpaceA_EnumA::SomeValue"
};
enum NameSpaceB_EnumB {
"NameSpaceB_EnumB::SomeValue"
};
This code compiles. However the problem is that, in javascript, the enum values are accessed by their unquallified name. Hence there is only a single Module.SomeValue defined and one of the two values gets lost.
I'm currently mapping nvidia PhysX with WebIDL and such enums are used as flags all over the place. Passing wrong values here can result in pretty weird and unexpected behavior. My current work-around is to use the internal functions generated by WebIDL Binder instead (e.g. Module._emscripten_enum_NameSpaceA_EnumA_SomeValue()).
However I think it would be better to map enum values with their quallified name or at least issue some kind of warning since this can produce bugs which are quite hard to track down.