Commit graph

536 commits

Author SHA1 Message Date
Anthony Ramine
6e1523f4ae Compile WebIDL return type "object" to NonZero<*mut JSObject> 2016-08-30 19:07:13 +02:00
tp6vup54
59dcb31491 Convert imports in generate_imports into one per line, so that it can easily add new ones with alphabetical order. 2016-08-27 14:45:47 +08:00
Tetsuharu OHZEKI
0277cf9174 Make DOMJSClass use JSClass instead of Class (fixes #13031) 2016-08-26 22:31:09 +02:00
Anthony Ramine
dccf771e25 Implement [Replaceable] (fixes #13033) 2016-08-26 10:37:59 +02:00
Anthony Ramine
6c1167b1e2 Pass the receiver to get_property_on_prototype (fixes #11600) 2016-08-25 15:48:07 +02:00
Anthony Ramine
f70fa98954 Make has_property_on_prototype fallible 2016-08-25 15:46:43 +02:00
Anthony Ramine
241de3dfd0 Call JS_SetImmutablePrototype for prototypes of globals (fixes #13023) 2016-08-25 14:29:27 +02:00
Anthony Ramine
6da56f7e67 Define interface members on the global object directly (fixes #4593) 2016-08-25 14:29:16 +02:00
Anthony Ramine
0729000b56 Pass a MutableHandleObject to create_global_object 2016-08-25 14:03:09 +02:00
Anthony Ramine
5f59bb2e0c Make create_global_object take a &'static Class 2016-08-25 14:03:08 +02:00
Anthony Ramine
a4f2159e36 Rename utils::create_dom_object to interface::create_global_object 2016-08-25 14:03:07 +02:00
Anthony Ramine
32a600246e Split global logic out of CGWrapMethod 2016-08-25 14:02:52 +02:00
bors-servo
1370fa5e3b Auto merge of #12819 - jdm:iterable2, r=nox
Support pair and value iterable WebIDL bindings

The actual iterator implementation and JSAPI calls related to setting up the interface are ported directly from Gecko's Codegen.py, IterableIterator.h, and IterableIterator.webidl. The changes to support multiple interfaces in one file are required because the internal iterator interface the parser generates gets associated with the original interface's WebIDL file. It seemed like a good time to address #571 in that case.

---
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #12628 and fix #571.
- [X] There are tests for these changes

<!-- 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/12819)
<!-- Reviewable:end -->
2016-08-24 12:47:53 -05:00
Josh Matthews
86a0c45f87 Use named arguments for CGImports. 2016-08-24 13:47:26 -04:00
Josh Matthews
6492c090f1 Set up the iterator prototype as the prototype of iterator interfaces, and alias forEach to the entries method. 2016-08-24 13:47:24 -04:00
Josh Matthews
812a761abf Implement pair iterators in WebIDL interfaces. 2016-08-24 11:26:01 -04:00
Josh Matthews
34bb937aee Support value iterators in WebIDL interfaces. 2016-08-24 11:26:00 -04:00
Josh Matthews
221bc84693 Support multiple WebIDL interfaces being generated in the same output binding file.
Each interface gets its own module named ${Interface}Binding. Structs, enums, and callbacks
continue to use the root module of the binding file. If there is only one interface in the
file, we generate reexports for several public APIs and types so that existing DOM implementations
don't need any modifications. When multiple interfaces exist, the reexported names get the interface
name prepended (eg. FooWrap instead of Wrap).

As part of this work, stop glob-importing all DOM types in every generated binding and start generating
more targeted lists of relevant types based on the methods, members, etc. of WebIDL types that are in use.
2016-08-24 11:25:58 -04:00
Ms2ger
b29ffb1c4c Reformat from_jsval implementation for unions. 2016-08-24 15:41:07 +02:00
bors-servo
3c4a08c016 Auto merge of #12954 - GuillaumeGomez:dictionary_error, r=nox
Update rust-mozjs

<!-- 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/12954)
<!-- Reviewable:end -->
2016-08-24 06:19:37 -05:00
Guillaume Gomez
2f3f4a5bd6 Update rust-mozjs dependency 2016-08-24 12:56:49 +02:00
Boris Zbarsky
5341f852ce Use JS_SplicePrototype to set the right proto on the global, instead of JS_SetPrototype, since the latter will permanently deoptimize it. 2016-08-24 00:43:52 -04:00
Malisa Smith
7fd65affab bindings generator: support default ByteString values in dictionary 2016-08-10 10:50:36 -07:00
Ms2ger
89efccc426 Update SpiderMonkey to m-c bcf4ff0c3eef.
This currently breaks Servo on Android, because there are a number of
interdependent changes that cannot easily land serially in a way that
keeps it working throughout. We expect to fix this in the near future.
2016-07-28 13:05:56 +02:00
Malisa Smith
56bdc002fc Union types now allow ByteString 2016-07-21 19:19:12 -07:00
bors-servo
4ae0897175 Auto merge of #12541 - jdm:seqseq, r=nox
Support sequences of sequences in generated bindings.

This fixes a blocker for #11897. `unroll` recursively gets the inner type of any sequence type encountered, so it's inappropriate for codegen that only wants the immediate inner type. However, if a type identifies as a sequence and is nullable, we need to reach through the nullable wrapper first. Gecko does very similar things.

---
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #12528 (github issue number if applicable).
- [X] There are tests for these changes

<!-- 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/12541)
<!-- Reviewable:end -->
2016-07-21 14:24:52 -05:00
Josh Matthews
9ef848b65e Support sequences of sequences in generated bindings.
unroll recursively gets the inner type of any sequence type encountered, so it's inappropriate for codegen that only wants the immediate inner type. However, if a type identifies as a sequence and is nullable, we need to reach through the nullable wrapper first. Gecko does very similar things.
2016-07-21 10:26:57 -04:00
Josh Matthews
3c2435a172 Generate a list of supported DOM APIs from parsed WebIDLs. 2016-07-15 18:13:09 -04:00
bors-servo
e2e7013e76 Auto merge of #12395 - jdm:nowrap, r=Ms2ger
Avoid calling JS_WrapValue for same-compartment DOM reflectors

This change shaves off 15-20ns per iteration of the node.firstChild getter test in tests/html/bindings_perf.html. Based on [similar Gecko code](http://searchfox.org/mozilla-central/rev/f43c9e0ffa92e72dbdbcbf57eecf04a43d46da63/dom/bindings/BindingUtils.h#781).

---
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix (partially) #12358

<!-- 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/12395)
<!-- Reviewable:end -->
2016-07-12 05:50:46 -07:00
Josh Matthews
fc3b785af1 Remove unused imports from codegen. 2016-07-12 08:22:51 -04:00
Ms2ger
d678b20616 Implement the [Exposed] extended attribute on interfaces.
Fixes #2823.
2016-07-12 13:06:56 +02:00
Ms2ger
4c31c8ac7b Simplify CGConstructorEnabled. 2016-07-12 13:06:54 +02:00
Ms2ger
28630f5487 Make DefineDOMInterface and ConstructorEnabled unsafe functions. 2016-07-12 13:06:53 +02:00
Ms2ger
e99054f731 Add support for unsafe Rust-ABI functions to CGAbstractMethod. 2016-07-12 13:06:52 +02:00
Ms2ger
1dcdc2859c Generate 'pub' before 'unsafe extern', if both are used. 2016-07-12 13:06:51 +02:00
Ms2ger
b5412f3840 Correct indentation in the DOMClass function. 2016-07-12 13:06:50 +02:00
bors-servo
80cb0cf821 Auto merge of #11872 - eddyb:back-to-roots, r=Ms2ger
Replace return_address usage for rooting with stack guards and convenience macros.

The existing `Rooted` and `RootedVec` users were migrated the the following two macros:
```rust
let x = Rooted::new(cx, value);
// Was changed to:
rooted!(in(cx) let x = value);
// Which expands to:
let mut __root = Rooted::new_unrooted(value);
let x = RootedGuard::new(cx, &mut __root);
```
```rust
let mut v = RootedVec::new();
v.extend(iterator);
// Was changed to:
rooted_vec!(let v <- iterator);
// Which expands to:
let mut __root = RootableVec::new();
let v = RootedVec::new(&mut __root, iterator);
```

The `rooted!` macro depends on servo/rust-mozjs#272.
These APIs based on two types, a container to be rooted and a rooting guard, allow implementing both `Rooted`-style rooting and `Traceable`-based rooting in stable Rust, without abusing `return_address`.

Such macros may have been tried before, but in 1.9 their hygiene is broken, they work only since 1.10.

Sadly, `Rooted` is a FFI type and completely exposed, so I cannot prevent anyone from creating their own, although all fields but the value get overwritten by `RootedGuard::new` anyway.
`RootableVec` OTOH is *guaranteed* to be empty when not rooted, which makes it harmless AFAICT.

By fixing rust-lang/rust#34227, this PR enables Servo to build with `-Zorbit`.

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix rust-lang/rust#34227
- [x] These changes do not require tests because they are not functional changes

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11872)
<!-- Reviewable:end -->
2016-07-04 11:03:35 -07:00
Eduard Burtescu
b79a7d468e Use a stack guard and a macro for RootedVec instead of return_address. 2016-07-04 20:59:06 +03:00
Eduard Burtescu
0db1faf876 Switch to using the new rooted!/RootedGuard API for rooting. 2016-07-04 20:59:01 +03:00
Corey Farwell
22928f50ac Refactor util::prefs operations to be methods on static struct. 2016-07-02 16:43:39 -04:00
Ms2ger
296afe4bc9 Use ObjectOpResult::succeed. 2016-06-27 17:59:08 +02:00
Ms2ger
300f2df203 Remove a useless local variable. 2016-06-27 17:59:07 +02:00
Josh Matthews
b8853554db Wrap executions of Rust code called from JS in catch_unwind. Propagate the interrupted panic to the origin of the JS execution via TLS before resuming. Fix #6462. 2016-06-22 09:35:19 -04:00
Jansen Jan
fda011923e Support WindowProxy return values in bindings
unscopable
2016-06-09 23:42:27 +02:00
Anthony Ramine
3529803975 Implement [Unscopable] (fixes #11583) 2016-06-07 15:34:44 +02:00
Anthony Ramine
3cc7b575fb Initialise reflector earlier for globals
This allows us to use global_root_from_object in the context of a Condition.
2016-05-27 14:11:34 +02:00
Anthony Ramine
e179cb02ff Implement [Func] 2016-05-27 00:55:02 +02:00
Anthony Ramine
fd7c4f8149 Remove utils::Prefable in favour of guard::Guard 2016-05-26 23:56:13 +02:00
Anthony Ramine
a20db08f06 Remove Prefable::terminator 🤖 2016-05-26 23:55:37 +02:00
Anthony Ramine
adcecda047 Simplify how Prefable arrays are passed in bindings::interface 2016-05-26 23:55:36 +02:00