Commit graph

246 commits

Author SHA1 Message Date
rohan.prinja
6e774ea6eb merge from master 2015-11-03 19:01:23 +09:00
Ms2ger
7ccc5ad7da Support unions that contain USVStrings. 2015-10-30 16:24:04 +01:00
rohan.prinja
45224028db more refactoring 2015-10-30 20:26:29 +09:00
bors-servo
3efa749976 Auto merge of #8226 - froydnj:gc-zeal, r=Ms2ger
unblock using JS_GC_ZEAL

I think these patches move the `JS_SetReservedSlot` call to the right place for #6057.  I'm not sure that the interface to `create_dom_global` is the best; passing a `JSVal` or a `*libc::c_void` seemed about equal, so I'd welcome feedback there.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8226)
<!-- Reviewable:end -->
2015-10-28 17:24:36 +05:30
Nathan Froyd
c82b6ce843 move reserved slot setting for DOM globals
Moving this slot setting prior to initializing standard classes and
other initialization tasks means that we can effectively use JS_GC_ZEAL.

Fixes #6057.
2015-10-27 18:08:35 -04:00
Nathan Froyd
3d39646c8e reduce indentation in CodegenRust.py
We're going to wind up tacking on different pieces of code for the
global vs. non-global case once we move the JS_SetReservedSlot call into
create_dom_global.  We might as well separate the indentation changes
into a separate commit.
2015-10-27 16:46:01 -04:00
bors-servo
d1295e9e7d Auto merge of #8040 - froydnj:codegen-arg-info, r=jdm
generate JIT argument type information for methods

This enhances `CodegenRust.py` to output `JSTypedMethodJitInfo` structures where appropriate.  This brings a notable speedup to tests like Dromaeo's `dom-attr/getAttribute`, which improves by several orders of magnitude with these patches applied.

If there are tricks for addressing the XXX comments, I would appreciate hearing them.

I think this addresses all of #6904.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8040)
<!-- Reviewable:end -->
2015-10-28 01:06:06 +05:30
Nathan Froyd
4f649ac6dd generate JIT argument type information for methods
Fixes #6904.
2015-10-27 15:09:32 -04:00
Nathan Froyd
dd74572dc0 add CGMemberJITInfo.{getJSArgType,getSingleArgType}
These are copied directly from Gecko's Codegen.py, with two changes:

- We need to use ArgType:: to qualify the enums rather than plain
  JSJitInfo::

- Given Rust's stronger notion of enums, we need to treat everything as an
  i32 so we can bitwise-or things together.
2015-10-27 15:07:55 -04:00
bors-servo
3342cd9531 Auto merge of #8132 - akiss77:codegen-u8, r=Ms2ger
Fix char types in script binding codegen

Use `libc::c_char` instead of `i8` for character data since that's more
portable. (Some architectures, e.g. AArch64, have unsigned characters,
i.e. `u8`.)

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8132)
<!-- Reviewable:end -->
2015-10-21 10:44:14 -06:00
Akos Kiss
8405ac70c9 Fix char types in script binding codegen
Use `libc::c_char` instead of `i8` for character data since that's more
portable. (Some architectures, e.g. AArch64, have unsigned characters,
i.e. `u8`.)
2015-10-21 14:31:07 +00:00
Anthony Ramine
13ea3ac413 Introduce trait Castable
This trait is used to hold onto the downcast and upcast functions of all
castable IDL interfaces. A castable IDL interface is one which either derives
from or is derived by other interfaces.

The deriving relation is represented by implementations of marker trait
DerivedFrom<T: Castable> generated in InheritTypes.

/^[ ]*use dom::bindings::codegen::InheritTypes::.*(Base|Cast|Derived)/ {
    /::[a-zA-Z]+(Base|Cast|Derived);/d
    s/([{ ])[a-zA-Z]+(Base|Cast|Derived), /\1/g
    s/([{ ])[a-zA-Z]+(Base|Cast|Derived), /\1/g
    s/, [a-zA-Z]+(Base|Cast|Derived)([},])/\2/g
    s/, [a-zA-Z]+(Base|Cast|Derived)([},])/\2/g
    /\{([a-zA-Z]+(Base|Cast|Derived))?\};$/d
    s/\{([a-zA-Z_]+)\};$/\1;/
}

s/([a-zA-Z]+)Cast::from_ref\(\&?\**([a-zA-Z_]+)(\.r\(\))?\)/\2.upcast::<\1>()/g
s/([a-zA-Z]+)Cast::from_ref\(\&?\**([a-zA-Z_]+)(\.[a-zA-Z_]+\(\))?\)/\2\3.upcast::<\1>()/g
s/\(([a-zA-Z]+)Cast::from_ref\)/\(Castable::upcast::<\1>\)/g

s/([a-zA-Z]+)Cast::from_root/Root::upcast::<\1>/g

s/([a-zA-Z]+)Cast::from_layout_js\(\&([a-zA-Z_.]+)\)/\2.upcast::<\1>()/g

s/([a-zA-Z]+)Cast::to_ref\(\&?\**([a-zA-Z_]+)(\.r\(\))?\)/\2.downcast::<\1>()/g
s/([a-zA-Z]+)Cast::to_ref\(\&?\**([a-zA-Z_]+)(\.[a-zA-Z_]+\(\))?\)/\2\3.downcast::<\1>()/g
s/\(([a-zA-Z]+)Cast::to_ref\)/\(Castable::downcast::<\1>\)/g

s/([a-zA-Z]+)Cast::to_root/Root::downcast::<\1>/g

s/([a-zA-Z]+)Cast::to_layout_js\(&?([a-zA-Z_.]+(\(\))?)\)/\2.downcast::<\1>()/g

s/\.is_document\(\)/.is::<Document>()/g
s/\.is_htmlanchorelement\(\)/.is::<HTMLAnchorElement>()/g
s/\.is_htmlappletelement\(\)/.is::<HTMLAppletElement>()/g
s/\.is_htmlareaelement\(\)/.is::<HTMLAreaElement>()/g
s/\.is_htmlbodyelement\(\)/.is::<HTMLBodyElement>()/g
s/\.is_htmlembedelement\(\)/.is::<HTMLEmbedElement>()/g
s/\.is_htmlfieldsetelement\(\)/.is::<HTMLFieldSetElement>()/g
s/\.is_htmlformelement\(\)/.is::<HTMLFormElement>()/g
s/\.is_htmlframesetelement\(\)/.is::<HTMLFrameSetElement>()/g
s/\.is_htmlhtmlelement\(\)/.is::<HTMLHtmlElement>()/g
s/\.is_htmlimageelement\(\)/.is::<HTMLImageElement>()/g
s/\.is_htmllegendelement\(\)/.is::<HTMLLegendElement>()/g
s/\.is_htmloptgroupelement\(\)/.is::<HTMLOptGroupElement>()/g
s/\.is_htmloptionelement\(\)/.is::<HTMLOptionElement>()/g
s/\.is_htmlscriptelement\(\)/.is::<HTMLScriptElement>()/g
s/\.is_htmltabledatacellelement\(\)/.is::<HTMLTableDataCellElement>()/g
s/\.is_htmltableheadercellelement\(\)/.is::<HTMLTableHeaderCellElement>()/g
s/\.is_htmltablerowelement\(\)/.is::<HTMLTableRowElement>()/g
s/\.is_htmltablesectionelement\(\)/.is::<HTMLTableSectionElement>()/g
s/\.is_htmltitleelement\(\)/.is::<HTMLTitleElement>()/g
2015-10-21 11:37:16 +02:00
Anthony Ramine
c77d3b965f Introduce IDLInterface::derives()
This method is given a DOMClass value and returns whether it derives from Self.

Interfaces with no descendants directly check whether the given DOMClass is the
same as their own.
2015-10-21 10:59:36 +02:00
Corey Farwell
26abff9663 Fix formatting for variable in doc-comment within codegen 2015-10-17 15:20:12 -04:00
bors-servo
417cf5738e Auto merge of #8020 - nox:codegen-derived, r=Ms2ger
Generate all Derived implementations in codegen

Follow-up of #7873.

@Ms2ger r? :)

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8020)
<!-- Reviewable:end -->
2015-10-15 12:53:08 -06:00
bors-servo
5a0a91eba7 Auto merge of #7972 - nox:codegen-heapsize, r=Ms2ger
Introduce DOMClass::heap_size_of

It holds a function pointer to the HeapSizeOf::heap_size_of_children()
implementation corresponding to that IDL interface.

This removes the need for a clumsly TypeId-based match expression in the
former heap_size_of_eventtarget() function.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7972)
<!-- Reviewable:end -->
2015-10-15 07:13:55 -06:00
Anthony Ramine
617fc08783 Generate all Derived implementations in codegen 2015-10-14 22:04:20 +02:00
Anthony Ramine
da67630931 Introduce DOMClass::heap_size_of
It holds a function pointer to the HeapSizeOf::heap_size_of_children()
implementation corresponding to that IDL interface.

This removes the need for a clumsly TypeId-based match expression in the
former heap_size_of_eventtarget() function.
2015-10-14 21:52:16 +02:00
Michael Wu
e733a7c46a Support the updated spidermonkey bindings 2015-10-14 15:30:52 -04:00
Anthony Ramine
aab2c40389 Generate the TypeId enums in codegen 2015-10-14 18:45:35 +02:00
Andriy Kunitsin
7301609c18 Changed dom_class type to Option<&'static DOMClass> 2015-10-09 19:57:22 +03:00
Ms2ger
6b160c6a29 Document RegisterBindings::RegisterProxyHandlers. 2015-10-07 12:22:15 +02:00
Ms2ger
03b04e5363 Add support for documenting CGAbstractMethods. 2015-10-07 12:21:59 +02:00
Anthony Ramine
e24b8ab644 Don't generate useless InheritTypes interfaces
Interfaces with no descendant need neither a Base trait nor upcast functions,
and interfaces with no ancestors neither a Derived trait nor downcast functions.
2015-10-02 16:15:12 +02:00
Corey Farwell
d8da5c20f6 Remove deprecated 'creator' WebIDL attribute
According to @Ms2ger, the 'creator' attribute was merged into 'setter'
2015-09-21 07:12:17 -04:00
Corey Farwell
3b99893eaa Python 'is' operator should not be used to check value
'is' checks reference. '==' checks value
2015-09-20 12:39:32 -04:00
Corey Farwell
38bbdd80db Remove parens around Python 'assert' statement
'assert' is a statement, not a function
2015-09-20 12:10:28 -04:00
Anthony Ramine
c25085f68a Introduce [Abstract] to mark non-leaf interfaces
Some interfaces like Node, CharacterData and HTMLTableCellElement are never
instantiated directly, only their descendant interfaces are. Those are marked
with [Abstract] to set their type_id to None instead of having dummy values
in the TypeId enums.
2015-09-13 19:46:28 +02:00
Michael Wu
941f7dc04b Move EventTargetTypeId/NodeTypeId to DOMClass 2015-09-12 01:09:46 +02:00
Corey Farwell
a4027f0259 Link to Servo issue instead of Gecko bug 2015-09-10 10:54:30 +02:00
bors-servo
a855669d4f Auto merge of #7455 - nox:rm-unused-warnings, r=jdm
Do not allow some warnings in codegen anymore

This fixes #395.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7455)
<!-- Reviewable:end -->
2015-08-30 11:37:04 -06:00
Anthony Ramine
cf6975f2a3 Do not allow unreachable_code in codegen anymore 2015-08-30 17:25:05 +02:00
Anthony Ramine
3c1c315838 Do not allow dead_code in codegen anymore 2015-08-30 17:19:42 +02:00
Anthony Ramine
2c8638ea9e Do not allow unused_parens in codegen anymore 2015-08-30 17:16:15 +02:00
Anthony Ramine
1064e7decc Do not allow unused_mut in codegen anymore 2015-08-30 16:53:35 +02:00
Anthony Ramine
aaa7a86381 Do not allow unused_unsafe in codegen anymore 2015-08-30 16:53:20 +02:00
bors-servo
940bcadc13 Auto merge of #7432 - jdm:dashedprops, r=nox
Add dashed CSS properties in CSSStyleDeclaration



<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7432)
<!-- Reviewable:end -->
2015-08-30 08:20:57 -06:00
Corey Farwell
8f876a179a Prefer JSTrue/JSFalse to 1/0 2015-08-28 22:03:01 -04:00
Josh Matthews
40806977b5 Add infrastructure for supporting dashed CSS property names on CSSStyleDeclaration. 2015-08-28 13:15:16 -04:00
Anthony Ramine
709d347872 Make the traits for the IDL interfaces take &self 2015-08-27 22:27:43 +02:00
bors-servo
a897795dab Auto merge of #7387 - Yoric:2240-2, r=Ms2ger
Fixes #2240 - NamedGetter and NamedSetter do not assume that the arg is named `name`

I'm not totally sure about how to test this.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7387)
<!-- Reviewable:end -->
2015-08-27 00:38:46 -06:00
bors-servo
98728a6c75 Auto merge of #7395 - Manishearth:doc-inherit, r=nox
Document InheritTypes



<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7395)
<!-- Reviewable:end -->
2015-08-26 20:56:02 -06:00
Manish Goregaokar
4ee5b664c2 Document InheritTypes 2015-08-27 04:35:50 +05:30
bors-servo
48945b0fc1 Auto merge of #7397 - Manishearth:doublepointer-meet-fire, r=nox
Remove doublepointer in VirtualMethods, and from_borrowed_ref



<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7397)
<!-- Reviewable:end -->
2015-08-26 15:01:12 -06:00
Manish Goregaokar
4678ec16bb remove to_borrowed_ref, fix Activatable 2015-08-27 02:27:42 +05:30
Manish Goregaokar
b33c5427bc Remove doublepointer in VirtualMethods, and from_borrowed_ref
Most of the heavy lifting done by:

```
$ ls *rs | xargs gawk -i inplace '/let .*: &&.*from_borrowed_ref/{sub("&&", "\\&");sub("_borrowed_","_");} {print $0}'
$ ls *rs | xargs gawk -i inplace "/impl.*VirtualMethods/{in_vm=1; sub(/<'a>/,\"\");sub(/&'a /,\"\")} /^}\$/{in_vm=0;} in_vm{\$0=gensub(/\\*self([^.])/,\"self\\\1\",\"g\"); sub(/from_borrowed_ref/,\"from_ref\")} {print}"
```
2015-08-27 02:14:48 +05:30
David Rajchenbach-Teller
d3ab0c2909 Fixes #2240 - NamedGetter and NamedSetter do not assume that the argument is named name 2015-08-26 16:58:39 +02:00
Corey Farwell
5bf262770f Don't use is operatory to compare Python strings
`is` checks identity. `==` checks value. I can't think of a reason why
we would want the former in these scenarios.

More info:

* http://stackoverflow.com/a/1504742
* https://docs.python.org/2/reference/expressions.html#is
2015-08-22 10:22:47 -04:00
Corey Farwell
2ab43bea5d Utilize Python context managers for opening/closing files
In some of these cases, files were not being closed
2015-08-21 11:15:17 -04:00
Corey Farwell
b11be4d253 Initial implementation of ownPropertyKeys proxy handler
Generates `SupportedPropertyNames` on DOM structs that should implement
it. Most of them are unimplemented now (which can be implemented in
later PRs), with the exception of `HTMLCollection`. Also added a couple
relevant WPT tests.

Closes #6390

Closes #2215
2015-08-20 11:58:42 -04:00