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

Fix binding generation for overloaded functions with optionals and de… #19180

Merged
merged 1 commit into from Nov 11, 2017

Conversation

@ferjm
Copy link
Member

ferjm commented Nov 10, 2017

…fault values

The generated bindings for an interface like this:

void someFunction(Foo foo, optional long a = 0, optional long b = 1);
void someFunction(Bar bar, optional long a = 0);

are failing to build with an error like:

    error[E0425]: cannot find function `Throw` in this scope
         --> /Users/ferjm/dev/mozilla/servo/target/debug/build/script-7b1a12ddd08207e3/out/Bindings/TestBindingBinding.rs:15395:24
          |
    15395 |                 return Throw(cx, NS_ERROR_XPC_BAD_CONVERT_JS);
          |                        ^^^^^ not found in this scope
     
    error[E0425]: cannot find value `NS_ERROR_XPC_BAD_CONVERT_JS` in this scope
         --> /Users/ferjm/dev/mozilla/servo/target/debug/build/script-7b1a12ddd08207e3/out/Bindings/TestBindingBinding.rs:15395:34
          |
    15395 |                 return Throw(cx, NS_ERROR_XPC_BAD_CONVERT_JS);
          |                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
     
    error[E0425]: cannot find function `Throw` in this scope
         --> /Users/ferjm/dev/mozilla/servo/target/debug/build/script-7b1a12ddd08207e3/out/Bindings/TestBindingBinding.rs:15468:24
          |
    15468 |                 return Throw(cx, NS_ERROR_XPC_BAD_CONVERT_JS);
          |                        ^^^^^ not found in this scope
     
    error[E0425]: cannot find value `NS_ERROR_XPC_BAD_CONVERT_JS` in this scope
         --> /Users/ferjm/dev/mozilla/servo/target/debug/build/script-7b1a12ddd08207e3/out/Bindings/TestBindingBinding.rs:15468:34
          |
    15468 |                 return Throw(cx, NS_ERROR_XPC_BAD_CONVERT_JS);
          |                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
     
    error: aborting due to 4 previous errors
     
    error: Could not compile `script`. 
  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • There are tests for these changes

** Note that this depends** on servo/rust-mozjs#379


This change is Reviewable

@ferjm ferjm force-pushed the ferjm:optional.overloaded.webidl branch from 24636e6 to e1d286a Nov 10, 2017
@@ -483,7 +483,8 @@ def pickFirstSignature(condition, filterLambda):
else:
# Just throw; we have no idea what we're supposed to
# do with this.
caseBody.append(CGGeneric("return Throw(cx, NS_ERROR_XPC_BAD_CONVERT_JS);"))
caseBody.append(CGGeneric("throw_internal_error(cx, \"NS_ERROR_XPC_BAD_CONVERT_JS\");\n"

This comment has been minimized.

@jdm

jdm Nov 10, 2017

Member

Let's pass "Could not convert JavaScript argument" instead: https://dxr.mozilla.org/mozilla-central/source/js/xpconnect/src/xpc.msg#20

@ferjm ferjm force-pushed the ferjm:optional.overloaded.webidl branch from e1d286a to 49f0cec Nov 10, 2017
@ferjm ferjm force-pushed the ferjm:optional.overloaded.webidl branch from 49f0cec to 2974dae Nov 11, 2017
@ferjm ferjm changed the title [WIP] Fix binding generation for overloaded functions with optionals and de… Fix binding generation for overloaded functions with optionals and de… Nov 11, 2017
@ferjm ferjm requested a review from jdm Nov 11, 2017
@jdm
Copy link
Member

jdm commented Nov 11, 2017

@bors-servo
Copy link
Contributor

bors-servo commented Nov 11, 2017

📌 Commit 2974dae has been approved by jdm

@bors-servo
Copy link
Contributor

bors-servo commented Nov 11, 2017

Testing commit 2974dae with merge 9d05552...

bors-servo added a commit that referenced this pull request Nov 11, 2017
Fix binding generation for overloaded functions with optionals and de…

…fault values

The generated bindings for an interface like this:

```webidl
void someFunction(Foo foo, optional long a = 0, optional long b = 1);
void someFunction(Bar bar, optional long a = 0);
```
are failing to build with an error like:

```bash
    error[E0425]: cannot find function `Throw` in this scope
         --> /Users/ferjm/dev/mozilla/servo/target/debug/build/script-7b1a12ddd08207e3/out/Bindings/TestBindingBinding.rs:15395:24
          |
    15395 |                 return Throw(cx, NS_ERROR_XPC_BAD_CONVERT_JS);
          |                        ^^^^^ not found in this scope

    error[E0425]: cannot find value `NS_ERROR_XPC_BAD_CONVERT_JS` in this scope
         --> /Users/ferjm/dev/mozilla/servo/target/debug/build/script-7b1a12ddd08207e3/out/Bindings/TestBindingBinding.rs:15395:34
          |
    15395 |                 return Throw(cx, NS_ERROR_XPC_BAD_CONVERT_JS);
          |                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope

    error[E0425]: cannot find function `Throw` in this scope
         --> /Users/ferjm/dev/mozilla/servo/target/debug/build/script-7b1a12ddd08207e3/out/Bindings/TestBindingBinding.rs:15468:24
          |
    15468 |                 return Throw(cx, NS_ERROR_XPC_BAD_CONVERT_JS);
          |                        ^^^^^ not found in this scope

    error[E0425]: cannot find value `NS_ERROR_XPC_BAD_CONVERT_JS` in this scope
         --> /Users/ferjm/dev/mozilla/servo/target/debug/build/script-7b1a12ddd08207e3/out/Bindings/TestBindingBinding.rs:15468:34
          |
    15468 |                 return Throw(cx, NS_ERROR_XPC_BAD_CONVERT_JS);
          |                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope

    error: aborting due to 4 previous errors

    error: Could not compile `script`.
```
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] There are tests for these changes

** Note that this depends** on servo/rust-mozjs#379

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19180)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Nov 11, 2017

@bors-servo bors-servo merged commit 2974dae into servo:master Nov 11, 2017
3 checks passed
3 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@ferjm ferjm deleted the ferjm:optional.overloaded.webidl branch Mar 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.