Bug 747815. Use const strings for arguments in DOM bindings. r=peterv

This commit is contained in:
Boris Zbarsky 2012-04-26 00:42:03 -04:00
parent b38f6768b1
commit 4399ca73fe
2 changed files with 16 additions and 4 deletions

View File

@ -1247,9 +1247,9 @@ def getArgumentConversionTemplate(type, descriptor):
undefinedBehavior = "eStringify"
return (
" xpc_qsDOMString ${name}(cx, ${argVal}, ${argPtr},\n"
" xpc_qsDOMString::%s,\n"
" xpc_qsDOMString::%s);\n"
" const xpc_qsDOMString ${name}(cx, ${argVal}, ${argPtr},\n"
" xpc_qsDOMString::%s,\n"
" xpc_qsDOMString::%s);\n"
" if (!${name}.IsValid()) {\n"
" return false;\n"
" }\n" % (nullBehavior, undefinedBehavior))

View File

@ -262,7 +262,7 @@ public:
Ptr()->~implementation_type();
}
JSBool IsValid() { return mValid; }
JSBool IsValid() const { return mValid; }
implementation_type *Ptr()
{
@ -270,12 +270,24 @@ public:
return reinterpret_cast<implementation_type *>(mBuf);
}
const implementation_type *Ptr() const
{
MOZ_ASSERT(mValid);
return reinterpret_cast<const implementation_type *>(mBuf);
}
operator interface_type &()
{
MOZ_ASSERT(mValid);
return *Ptr();
}
operator const interface_type &() const
{
MOZ_ASSERT(mValid);
return *Ptr();
}
/* Enum that defines how JS |null| and |undefined| should be treated. See
* the WebIDL specification. eStringify means convert to the string "null"
* or "undefined" respectively, via the standard JS ToString() operation;