servo/components/script
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
..
dom Introduce trait Castable 2015-10-21 11:37:16 +02:00
parse Introduce trait Castable 2015-10-21 11:37:16 +02:00
build.rs Fix build scripts warnings. 2015-03-18 21:53:48 +01:00
Cargo.toml Auto merge of #7777 - KiChjang:caseless-group-name-match, r=jdm 2015-10-02 13:26:05 -06:00
clipboard_provider.rs Fix reported test-tidy errors for unmerged import blocks 2015-09-19 12:50:14 -04:00
cors.rs Simplify AsyncResponseListener implementations. 2015-10-15 16:53:47 -07:00
devtools.rs Introduce trait Castable 2015-10-21 11:37:16 +02:00
document_loader.rs sorted the extern crate, mod & use declarations 2015-09-24 02:12:45 +05:30
horribly_inefficient_timers.rs sorted the extern crate, mod & use declarations 2015-09-24 02:12:45 +05:30
layout_interface.rs Handle <meta name=viewport> elements when added to document 2015-09-30 20:31:35 -07:00
lib.rs Introduce trait Castable 2015-10-21 11:37:16 +02:00
makefile.cargo Fix spurious rebuilds of the script crate 2015-10-08 21:37:56 -07:00
mem.rs Introduce DOMClass::heap_size_of 2015-10-14 21:52:16 +02:00
network_listener.rs Make AsyncResponseListener methods take &mut self. 2015-10-15 16:44:39 -07:00
page.rs Update script to work with lint changes 2015-10-16 01:20:27 +05:30
script_task.rs Introduce trait Castable 2015-10-21 11:37:16 +02:00
textinput.rs sorted the extern crate, mod & use declarations 2015-09-24 02:12:45 +05:30
timers.rs Support the updated spidermonkey bindings 2015-10-14 15:30:52 -04:00
webdriver_handlers.rs Introduce trait Castable 2015-10-21 11:37:16 +02:00