Bug 989619 - patch 1 - Codegen should allow static methods with a reserved C++ keywords as the name, r=peterv
authorAndrea Marchesini <amarchesini@mozilla.com>
Sat, 04 Jun 2016 09:31:44 +0200
changeset 339523 c54d1374d42a0c7892fcd96e1e51045e68922b29
parent 339522 1a641275e97e48f383f1ed65363109e94c475b9b
child 339524 f4c1500759bf9f4a970967cf7f0b8ca47254f349
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 989619 - patch 1 - Codegen should allow static methods with a reserved C++ keywords as the name, r=peterv
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -2281,16 +2281,20 @@ class MethodDefiner(PropertyDefiner):
                 # Methods generated for a maplike/setlike declaration are not
                 # enumerable.
                 "flags": "JSPROP_ENUMERATE" if not isMaplikeOrSetlikeMethod else "0",
                 "condition": PropertyDefiner.getControllingCondition(m, descriptor),
                 "allowCrossOriginThis": m.getExtendedAttribute("CrossOriginCallable"),
                 "returnsPromise": m.returnsPromise(),
                 "hasIteratorAlias": "@@iterator" in m.aliases
+            if m.isStatic():
+                method["nativeName"] = CppKeywords.checkMethodName(IDLToCIdentifier(m.identifier.name))
             if isChromeOnly(m):
         # TODO: Once iterable is implemented, use tiebreak rules instead of
         # failing. Also, may be more tiebreak rules to implement once spec bug
         # is resolved.
@@ -6056,17 +6060,17 @@ def convertConstIDLValueToJSVal(value):
     if tag in [IDLType.Tags.int8, IDLType.Tags.uint8, IDLType.Tags.int16,
                IDLType.Tags.uint16, IDLType.Tags.int32]:
         return "JS::Int32Value(%s)" % (value.value)
     if tag == IDLType.Tags.uint32:
         return "JS::NumberValue(%sU)" % (value.value)
     if tag in [IDLType.Tags.int64, IDLType.Tags.uint64]:
         return "JS::CanonicalizedDoubleValue(%s)" % numericValue(tag, value.value)
     if tag == IDLType.Tags.bool:
-        return "JSVAL_TRUE" if value.value else "JSVAL_FALSE"
+        return "JS::BooleanValue(true)" if value.value else "JS::BooleanValue(false)"
     if tag in [IDLType.Tags.float, IDLType.Tags.double]:
         return "JS::CanonicalizedDoubleValue(%s)" % (value.value)
     raise TypeError("Const value of unhandled type: %s" % value.type)
 class CGArgumentConverter(CGThing):
     A class that takes an IDL argument object and its index in the
@@ -8608,17 +8612,17 @@ class CppKeywords():
 class CGStaticMethod(CGAbstractStaticBindingMethod):
     A class for generating the C++ code for an IDL static method.
     def __init__(self, descriptor, method):
         self.method = method
-        name = IDLToCIdentifier(method.identifier.name)
+        name = CppKeywords.checkMethodName(IDLToCIdentifier(method.identifier.name))
         CGAbstractStaticBindingMethod.__init__(self, descriptor, name)
     def generate_code(self):
         nativeName = CGSpecializedMethod.makeNativeName(self.descriptor,
         return CGMethodCall(nativeName, True, self.descriptor, self.method)
--- a/dom/bindings/test/TestBindingHeader.h
+++ b/dom/bindings/test/TestBindingHeader.h
@@ -790,16 +790,17 @@ public:
   int8_t DeprecatedMethod();
   int8_t DeprecatedMethodWithContext(JSContext*, JS::Value);
   // Static methods and attributes
   static void StaticMethod(const GlobalObject&, bool);
   static void StaticMethodWithContext(const GlobalObject&, JS::Value);
   static bool StaticAttribute(const GlobalObject&);
   static void SetStaticAttribute(const GlobalObject&, bool);
+  static void Assert(const GlobalObject&, bool);
   // Deprecated static methods and attributes
   static int8_t StaticDeprecatedAttribute(const GlobalObject&);
   static int8_t SetStaticDeprecatedAttribute(const GlobalObject&, int8_t);
   static int8_t StaticDeprecatedMethod(const GlobalObject&);
   static int8_t StaticDeprecatedMethodWithContext(const GlobalObject&, JS::Value);
   // Overload resolution tests
--- a/dom/bindings/test/TestCodeGen.webidl
+++ b/dom/bindings/test/TestCodeGen.webidl
@@ -778,16 +778,19 @@ interface TestInterface {
   byte deprecatedMethodWithContext(any arg);
   // Static methods and attributes
   static attribute boolean staticAttribute;
   static void staticMethod(boolean arg);
   static void staticMethodWithContext(any arg);
+  // Testing static method with a reserved C++ keyword as the name
+  static void assert(boolean arg);
   // Deprecated static methods and attributes
   static attribute byte staticDeprecatedAttribute;
   static void staticDeprecatedMethod();
   static void staticDeprecatedMethodWithContext(any arg);