Bug 796983 part 1. Switch nullable primitives to using a const Nullable. r=jst

This commit is contained in:
Boris Zbarsky 2012-10-17 17:01:55 -04:00
parent 07051f705a
commit 0d788a841d
3 changed files with 13 additions and 8 deletions

View File

@ -33,7 +33,7 @@ public:
NS_DECL_NSIDOMEVENTTARGET
void AddEventListener(const nsAString& aType,
nsIDOMEventListener* aCallback, // XXX nullable
bool aCapture, Nullable<bool>& aWantsUntrusted,
bool aCapture, const Nullable<bool>& aWantsUntrusted,
mozilla::ErrorResult& aRv)
{
aRv = AddEventListener(aType, aCallback, aCapture,

View File

@ -2539,17 +2539,20 @@ for (uint32_t i = 0; i < length; ++i) {
conversionBehavior = "eClamp"
if type.nullable():
dataLoc = "${declName}.SetValue()"
declType = CGGeneric("Nullable<" + typeName + ">")
mutableType = declType.define() + "&"
if not isOptional and not isMember:
declType = CGWrapper(declType, pre="const ")
dataLoc = ("const_cast< %s >(${declName}).SetValue()" % mutableType)
nullCondition = "${val}.isNullOrUndefined()"
if defaultValue is not None and isinstance(defaultValue, IDLNullValue):
nullCondition = "!(${haveValue}) || " + nullCondition
template = (
"if (%s) {\n"
" ${declName}.SetNull();\n"
" const_cast< %s >(${declName}).SetNull();\n"
"} else if (!ValueToPrimitive<%s, %s>(cx, ${val}, &%s)) {\n"
" return false;\n"
"}" % (nullCondition, typeName, conversionBehavior, dataLoc))
declType = CGGeneric("Nullable<" + typeName + ">")
"}" % (nullCondition, mutableType, typeName, conversionBehavior, dataLoc))
else:
assert(defaultValue is None or
not isinstance(defaultValue, IDLNullValue))

View File

@ -112,7 +112,8 @@ public:
ErrorResult&);
static
already_AddRefed<TestInterface> Constructor(nsISupports*, uint32_t,
Nullable<bool>&, ErrorResult&);
const Nullable<bool>&,
ErrorResult&);
static
already_AddRefed<TestInterface> Constructor(nsISupports*, TestInterface*,
ErrorResult&);
@ -135,7 +136,7 @@ public:
int8_t ReceiveByte();
void PassOptionalByte(const Optional<int8_t>&);
void PassOptionalByteWithDefault(int8_t);
void PassNullableByte(Nullable<int8_t>&);
void PassNullableByte(const Nullable<int8_t>&);
void PassOptionalNullableByte(const Optional< Nullable<int8_t> >&);
int16_t ReadonlyShort();
@ -326,7 +327,7 @@ public:
void PassOptionalNullableString(const Optional<nsAString>&);
void PassOptionalNullableStringWithDefaultValue(const nsAString&);
// Enumarated types
// Enumerated types
void PassEnum(TestEnum);
void PassOptionalEnum(const Optional<TestEnum>&);
void PassEnumWithDefault(TestEnum);
@ -440,6 +441,7 @@ private:
void SetWritableByte(T) MOZ_DELETE;
template<typename T>
void PassByte(T) MOZ_DELETE;
void PassNullableByte(Nullable<int8_t>&) MOZ_DELETE;
template<typename T>
void PassOptionalByte(const Optional<T>&) MOZ_DELETE;
template<typename T>