aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/codegen/CodegenRust.py
diff options
context:
space:
mode:
authorChris Manchester <cmanchester@mozilla.com>2015-01-18 17:12:35 -0500
committerChris Manchester <cmanchester@mozilla.com>2015-02-20 11:35:16 -0800
commit00f863b4fea0cac93dd2d77964d4b2e6f1f5ccba (patch)
treef92ccae9866d0042ae858b645fed4b61fba67776 /components/script/dom/bindings/codegen/CodegenRust.py
parentd1c8ed4359c47cd047e5ca3edfa37e8692058644 (diff)
downloadservo-00f863b4fea0cac93dd2d77964d4b2e6f1f5ccba.tar.gz
servo-00f863b4fea0cac93dd2d77964d4b2e6f1f5ccba.zip
Add stringifier method support to CodegenRust.py (fixes #1986)
Add a stringifier to URLUtils (Location). (fixes #4605) wpt metadata updates for #4605
Diffstat (limited to 'components/script/dom/bindings/codegen/CodegenRust.py')
-rw-r--r--components/script/dom/bindings/codegen/CodegenRust.py33
1 files changed, 29 insertions, 4 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py
index edb64705c3e..5d2aad2139e 100644
--- a/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/components/script/dom/bindings/codegen/CodegenRust.py
@@ -68,6 +68,13 @@ def stripTrailingWhitespace(text):
return '\n'.join(lines) + tail
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:]
builtinNames = {
@@ -1182,13 +1189,25 @@ class MethodDefiner(PropertyDefiner):
"length": 0,
"flags": "JSPROP_ENUMERATE" })
+ if not static:
+ stringifier = descriptor.operations['Stringifier']
+ if stringifier:
+ self.regular.append({
+ "name": "toString",
+ "nativeName": stringifier.identifier.name,
+ "length": 0,
+ "flags": "JSPROP_ENUMERATE"
+ })
+
+
def generateArray(self, array, name):
if len(array) == 0:
return ""
def specData(m):
if m.get("methodInfo", True):
- jitinfo = ("&%s_methodinfo" % m["name"])
+ identifier = m.get("nativeName", m["name"])
+ jitinfo = "&%s_methodinfo" % identifier
accessor = "genericMethod as NonNullJSNative"
else:
jitinfo = "0 as *const JSJitInfo"
@@ -4056,8 +4075,8 @@ class CGInterfaceTrait(CGThing):
def members():
for m in descriptor.interface.members:
- if m.isMethod() and not m.isStatic() \
- and not m.isIdentifierLess():
+ if (m.isMethod() and not m.isStatic() and
+ (not m.isIdentifierLess() or m.isStringifier())):
name = CGSpecializedMethod.makeNativeName(descriptor, m)
infallible = 'infallible' in descriptor.getExtendedAttributes(m)
for idx, (rettype, arguments) in enumerate(m.signatures()):
@@ -4125,7 +4144,8 @@ class CGDescriptor(CGThing):
(hasMethod, hasGetter, hasLenientGetter,
hasSetter, hasLenientSetter) = False, False, False, False, False
for m in descriptor.interface.members:
- if m.isMethod() and not m.isIdentifierLess():
+ if (m.isMethod() and
+ (not m.isIdentifierLess() or m == descriptor.operations["Stringifier"])):
if m.isStatic():
assert descriptor.interface.hasInterfaceObject()
cgThings.append(CGStaticMethod(descriptor, m))
@@ -4134,6 +4154,11 @@ class CGDescriptor(CGThing):
cgThings.append(CGMemberJITInfo(descriptor, m))
hasMethod = True
elif m.isAttr():
+ if m.stringifier:
+ raise TypeError("Stringifier attributes not supported yet. "
+ "See bug 824857.\n"
+ "%s" % m.location)
+
if m.isStatic():
assert descriptor.interface.hasInterfaceObject()
cgThings.append(CGStaticGetter(descriptor, m))