mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 15:25:52 +00:00
Bug 841429. Fix callback codegen for optional arguments with default values. r=mccr8
The change to enum wrapping is just to fix an indentation bug I ran into while reading the generated code for some of these test methods.
This commit is contained in:
parent
0745baf88c
commit
f9be62fa75
@ -3536,7 +3536,7 @@ if (!%(resultStr)s) {
|
||||
""" % { "result" : result,
|
||||
"resultStr" : result + "_str",
|
||||
"strings" : type.inner.identifier.name + "Values::strings",
|
||||
"exceptionCode" : exceptionCode } +
|
||||
"exceptionCode" : exceptionCodeIndented.define() } +
|
||||
setValue("JS::StringValue(%s_str)" % result), False)
|
||||
|
||||
if type.isCallback() or type.isCallbackInterface():
|
||||
@ -8382,7 +8382,7 @@ class CallbackMember(CGNativeMember):
|
||||
jsvalIndex = "%d + idx" % i
|
||||
else:
|
||||
jsvalIndex = "%d" % i
|
||||
if arg.optional:
|
||||
if arg.optional and not arg.defaultValue:
|
||||
argval += ".Value()"
|
||||
if arg.type.isString():
|
||||
# XPConnect string-to-JS conversion wants to mutate the string. So
|
||||
@ -8413,7 +8413,7 @@ class CallbackMember(CGNativeMember):
|
||||
CGIndenter(CGGeneric(conversion)).define() + "\n"
|
||||
"}\n"
|
||||
"break;").substitute({ "arg": arg.identifier.name })
|
||||
elif arg.optional:
|
||||
elif arg.optional and not arg.defaultValue:
|
||||
conversion = (
|
||||
CGIfWrapper(CGGeneric(conversion),
|
||||
"%s.WasPassed()" % arg.identifier.name).define() +
|
||||
|
@ -26,8 +26,7 @@ interface TestJSImplInterface {
|
||||
void passByte(byte arg);
|
||||
byte receiveByte();
|
||||
void passOptionalByte(optional byte arg);
|
||||
// Callback interface limitation. See bug 841429.
|
||||
// void passOptionalByteWithDefault(optional byte arg = 0);
|
||||
void passOptionalByteWithDefault(optional byte arg = 0);
|
||||
void passNullableByte(byte? arg);
|
||||
void passOptionalNullableByte(optional byte? arg);
|
||||
void passVariadicByte(byte... arg);
|
||||
@ -37,56 +36,49 @@ interface TestJSImplInterface {
|
||||
void passShort(short arg);
|
||||
short receiveShort();
|
||||
void passOptionalShort(optional short arg);
|
||||
// Callback interface limitation. See bug 841429.
|
||||
//void passOptionalShortWithDefault(optional short arg = 5);
|
||||
void passOptionalShortWithDefault(optional short arg = 5);
|
||||
|
||||
readonly attribute long readonlyLong;
|
||||
attribute long writableLong;
|
||||
void passLong(long arg);
|
||||
long receiveLong();
|
||||
void passOptionalLong(optional long arg);
|
||||
// Callback interface limitation. See bug 841429.
|
||||
//void passOptionalLongWithDefault(optional long arg = 7);
|
||||
void passOptionalLongWithDefault(optional long arg = 7);
|
||||
|
||||
readonly attribute long long readonlyLongLong;
|
||||
attribute long long writableLongLong;
|
||||
void passLongLong(long long arg);
|
||||
long long receiveLongLong();
|
||||
void passOptionalLongLong(optional long long arg);
|
||||
// Callback interface limitation. See bug 841429.
|
||||
//void passOptionalLongLongWithDefault(optional long long arg = -12);
|
||||
void passOptionalLongLongWithDefault(optional long long arg = -12);
|
||||
|
||||
readonly attribute octet readonlyOctet;
|
||||
attribute octet writableOctet;
|
||||
void passOctet(octet arg);
|
||||
octet receiveOctet();
|
||||
void passOptionalOctet(optional octet arg);
|
||||
// Callback interface limitation. See bug 841429.
|
||||
//void passOptionalOctetWithDefault(optional octet arg = 19);
|
||||
void passOptionalOctetWithDefault(optional octet arg = 19);
|
||||
|
||||
readonly attribute unsigned short readonlyUnsignedShort;
|
||||
attribute unsigned short writableUnsignedShort;
|
||||
void passUnsignedShort(unsigned short arg);
|
||||
unsigned short receiveUnsignedShort();
|
||||
void passOptionalUnsignedShort(optional unsigned short arg);
|
||||
// Callback interface limitation. See bug 841429.
|
||||
//void passOptionalUnsignedShortWithDefault(optional unsigned short arg = 2);
|
||||
void passOptionalUnsignedShortWithDefault(optional unsigned short arg = 2);
|
||||
|
||||
readonly attribute unsigned long readonlyUnsignedLong;
|
||||
attribute unsigned long writableUnsignedLong;
|
||||
void passUnsignedLong(unsigned long arg);
|
||||
unsigned long receiveUnsignedLong();
|
||||
void passOptionalUnsignedLong(optional unsigned long arg);
|
||||
// Callback interface limitation. See bug 841429.
|
||||
//void passOptionalUnsignedLongWithDefault(optional unsigned long arg = 6);
|
||||
void passOptionalUnsignedLongWithDefault(optional unsigned long arg = 6);
|
||||
|
||||
readonly attribute unsigned long long readonlyUnsignedLongLong;
|
||||
attribute unsigned long long writableUnsignedLongLong;
|
||||
void passUnsignedLongLong(unsigned long long arg);
|
||||
unsigned long long receiveUnsignedLongLong();
|
||||
void passOptionalUnsignedLongLong(optional unsigned long long arg);
|
||||
// Callback interface limitation. See bug 841429.
|
||||
//void passOptionalUnsignedLongLongWithDefault(optional unsigned long long arg = 17);
|
||||
void passOptionalUnsignedLongLongWithDefault(optional unsigned long long arg = 17);
|
||||
|
||||
attribute float writableFloat;
|
||||
attribute unrestricted float writableUnrestrictedFloat;
|
||||
@ -141,8 +133,7 @@ interface TestJSImplInterface {
|
||||
// Optional arguments
|
||||
void passOptionalSelf(optional TestJSImplInterface? arg);
|
||||
void passOptionalNonNullSelf(optional TestJSImplInterface arg);
|
||||
// Callback interface limitation. See bug 841429.
|
||||
//void passOptionalSelfWithDefault(optional TestJSImplInterface? arg = null);
|
||||
void passOptionalSelfWithDefault(optional TestJSImplInterface? arg = null);
|
||||
|
||||
// Non-wrapper-cache interface types
|
||||
[Creator]
|
||||
@ -177,8 +168,7 @@ interface TestJSImplInterface {
|
||||
// Optional arguments
|
||||
void passOptionalOther(optional IndirectlyImplementedInterface? arg);
|
||||
void passOptionalNonNullOther(optional IndirectlyImplementedInterface arg);
|
||||
// Callback interface limitation. See bug 841429.
|
||||
//void passOptionalOtherWithDefault(optional IndirectlyImplementedInterface? arg = null);
|
||||
void passOptionalOtherWithDefault(optional IndirectlyImplementedInterface? arg = null);
|
||||
|
||||
// External interface types
|
||||
TestExternalInterface receiveExternal();
|
||||
@ -196,8 +186,7 @@ interface TestJSImplInterface {
|
||||
// Optional arguments
|
||||
void passOptionalExternal(optional TestExternalInterface? arg);
|
||||
void passOptionalNonNullExternal(optional TestExternalInterface arg);
|
||||
// Callback interface limitation. See bug 841429.
|
||||
//void passOptionalExternalWithDefault(optional TestExternalInterface? arg = null);
|
||||
void passOptionalExternalWithDefault(optional TestExternalInterface? arg = null);
|
||||
|
||||
// Callback interface types
|
||||
TestCallbackInterface receiveCallbackInterface();
|
||||
@ -215,8 +204,7 @@ interface TestJSImplInterface {
|
||||
// Optional arguments
|
||||
void passOptionalCallbackInterface(optional TestCallbackInterface? arg);
|
||||
void passOptionalNonNullCallbackInterface(optional TestCallbackInterface arg);
|
||||
// Callback interface limitation. See bug 841429.
|
||||
//void passOptionalCallbackInterfaceWithDefault(optional TestCallbackInterface? arg = null);
|
||||
void passOptionalCallbackInterfaceWithDefault(optional TestCallbackInterface? arg = null);
|
||||
|
||||
// Miscellaneous interface tests
|
||||
IndirectlyImplementedInterface receiveConsequentialInterface();
|
||||
@ -250,8 +238,7 @@ interface TestJSImplInterface {
|
||||
void passNullableCastableObjectNullableSequence(sequence<TestJSImplInterface?>? arg);
|
||||
void passOptionalSequence(optional sequence<long> arg);
|
||||
void passOptionalNullableSequence(optional sequence<long>? arg);
|
||||
// Callback interface limitation. See bug 841429.
|
||||
//void passOptionalNullableSequenceWithDefaultValue(optional sequence<long>? arg = null);
|
||||
void passOptionalNullableSequenceWithDefaultValue(optional sequence<long>? arg = null);
|
||||
void passOptionalObjectSequence(optional sequence<TestJSImplInterface> arg);
|
||||
void passExternalInterfaceSequence(sequence<TestExternalInterface> arg);
|
||||
void passNullableExternalInterfaceSequence(sequence<TestExternalInterface?> arg);
|
||||
@ -290,11 +277,9 @@ interface TestJSImplInterface {
|
||||
void passString(DOMString arg);
|
||||
void passNullableString(DOMString? arg);
|
||||
void passOptionalString(optional DOMString arg);
|
||||
// Callback interface limitation. See bug 841429.
|
||||
//void passOptionalStringWithDefaultValue(optional DOMString arg = "abc");
|
||||
void passOptionalStringWithDefaultValue(optional DOMString arg = "abc");
|
||||
void passOptionalNullableString(optional DOMString? arg);
|
||||
// Callback interface limitation. See bug 841429.
|
||||
//void passOptionalNullableStringWithDefaultValue(optional DOMString? arg = null);
|
||||
void passOptionalNullableStringWithDefaultValue(optional DOMString? arg = null);
|
||||
void passVariadicString(DOMString... arg);
|
||||
|
||||
// Enumerated types
|
||||
@ -303,8 +288,7 @@ interface TestJSImplInterface {
|
||||
// void passNullableEnum(MyTestEnum? arg);
|
||||
// Optional enum arg doesn't work with callback interfaces. See bug 843355.
|
||||
//void passOptionalEnum(optional MyTestEnum arg);
|
||||
// Callback interface limitation. See bug 841429.
|
||||
//void passEnumWithDefault(optional MyTestEnum arg = "a");
|
||||
void passEnumWithDefault(optional MyTestEnum arg = "a");
|
||||
// void passOptionalNullableEnum(optional MyTestEnum? arg);
|
||||
// void passOptionalNullableEnumWithDefaultValue(optional MyTestEnum? arg = null);
|
||||
MyTestEnum receiveEnum();
|
||||
@ -316,15 +300,13 @@ interface TestJSImplInterface {
|
||||
void passNullableCallback(MyTestCallback? arg);
|
||||
void passOptionalCallback(optional MyTestCallback arg);
|
||||
void passOptionalNullableCallback(optional MyTestCallback? arg);
|
||||
// Callback interface limitation. See bug 841429.
|
||||
//void passOptionalNullableCallbackWithDefaultValue(optional MyTestCallback? arg = null);
|
||||
void passOptionalNullableCallbackWithDefaultValue(optional MyTestCallback? arg = null);
|
||||
MyTestCallback receiveCallback();
|
||||
MyTestCallback? receiveNullableCallback();
|
||||
// Hmm. These two don't work, I think because I need a locally modified version of TestTreatAsNullCallback.
|
||||
//void passNullableTreatAsNullCallback(TestTreatAsNullCallback? arg);
|
||||
//void passOptionalNullableTreatAsNullCallback(optional TestTreatAsNullCallback? arg);
|
||||
// Callback interface limitation. See bug 841429.
|
||||
//void passOptionalNullableTreatAsNullCallbackWithDefaultValue(optional TestTreatAsNullCallback? arg = null);
|
||||
void passOptionalNullableTreatAsNullCallbackWithDefaultValue(optional TestTreatAsNullCallback? arg = null);
|
||||
|
||||
/* The rest of these are untested.
|
||||
// Any types
|
||||
|
Loading…
Reference in New Issue
Block a user