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

Deal with exceptions from custom element reaction steps #19265

Open
jdm opened this issue Nov 17, 2017 · 5 comments
Open

Deal with exceptions from custom element reaction steps #19265

jdm opened this issue Nov 17, 2017 · 5 comments

Comments

@jdm
Copy link
Member

@jdm jdm commented Nov 17, 2017

@tigercosmos
Copy link
Collaborator

@tigercosmos tigercosmos commented Jun 13, 2018

@jdm Could you point out where is the related code for https://html.spec.whatwg.org/multipage/custom-elements.html#cereactions ?
I try to find it in components/script/dom/customelementregistry.rs, but with no result. 😞

@cbrewster
Copy link
Member

@cbrewster cbrewster commented Jun 13, 2018

@tigercosmos the relevant code is in codegen:

if hasCEReactions:
self.cgRoot.append(CGGeneric("push_new_element_queue();\n"))
self.cgRoot.append(CGList([
CGGeneric("let result: "),
result,
CGGeneric(" = "),
call,
CGGeneric(";"),
]))
if hasCEReactions:
self.cgRoot.append(CGGeneric("pop_current_element_queue();\n"))

@tigercosmos
Copy link
Collaborator

@tigercosmos tigercosmos commented Jun 14, 2018

I am not familiar with CodeGen. What's the purpose of CodeGen? Why we use this way?
I am confused about code like this:

        self.cgRoot.append(CGList([
            CGGeneric("let result: "),
            result,
            CGGeneric(" = "),
            call,
            CGGeneric(";"),
        ]))
@jdm
Copy link
Member Author

@jdm jdm commented Jun 14, 2018

The code that is generated by CodeGenRust.py is responsible for:

  • creating JS objects that have properties and methods that match WebIDL interfaces
  • providing glue code between the JS properties and methods that are implemented in native Rust code
  • converting JS value types to native Rust types in well-defined ways

Since each of these is very repetitive and easy to mess up, we generate lots of very similar code during the build instead of handwriting it. Python code like the one you quote are building up Rust code piece by piece - a CGList is a list of generated code snippets; CGGeneric is just a raw string that will be included in the generated code.

@jdm
Copy link
Member Author

@jdm jdm commented Jun 14, 2018

You can find the generated code output for a given Something.webidl in target/debug/build/script-[hash]/out/Bindings/InterfaceBinding.rs.

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.