mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
Remove unused references to jsids in the generated code for dictionaries.
This commit is contained in:
parent
9d7478ab8a
commit
857eb87bb6
1 changed files with 5 additions and 40 deletions
|
@ -4175,9 +4175,6 @@ class CGDictionary(CGThing):
|
||||||
"pub struct ${selfName} {\n" +
|
"pub struct ${selfName} {\n" +
|
||||||
"${inheritance}" +
|
"${inheritance}" +
|
||||||
"\n".join(memberDecls) + "\n" +
|
"\n".join(memberDecls) + "\n" +
|
||||||
"\n".join(" //static jsid " +
|
|
||||||
self.makeIdName(m.identifier.name) + ";" for
|
|
||||||
m in d.members) + "\n"
|
|
||||||
"}").substitute( { "selfName": self.makeClassName(d),
|
"}").substitute( { "selfName": self.makeClassName(d),
|
||||||
"inheritance": inheritance }))
|
"inheritance": inheritance }))
|
||||||
|
|
||||||
|
@ -4193,15 +4190,6 @@ class CGDictionary(CGThing):
|
||||||
|
|
||||||
memberInits = [CGIndenter(self.getMemberConversion(m), indentLevel=6).define()
|
memberInits = [CGIndenter(self.getMemberConversion(m), indentLevel=6).define()
|
||||||
for m in self.memberInfo]
|
for m in self.memberInfo]
|
||||||
idinit = [CGGeneric('!InternJSString(cx, %s, "%s")' %
|
|
||||||
(m.identifier.name + "_id", m.identifier.name))
|
|
||||||
for m in d.members]
|
|
||||||
idinit = CGList(idinit, " ||\n")
|
|
||||||
idinit = CGWrapper(idinit, pre="if (",
|
|
||||||
post=(") {\n"
|
|
||||||
" return false;\n"
|
|
||||||
"}"),
|
|
||||||
reindent=True)
|
|
||||||
|
|
||||||
def defaultValue(ty):
|
def defaultValue(ty):
|
||||||
if ty is "bool":
|
if ty is "bool":
|
||||||
|
@ -4216,11 +4204,6 @@ class CGDictionary(CGThing):
|
||||||
return "/* uh oh: %s */" % ty
|
return "/* uh oh: %s */" % ty
|
||||||
|
|
||||||
return string.Template(
|
return string.Template(
|
||||||
"static initedIds: bool = false;\n" +
|
|
||||||
"\n".join("static %s: jsid = JSID_VOID;" %
|
|
||||||
self.makeIdName(m.identifier.name)
|
|
||||||
for m in d.members) + "\n"
|
|
||||||
"\n"
|
|
||||||
"impl ${selfName} {\n"
|
"impl ${selfName} {\n"
|
||||||
" pub fn new() -> ${selfName} {\n"
|
" pub fn new() -> ${selfName} {\n"
|
||||||
" ${selfName} {\n" +
|
" ${selfName} {\n" +
|
||||||
|
@ -4230,18 +4213,8 @@ class CGDictionary(CGThing):
|
||||||
" }\n"
|
" }\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"\n"
|
"\n"
|
||||||
" pub fn InitIds(&mut self, cx: *JSContext) -> bool {\n"
|
|
||||||
" //MOZ_ASSERT(!initedIds);\n"
|
|
||||||
" /*${idInit}\n"
|
|
||||||
" initedIds = true;*/ //XXXjdm\n"
|
|
||||||
" return true;\n"
|
|
||||||
" }\n"
|
|
||||||
"\n"
|
|
||||||
" pub fn Init(&mut self, cx: *JSContext, val: JSVal) -> JSBool {\n"
|
" pub fn Init(&mut self, cx: *JSContext, val: JSVal) -> JSBool {\n"
|
||||||
" unsafe {\n"
|
" unsafe {\n"
|
||||||
" if !initedIds && !self.InitIds(cx) {\n"
|
|
||||||
" return 0;\n"
|
|
||||||
" }\n"
|
|
||||||
"${initParent}"
|
"${initParent}"
|
||||||
" let mut found: JSBool = 0;\n"
|
" let mut found: JSBool = 0;\n"
|
||||||
" let temp: JSVal = NullValue();\n"
|
" let temp: JSVal = NullValue();\n"
|
||||||
|
@ -4259,7 +4232,6 @@ class CGDictionary(CGThing):
|
||||||
"selfName": self.makeClassName(d),
|
"selfName": self.makeClassName(d),
|
||||||
"initParent": CGIndenter(CGGeneric(initParent), indentLevel=6).define(),
|
"initParent": CGIndenter(CGGeneric(initParent), indentLevel=6).define(),
|
||||||
"initMembers": "\n\n".join(memberInits),
|
"initMembers": "\n\n".join(memberInits),
|
||||||
"idInit": CGIndenter(idinit).define(),
|
|
||||||
})
|
})
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -4304,18 +4276,11 @@ class CGDictionary(CGThing):
|
||||||
if member.defaultValue:
|
if member.defaultValue:
|
||||||
replacements["haveValue"] = "found != 0"
|
replacements["haveValue"] = "found != 0"
|
||||||
|
|
||||||
if True: #XXXjdm hack until 'static mut' exists for global jsids
|
|
||||||
propName = member.identifier.name
|
propName = member.identifier.name
|
||||||
propCheck = ('"%s".to_c_str().with_ref(|s| { JS_HasProperty(cx, val.to_object(), s, &found) })' %
|
propCheck = ('"%s".to_c_str().with_ref(|s| { JS_HasProperty(cx, val.to_object(), s, &found) })' %
|
||||||
propName)
|
propName)
|
||||||
propGet = ('"%s".to_c_str().with_ref(|s| { JS_GetProperty(cx, val.to_object(), s, &temp) })' %
|
propGet = ('"%s".to_c_str().with_ref(|s| { JS_GetProperty(cx, val.to_object(), s, &temp) })' %
|
||||||
propName)
|
propName)
|
||||||
else:
|
|
||||||
propId = self.makeIdName(member.identifier.name);
|
|
||||||
propCheck = ("JS_HasPropertyById(cx, val.to_object(), %s, &found)" %
|
|
||||||
propId)
|
|
||||||
propGet = ("JS_GetPropertyById(cx, val.to_object(), %s, &temp)" %
|
|
||||||
propId)
|
|
||||||
|
|
||||||
conversionReplacements = {
|
conversionReplacements = {
|
||||||
"prop": "(this->%s)" % member.identifier.name,
|
"prop": "(this->%s)" % member.identifier.name,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue