mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-03 02:25:34 +00:00
Bug 796983 part 1. Switch nullable primitives to using a const Nullable. r=jst
This commit is contained in:
parent
07051f705a
commit
0d788a841d
@ -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,
|
||||
|
@ -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))
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user