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

Should we be using FromJSValConvertible for enum conversions? #26169

Closed
Manishearth opened this issue Apr 10, 2020 · 0 comments
Closed

Should we be using FromJSValConvertible for enum conversions? #26169

Manishearth opened this issue Apr 10, 2020 · 0 comments

Comments

@Manishearth
Copy link
Member

@Manishearth Manishearth commented Apr 10, 2020

It seems like we don't have FromJSValConvertible implementations for enums. I can't think of a good reason for doing this, and this also means our bindings code is littered with code like

        let arg0: XRReferenceSpaceType = match find_enum_value(*cx, HandleValue::from_raw(args.get(0)), XRReferenceSpaceTypeValues::pairs) {
            Err(_) => { return false;
         },
            Ok((None, search)) => { throw_type_error(*cx, &format!("'{}' is not a valid enum value for enumeration 'XRReferenceSpaceType'.", search)); return false;
         },
            Ok((Some(&value), _)) => value,
        };

We should probably fix this.

Furthermore, this prevents us from using sequence<EnumType> in dictionaries in WebIDL

bors-servo added a commit that referenced this issue Apr 11, 2020
Add FromJSValConvertible for enums

Fixes #26169

This adds FromJSValConvertible implementations for webidl enums, which allows them to be used within `sequence<>`, etc.

This also uses these implementations when converting arguments.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

1 participant
You can’t perform that action at this time.