Commit graph

607 commits

Author SHA1 Message Date
Anthony Ramine
ca979e115b Cache legacy callback interface objects in proto_or_icache_array
We need them to be cached to not instantiate them multiple times with
lazy initialisation.
2016-02-25 15:15:44 +01:00
Anthony Ramine
2c4d5da866 Lazily-define standard ECMAScript classes 2016-02-25 15:15:44 +01:00
Anthony Ramine
86f3f37950 Always implement getOwnEnumerablePropertyKeys
According to JSProxy.h, without this the default implementation calls
ownPropertyKeys and filters out the unenumerable properties. We know when such
things exist so we don't need to do that.
2016-02-23 17:23:56 +01:00
Anthony Ramine
7f36247d03 Support [LegacyUnenumerableNamedProperties] 2016-02-23 17:23:51 +01:00
Anthony Ramine
cbf514d63f Fix a typo in CGDOMJSProxyHandler_getOwnPropertyDescriptor
Named properties are read-only if there is no named setter.
2016-02-23 17:23:03 +01:00
Anthony Ramine
b783d96749 Make fill_property_descriptor take a flags argument 2016-02-23 17:14:27 +01:00
Anthony Ramine
0af373cef6 Just pass global to CreateInterfaceObjects
The receiver parameter is useless here.
2016-02-23 15:42:45 +01:00
Anthony Ramine
96e28086e3 Clean up CGDOMJSClass 2016-02-23 15:42:44 +01:00
bors-servo
2676307793 Auto merge of #9633 - GuillaumeGomez:has_instance, r=nox
All interface objects now share the same hasInstance

r? @nox

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9633)
<!-- Reviewable:end -->
2016-02-19 19:49:33 +05:30
zakorgyula
6d6f23a69d Fixing issue with uniontypes not created with primitive types
refer to #9531
2016-02-18 11:08:47 +01:00
Ms2ger
eede44984d Derive the Debug trait for WebIDL-generated enums. 2016-02-17 16:29:37 +01:00
Anthony Ramine
c21a164396 Support [ExceptionClass]
Use it on DOMException.
2016-02-17 13:58:58 +01:00
Guillaume Gomez
bb9d3692c7 All interface objects now share the same hasInstance 2016-02-17 06:37:52 +01:00
Alexander Lopatin
2be49404be Fix #9508: Beautify our union enums constructors 2016-02-07 02:55:21 +03:00
bors-servo
a75f2cecda Auto merge of #9419 - psdh:includeTypedef, r=nox
generate typedefs in CodegenRust.

fixes #9384

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9419)
<!-- Reviewable:end -->
2016-01-26 22:10:57 +05:30
Prabhjyot Singh Sodhi
d6df844ae5 generate typedefs in CodegenRust 2016-01-26 21:56:44 +05:30
Michael Rosenberg
1f45eaf8a1 For WebIDL interfaces without constant members, do not generate a 'Constant' module 2016-01-26 02:50:53 -05:00
nxnfufunezn
e54929b4d7 Move ConstantSpec, NonNullJSNative and define_constants from utils to interface 2016-01-24 20:37:30 +05:30
Emilio Cobos Álvarez
950821989f webidl: Refactor isSequence in getJSToNativeConversionInfo
That way it does not depend on the return value for the same type.

This hopefully makes the code more clear, and avoids errors if something
changes in the future (for example, we could want to pass slices as
sequence arguments).
2016-01-15 14:30:38 +01:00
Emilio Cobos Álvarez
4ad1a8ddcc webidl: Implement sequences in unions
Unblocks #9053
2016-01-15 13:42:08 +01:00
Emilio Cobos Álvarez
92d7c49924 codegen: Implement WebIDL sequence arguments 2016-01-12 18:25:46 +01:00
Emilio Cobos Álvarez
2f1eee599c codegen: Move conversion behaviour to a common function 2016-01-12 18:25:46 +01:00
Anthony Ramine
d13da7d9b3 Fix prototypes of interface objects (fixes #2665) 2016-01-12 17:15:44 +01:00
Anthony Ramine
e1d3e4df2a Describe non-callback interface objects with JSClass structures
JS_NewFunction doesn't allow us to set the prototype of the interface objects.
2016-01-12 17:15:42 +01:00
Anthony Ramine
2957a56ad3 Bump rust-mozjs to 4d384eb830d8d53c1268e8ce37135ace21e41721 2016-01-12 17:15:29 +01:00
Anthony Ramine
d52948dfd5 Introduce Descriptor.prototypeDepth 2016-01-12 12:34:18 +01:00
Anthony Ramine
7693aecf15 Use the object prototype for callback interface objects
window.NodeFilter's prototype should be the object prototype.
2016-01-12 12:34:18 +01:00
Anthony Ramine
833e0d2fac Refactor prototype initialisation
The function do_create_interface_objects is removed in favour of 4 functions:
create_callback_interface_object, create_interface_prototype_object,
create_noncallback_interface_object and create_named_constructors.

While this increases the amount of codegen'd code, this greatly improves the
readability of the code involved in this part of DOM, instead of having one function
doing 4 different things. We can always find a more adequate abstraction later.

NativeProperties and everything related to the interface objects have been removed
from the utils module.
2016-01-12 12:34:18 +01:00
Anthony Ramine
967948be06 Remove NativePropertyHooks 2016-01-12 12:34:18 +01:00
Corey Farwell
d63c9d79d3 Remove unneeded dict sorting functions in CodegenRust.py 2016-01-10 12:20:46 -05:00
Guillaume Gomez
99ac1a81cc Generate PartialEq automatically 2016-01-03 18:07:09 +01:00
bors-servo
8dc4b8dcb9 Auto merge of #8993 - nox:small-codegen-slimming, r=Ms2ger
Slightly reduce the output of codegen

Interfaces which we know are never instantiated can generate less code.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8993)
<!-- Reviewable:end -->
2015-12-18 06:35:15 +05:30
bors-servo
d1ea209f0f Auto merge of #8996 - nox:rm-empty-modules, r=frewsxcv
Do not create modules from files with nothing to codegen (fixes #8711)

Fixes #8711.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8996)
<!-- Reviewable:end -->
2015-12-16 21:06:37 +05:30
bors-servo
9c4ca39ebe Auto merge of #8055 - nox:rm-webidl-patches, r=Ms2ger
Remove all our patches to the WebIDL parser

All the tweaks we need can just be made through Configuration.py.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8055)
<!-- Reviewable:end -->
2015-12-16 15:19:25 +05:30
Anthony Ramine
2522cfe539 Do not create modules from files with nothing to codegen (fixes #8711) 2015-12-16 01:17:06 +01:00
Anthony Ramine
372da02a42 Link [Abstract] to the existing concrete descriptor field
This makes codegen not emit anything strictly related to the interface which
are never used in the case of abstract interfaces, such as the Wrap method
or the DOMJSClass.
2015-12-16 00:42:15 +01:00
Anthony Ramine
05e456d0d2 Do not export GetProtoObject if the interface has no descendants 2015-12-16 00:39:22 +01:00
Anthony Ramine
561fdbb150 Merge CGClassConstructHook and CGClassNameConstructHook (fixes #8934) 2015-12-15 23:55:06 +01:00
Anthony Ramine
06947965b1 Remove all our local patches to the WebIDL parser
All the tweaks we need can just be made through Configuration.py, and
[Abstract] is being submitted upstream by Ms2ger.
2015-12-15 23:06:35 +01:00
Guillaume Gomez
14a22953dd Fix invalid returned value for dictionary types 2015-12-15 18:26:35 +01:00
Guillaume Gomez
4c99a85c73 Fix invalid dictionary inheritance 2015-12-14 00:53:21 +01:00
Keith Yeung
db92a8b030 Treat undefined arguments in JS as missing 2015-12-12 21:13:29 -08:00
Josh Matthews
30d1ff6abc Avoid a null-dereference using debug mozjs builds. This matches the equivalent code upstream in Gecko. 2015-12-07 14:58:00 -05:00
Anthony Ramine
60976406cc Implement [Unforgeable]
This is mostly stolen from Gecko. As there, we define the unforgeable members
on an object stored in the slots of the prototype object. They are then copied
onto instance objects when they are instantiated. It should be noted that
proxy objects see their unforgeable memebers defined on their expando object.

Unforgeable attributes aren't properly inherited in codegen (in a similar
fashion as getters and setters as filed in #5875) and require to be redefined
in derived interfaces. Fortunately, there are currently no such interfaces.

No unforgeable members can be included into the TestBinding interfaces for good
measure because they are not compatible with setters.

Given the unforgeable holder object has the same prototype as actual instances
of the interface, the finalize hook needs to check its slot pointer for nullity
before dropping it.

The new failing test isn't related to Unforgeable attributes, but to the fact
that all Document instances currently have a Location, even if their window
isn't in a browsing context.
2015-12-02 22:15:11 +01:00
Anthony Ramine
7547bcac24 Remove unused slot in prototype object (fixes #8588) 2015-11-30 14:48:24 +01:00
bors-servo
62acdd303b Auto merge of #8477 - asajeffrey:opaque-domstring, r=asajeffrey
Opaque DOMString

This patch makes DOMString an opaque wrapper round String (currently it's a transparent wrapper).

The changes are:

* Replacing DOMString(foo) by DOMString::from(foo).
* Replacing foo.0 by String::from(foo).
* Adding functions clear, push_str and extend for in-place mutation of DOMStrings.
* Replacing DOMString by String in other threads (devtools, storage and filereader).
* Making DOMString implement !Send.
* Removing the pub attribute from the contents of DOMString.

This enables experimenting with other string representations in the DOM.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8477)
<!-- Reviewable:end -->
2015-11-13 07:17:30 +05:30
bors-servo
e63b1e83d4 Auto merge of #8147 - nox:weakref, r=Ms2ger
Implement weak-referenceable JS-managed objects

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8147)
<!-- Reviewable:end -->
2015-11-13 06:22:40 +05:30
Alan Jeffrey
034769f280 Code generation uses DOMString::from("...") rather than DOMString("...".to_owned()). 2015-11-12 17:53:00 -06:00
bors-servo
c44c73aa00 Auto merge of #8498 - nox:fix-variadic-and-default-arguments, r=jdm
Properly handle variadic arguments preceded by default values

I broke that in #8197.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8498)
<!-- Reviewable:end -->
2015-11-13 04:22:11 +05:30
Anthony Ramine
d4ce25d07c Properly handle variadic arguments preceded by default values
I broke that in #8197.
2015-11-12 21:10:45 +01:00