Bug 820544 - Prefix WebIDL dictionary native member names to avoid C++ keywords. r=bz

This commit is contained in:
William Chen 2012-12-17 13:44:04 -08:00
parent 669a59fe4e
commit c3b4bdb077
9 changed files with 30 additions and 38 deletions

View File

@ -191,15 +191,15 @@ nsDOMMultipartFile::InitBlob(JSContext* aCx,
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;
}
}
@ -286,9 +286,9 @@ nsDOMMultipartFile::InitFile(JSContext* aCx,
if (!d.Init(aCx, nullptr, aArgv[1])) {
return NS_ERROR_TYPE_ERR;
}
mName = d.name;
mContentType = d.type;
nativeEOL = d.endings == EndingTypesValues::Native;
mName = d.mName;
mContentType = d.mType;
nativeEOL = d.mEndings == EndingTypesValues::Native;
}
// We expect to get a path to represent as a File object,

View File

@ -159,7 +159,7 @@ public:
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();
}

View File

@ -896,12 +896,12 @@ WebGLContext::GetContextAttributes(Nullable<dom::WebGLContextAttributesInitializ
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

View File

@ -6400,7 +6400,8 @@ class CGDictionary(CGThing):
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(
@ -6545,6 +6546,10 @@ class CGDictionary(CGThing):
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
@ -6559,14 +6564,7 @@ class CGDictionary(CGThing):
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.
@ -6594,7 +6592,7 @@ class CGDictionary(CGThing):
propId)
conversionReplacements = {
"prop": "(this->%s)" % member.identifier.name,
"prop": self.makeMemberName(member.identifier.name),
"convert": string.Template(templateBody).substitute(replacements),
"propCheck": propCheck,
"propGet": propGet
@ -6631,14 +6629,7 @@ class CGDictionary(CGThing):
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:

View File

@ -510,6 +510,7 @@ dictionary Dict : ParentDict {
TestEnum otherEnum = "b";
DOMString otherStr = "def";
DOMString? yetAnotherStr = null;
DOMString template;
};
dictionary ParentDict : GrandparentDict {

View File

@ -31,7 +31,7 @@ TextDecoder::Init(const nsAString& aEncoding,
// 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 =
@ -94,7 +94,7 @@ TextDecoder::Decode(const ArrayBufferView* aView,
// 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) {

View File

@ -77,7 +77,7 @@ TextEncoder::Encode(JSContext* aCx,
// 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)) {

View File

@ -167,7 +167,7 @@ MobileConnection::Observe(nsISupports* aSubject,
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);

View File

@ -1503,8 +1503,8 @@ XMLHttpRequest::Constructor(JSContext* aCx,
}
if (workerPrivate->XHRParamsAllowed()) {
xhr->mMozAnon = aParams.mozAnon;
xhr->mMozSystem = aParams.mozSystem;
xhr->mMozAnon = aParams.mMozAnon;
xhr->mMozSystem = aParams.mMozSystem;
}
xhr->mJSObject = xhr->GetJSObject();