Bug 820544 - Prefix webidl dictionary native members names to avoid C++ keywords. r=bz
☠☠ backed out by 15e83fa70172 ☠ ☠
authorWilliam Chen <wchen@mozilla.com>
Tue, 11 Dec 2012 16:05:46 -0800
changeset 116031 67d84be0cc83fd23075465eca4d131436e10a132
parent 116030 f255406bb4aa578bcf70364c5b21af473f4bf637
child 116032 08f9c8a1c7e765e8ae50c32487859674754f9dc1
push id19701
push usernfroyd@mozilla.com
push dateFri, 14 Dec 2012 16:48:52 +0000
treeherdermozilla-inbound@67d84be0cc83 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs820544
milestone20.0a1
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 820544 - Prefix webidl dictionary native members names to avoid C++ keywords. r=bz
content/base/src/nsDOMBlobBuilder.cpp
content/base/src/nsXMLHttpRequest.h
content/canvas/src/WebGLContext.cpp
dom/bindings/Codegen.py
dom/bindings/test/TestCodeGen.webidl
dom/encoding/TextDecoder.cpp
dom/encoding/TextEncoder.cpp
dom/network/src/MobileConnection.cpp
dom/workers/XMLHttpRequest.cpp
--- a/content/base/src/nsDOMBlobBuilder.cpp
+++ b/content/base/src/nsDOMBlobBuilder.cpp
@@ -186,25 +186,25 @@ nsDOMMultipartFile::InitBlob(JSContext* 
 {
   bool nativeEOL = false;
   if (aArgc > 1) {
     if (NS_IsMainThread()) {
       BlobPropertyBag d;
       if (!d.Init(aCx, nullptr, aArgv[1])) {
         return NS_ERROR_TYPE_ERR;
       }
-      mContentType = d.type;
-      nativeEOL = d.endings == EndingTypesValues::Native;
+      mContentType = d.mType;
+      nativeEOL = d.mEndings == EndingTypesValues::Native;
     } else {
       BlobPropertyBagWorkers d;
       if (!d.Init(aCx, nullptr, aArgv[1])) {
         return NS_ERROR_TYPE_ERR;
       }
-      mContentType = d.type;
-      nativeEOL = d.endings == EndingTypesValues::Native;
+      mContentType = d.mType;
+      nativeEOL = d.mEndings == EndingTypesValues::Native;
     }
   }
 
   if (aArgc > 0) {
     if (!aArgv[0].isObject()) {
       return NS_ERROR_TYPE_ERR; // We're not interested
     }
 
--- a/content/base/src/nsXMLHttpRequest.h
+++ b/content/base/src/nsXMLHttpRequest.h
@@ -154,17 +154,17 @@ public:
     nsCOMPtr<nsIScriptObjectPrincipal> principal = do_QueryInterface(aGlobal);
     if (!window || ! principal) {
       aRv.Throw(NS_ERROR_FAILURE);
       return NULL;
     }
 
     nsRefPtr<nsXMLHttpRequest> req = new nsXMLHttpRequest();
     req->Construct(principal->GetPrincipal(), window);
-    req->InitParameters(aParams.mozAnon, aParams.mozSystem);
+    req->InitParameters(aParams.mMozAnon, aParams.mMozSystem);
     return req.forget();
   }
 
   static already_AddRefed<nsXMLHttpRequest>
   Constructor(JSContext* aCx,
               nsISupports* aGlobal,
               const nsAString& ignored,
               ErrorResult& aRv)
--- a/content/canvas/src/WebGLContext.cpp
+++ b/content/canvas/src/WebGLContext.cpp
@@ -891,22 +891,22 @@ WebGLContext::GetContextAttributes(Nulla
 {
     retval.SetNull();
     if (!IsContextStable())
         return;
 
     dom::WebGLContextAttributes& result = retval.SetValue();
 
     gl::ContextFormat cf = gl->ActualFormat();
-    result.alpha = cf.alpha > 0;
-    result.depth = cf.depth > 0;
-    result.stencil = cf.stencil > 0;
-    result.antialias = cf.samples > 1;
-    result.premultipliedAlpha = mOptions.premultipliedAlpha;
-    result.preserveDrawingBuffer = mOptions.preserveDrawingBuffer;
+    result.mAlpha = cf.alpha > 0;
+    result.mDepth = cf.depth > 0;
+    result.mStencil = cf.stencil > 0;
+    result.mAntialias = cf.samples > 1;
+    result.mPremultipliedAlpha = mOptions.premultipliedAlpha;
+    result.mPreserveDrawingBuffer = mOptions.preserveDrawingBuffer;
 }
 
 bool
 WebGLContext::IsExtensionEnabled(WebGLExtensionID ext) const {
     return mExtensions.SafeElementAt(ext);
 }
 
 /* [noscript] DOMString mozGetUnderlyingParamString(in WebGLenum pname); */
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -6380,17 +6380,18 @@ class CGDictionary(CGThing):
         d = self.dictionary
         if d.parent:
             inheritance = ": public %s " % self.makeClassName(d.parent)
         elif not self.workers:
             inheritance = ": public MainThreadDictionaryBase "
         else:
             inheritance = ""
         memberDecls = ["  %s %s;" %
-                       (self.getMemberType(m), m[0].identifier.name)
+                       (self.getMemberType(m),
+                        self.makeMemberName(m[0].identifier.name))
                        for m in self.memberInfo]
 
         return (string.Template(
                 "struct ${selfName} ${inheritance}{\n"
                 "  ${selfName}() {}\n"
                 "  bool Init(JSContext* cx, JSObject* scopeObj, const JS::Value& val);\n"
                 "  bool ToObject(JSContext* cx, JSObject* parentObject, JS::Value *vp);\n"
                 "\n" +
@@ -6525,38 +6526,35 @@ class CGDictionary(CGThing):
     @staticmethod
     def makeDictionaryName(dictionary, workers):
         suffix = "Workers" if workers else ""
         return dictionary.identifier.name + suffix
 
     def makeClassName(self, dictionary):
         return self.makeDictionaryName(dictionary, self.workers)
 
+    @staticmethod
+    def makeMemberName(name):
+        return "m" + name[0].upper() + name[1:]
+
     def getMemberType(self, memberInfo):
         (member, (templateBody, declType,
                   holderType, dealWithOptional)) = memberInfo
         # We can't handle having a holderType here
         assert holderType is None
         if dealWithOptional:
             declType = CGWrapper(declType, pre="Optional< ", post=" >")
         return declType.define()
 
     def getMemberConversion(self, memberInfo):
         (member, (templateBody, declType,
                   holderType, dealWithOptional)) = memberInfo
         replacements = { "val": "temp",
                          "valPtr": "&temp",
-                         # Use this->%s to refer to members, because we don't
-                         # control the member names and want to make sure we're
-                         # talking about the member, not some local that
-                         # shadows the member.  Another option would be to move
-                         # the guts of init to a static method which is passed
-                         # an explicit reference to our dictionary object, so
-                         # we couldn't screw this up even if we wanted to....
-                         "declName": ("(this->%s)" % member.identifier.name),
+                         "declName": self.makeMemberName(member.identifier.name),
                          # We need a holder name for external interfaces, but
                          # it's scoped down to the conversion so we can just use
                          # anything we want.
                          "holderName": "holder",
                          "obj": "scopeObj" }
         # We can't handle having a holderType here
         assert holderType is None
         if dealWithOptional:
@@ -6574,17 +6572,17 @@ class CGDictionary(CGThing):
         else:
             propId = self.makeIdName(member.identifier.name);
             propCheck = ("JS_HasPropertyById(cx, &val.toObject(), %s, &found)" %
                          propId)
             propGet = ("JS_GetPropertyById(cx, &val.toObject(), %s, &temp)" %
                        propId)
 
         conversionReplacements = {
-            "prop": "(this->%s)" % member.identifier.name,
+            "prop": self.makeMemberName(member.identifier.name),
             "convert": string.Template(templateBody).substitute(replacements),
             "propCheck": propCheck,
             "propGet": propGet
             }
         conversion = ("if (isNull) {\n"
                       "  found = false;\n"
                       "} else if (!${propCheck}) {\n"
                       "  return false;\n"
@@ -6611,24 +6609,17 @@ class CGDictionary(CGThing):
         
         return CGGeneric(
             string.Template(conversion).substitute(conversionReplacements)
             )
 
     def getMemberDefinition(self, memberInfo):
         member = memberInfo[0]
         declType = memberInfo[1][1]
-        # Use this->%s to refer to members, because we don't control
-        # the member names and want to make sure we're talking about
-        # the member, not some local that shadows the member.  Another
-        # option would be to move the guts of init to a static method
-        # which is passed an explicit reference to our dictionary
-        # object, so we couldn't screw this up even if we wanted
-        # to....
-        memberLoc = "(this->%s)" % member.identifier.name
+        memberLoc = self.makeMemberName(member.identifier.name)
         if member.defaultValue:
             memberData = memberLoc
         else:
             # The data is inside the Optional<>
             memberData = "%s.Value()" % memberLoc
 
         if self.workers:
             propDef = (
--- a/dom/bindings/test/TestCodeGen.webidl
+++ b/dom/bindings/test/TestCodeGen.webidl
@@ -502,16 +502,17 @@ dictionary Dict : ParentDict {
   long a;
   long b = 8;
   long z = 9;
   DOMString str;
   DOMString empty = "";
   TestEnum otherEnum = "b";
   DOMString otherStr = "def";
   DOMString? yetAnotherStr = null;
+  DOMString template;
 };
 
 dictionary ParentDict : GrandparentDict {
   long c = 5;
   TestInterface someInterface;
   TestExternalInterface someExternalInterface;
 };
 
--- a/dom/encoding/TextDecoder.cpp
+++ b/dom/encoding/TextDecoder.cpp
@@ -26,17 +26,17 @@ TextDecoder::Init(const nsAString& aEnco
   if (!EncodingUtils::FindEncodingForLabel(label, mEncoding)) {
     aRv.ThrowTypeError(MSG_ENCODING_NOT_SUPPORTED, &label);
     return;
   }
 
   // If the constructor is called with an options argument,
   // and the fatal property of the dictionary is set,
   // set the internal fatal flag of the decoder object.
-  mFatal = aFatal.fatal;
+  mFatal = aFatal.mFatal;
 
   // Create a decoder object for mEncoding.
   nsCOMPtr<nsICharsetConverterManager> ccm =
     do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID);
   if (!ccm) {
     aRv.Throw(NS_ERROR_UNEXPECTED);
     return;
   }
@@ -89,17 +89,17 @@ TextDecoder::Decode(const ArrayBufferVie
 
   rv = mDecoder->Convert(data, &length, buf, &outLen);
   MOZ_ASSERT(mFatal || rv != NS_ERROR_ILLEGAL_INPUT);
   buf[outLen] = 0;
   aOutDecodedString.Append(buf, outLen);
 
   // If the internal streaming flag of the decoder object is not set,
   // then reset the encoding algorithm state to the default values
-  if (!aOptions.stream) {
+  if (!aOptions.mStream) {
     mDecoder->Reset();
     if (rv == NS_OK_UDEC_MOREINPUT) {
       if (mFatal) {
         aRv.Throw(NS_ERROR_DOM_ENCODING_DECODE_ERR);
       } else {
         // Need to emit a decode error manually
         // to simulate the EOF handling of the Encoding spec.
         aOutDecodedString.Append(kReplacementChar);
--- a/dom/encoding/TextEncoder.cpp
+++ b/dom/encoding/TextEncoder.cpp
@@ -72,17 +72,17 @@ TextEncoder::Encode(JSContext* aCx,
     return nullptr;
   }
 
   int32_t dstLen = maxLen;
   rv = mEncoder->Convert(data, &srcLen, buf, &dstLen);
 
   // If the internal streaming flag is not set, then reset
   // the encoding algorithm state to the default values for encoding.
-  if (!aOptions.stream) {
+  if (!aOptions.mStream) {
     int32_t finishLen = maxLen - dstLen;
     rv = mEncoder->Finish(buf + dstLen, &finishLen);
     if (NS_SUCCEEDED(rv)) {
       dstLen += finishLen;
     }
   }
 
   JSObject* outView = nullptr;
--- a/dom/network/src/MobileConnection.cpp
+++ b/dom/network/src/MobileConnection.cpp
@@ -162,17 +162,17 @@ MobileConnection::Observe(nsISupports* a
   }
 
   if (!strcmp(aTopic, kUssdReceivedTopic)) {
     mozilla::dom::USSDReceivedEventDict dict;
     bool ok = dict.Init(nsDependentString(aData));
     NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE);
 
     nsRefPtr<USSDReceivedEvent> event =
-      USSDReceivedEvent::Create(dict.message, dict.sessionEnded);
+      USSDReceivedEvent::Create(dict.mMessage, dict.mSessionEnded);
     NS_ASSERTION(event, "This should never fail!");
 
     nsresult rv = event->Dispatch(ToIDOMEventTarget(), USSDRECEIVED_EVENTNAME);
     NS_ENSURE_SUCCESS(rv, rv);
     return NS_OK;
   }
 
   if (!strcmp(aTopic, kDataErrorTopic)) {
--- a/dom/workers/XMLHttpRequest.cpp
+++ b/dom/workers/XMLHttpRequest.cpp
@@ -1498,18 +1498,18 @@ XMLHttpRequest::Constructor(JSContext* a
   nsRefPtr<XMLHttpRequest> xhr = new XMLHttpRequest(aCx, workerPrivate);
 
   if (!Wrap(aCx, aGlobal, xhr)) {
     aRv.Throw(NS_ERROR_FAILURE);
     return NULL;
   }
 
   if (workerPrivate->XHRParamsAllowed()) {
-    xhr->mMozAnon = aParams.mozAnon;
-    xhr->mMozSystem = aParams.mozSystem;
+    xhr->mMozAnon = aParams.mMozAnon;
+    xhr->mMozSystem = aParams.mMozSystem;
   }
 
   xhr->mJSObject = xhr->GetJSObject();
   return xhr;
 }
 
 void
 XMLHttpRequest::ReleaseProxy(ReleaseType aType)