Changeset 102351 in webkit


Ignore:
Timestamp:
Dec 8, 2011 10:55:05 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Fixing support for static conditional overloaded functions.
https://bugs.webkit.org/show_bug.cgi?id=74068

Patch by Kaustubh Atrawalkar <Kaustubh Atrawalkar> on 2011-12-08
Reviewed by Adam Barth.

  • bindings/scripts/CodeGeneratorJS.pm:

(GenerateImplementation): Pushing "static" keyword after condition "#if".

  • bindings/scripts/test/CPP/WebDOMTestObj.cpp:

(WebDOMTestObj::overloadedMethod1): Added newly generated bindings.

  • bindings/scripts/test/CPP/WebDOMTestObj.h: Ditto.
  • bindings/scripts/test/GObject/WebKitDOMTestObj.cpp: Ditto.

(webkit_dom_test_obj_overloaded_method1):

  • bindings/scripts/test/GObject/WebKitDOMTestObj.h: Ditto.
  • bindings/scripts/test/JS/JSTestObj.cpp: Ditto.

(WebCore::jsTestObjConstructorFunctionOverloadedMethod11):
(WebCore::jsTestObjConstructorFunctionOverloadedMethod12):
(WebCore::jsTestObjConstructorFunctionOverloadedMethod1):

  • bindings/scripts/test/JS/JSTestObj.h: Ditto.
  • bindings/scripts/test/ObjC/DOMTestObj.h: Ditto.
  • bindings/scripts/test/ObjC/DOMTestObj.mm: Ditto.

(-[DOMTestObj overloadedMethod1:]):

  • bindings/scripts/test/TestObj.idl: Ditto.
  • bindings/scripts/test/V8/V8TestObj.cpp: Ditto.

(WebCore::TestObjInternal::overloadedMethod11Callback):
(WebCore::TestObjInternal::overloadedMethod12Callback):
(WebCore::TestObjInternal::overloadedMethod1Callback):
(WebCore::ConfigureV8TestObjTemplate):

Location:
trunk/Source/WebCore
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r102349 r102351  
     12011-12-08  Kaustubh Atrawalkar  <kaustubh@motorola.com>
     2
     3        Fixing support for static conditional overloaded functions.
     4        https://bugs.webkit.org/show_bug.cgi?id=74068
     5
     6        Reviewed by Adam Barth.
     7
     8        * bindings/scripts/CodeGeneratorJS.pm:
     9        (GenerateImplementation): Pushing "static" keyword after condition "#if".
     10        * bindings/scripts/test/CPP/WebDOMTestObj.cpp:
     11        (WebDOMTestObj::overloadedMethod1): Added newly generated bindings.
     12        * bindings/scripts/test/CPP/WebDOMTestObj.h: Ditto.
     13        * bindings/scripts/test/GObject/WebKitDOMTestObj.cpp: Ditto.
     14        (webkit_dom_test_obj_overloaded_method1):
     15        * bindings/scripts/test/GObject/WebKitDOMTestObj.h: Ditto.
     16        * bindings/scripts/test/JS/JSTestObj.cpp: Ditto.
     17        (WebCore::jsTestObjConstructorFunctionOverloadedMethod11):
     18        (WebCore::jsTestObjConstructorFunctionOverloadedMethod12):
     19        (WebCore::jsTestObjConstructorFunctionOverloadedMethod1):
     20        * bindings/scripts/test/JS/JSTestObj.h: Ditto.
     21        * bindings/scripts/test/ObjC/DOMTestObj.h: Ditto.
     22        * bindings/scripts/test/ObjC/DOMTestObj.mm: Ditto.
     23        (-[DOMTestObj overloadedMethod1:]):
     24        * bindings/scripts/test/TestObj.idl: Ditto.
     25        * bindings/scripts/test/V8/V8TestObj.cpp: Ditto.
     26        (WebCore::TestObjInternal::overloadedMethod11Callback):
     27        (WebCore::TestObjInternal::overloadedMethod12Callback):
     28        (WebCore::TestObjInternal::overloadedMethod1Callback):
     29        (WebCore::ConfigureV8TestObjTemplate):
     30
    1312011-12-08  Andreas Kling  <kling@webkit.org>
    232
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r102233 r102351  
    20722072            my $functionName = GetFunctionName($className, $function);
    20732073
     2074            my $conditional = $function->signature->extendedAttributes->{"Conditional"};
     2075            if ($conditional) {
     2076                my $conditionalString = $codeGenerator->GenerateConditionalStringFromAttributeValue($conditional);
     2077                push(@implContent, "#if ${conditionalString}\n");
     2078            }
     2079
     2080
    20742081            if (!$isCustom && $isOverloaded) {
    20752082                # Append a number to an overloaded method's name to make it unique:
     
    20792086                push(@implContent, "static ");
    20802087            }
    2081            
     2088
    20822089            my $functionImplementationName = $function->signature->extendedAttributes->{"ImplementationFunction"} || $codeGenerator->WK_lcfirst($function->signature->name);
    2083 
    2084             my $conditional = $function->signature->extendedAttributes->{"Conditional"};
    2085             if ($conditional) {
    2086                 my $conditionalString = $codeGenerator->GenerateConditionalStringFromAttributeValue($conditional);
    2087                 push(@implContent, "#if ${conditionalString}\n");
    2088             }
    20892090
    20902091            push(@implContent, "EncodedJSValue JSC_HOST_CALL ${functionName}(ExecState* exec)\n");
  • trunk/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp

    r100163 r102351  
    906906}
    907907
     908
     909#if ENABLE(Condition1)
     910void WebDOMTestObj::overloadedMethod1(int arg)
     911{
     912    if (!impl())
     913        return;
     914
     915    impl()->overloadedMethod1(arg);
     916}
     917
     918#endif
     919
     920
     921#if ENABLE(Condition1)
     922void WebDOMTestObj::overloadedMethod1(const WebDOMString& type)
     923{
     924    if (!impl())
     925        return;
     926
     927    impl()->overloadedMethod1(type);
     928}
     929
     930#endif
     931
    908932WebCore::TestObj* toWebCore(const WebDOMTestObj& wrapper)
    909933{
  • trunk/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.h

    r101102 r102351  
    182182    void classMethod();
    183183    int classMethodWithOptional(int arg);
     184    void overloadedMethod1(int arg);
     185    void overloadedMethod1(const WebDOMString& type);
    184186
    185187    WebCore::TestObj* impl() const;
  • trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp

    r100163 r102351  
    414414    glong res = item->classMethodWithOptional(arg);
    415415    return res;
     416}
     417
     418void
     419webkit_dom_test_obj_overloaded_method1(WebKitDOMTestObj* self, glong arg)
     420{
     421#if ENABLE(Condition1)
     422    g_return_if_fail(self);
     423    WebCore::JSMainThreadNullState state;
     424    WebCore::TestObj * item = WebKit::core(self);
     425    item->overloadedMethod1(arg);
     426#endif /* ENABLE(Condition1) */
     427}
     428
     429void
     430webkit_dom_test_obj_overloaded_method1(WebKitDOMTestObj* self, const gchar* type)
     431{
     432#if ENABLE(Condition1)
     433    g_return_if_fail(self);
     434    WebCore::JSMainThreadNullState state;
     435    WebCore::TestObj * item = WebKit::core(self);
     436    g_return_if_fail(type);
     437    WTF::String converted_type = WTF::String::fromUTF8(type);
     438    item->overloadedMethod1(converted_type);
     439#endif /* ENABLE(Condition1) */
    416440}
    417441
  • trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h

    r100163 r102351  
    370370
    371371/**
     372 * webkit_dom_test_obj_overloaded_method1:
     373 * @self: A #WebKitDOMTestObj
     374 * @arg: A #glong
     375 *
     376 * Returns:
     377 *
     378**/
     379WEBKIT_API void
     380webkit_dom_test_obj_overloaded_method1(WebKitDOMTestObj* self, glong arg);
     381
     382/**
     383 * webkit_dom_test_obj_overloaded_method1:
     384 * @self: A #WebKitDOMTestObj
     385 * @type: A #gchar
     386 *
     387 * Returns:
     388 *
     389**/
     390WEBKIT_API void
     391webkit_dom_test_obj_overloaded_method1(WebKitDOMTestObj* self, const gchar* type);
     392
     393/**
    372394 * webkit_dom_test_obj_get_read_only_int_attr:
    373395 * @self: A #WebKitDOMTestObj
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp

    r102233 r102351  
    165165    { "classMethod", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjConstructorFunctionClassMethod), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
    166166    { "classMethodWithOptional", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjConstructorFunctionClassMethodWithOptional), (intptr_t)1 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
     167#if ENABLE(Condition1)
     168    { "overloadedMethod1", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjConstructorFunctionOverloadedMethod1), (intptr_t)1 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
     169#endif
    167170    { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
    168171};
    169172
    170173#undef THUNK_GENERATOR
    171 static const HashTable JSTestObjConstructorTable = { 35, 31, JSTestObjConstructorTableValues, 0 };
     174static const HashTable JSTestObjConstructorTable = { 36, 31, JSTestObjConstructorTableValues, 0 };
    172175
    173176#if ENABLE(Condition1)
     
    18901893}
    18911894
     1895#if ENABLE(Condition1)
     1896static EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionOverloadedMethod11(ExecState* exec)
     1897{
     1898    if (exec->argumentCount() < 1)
     1899        return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
     1900    int arg(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).toInt32(exec));
     1901    if (exec->hadException())
     1902        return JSValue::encode(jsUndefined());
     1903    TestObj::overloadedMethod1(arg);
     1904    return JSValue::encode(jsUndefined());
     1905}
     1906
     1907#endif
     1908
     1909#if ENABLE(Condition1)
     1910static EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionOverloadedMethod12(ExecState* exec)
     1911{
     1912    if (exec->argumentCount() < 1)
     1913        return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
     1914    const String& type(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).toString(exec)));
     1915    if (exec->hadException())
     1916        return JSValue::encode(jsUndefined());
     1917    TestObj::overloadedMethod1(type);
     1918    return JSValue::encode(jsUndefined());
     1919}
     1920
     1921EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionOverloadedMethod1(ExecState* exec)
     1922{
     1923    size_t argsCount = exec->argumentCount();
     1924    if (argsCount == 1)
     1925        return jsTestObjConstructorFunctionOverloadedMethod11(exec);
     1926    JSValue arg0(exec->argument(0));
     1927    if ((argsCount == 1 && (arg0.isUndefinedOrNull() || arg0.isString() || arg0.isObject())))
     1928        return jsTestObjConstructorFunctionOverloadedMethod12(exec);
     1929    return throwVMTypeError(exec);
     1930}
     1931
     1932#endif
     1933
    18921934void JSTestObj::visitChildren(JSCell* cell, SlotVisitor& visitor)
    18931935{
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h

    r101421 r102351  
    186186JSC::EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionClassMethod(JSC::ExecState*);
    187187JSC::EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionClassMethodWithOptional(JSC::ExecState*);
     188JSC::EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionOverloadedMethod1(JSC::ExecState*);
    188189// Attributes
    189190
  • trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h

    r101102 r102351  
    174174- (void)classMethod;
    175175- (int)classMethodWithOptional:(int)arg;
     176- (void)overloadedMethod1:(int)arg;
     177- (void)overloadedMethod1:(NSString *)type;
    176178@end
    177179
  • trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm

    r100163 r102351  
    769769}
    770770
     771
     772#if ENABLE(Condition1)
     773- (void)overloadedMethod1:(int)arg
     774{
     775    WebCore::JSMainThreadNullState state;
     776    IMPL->overloadedMethod1(arg);
     777}
     778
     779#endif
     780
     781
     782#if ENABLE(Condition1)
     783- (void)overloadedMethod1:(NSString *)type
     784{
     785    WebCore::JSMainThreadNullState state;
     786    IMPL->overloadedMethod1(type);
     787}
     788
     789#endif
     790
    771791@end
    772792
  • trunk/Source/WebCore/bindings/scripts/test/TestObj.idl

    r101433 r102351  
    166166        static long classMethodWithOptional(in [Optional] long arg);
    167167
     168        // Static method with conditional on overloaded methods
     169
     170        static [Conditional=Condition1] void overloadedMethod1(in long arg);
     171        static [Conditional=Condition1] void overloadedMethod1(in DOMString type);
     172
    168173#if defined(TESTING_V8)
    169174        // 'EnabledAtRuntime' methods and attributes.
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp

    r102233 r102351  
    12841284    EXCEPTION_BLOCK(int, arg, toInt32(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined)));
    12851285    return v8::Integer::New(TestObj::classMethodWithOptional(arg));
     1286}
     1287
     1288static v8::Handle<v8::Value> overloadedMethod11Callback(const v8::Arguments& args)
     1289{
     1290    INC_STATS("DOM.TestObj.overloadedMethod11");
     1291    if (args.Length() < 1)
     1292        return throwError("Not enough arguments", V8Proxy::TypeError);
     1293    EXCEPTION_BLOCK(int, arg, toInt32(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined)));
     1294    TestObj::overloadedMethod1(arg);
     1295    return v8::Handle<v8::Value>();
     1296}
     1297
     1298static v8::Handle<v8::Value> overloadedMethod12Callback(const v8::Arguments& args)
     1299{
     1300    INC_STATS("DOM.TestObj.overloadedMethod12");
     1301    if (args.Length() < 1)
     1302        return throwError("Not enough arguments", V8Proxy::TypeError);
     1303    STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, type, MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined));
     1304    TestObj::overloadedMethod1(type);
     1305    return v8::Handle<v8::Value>();
     1306}
     1307
     1308static v8::Handle<v8::Value> overloadedMethod1Callback(const v8::Arguments& args)
     1309{
     1310    INC_STATS("DOM.TestObj.overloadedMethod1");
     1311    if (args.Length() == 1)
     1312        return overloadedMethod11Callback(args);
     1313    if ((args.Length() == 1 && (args[0]->IsNull() || args[0]->IsUndefined() || args[0]->IsString() || args[0]->IsObject())))
     1314        return overloadedMethod12Callback(args);
     1315    V8Proxy::throwTypeError();
     1316    return notHandledByInterceptor();
    12861317}
    12871318
     
    15611592    desc->Set(v8::String::New("classMethod"), v8::FunctionTemplate::New(TestObjInternal::classMethodCallback, v8::Handle<v8::Value>(), v8::Local<v8::Signature>()));
    15621593    desc->Set(v8::String::New("classMethodWithOptional"), v8::FunctionTemplate::New(TestObjInternal::classMethodWithOptionalCallback, v8::Handle<v8::Value>(), v8::Local<v8::Signature>()));
     1594    desc->Set(v8::String::New("overloadedMethod1"), v8::FunctionTemplate::New(TestObjInternal::overloadedMethod1Callback, v8::Handle<v8::Value>(), v8::Local<v8::Signature>()));
    15631595    if (RuntimeEnabledFeatures::enabledAtRuntimeMethod1Enabled())
    15641596        proto->Set(v8::String::New("enabledAtRuntimeMethod1"), v8::FunctionTemplate::New(TestObjInternal::enabledAtRuntimeMethod1Callback, v8::Handle<v8::Value>(), defaultSignature));
Note: See TracChangeset for help on using the changeset viewer.