mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
CodegenRust fixes for NamedGetter
This commit is contained in:
parent
c17d5330af
commit
1533c07453
1 changed files with 16 additions and 6 deletions
|
@ -2090,11 +2090,14 @@ class CGDefineProxyHandler(CGAbstractMethod):
|
|||
return CGAbstractMethod.define(self)
|
||||
|
||||
def definition_body(self):
|
||||
customDefineProperty = 'defineProperty_'
|
||||
if self.descriptor.operations['IndexedSetter'] or self.descriptor.operations['NamedSetter']:
|
||||
customDefineProperty = 'defineProperty'
|
||||
body = """\
|
||||
let traps = ProxyTraps {
|
||||
getPropertyDescriptor: Some(getPropertyDescriptor),
|
||||
getOwnPropertyDescriptor: Some(getOwnPropertyDescriptor),
|
||||
defineProperty: Some(defineProperty_),
|
||||
defineProperty: Some(%s),
|
||||
getOwnPropertyNames: ptr::null(),
|
||||
delete_: Some(delete_),
|
||||
enumerate: ptr::null(),
|
||||
|
@ -2124,7 +2127,7 @@ let traps = ProxyTraps {
|
|||
};
|
||||
|
||||
CreateProxyHandler(&traps, &Class as *const _ as *const _)
|
||||
""" % (FINALIZE_HOOK_NAME,
|
||||
""" % (customDefineProperty, FINALIZE_HOOK_NAME,
|
||||
TRACE_HOOK_NAME)
|
||||
return CGGeneric(body)
|
||||
|
||||
|
@ -2280,8 +2283,15 @@ class CGPerSignatureCall(CGThing):
|
|||
invalidEnumValueFatal=not setter) for
|
||||
i in range(argConversionStartsAt, self.argCount)])
|
||||
|
||||
errorResult = None
|
||||
if self.isFallible():
|
||||
if nativeMethodName == "NamedSetter":
|
||||
errorResult = " false"
|
||||
else:
|
||||
errorResult = " false as JSBool"
|
||||
|
||||
cgThings.append(CGCallGenerator(
|
||||
' false as JSBool' if self.isFallible() else None,
|
||||
errorResult,
|
||||
self.getArguments(), self.argsPre, returnType,
|
||||
self.extendedAttributes, descriptor, nativeMethodName,
|
||||
static))
|
||||
|
@ -3840,14 +3850,14 @@ if expando.is_not_null() {
|
|||
getIndexedOrExpando = getFromExpando + "\n"
|
||||
|
||||
namedGetter = self.descriptor.operations['NamedGetter']
|
||||
if namedGetter and False: #XXXjdm unfinished
|
||||
getNamed = ("if (JSID_IS_STRING(id)) {\n" +
|
||||
if namedGetter:
|
||||
getNamed = ("if (RUST_JSID_IS_STRING(id) != 0) {\n" +
|
||||
" let name = jsid_to_str(cx, id);\n" +
|
||||
" let this = UnwrapProxy(proxy);\n" +
|
||||
" let this = JS::from_raw(this);\n" +
|
||||
" let this = this.root();\n" +
|
||||
CGIndenter(CGProxyNamedGetter(self.descriptor, templateValues)).define() +
|
||||
"}\n") % (self.descriptor.concreteType)
|
||||
"}\n")
|
||||
else:
|
||||
getNamed = ""
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue