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

Beautify our union enums constructors #9508

Closed
nox opened this issue Feb 2, 2016 · 3 comments
Closed

Beautify our union enums constructors #9508

nox opened this issue Feb 2, 2016 · 3 comments

Comments

@nox
Copy link
Member

@nox nox commented Feb 2, 2016

They should be NodeOrString::Node instead of NodeOrString::eNode.

Files:

  • components/script/dom/bindings/codegen/CodegenRust.py
@jdm
Copy link
Member

@jdm jdm commented Feb 2, 2016

Specifically, CGUnionStruct is the python class that defines this.

@jdm jdm added the L-python label Feb 2, 2016
@alopatindev
Copy link
Contributor

@alopatindev alopatindev commented Feb 4, 2016

Anyone mind if I pick this up?

The change should be probably something like that

diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/Co
degenRust.py
index 8d53913..c4cc86a 100644
--- a/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/components/script/dom/bindings/codegen/CodegenRust.py
@@ -3636,10 +3636,10 @@ class CGUnionStruct(CGThing):
         templateVars = map(lambda t: getUnionTypeTemplateVars(t, self.descriptorProvider),
                            self.type.flatMemberTypes)
         enumValues = [
-            "    e%s(%s)," % (v["name"], v["typeName"]) for v in templateVars
+            "    %s(%s)," % (v["name"], v["typeName"]) for v in templateVars
         ]
         enumConversions = [
-            "            %s::e%s(ref inner) => inner.to_jsval(cx, rval),"
+            "            %s::%s(ref inner) => inner.to_jsval(cx, rval),"
             % (self.type, v["name"]) for v in templateVars
         ]
         return ("""\

But after the change I've got compilation errors related to enums that are used in components/script/dom.

error: no associated item named `eHTMLCanvasElement` found for type `dom::bindings::codegen::UnionTypes::ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement` in the current scope servo/components/script/dom/webglrenderingcontext.rs:1160

Should the files in components/script/dom be regenerated (How if so? I didn't figure out from the docs) or changed manually?

Thanks!

@jdm
Copy link
Member

@jdm jdm commented Feb 4, 2016

Everything under components is written by hand.

alopatindev added a commit to alopatindev/servo that referenced this issue Feb 4, 2016
alopatindev added a commit to alopatindev/servo that referenced this issue Feb 5, 2016
alopatindev added a commit to alopatindev/servo that referenced this issue Feb 5, 2016
bors-servo added a commit that referenced this issue Feb 7, 2016
… r=KiChjang

Fix #9508: Beautify our union enums constructors

Solves #9508
@jdm Please review. Thanks!

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9543)
<!-- Reviewable:end -->
@bors-servo bors-servo closed this in 2be4940 Feb 7, 2016
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.

None yet
3 participants
You can’t perform that action at this time.