Skip to content

Beautify our union enums constructors #9508

Closed

Description

@nox

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

Files:

  • components/script/dom/bindings/codegen/CodegenRust.py

Activity

  1. added
    E-less-complex
    I-cleanup
    on Feb 2, 2016
  2. jdm commented on Feb 2, 2016

    @jdm
    Member

    Specifically, CGUnionStruct is the python class that defines this.

  3. added
    L-python
    on Feb 2, 2016
  4. alopatindev commented on Feb 4, 2016

    @alopatindev
    Contributor

    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!

  5. jdm commented on Feb 4, 2016

    @jdm
    Member

    Everything under components is written by hand.

  6. added 4 commits that reference this issue on Feb 4, 2016
    9bfeb19
    8141d57
    892ea30
    2be4940
  7. added a commit that references this issue on Feb 7, 2016
    28ecb0b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-less-complexI-cleanupL-python

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions