mirror of
https://github.com/servo/servo.git
synced 2025-07-29 18:20:24 +01:00
Improve the readability of dictionaries' new() method.
This commit is contained in:
parent
edc5765978
commit
f376f9c2d7
1 changed files with 19 additions and 16 deletions
|
@ -5894,14 +5894,16 @@ class CGDictionary(CGThing):
|
||||||
def impl(self):
|
def impl(self):
|
||||||
d = self.dictionary
|
d = self.dictionary
|
||||||
if d.parent:
|
if d.parent:
|
||||||
initParent = ("parent: match try!(%s::%s::new(cx, val)) {\n"
|
initParent = ("parent: {\n"
|
||||||
" ConversionResult::Success(v) => v,\n"
|
" match try!(%s::%s::new(cx, val)) {\n"
|
||||||
" ConversionResult::Failure(error) => {\n"
|
" ConversionResult::Success(v) => v,\n"
|
||||||
" throw_type_error(cx, &error);\n"
|
" ConversionResult::Failure(error) => {\n"
|
||||||
" return Err(());\n"
|
" throw_type_error(cx, &error);\n"
|
||||||
" }\n"
|
" return Err(());\n"
|
||||||
" },\n" % (self.makeModuleName(d.parent),
|
" }\n"
|
||||||
self.makeClassName(d.parent)))
|
" }\n"
|
||||||
|
"},\n" % (self.makeModuleName(d.parent),
|
||||||
|
self.makeClassName(d.parent)))
|
||||||
else:
|
else:
|
||||||
initParent = ""
|
initParent = ""
|
||||||
|
|
||||||
|
@ -5999,7 +6001,7 @@ class CGDictionary(CGThing):
|
||||||
|
|
||||||
def getMemberConversion(self, memberInfo, memberType):
|
def getMemberConversion(self, memberInfo, memberType):
|
||||||
def indent(s):
|
def indent(s):
|
||||||
return CGIndenter(CGGeneric(s), 8).define()
|
return CGIndenter(CGGeneric(s), 12).define()
|
||||||
|
|
||||||
member, info = memberInfo
|
member, info = memberInfo
|
||||||
templateBody = info.template
|
templateBody = info.template
|
||||||
|
@ -6020,15 +6022,16 @@ class CGDictionary(CGThing):
|
||||||
|
|
||||||
conversion = (
|
conversion = (
|
||||||
"{\n"
|
"{\n"
|
||||||
"rooted!(in(cx) let mut rval = UndefinedValue());\n"
|
" rooted!(in(cx) let mut rval = UndefinedValue());\n"
|
||||||
"match try!(get_dictionary_property(cx, object.handle(), \"%s\", rval.handle_mut())) {\n"
|
" match try!(get_dictionary_property(cx, object.handle(), \"%s\", rval.handle_mut())) {\n"
|
||||||
" true => {\n"
|
" true => {\n"
|
||||||
"%s\n"
|
"%s\n"
|
||||||
" },\n"
|
" },\n"
|
||||||
" false => {\n"
|
" false => {\n"
|
||||||
"%s\n"
|
"%s\n"
|
||||||
" },\n"
|
" },\n"
|
||||||
"}\n}") % (member.identifier.name, indent(conversion), indent(default))
|
" }\n"
|
||||||
|
"}") % (member.identifier.name, indent(conversion), indent(default))
|
||||||
|
|
||||||
return CGGeneric(conversion)
|
return CGGeneric(conversion)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue