Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

script: Fix integer-JSID handling in named getters. #18543

Merged
merged 3 commits into from Sep 18, 2017
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Prev

script: Properly implement LegacyPlatformGetOwnProperty in WebIDL.

We were missing the "ignoreNamedProperties" bit, which my previous patch
uncovers.
  • Loading branch information
emilio committed Sep 18, 2017
commit 90fb2847207678e7feee06eaf17d75ac359d6a07
@@ -4817,15 +4817,14 @@ def __init__(self, descriptor):
"bool", args)
self.descriptor = descriptor

# https://heycam.github.io/webidl/#LegacyPlatformObjectGetOwnProperty
def getBody(self):
indexedGetter = self.descriptor.operations['IndexedGetter']
indexedSetter = self.descriptor.operations['IndexedSetter']

get = ""
if indexedGetter or indexedSetter:
if indexedGetter:
get = "let index = get_array_index_from_id(cx, id);\n"

if indexedGetter:
attrs = "JSPROP_ENUMERATE"
if self.descriptor.operations['IndexedSetter'] is None:
attrs += " | JSPROP_READONLY"
@@ -4864,11 +4863,16 @@ def getBody(self):
'successCode': fillDescriptor,
'pre': 'rooted!(in(cx) let mut result_root = UndefinedValue());'
}

# See the similar-looking in CGDOMJSProxyHandler_get for the spec quote.
condition = "RUST_JSID_IS_STRING(id) || RUST_JSID_IS_INT(id)"
if indexedGetter:
condition = "index.is_none() && (%s)" % condition
# Once we start supporting OverrideBuiltins we need to make
# ResolveOwnProperty or EnumerateOwnProperties filter out named
# properties that shadow prototype properties.
namedGet = """
if RUST_JSID_IS_STRING(id) || RUST_JSID_IS_INT(id) {
if %s {
let mut has_on_proto = false;
if !has_property_on_prototype(cx, proxy, id, &mut has_on_proto) {
return false;
@@ -4877,7 +4881,7 @@ def getBody(self):
%s
}
}
""" % CGIndenter(CGProxyNamedGetter(self.descriptor, templateValues), 8).define()
""" % (condition, CGIndenter(CGProxyNamedGetter(self.descriptor, templateValues), 8).define())
else:
namedGet = ""

@@ -5093,9 +5097,12 @@ def getBody(self):
indexed = ""

namedGetter = self.descriptor.operations['NamedGetter']
condition = "RUST_JSID_IS_STRING(id) || RUST_JSID_IS_INT(id)"
if indexedGetter:
condition = "index.is_none() && (%s)" % condition
if namedGetter:
named = """\
if RUST_JSID_IS_STRING(id) || RUST_JSID_IS_INT(id) {
if %s {
let mut has_on_proto = false;
if !has_property_on_prototype(cx, proxy, id, &mut has_on_proto) {
return false;
@@ -5107,7 +5114,7 @@ def getBody(self):
}
}
""" % CGIndenter(CGProxyNamedGetter(self.descriptor), 8).define()
""" % (condition, CGIndenter(CGProxyNamedGetter(self.descriptor), 8).define())
else:
named = ""

@@ -5136,6 +5143,7 @@ def __init__(self, descriptor):
CGAbstractExternMethod.__init__(self, descriptor, "get", "bool", args)
self.descriptor = descriptor

# https://heycam.github.io/webidl/#LegacyPlatformObjectGetOwnProperty
def getBody(self):
getFromExpando = """\
rooted!(in(cx) let mut expando = ptr::null_mut());
@@ -5175,9 +5183,16 @@ def getBody(self):

namedGetter = self.descriptor.operations['NamedGetter']
if namedGetter:
getNamed = ("if RUST_JSID_IS_STRING(id) || RUST_JSID_IS_INT(id) {\n" +
condition = "RUST_JSID_IS_STRING(id) || RUST_JSID_IS_INT(id)"
# From step 1:
# If O supports indexed properties and P is an array index, then:
#
# 3. Set ignoreNamedProps to true.
if indexedGetter:
condition = "index.is_none() && (%s)" % condition
getNamed = ("if %s {\n" +
CGIndenter(CGProxyNamedGetter(self.descriptor, templateValues)).define() +
"}\n")
"}\n") % condition
else:
getNamed = ""

This file was deleted.

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.