[Webkit-unassigned] [Bug 38920] V8 overload support ported to JSC

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed May 12 18:37:20 PDT 2010


https://bugs.webkit.org/show_bug.cgi?id=38920





--- Comment #5 from Sam Weinig <sam at webkit.org>  2010-05-12 18:37:19 PST ---
(From update of attachment 55882)
> Index: WebCore/bindings/scripts/test/JS/JSTestObj.cpp
> ===================================================================
> --- WebCore/bindings/scripts/test/JS/JSTestObj.cpp	(revision 59097)
> +++ WebCore/bindings/scripts/test/JS/JSTestObj.cpp	(working copy)
> @@ -133,7 +133,7 @@ bool JSTestObjConstructor::getOwnPropert
>  #define THUNK_GENERATOR(generator)
>  #endif
>  
> -static const HashTableValue JSTestObjPrototypeTableValues[26] =
> +static const HashTableValue JSTestObjPrototypeTableValues[27] =
>  {
>      { "voidMethod", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionVoidMethod), (intptr_t)0 THUNK_GENERATOR(0) },
>      { "voidMethodWithArgs", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionVoidMethodWithArgs), (intptr_t)3 THUNK_GENERATOR(0) },
> @@ -160,6 +160,7 @@ static const HashTableValue JSTestObjPro
>      { "methodWithOptionalArg", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalArg), (intptr_t)1 THUNK_GENERATOR(0) },
>      { "methodWithNonOptionalArgAndOptionalArg", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndOptionalArg), (intptr_t)2 THUNK_GENERATOR(0) },
>      { "methodWithNonOptionalArgAndTwoOptionalArgs", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndTwoOptionalArgs), (intptr_t)3 THUNK_GENERATOR(0) },
> +    { "overloadedMethod", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionOverloadedMethod), (intptr_t)2 THUNK_GENERATOR(0) },
>      { 0, 0, 0, 0 THUNK_GENERATOR(0) }
>  };
>  
> @@ -801,6 +802,80 @@ JSValue JSC_HOST_CALL jsTestObjPrototype
>      return jsUndefined();
>  }
>  
> +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod1(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
> +{
> +    UNUSED_PARAM(args);
> +    if (!thisValue.inherits(&JSTestObj::s_info))
> +        return throwError(exec, TypeError);
> +    JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
> +    TestObj* imp = static_cast<TestObj*>(castedThis->impl());
> +    TestObj* objArg = toTestObj(args.at(0));
> +    const String& strArg = ustringToString(args.at(1).toString(exec));
> +
> +    imp->overloadedMethod(objArg, strArg);
> +    return jsUndefined();
> +}
> +
> +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod2(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
> +{
> +    UNUSED_PARAM(args);
> +    if (!thisValue.inherits(&JSTestObj::s_info))
> +        return throwError(exec, TypeError);
> +    JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
> +    TestObj* imp = static_cast<TestObj*>(castedThis->impl());
> +    TestObj* objArg = toTestObj(args.at(0));
> +
> +    int argsCount = args.size();
> +    if (argsCount < 2) {
> +        imp->overloadedMethod(objArg);
> +        return jsUndefined();
> +    }
> +
> +    int intArg = args.at(1).toInt32(exec);
> +
> +    imp->overloadedMethod(objArg, intArg);
> +    return jsUndefined();
> +}
> +
> +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod3(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
> +{
> +    UNUSED_PARAM(args);
> +    if (!thisValue.inherits(&JSTestObj::s_info))
> +        return throwError(exec, TypeError);
> +    JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
> +    TestObj* imp = static_cast<TestObj*>(castedThis->impl());
> +    const String& strArg = ustringToString(args.at(0).toString(exec));
> +
> +    imp->overloadedMethod(strArg);
> +    return jsUndefined();
> +}
> +
> +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod4(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
> +{
> +    UNUSED_PARAM(args);
> +    if (!thisValue.inherits(&JSTestObj::s_info))
> +        return throwError(exec, TypeError);
> +    JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
> +    TestObj* imp = static_cast<TestObj*>(castedThis->impl());
> +    int intArg = args.at(0).toInt32(exec);
> +
> +    imp->overloadedMethod(intArg);
> +    return jsUndefined();
> +}
> +
> +JSValue JSC_HOST_CALL testObjPrototypeFunctionOverloadedMethod(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
> +{
> +    if ((args.size() == 2 && (args.at(0).isNull() || asObject(args.at(0))->inherits(JSTestObj::s_info) && (args.at(1).isNull() || args.at(1).isUndefined() || args.at(1).isString() || args.at(1).isObject())))
> +        return testObjPrototypeFunctionOverloadedMethod1Callback(args);
> +    if ((args.size() == 1 && (args.at(0).isNull() || asObject(args.at(0))->inherits(JSTestObj::s_info)) || (args.size() == 2 && (args.at(0).isNull() || asObject(args.at(0))->inherits(JSTestObj::s_info)))
> +        return testObjPrototypeFunctionOverloadedMethod2Callback(args);
> +    if ((args.size() == 1 && (args.at(0).isNull() || args.at(0).isUndefined() || args.at(0).isString() || args.at(0).isObject())))
> +        return testObjPrototypeFunctionOverloadedMethod3Callback(args);
> +    if (args.size() == 1)
> +        return testObjPrototypeFunctionOverloadedMethod4Callback(args);
> +    return throwError(exec, TypeError);
> +}
> +
>  JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestObj* object)
>  {


It is possible I am reading this wrong, but where are the implementations of testObjPrototypeFunctionOverloadedMethod1Callback and friends.  Are they supposed to be called jsTestObjPrototypeFunctionOverloadedMethod1 and friends. Are they supposed to take more parameters?  Can we optimize the if statement in this function so it does not do the same work multiple times (calling things like inherits)?

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the webkit-unassigned mailing list