mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
auto merge of #5094 : chmanchester/servo/binarynames, r=jdm
This commit is contained in:
commit
1f53d30f85
5 changed files with 47 additions and 20 deletions
|
@ -68,13 +68,6 @@ def stripTrailingWhitespace(text):
|
||||||
return '\n'.join(lines) + tail
|
return '\n'.join(lines) + tail
|
||||||
|
|
||||||
def MakeNativeName(name):
|
def MakeNativeName(name):
|
||||||
# The gecko counterpart to this file uses the BinaryName machinery
|
|
||||||
# for this purpose (#4435 is the servo issue for BinaryName).
|
|
||||||
replacements = {
|
|
||||||
"__stringifier": "Stringify",
|
|
||||||
}
|
|
||||||
if name in replacements:
|
|
||||||
return replacements[name]
|
|
||||||
return name[0].upper() + name[1:]
|
return name[0].upper() + name[1:]
|
||||||
|
|
||||||
builtinNames = {
|
builtinNames = {
|
||||||
|
@ -2569,7 +2562,8 @@ class CGSpecializedMethod(CGAbstractExternMethod):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def makeNativeName(descriptor, method):
|
def makeNativeName(descriptor, method):
|
||||||
return MakeNativeName(method.identifier.name)
|
name = method.identifier.name
|
||||||
|
return MakeNativeName(descriptor.binaryNameFor(name))
|
||||||
|
|
||||||
class CGStaticMethod(CGAbstractStaticBindingMethod):
|
class CGStaticMethod(CGAbstractStaticBindingMethod):
|
||||||
"""
|
"""
|
||||||
|
@ -2635,7 +2629,8 @@ class CGSpecializedGetter(CGAbstractExternMethod):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def makeNativeName(descriptor, attr):
|
def makeNativeName(descriptor, attr):
|
||||||
nativeName = MakeNativeName(attr.identifier.name)
|
name = attr.identifier.name
|
||||||
|
nativeName = MakeNativeName(descriptor.binaryNameFor(name))
|
||||||
infallible = ('infallible' in
|
infallible = ('infallible' in
|
||||||
descriptor.getExtendedAttributes(attr, getter=True))
|
descriptor.getExtendedAttributes(attr, getter=True))
|
||||||
if attr.type.nullable() or not infallible:
|
if attr.type.nullable() or not infallible:
|
||||||
|
@ -2713,7 +2708,8 @@ class CGSpecializedSetter(CGAbstractExternMethod):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def makeNativeName(descriptor, attr):
|
def makeNativeName(descriptor, attr):
|
||||||
return "Set" + MakeNativeName(attr.identifier.name)
|
name = attr.identifier.name
|
||||||
|
return "Set" + MakeNativeName(descriptor.binaryNameFor(name))
|
||||||
|
|
||||||
|
|
||||||
class CGStaticSetter(CGAbstractStaticBindingMethod):
|
class CGStaticSetter(CGAbstractStaticBindingMethod):
|
||||||
|
@ -3569,7 +3565,7 @@ class CGProxySpecialOperation(CGPerSignatureCall):
|
||||||
(don't use this directly, use the derived classes below).
|
(don't use this directly, use the derived classes below).
|
||||||
"""
|
"""
|
||||||
def __init__(self, descriptor, operation):
|
def __init__(self, descriptor, operation):
|
||||||
nativeName = MakeNativeName(operation)
|
nativeName = MakeNativeName(descriptor.binaryNameFor(operation))
|
||||||
operation = descriptor.operations[operation]
|
operation = descriptor.operations[operation]
|
||||||
assert len(operation.signatures()) == 1
|
assert len(operation.signatures()) == 1
|
||||||
signature = operation.signatures()[0]
|
signature = operation.signatures()[0]
|
||||||
|
@ -3993,7 +3989,8 @@ class CGDOMJSProxyHandler_obj_toString(CGAbstractExternMethod):
|
||||||
def getBody(self):
|
def getBody(self):
|
||||||
stringifier = self.descriptor.operations['Stringifier']
|
stringifier = self.descriptor.operations['Stringifier']
|
||||||
if stringifier:
|
if stringifier:
|
||||||
nativeName = MakeNativeName(stringifier.identifier.name)
|
name = self.descriptor.binaryNameFor(stringifier.identifier.name)
|
||||||
|
nativeName = MakeNativeName(name)
|
||||||
signature = stringifier.signatures()[0]
|
signature = stringifier.signatures()[0]
|
||||||
returnType = signature[0]
|
returnType = signature[0]
|
||||||
extendedAttributes = self.descriptor.getExtendedAttributes(stringifier)
|
extendedAttributes = self.descriptor.getExtendedAttributes(stringifier)
|
||||||
|
@ -4077,7 +4074,8 @@ class CGClassConstructHook(CGAbstractExternMethod):
|
||||||
let global = global_object_for_js_object(JS_CALLEE(cx, vp).to_object());
|
let global = global_object_for_js_object(JS_CALLEE(cx, vp).to_object());
|
||||||
let global = global.root();
|
let global = global.root();
|
||||||
""")
|
""")
|
||||||
nativeName = MakeNativeName(self._ctor.identifier.name)
|
name = self._ctor.identifier.name
|
||||||
|
nativeName = MakeNativeName(self.descriptor.binaryNameFor(name))
|
||||||
callGenerator = CGMethodCall(["global.r()"], nativeName, True,
|
callGenerator = CGMethodCall(["global.r()"], nativeName, True,
|
||||||
self.descriptor, self._ctor)
|
self.descriptor, self._ctor)
|
||||||
return CGList([preamble, callGenerator])
|
return CGList([preamble, callGenerator])
|
||||||
|
@ -4848,11 +4846,15 @@ class CGCallback(CGClass):
|
||||||
return self._deps
|
return self._deps
|
||||||
|
|
||||||
# We're always fallible
|
# We're always fallible
|
||||||
def callbackGetterName(attr):
|
def callbackGetterName(attr, descriptor):
|
||||||
return "Get" + MakeNativeName(attr.identifier.name)
|
return "Get" + MakeNativeName(
|
||||||
|
descriptor.binaryNameFor(attr.identifier.name))
|
||||||
|
|
||||||
|
|
||||||
|
def callbackSetterName(attr, descriptor):
|
||||||
|
return "Set" + MakeNativeName(
|
||||||
|
descriptor.binaryNameFor(attr.identifier.name))
|
||||||
|
|
||||||
def callbackSetterName(attr):
|
|
||||||
return "Set" + MakeNativeName(attr.identifier.name)
|
|
||||||
|
|
||||||
class CGCallbackFunction(CGCallback):
|
class CGCallbackFunction(CGCallback):
|
||||||
def __init__(self, callback, descriptorProvider):
|
def __init__(self, callback, descriptorProvider):
|
||||||
|
@ -5179,7 +5181,8 @@ class CallbackOperation(CallbackOperationBase):
|
||||||
self.ensureASCIIName(method)
|
self.ensureASCIIName(method)
|
||||||
jsName = method.identifier.name
|
jsName = method.identifier.name
|
||||||
CallbackOperationBase.__init__(self, signature,
|
CallbackOperationBase.__init__(self, signature,
|
||||||
jsName, MakeNativeName(jsName),
|
jsName,
|
||||||
|
MakeNativeName(descriptor.binaryNameFor(jsName)),
|
||||||
descriptor, descriptor.interface.isSingleOperationInterface())
|
descriptor, descriptor.interface.isSingleOperationInterface())
|
||||||
|
|
||||||
class CallbackGetter(CallbackMember):
|
class CallbackGetter(CallbackMember):
|
||||||
|
|
|
@ -251,6 +251,20 @@ class Descriptor(DescriptorProvider):
|
||||||
else:
|
else:
|
||||||
add('all', [config], attribute)
|
add('all', [config], attribute)
|
||||||
|
|
||||||
|
self._binaryNames = desc.get('binaryNames', {})
|
||||||
|
self._binaryNames.setdefault('__legacycaller', 'LegacyCall')
|
||||||
|
self._binaryNames.setdefault('__stringifier', 'Stringify')
|
||||||
|
|
||||||
|
for member in self.interface.members:
|
||||||
|
if not member.isAttr() and not member.isMethod():
|
||||||
|
continue
|
||||||
|
binaryName = member.getExtendedAttribute("BinaryName")
|
||||||
|
if binaryName:
|
||||||
|
assert isinstance(binaryName, list)
|
||||||
|
assert len(binaryName) == 1
|
||||||
|
self._binaryNames.setdefault(member.identifier.name,
|
||||||
|
binaryName[0])
|
||||||
|
|
||||||
# Build the prototype chain.
|
# Build the prototype chain.
|
||||||
self.prototypeChain = []
|
self.prototypeChain = []
|
||||||
parent = interface
|
parent = interface
|
||||||
|
@ -260,6 +274,9 @@ class Descriptor(DescriptorProvider):
|
||||||
config.maxProtoChainLength = max(config.maxProtoChainLength,
|
config.maxProtoChainLength = max(config.maxProtoChainLength,
|
||||||
len(self.prototypeChain))
|
len(self.prototypeChain))
|
||||||
|
|
||||||
|
def binaryNameFor(self, name):
|
||||||
|
return self._binaryNames.get(name, name)
|
||||||
|
|
||||||
def getExtendedAttributes(self, member, getter=False, setter=False):
|
def getExtendedAttributes(self, member, getter=False, setter=False):
|
||||||
def maybeAppendInfallibleToAttrs(attrs, throws):
|
def maybeAppendInfallibleToAttrs(attrs, throws):
|
||||||
if throws is None:
|
if throws is None:
|
||||||
|
|
|
@ -3262,7 +3262,8 @@ class IDLAttribute(IDLInterfaceMember):
|
||||||
identifier == "Frozen" or
|
identifier == "Frozen" or
|
||||||
identifier == "AvailableIn" or
|
identifier == "AvailableIn" or
|
||||||
identifier == "NewObject" or
|
identifier == "NewObject" or
|
||||||
identifier == "CheckPermissions"):
|
identifier == "CheckPermissions" or
|
||||||
|
identifier == "BinaryName"):
|
||||||
# Known attributes that we don't need to do anything with here
|
# Known attributes that we don't need to do anything with here
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
@ -3861,7 +3862,8 @@ class IDLMethod(IDLInterfaceMember, IDLScope):
|
||||||
identifier == "Pref" or
|
identifier == "Pref" or
|
||||||
identifier == "Func" or
|
identifier == "Func" or
|
||||||
identifier == "AvailableIn" or
|
identifier == "AvailableIn" or
|
||||||
identifier == "CheckPermissions"):
|
identifier == "CheckPermissions" or
|
||||||
|
identifier == "BinaryName"):
|
||||||
# Known attributes that we don't need to do anything with here
|
# Known attributes that we don't need to do anything with here
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -98,6 +98,8 @@ impl<'a> TestBindingMethods for JSRef<'a, TestBinding> {
|
||||||
fn SetByteStringAttributeNullable(self, _: Option<ByteString>) {}
|
fn SetByteStringAttributeNullable(self, _: Option<ByteString>) {}
|
||||||
fn GetStringAttributeNullable(self) -> Option<DOMString> { Some("".to_owned()) }
|
fn GetStringAttributeNullable(self) -> Option<DOMString> { Some("".to_owned()) }
|
||||||
fn SetStringAttributeNullable(self, _: Option<DOMString>) {}
|
fn SetStringAttributeNullable(self, _: Option<DOMString>) {}
|
||||||
|
fn SetBinaryRenamedAttribute(self, _: DOMString) {}
|
||||||
|
fn BinaryRenamedAttribute(self) -> DOMString { "".to_owned() }
|
||||||
fn GetEnumAttributeNullable(self) -> Option<TestEnum> { Some(_empty) }
|
fn GetEnumAttributeNullable(self) -> Option<TestEnum> { Some(_empty) }
|
||||||
fn GetInterfaceAttributeNullable(self) -> Option<Temporary<Blob>> {
|
fn GetInterfaceAttributeNullable(self) -> Option<Temporary<Blob>> {
|
||||||
let global = self.global.root();
|
let global = self.global.root();
|
||||||
|
@ -108,6 +110,7 @@ impl<'a> TestBindingMethods for JSRef<'a, TestBinding> {
|
||||||
fn SetUnionAttributeNullable(self, _: Option<HTMLElementOrLong>) {}
|
fn SetUnionAttributeNullable(self, _: Option<HTMLElementOrLong>) {}
|
||||||
fn GetUnion2AttributeNullable(self) -> Option<EventOrString> { Some(eString("".to_owned())) }
|
fn GetUnion2AttributeNullable(self) -> Option<EventOrString> { Some(eString("".to_owned())) }
|
||||||
fn SetUnion2AttributeNullable(self, _: Option<EventOrString>) {}
|
fn SetUnion2AttributeNullable(self, _: Option<EventOrString>) {}
|
||||||
|
fn BinaryRenamedMethod(self) -> () {}
|
||||||
fn ReceiveVoid(self) -> () {}
|
fn ReceiveVoid(self) -> () {}
|
||||||
fn ReceiveBoolean(self) -> bool { false }
|
fn ReceiveBoolean(self) -> bool { false }
|
||||||
fn ReceiveByte(self) -> i8 { 0 }
|
fn ReceiveByte(self) -> i8 { 0 }
|
||||||
|
|
|
@ -91,7 +91,9 @@ interface TestBinding {
|
||||||
attribute Blob? interfaceAttributeNullable;
|
attribute Blob? interfaceAttributeNullable;
|
||||||
attribute (HTMLElement or long)? unionAttributeNullable;
|
attribute (HTMLElement or long)? unionAttributeNullable;
|
||||||
attribute (Event or DOMString)? union2AttributeNullable;
|
attribute (Event or DOMString)? union2AttributeNullable;
|
||||||
|
[BinaryName="BinaryRenamedAttribute"] attribute DOMString attrToBinaryRename;
|
||||||
|
|
||||||
|
[BinaryName="BinaryRenamedMethod"] void methToBinaryRename();
|
||||||
void receiveVoid();
|
void receiveVoid();
|
||||||
boolean receiveBoolean();
|
boolean receiveBoolean();
|
||||||
byte receiveByte();
|
byte receiveByte();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue