Skip to content

Commit

Permalink
fix defineproperty for cases with namedsetter
Browse files Browse the repository at this point in the history
  • Loading branch information
snf committed Apr 27, 2015
1 parent 8ecb9d6 commit cdcd667
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 62 deletions.
45 changes: 31 additions & 14 deletions components/script/dom/bindings/codegen/CodegenRust.py
Expand Up @@ -3745,6 +3745,14 @@ def __init__(self, descriptor, templateValues=None):
self.templateValues = templateValues
CGProxySpecialOperation.__init__(self, descriptor, 'NamedGetter')

class CGProxyNamedPresenceChecker(CGProxyNamedGetter):
"""
Class to generate a call that checks whether a named property exists.
For now, we just delegate to CGProxyNamedGetter
"""
def __init__(self, descriptor):
CGProxyNamedGetter.__init__(self, descriptor)

class CGProxyNamedSetter(CGProxySpecialOperation):
"""
Class to generate a call to a named setter.
Expand Down Expand Up @@ -3872,6 +3880,7 @@ def getBody(self):
def definition_body(self):
return CGGeneric(self.getBody())

# TODO(Issue 5876)
class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod):
def __init__(self, descriptor):
args = [Argument('*mut JSContext', 'cx'), Argument('*mut JSObject', 'proxy'),
Expand Down Expand Up @@ -3911,21 +3920,29 @@ def getBody(self):
" let this = Unrooted::from_raw(this);\n" +
" let this = this.root();\n" +
CGIndenter(CGProxyNamedSetter(self.descriptor)).define() +
" return true;\n" +
"} else {\n" +
" return false;\n" +
"}\n")
elif self.descriptor.operations['NamedGetter']:
set += ("if RUST_JSID_IS_STRING(id) != 0 {\n" +
" let name = jsid_to_str(cx, id);\n" +
" let this = UnwrapProxy(proxy);\n" +
" let this = Unrooted::from_raw(this);\n" +
" let this = this.root();\n" +
CGIndenter(CGProxyNamedGetter(self.descriptor)).define() +
" if (found) {\n"
" return false;\n" +
" //return ThrowErrorMessage(cx, MSG_NO_PROPERTY_SETTER, \"%s\");\n" +
" }\n" +
" return true;\n"
"}\n") % (self.descriptor.name)
return set + """return proxyhandler::define_property(%s);""" % ", ".join(a.name for a in self.args)
else:
if self.descriptor.operations['NamedGetter']:
set += ("if RUST_JSID_IS_STRING(id) != 0 {\n" +
" let name = jsid_to_str(cx, id);\n" +
" let this = UnwrapProxy(proxy);\n" +
" let this = Unrooted::from_raw(this);\n" +
" let this = this.root();\n" +
CGProxyNamedPresenceChecker(self.descriptor).define() +
" if (found) {\n" +
# TODO(Issue 5876)
" //return js::IsInNonStrictPropertySet(cx)\n" +
" // ? opresult.succeed()\n" +
" // : ThrowErrorMessage(cx, MSG_NO_NAMED_SETTER, \"${name}\");\n" +
" return true;\n" +
" }\n" +
"}"
) % (self.descriptor.name, self.descriptor.name)
set += "return proxyhandler::define_property(%s);" % ", ".join(a.name for a in self.args)
return set

def definition_body(self):
return CGGeneric(self.getBody())
Expand Down
8 changes: 0 additions & 8 deletions tests/wpt/metadata/webstorage/builtins.html.ini

This file was deleted.

8 changes: 0 additions & 8 deletions tests/wpt/metadata/webstorage/in.html.ini

This file was deleted.

32 changes: 0 additions & 32 deletions tests/wpt/metadata/webstorage/setitem.html.ini

This file was deleted.

0 comments on commit cdcd667

Please sign in to comment.