mirror of
https://github.com/servo/servo.git
synced 2025-06-15 11:54:28 +00:00
auto merge of #5206 : Ms2ger/servo/pre-rustup-codegen-cleanup, r=jdm,SimonSapin
This commit is contained in:
commit
c05de08630
2 changed files with 15 additions and 17 deletions
|
@ -4150,13 +4150,16 @@ class CGInterfaceTrait(CGThing):
|
||||||
def fmt(arguments):
|
def fmt(arguments):
|
||||||
return "".join(", %s: %s" % argument for argument in arguments)
|
return "".join(", %s: %s" % argument for argument in arguments)
|
||||||
|
|
||||||
methods = CGList([
|
methods = [
|
||||||
CGGeneric("fn %s(self%s) -> %s;\n" % (name, fmt(arguments), rettype))
|
CGGeneric("fn %s(self%s) -> %s;\n" % (name, fmt(arguments), rettype))
|
||||||
for name, arguments, rettype in members()
|
for name, arguments, rettype in members()
|
||||||
], "")
|
]
|
||||||
self.cgRoot = CGWrapper(CGIndenter(methods),
|
if methods:
|
||||||
pre="pub trait %sMethods {\n" % descriptor.interface.identifier.name,
|
self.cgRoot = CGWrapper(CGIndenter(CGList(methods, "")),
|
||||||
post="}")
|
pre="pub trait %sMethods {\n" % descriptor.interface.identifier.name,
|
||||||
|
post="}")
|
||||||
|
else:
|
||||||
|
self.cgRoot = CGGeneric("")
|
||||||
|
|
||||||
def define(self):
|
def define(self):
|
||||||
return self.cgRoot.define()
|
return self.cgRoot.define()
|
||||||
|
@ -4362,8 +4365,8 @@ class CGDictionary(CGThing):
|
||||||
def struct(self):
|
def struct(self):
|
||||||
d = self.dictionary
|
d = self.dictionary
|
||||||
if d.parent:
|
if d.parent:
|
||||||
inheritance = " pub parent: %s::%s<'a, 'b>,\n" % (self.makeModuleName(d.parent),
|
inheritance = " pub parent: %s::%s,\n" % (self.makeModuleName(d.parent),
|
||||||
self.makeClassName(d.parent))
|
self.makeClassName(d.parent))
|
||||||
else:
|
else:
|
||||||
inheritance = ""
|
inheritance = ""
|
||||||
memberDecls = [" pub %s: %s," %
|
memberDecls = [" pub %s: %s," %
|
||||||
|
@ -4371,7 +4374,7 @@ class CGDictionary(CGThing):
|
||||||
for m in self.memberInfo]
|
for m in self.memberInfo]
|
||||||
|
|
||||||
return (string.Template(
|
return (string.Template(
|
||||||
"pub struct ${selfName}<'a, 'b> {\n" +
|
"pub struct ${selfName} {\n" +
|
||||||
"${inheritance}" +
|
"${inheritance}" +
|
||||||
"\n".join(memberDecls) + "\n" +
|
"\n".join(memberDecls) + "\n" +
|
||||||
"}").substitute( { "selfName": self.makeClassName(d),
|
"}").substitute( { "selfName": self.makeClassName(d),
|
||||||
|
@ -4395,11 +4398,11 @@ class CGDictionary(CGThing):
|
||||||
memberInits = CGList([memberInit(m) for m in self.memberInfo])
|
memberInits = CGList([memberInit(m) for m in self.memberInfo])
|
||||||
|
|
||||||
return string.Template(
|
return string.Template(
|
||||||
"impl<'a, 'b> ${selfName}<'a, 'b> {\n"
|
"impl ${selfName} {\n"
|
||||||
" pub fn empty() -> ${selfName}<'a, 'b> {\n"
|
" pub fn empty() -> ${selfName} {\n"
|
||||||
" ${selfName}::new(ptr::null_mut(), NullValue()).unwrap()\n"
|
" ${selfName}::new(ptr::null_mut(), NullValue()).unwrap()\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
" pub fn new(cx: *mut JSContext, val: JSVal) -> Result<${selfName}<'a, 'b>, ()> {\n"
|
" pub fn new(cx: *mut JSContext, val: JSVal) -> Result<${selfName}, ()> {\n"
|
||||||
" let object = if val.is_null_or_undefined() {\n"
|
" let object = if val.is_null_or_undefined() {\n"
|
||||||
" ptr::null_mut()\n"
|
" ptr::null_mut()\n"
|
||||||
" } else if val.is_object() {\n"
|
" } else if val.is_object() {\n"
|
||||||
|
|
|
@ -3,9 +3,8 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use dom::bindings::codegen::Bindings::NodeIteratorBinding;
|
use dom::bindings::codegen::Bindings::NodeIteratorBinding;
|
||||||
use dom::bindings::codegen::Bindings::NodeIteratorBinding::NodeIteratorMethods;
|
|
||||||
use dom::bindings::global::GlobalRef;
|
use dom::bindings::global::GlobalRef;
|
||||||
use dom::bindings::js::{JSRef, Temporary};
|
use dom::bindings::js::Temporary;
|
||||||
use dom::bindings::utils::{Reflector, reflect_dom_object};
|
use dom::bindings::utils::{Reflector, reflect_dom_object};
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
|
@ -24,7 +23,3 @@ impl NodeIterator {
|
||||||
reflect_dom_object(box NodeIterator::new_inherited(), global, NodeIteratorBinding::Wrap)
|
reflect_dom_object(box NodeIterator::new_inherited(), global, NodeIteratorBinding::Wrap)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> NodeIteratorMethods for JSRef<'a, NodeIterator> {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue