+2012-04-27 Kentaro Hara <haraken@chromium.org>
+
+ [JSC] Implement a helper method createNotEnoughArgumentsError()
+ https://bugs.webkit.org/show_bug.cgi?id=85102
+
+ Reviewed by Geoffrey Garen.
+
+ In bug 84787, kbr@ requested to avoid hard-coding
+ createTypeError(exec, "Not enough arguments") here and there.
+ This patch implements createNotEnoughArgumentsError(exec)
+ and uses it in JSC bindings.
+
+ c.f. a corresponding bug for V8 bindings is bug 85097.
+
+ Test: bindings/scripts/test/TestObj.idl
+
+ * bindings/scripts/CodeGeneratorJS.pm: Modified as described above.
+ (GenerateArgumentsCountCheck):
+
+ * bindings/js/JSDataViewCustom.cpp: Ditto.
+ (WebCore::getDataViewMember):
+ (WebCore::setDataViewMember):
+ * bindings/js/JSDeprecatedPeerConnectionCustom.cpp:
+ (WebCore::JSDeprecatedPeerConnectionConstructor::constructJSDeprecatedPeerConnection):
+ * bindings/js/JSDirectoryEntryCustom.cpp:
+ (WebCore::JSDirectoryEntry::getFile):
+ (WebCore::JSDirectoryEntry::getDirectory):
+ * bindings/js/JSSharedWorkerCustom.cpp:
+ (WebCore::JSSharedWorkerConstructor::constructJSSharedWorker):
+ * bindings/js/JSWebKitMutationObserverCustom.cpp:
+ (WebCore::JSWebKitMutationObserverConstructor::constructJSWebKitMutationObserver):
+ (WebCore::JSWebKitMutationObserver::observe):
+ * bindings/js/JSWorkerCustom.cpp:
+ (WebCore::JSWorkerConstructor::constructJSWorker):
+
+ * bindings/scripts/test/JS/JSFloat64Array.cpp: Updated run-bindings-tests.
+ (WebCore::jsFloat64ArrayPrototypeFunctionFoo):
+ * bindings/scripts/test/JS/JSTestActiveDOMObject.cpp:
+ (WebCore::jsTestActiveDOMObjectPrototypeFunctionExcitingFunction):
+ (WebCore::jsTestActiveDOMObjectPrototypeFunctionPostMessage):
+ * bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp:
+ (WebCore::jsTestCustomNamedGetterPrototypeFunctionAnotherFunction):
+ * bindings/scripts/test/JS/JSTestEventTarget.cpp:
+ (WebCore::jsTestEventTargetPrototypeFunctionItem):
+ (WebCore::jsTestEventTargetPrototypeFunctionAddEventListener):
+ (WebCore::jsTestEventTargetPrototypeFunctionRemoveEventListener):
+ (WebCore::jsTestEventTargetPrototypeFunctionDispatchEvent):
+ * bindings/scripts/test/JS/JSTestInterface.cpp:
+ (WebCore::JSTestInterfaceConstructor::constructJSTestInterface):
+ (WebCore::jsTestInterfacePrototypeFunctionSupplementalMethod2):
+ * bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp:
+ (WebCore::jsTestMediaQueryListListenerPrototypeFunctionMethod):
+ * bindings/scripts/test/JS/JSTestNamedConstructor.cpp:
+ (WebCore::JSTestNamedConstructorNamedConstructor::constructJSTestNamedConstructor):
+ * bindings/scripts/test/JS/JSTestObj.cpp:
+ (WebCore::JSTestObjConstructor::constructJSTestObj):
+ (WebCore::jsTestObjPrototypeFunctionVoidMethodWithArgs):
+ (WebCore::jsTestObjPrototypeFunctionIntMethodWithArgs):
+ (WebCore::jsTestObjPrototypeFunctionObjMethodWithArgs):
+ (WebCore::jsTestObjPrototypeFunctionMethodWithSequenceArg):
+ (WebCore::jsTestObjPrototypeFunctionMethodReturningSequence):
+ (WebCore::jsTestObjPrototypeFunctionMethodThatRequiresAllArgsAndThrows):
+ (WebCore::jsTestObjPrototypeFunctionSerializedValue):
+ (WebCore::jsTestObjPrototypeFunctionIdbKey):
+ (WebCore::jsTestObjPrototypeFunctionOptionsObject):
+ (WebCore::jsTestObjPrototypeFunctionAddEventListener):
+ (WebCore::jsTestObjPrototypeFunctionRemoveEventListener):
+ (WebCore::jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndOptionalArg):
+ (WebCore::jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndTwoOptionalArgs):
+ (WebCore::jsTestObjPrototypeFunctionMethodWithCallbackArg):
+ (WebCore::jsTestObjPrototypeFunctionMethodWithNonCallbackArgAndCallbackArg):
+ (WebCore::jsTestObjPrototypeFunctionOverloadedMethod1):
+ (WebCore::jsTestObjPrototypeFunctionOverloadedMethod2):
+ (WebCore::jsTestObjPrototypeFunctionOverloadedMethod3):
+ (WebCore::jsTestObjPrototypeFunctionOverloadedMethod4):
+ (WebCore::jsTestObjPrototypeFunctionOverloadedMethod5):
+ (WebCore::jsTestObjPrototypeFunctionOverloadedMethod6):
+ (WebCore::jsTestObjPrototypeFunctionOverloadedMethod7):
+ (WebCore::jsTestObjConstructorFunctionClassMethod2):
+ (WebCore::jsTestObjConstructorFunctionOverloadedMethod11):
+ (WebCore::jsTestObjConstructorFunctionOverloadedMethod12):
+ (WebCore::jsTestObjPrototypeFunctionMethodWithUnsignedLongArray):
+ (WebCore::jsTestObjPrototypeFunctionConvert1):
+ (WebCore::jsTestObjPrototypeFunctionConvert2):
+ (WebCore::jsTestObjPrototypeFunctionConvert3):
+ (WebCore::jsTestObjPrototypeFunctionConvert4):
+ (WebCore::jsTestObjPrototypeFunctionConvert5):
+ (WebCore::jsTestObjPrototypeFunctionStrictFunction):
+ * bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp:
+ (WebCore::JSTestSerializedScriptValueInterfaceConstructor::constructJSTestSerializedScriptValueInterface):
+ (WebCore::jsTestSerializedScriptValueInterfacePrototypeFunctionAcceptTransferList):
+
2012-04-27 Mark Pilgrim <pilgrim@chromium.org>
[Chromium] Call highMemoryUsageMB directly
{
JSTestObjConstructor* castedThis = jsCast<JSTestObjConstructor*>(exec->callee());
if (exec->argumentCount() < 1)
- return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
+ return throwVMError(exec, createNotEnoughArgumentsError(exec));
if (exec->argumentCount() <= 0 || !exec->argument(0).isFunction()) {
setDOMException(exec, TYPE_MISMATCH_ERR);
return JSValue::encode(jsUndefined());
ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info);
TestObj* impl = static_cast<TestObj*>(castedThis->impl());
if (exec->argumentCount() < 3)
- return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
+ return throwVMError(exec, createNotEnoughArgumentsError(exec));
int intArg(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toInt32(exec));
if (exec->hadException())
return JSValue::encode(jsUndefined());
ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info);
TestObj* impl = static_cast<TestObj*>(castedThis->impl());
if (exec->argumentCount() < 3)
- return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
+ return throwVMError(exec, createNotEnoughArgumentsError(exec));
int intArg(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toInt32(exec));
if (exec->hadException())
return JSValue::encode(jsUndefined());
ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info);
TestObj* impl = static_cast<TestObj*>(castedThis->impl());
if (exec->argumentCount() < 3)
- return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
+ return throwVMError(exec, createNotEnoughArgumentsError(exec));
int intArg(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toInt32(exec));
if (exec->hadException())
return JSValue::encode(jsUndefined());
ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info);
TestObj* impl = static_cast<TestObj*>(castedThis->impl());
if (exec->argumentCount() < 1)
- return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
+ return throwVMError(exec, createNotEnoughArgumentsError(exec));
sequence<ScriptProfile>* sequenceArg(toNativeArray<ScriptProfile>(exec, MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined)));
if (exec->hadException())
return JSValue::encode(jsUndefined());
ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info);
TestObj* impl = static_cast<TestObj*>(castedThis->impl());
if (exec->argumentCount() < 1)
- return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
+ return throwVMError(exec, createNotEnoughArgumentsError(exec));
int intArg(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toInt32(exec));
if (exec->hadException())
return JSValue::encode(jsUndefined());
ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info);
TestObj* impl = static_cast<TestObj*>(castedThis->impl());
if (exec->argumentCount() < 2)
- return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
+ return throwVMError(exec, createNotEnoughArgumentsError(exec));
ExceptionCode ec = 0;
const String& strArg(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toString(exec)->value(exec)));
if (exec->hadException())
ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info);
TestObj* impl = static_cast<TestObj*>(castedThis->impl());
if (exec->argumentCount() < 1)
- return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
+ return throwVMError(exec, createNotEnoughArgumentsError(exec));
RefPtr<SerializedScriptValue> serializedArg(SerializedScriptValue::create(exec, MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined)));
if (exec->hadException())
return JSValue::encode(jsUndefined());
ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info);
TestObj* impl = static_cast<TestObj*>(castedThis->impl());
if (exec->argumentCount() < 1)
- return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
+ return throwVMError(exec, createNotEnoughArgumentsError(exec));
PassRefPtr<IDBKey> key(createIDBKeyFromValue(exec, MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined)));
if (exec->hadException())
return JSValue::encode(jsUndefined());
ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info);
TestObj* impl = static_cast<TestObj*>(castedThis->impl());
if (exec->argumentCount() < 1)
- return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
+ return throwVMError(exec, createNotEnoughArgumentsError(exec));
Dictionary oo(exec, MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined));
if (exec->hadException())
return JSValue::encode(jsUndefined());
ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info);
TestObj* impl = static_cast<TestObj*>(castedThis->impl());
if (exec->argumentCount() < 2)
- return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
+ return throwVMError(exec, createNotEnoughArgumentsError(exec));
JSValue listener = exec->argument(1);
if (!listener.isObject())
return JSValue::encode(jsUndefined());
ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info);
TestObj* impl = static_cast<TestObj*>(castedThis->impl());
if (exec->argumentCount() < 2)
- return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
+ return throwVMError(exec, createNotEnoughArgumentsError(exec));
JSValue listener = exec->argument(1);
if (!listener.isObject())
return JSValue::encode(jsUndefined());
ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info);
TestObj* impl = static_cast<TestObj*>(castedThis->impl());
if (exec->argumentCount() < 1)
- return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
+ return throwVMError(exec, createNotEnoughArgumentsError(exec));
int nonOpt(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toInt32(exec));
if (exec->hadException())
return JSValue::encode(jsUndefined());
ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info);
TestObj* impl = static_cast<TestObj*>(castedThis->impl());
if (exec->argumentCount() < 1)
- return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
+ return throwVMError(exec, createNotEnoughArgumentsError(exec));
int nonOpt(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toInt32(exec));
if (exec->hadException())
return JSValue::encode(jsUndefined());
ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info);
TestObj* impl = static_cast<TestObj*>(castedThis->impl());
if (exec->argumentCount() < 1)
- return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
+ return throwVMError(exec, createNotEnoughArgumentsError(exec));
if (exec->argumentCount() <= 0 || !exec->argument(0).isFunction()) {
setDOMException(exec, TYPE_MISMATCH_ERR);
return JSValue::encode(jsUndefined());
ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info);
TestObj* impl = static_cast<TestObj*>(castedThis->impl());
if (exec->argumentCount() < 2)
- return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
+ return throwVMError(exec, createNotEnoughArgumentsError(exec));
int nonCallback(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toInt32(exec));
if (exec->hadException())
return JSValue::encode(jsUndefined());
ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info);
TestObj* impl = static_cast<TestObj*>(castedThis->impl());
if (exec->argumentCount() < 2)
- return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
+ return throwVMError(exec, createNotEnoughArgumentsError(exec));
TestObj* objArg(toTestObj(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined)));
if (exec->hadException())
return JSValue::encode(jsUndefined());
ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info);
TestObj* impl = static_cast<TestObj*>(castedThis->impl());
if (exec->argumentCount() < 1)
- return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
+ return throwVMError(exec, createNotEnoughArgumentsError(exec));
TestObj* objArg(toTestObj(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined)));
if (exec->hadException())
return JSValue::encode(jsUndefined());
ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info);
TestObj* impl = static_cast<TestObj*>(castedThis->impl());
if (exec->argumentCount() < 1)
- return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
+ return throwVMError(exec, createNotEnoughArgumentsError(exec));
const String& strArg(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toString(exec)->value(exec)));
if (exec->hadException())
return JSValue::encode(jsUndefined());
ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info);
TestObj* impl = static_cast<TestObj*>(castedThis->impl());
if (exec->argumentCount() < 1)
- return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
+ return throwVMError(exec, createNotEnoughArgumentsError(exec));
int intArg(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toInt32(exec));
if (exec->hadException())
return JSValue::encode(jsUndefined());
ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info);
TestObj* impl = static_cast<TestObj*>(castedThis->impl());
if (exec->argumentCount() < 1)
- return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
+ return throwVMError(exec, createNotEnoughArgumentsError(exec));
if (exec->argumentCount() <= 0 || !exec->argument(0).isFunction()) {
setDOMException(exec, TYPE_MISMATCH_ERR);
return JSValue::encode(jsUndefined());
ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info);
TestObj* impl = static_cast<TestObj*>(castedThis->impl());
if (exec->argumentCount() < 1)
- return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
+ return throwVMError(exec, createNotEnoughArgumentsError(exec));
DOMStringList* listArg(toDOMStringList(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined)));
if (exec->hadException())
return JSValue::encode(jsUndefined());
ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info);
TestObj* impl = static_cast<TestObj*>(castedThis->impl());
if (exec->argumentCount() < 1)
- return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
+ return throwVMError(exec, createNotEnoughArgumentsError(exec));
DOMStringList* arrayArg(toDOMStringList(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined)));
if (exec->hadException())
return JSValue::encode(jsUndefined());
EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionClassMethod2(ExecState* exec)
{
if (exec->argumentCount() < 1)
- return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
+ return throwVMError(exec, createNotEnoughArgumentsError(exec));
return JSValue::encode(JSTestObj::classMethod2(exec));
}
static EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionOverloadedMethod11(ExecState* exec)
{
if (exec->argumentCount() < 1)
- return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
+ return throwVMError(exec, createNotEnoughArgumentsError(exec));
int arg(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toInt32(exec));
if (exec->hadException())
return JSValue::encode(jsUndefined());
static EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionOverloadedMethod12(ExecState* exec)
{
if (exec->argumentCount() < 1)
- return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
+ return throwVMError(exec, createNotEnoughArgumentsError(exec));
const String& type(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toString(exec)->value(exec)));
if (exec->hadException())
return JSValue::encode(jsUndefined());
ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info);
TestObj* impl = static_cast<TestObj*>(castedThis->impl());
if (exec->argumentCount() < 1)
- return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
+ return throwVMError(exec, createNotEnoughArgumentsError(exec));
Vector<unsigned long> unsignedLongArray(jsUnsignedLongArrayToVector(exec, MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined)));
if (exec->hadException())
return JSValue::encode(jsUndefined());
ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info);
TestObj* impl = static_cast<TestObj*>(castedThis->impl());
if (exec->argumentCount() < 1)
- return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
+ return throwVMError(exec, createNotEnoughArgumentsError(exec));
a* (toa(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined)));
if (exec->hadException())
return JSValue::encode(jsUndefined());
ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info);
TestObj* impl = static_cast<TestObj*>(castedThis->impl());
if (exec->argumentCount() < 1)
- return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
+ return throwVMError(exec, createNotEnoughArgumentsError(exec));
b* (tob(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined)));
if (exec->hadException())
return JSValue::encode(jsUndefined());
ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info);
TestObj* impl = static_cast<TestObj*>(castedThis->impl());
if (exec->argumentCount() < 1)
- return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
+ return throwVMError(exec, createNotEnoughArgumentsError(exec));
c* (toc(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined)));
if (exec->hadException())
return JSValue::encode(jsUndefined());
ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info);
TestObj* impl = static_cast<TestObj*>(castedThis->impl());
if (exec->argumentCount() < 1)
- return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
+ return throwVMError(exec, createNotEnoughArgumentsError(exec));
d* (tod(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined)));
if (exec->hadException())
return JSValue::encode(jsUndefined());
ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info);
TestObj* impl = static_cast<TestObj*>(castedThis->impl());
if (exec->argumentCount() < 1)
- return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
+ return throwVMError(exec, createNotEnoughArgumentsError(exec));
e* (toe(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined)));
if (exec->hadException())
return JSValue::encode(jsUndefined());
ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info);
TestObj* impl = static_cast<TestObj*>(castedThis->impl());
if (exec->argumentCount() < 3)
- return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
+ return throwVMError(exec, createNotEnoughArgumentsError(exec));
ExceptionCode ec = 0;
const String& str(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toString(exec)->value(exec)));
if (exec->hadException())