Changeset 136507 in webkit


Ignore:
Timestamp:
Dec 4, 2012 6:56:21 AM (11 years ago)
Author:
adam.bergkvist@ericsson.com
Message:

Add support for generic types in arrays and sequences to the code generators
https://bugs.webkit.org/show_bug.cgi?id=103642

Reviewed by Kentaro Hara.

Updated the bindings generators to support arrays and sequences of host objects.

  • Arrays and sequences of host objects are mapped to Vector<RefPtr<%RefPtrType%> >.
  • Fixed issue where "sequence<String>" was used in IDL files instead of "sequence<DOMString>".

Updated existing test results.

  • Modules/indexeddb/IDBDatabase.idl:
  • Modules/indexeddb/IDBObjectStore.idl:
  • Modules/mediastream/RTCStatsElement.idl:
  • Modules/websockets/WebSocket.idl:
  • bindings/js/JSDOMBinding.h:

(WebCore::toRefPtrNativeArray):
(WebCore):

  • bindings/scripts/CodeGenerator.pm:

(IsRefPtrType):

  • bindings/scripts/CodeGeneratorJS.pm:

(AddIncludesForType):
(GetNativeType):
(GetNativeVectorInnerType):
(JSValueToNative):
(NativeToJSValue):

  • bindings/scripts/CodeGeneratorV8.pm:

(GenerateNormalAttrGetter):
(GenerateNormalAttrSetter):
(GenerateParametersCheckExpression):
(GenerateFunctionCallString):
(GetNativeType):
(JSValueToNative):
(CreateCustomSignature):
(NativeToJSValue):

  • bindings/scripts/test/JS/JSTestObj.cpp:

(WebCore::jsTestObjPrototypeFunctionMethodWithSequenceArg):

  • bindings/scripts/test/V8/V8TestObj.cpp:

(WebCore::TestObjV8Internal::longLongAttrAttrSetter):
(WebCore::TestObjV8Internal::unsignedLongLongAttrAttrSetter):
(WebCore::TestObjV8Internal::methodWithSequenceArgCallback):
(WebCore::TestObjV8Internal::overloadedMethod10Callback):

  • bindings/v8/V8Binding.h:

(WebCore::toRefPtrNativeArray):

  • testing/Internals.idl:
Location:
trunk/Source/WebCore
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r136506 r136507  
     12012-12-04  Adam Bergkvist  <adam.bergkvist@ericsson.com>
     2
     3        Add support for generic types in arrays and sequences to the code generators
     4        https://bugs.webkit.org/show_bug.cgi?id=103642
     5
     6        Reviewed by Kentaro Hara.
     7
     8        Updated the bindings generators to support arrays and sequences of host objects.
     9
     10        - Arrays and sequences of host objects are mapped to Vector<RefPtr<%RefPtrType%> >.
     11        - Fixed issue where "sequence<String>" was used in IDL files instead of "sequence<DOMString>".
     12
     13        Updated existing test results.
     14
     15        * Modules/indexeddb/IDBDatabase.idl:
     16        * Modules/indexeddb/IDBObjectStore.idl:
     17        * Modules/mediastream/RTCStatsElement.idl:
     18        * Modules/websockets/WebSocket.idl:
     19        * bindings/js/JSDOMBinding.h:
     20        (WebCore::toRefPtrNativeArray):
     21        (WebCore):
     22        * bindings/scripts/CodeGenerator.pm:
     23        (IsRefPtrType):
     24        * bindings/scripts/CodeGeneratorJS.pm:
     25        (AddIncludesForType):
     26        (GetNativeType):
     27        (GetNativeVectorInnerType):
     28        (JSValueToNative):
     29        (NativeToJSValue):
     30        * bindings/scripts/CodeGeneratorV8.pm:
     31        (GenerateNormalAttrGetter):
     32        (GenerateNormalAttrSetter):
     33        (GenerateParametersCheckExpression):
     34        (GenerateFunctionCallString):
     35        (GetNativeType):
     36        (JSValueToNative):
     37        (CreateCustomSignature):
     38        (NativeToJSValue):
     39        * bindings/scripts/test/JS/JSTestObj.cpp:
     40        (WebCore::jsTestObjPrototypeFunctionMethodWithSequenceArg):
     41        * bindings/scripts/test/V8/V8TestObj.cpp:
     42        (WebCore::TestObjV8Internal::longLongAttrAttrSetter):
     43        (WebCore::TestObjV8Internal::unsignedLongLongAttrAttrSetter):
     44        (WebCore::TestObjV8Internal::methodWithSequenceArgCallback):
     45        (WebCore::TestObjV8Internal::overloadedMethod10Callback):
     46        * bindings/v8/V8Binding.h:
     47        (WebCore::toRefPtrNativeArray):
     48        * testing/Internals.idl:
     49
    1502012-12-04  Antoine Quint  <graouts@apple.com>
    251
  • trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.idl

    r135904 r136507  
    4545    [CallWith=ScriptExecutionContext] IDBTransaction transaction(in DOMStringList storeNames, in [Optional=DefaultIsNullString] DOMString mode)
    4646        raises (DOMException);
    47     [CallWith=ScriptExecutionContext] IDBTransaction transaction(in sequence<String> storeNames, in [Optional=DefaultIsNullString] DOMString mode)
     47    [CallWith=ScriptExecutionContext] IDBTransaction transaction(in sequence<DOMString> storeNames, in [Optional=DefaultIsNullString] DOMString mode)
    4848        raises (DOMException);
    4949    [CallWith=ScriptExecutionContext] IDBTransaction transaction(in DOMString storeName, in [Optional=DefaultIsNullString] DOMString mode)
  • trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.idl

    r135471 r136507  
    5353        raises (DOMException);
    5454
    55     [CallWith=ScriptExecutionContext] IDBIndex createIndex(in DOMString name, in sequence<String> keyPath, in [Optional] Dictionary options)
     55    [CallWith=ScriptExecutionContext] IDBIndex createIndex(in DOMString name, in sequence<DOMString> keyPath, in [Optional] Dictionary options)
    5656        raises (DOMException);
    5757    [CallWith=ScriptExecutionContext] IDBIndex createIndex(in DOMString name, in DOMString keyPath, in [Optional] Dictionary options)
  • trunk/Source/WebCore/Modules/mediastream/RTCStatsElement.idl

    r135500 r136507  
    2828    readonly attribute Date timestamp;
    2929    DOMString stat(in DOMString name);
    30     sequence<String> names();
     30    sequence<DOMString> names();
    3131};
  • trunk/Source/WebCore/Modules/websockets/WebSocket.idl

    r134386 r136507  
    3434    ActiveDOMObject,
    3535    Constructor(in DOMString url),
    36     Constructor(in DOMString url, in sequence<String> protocols),
     36    Constructor(in DOMString url, in sequence<DOMString> protocols),
    3737    Constructor(in DOMString url, in DOMString protocol),
    3838    ConstructorRaisesException,
  • trunk/Source/WebCore/bindings/js/JSDOMBinding.h

    r135009 r136507  
    44 *  Copyright (C) 2007 Samuel Weinig <sam@webkit.org>
    55 *  Copyright (C) 2009 Google, Inc. All rights reserved.
     6 *  Copyright (C) 2012 Ericsson AB. All rights reserved.
    67 *
    78 *  This library is free software; you can redistribute it and/or
     
    412413    };
    413414
     415    template <class T, class JST>
     416    Vector<RefPtr<T> > toRefPtrNativeArray(JSC::ExecState* exec, JSC::JSValue value, T* (*toT)(JSC::JSValue value))
     417    {
     418        if (!isJSArray(value))
     419            return Vector<RefPtr<T> >();
     420
     421        Vector<RefPtr<T> > result;
     422        JSC::JSArray* array = asArray(value);
     423        for (size_t i = 0; i < array->length(); ++i) {
     424            JSC::JSValue element = array->getIndex(exec, i);
     425            if (element.inherits(&JST::s_info))
     426                result.append((*toT)(element));
     427            else {
     428                throwVMError(exec, createTypeError(exec, "Invalid Array element type"));
     429                return Vector<RefPtr<T> >();
     430            }
     431        }
     432        return result;
     433    }
     434
    414435    template <class T>
    415436    Vector<T> toNativeArray(JSC::ExecState* exec, JSC::JSValue value)
  • trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm

    r135426 r136507  
    396396}
    397397
     398sub IsRefPtrType
     399{
     400    my $object = shift;
     401    my $type = shift;
     402
     403    return 0 if $object->IsPrimitiveType($type);
     404    return 0 if $type eq "DOMString";
     405
     406    return 1;
     407}
     408
    398409sub GetSVGTypeNeedingTearOff
    399410{
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r136482 r136507  
    99# Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
    1010# Copyright (C) 2011 Patrick Gansterer <paroga@webkit.org>
     11# Copyright (C) 2012 Ericsson AB. All rights reserved.
    1112#
    1213# This library is free software; you can redistribute it and/or
     
    242243        $includesRef->{"JSCustomXPathNSResolver.h"} = 1;
    243244    } elsif ($type eq "DOMString[]") {
    244         # FIXME: Add proper support for T[], T[]?, sequence<T>
     245        # FIXME: Consider replacing DOMStringList with DOMString[] or sequence<DOMString>.
    245246        $includesRef->{"JSDOMStringList.h"} = 1;
    246247    } elsif ($type eq "SerializedScriptValue") {
     
    30313032    "CompareHow" => "Range::CompareHow",
    30323033    "DOMString" => "const String&",
    3033     # FIXME: Add proper support for T[], T[]?, sequence<T>
     3034    # FIXME: Consider replacing DOMStringList with DOMString[] or sequence<DOMString>.
    30343035    "DOMString[]" => "RefPtr<DOMStringList>",
    30353036    "DOMObject" => "ScriptValue",
     
    30613062    return $nativeType{$type} if exists $nativeType{$type};
    30623063
     3064    my $arrayType = $codeGenerator->GetArrayType($type);
    30633065    my $sequenceType = $codeGenerator->GetSequenceType($type);
    3064     return "Vector<${sequenceType}>" if $sequenceType;
     3066    my $arrayOrSequenceType = $arrayType || $sequenceType;
     3067
     3068    return "Vector<" . GetNativeVectorInnerType($arrayOrSequenceType) . ">" if $arrayOrSequenceType;
    30653069
    30663070    # For all other types, the native type is a pointer with same type name as the IDL type.
    30673071    return "${type}*";
     3072}
     3073
     3074sub GetNativeVectorInnerType
     3075{
     3076    my $arrayOrSequenceType = shift;
     3077
     3078    # FIXME: The nativeType hash translates "unsigned long" to "unsigned" which
     3079    # is according to WebIDL. The Vibration API depends on the old behavior
     3080    # where "unsigned long" is kept as the WebCore type.
     3081    # Remove workaround when http://webkit.org/b/103899 is fixed.
     3082    return "unsigned long" if $arrayOrSequenceType eq "unsigned long";
     3083
     3084    return "String" if $arrayOrSequenceType eq "DOMString";
     3085    return $nativeType{$arrayOrSequenceType} if exists $nativeType{$arrayOrSequenceType};
     3086    return "RefPtr<${arrayOrSequenceType}> ";
    30683087}
    30693088
     
    31933212
    31943213    my $arrayType = $codeGenerator->GetArrayType($type);
    3195     if ($arrayType) {
    3196         return "toNativeArray<$arrayType>(exec, $value)";
    3197     }
    3198 
    31993214    my $sequenceType = $codeGenerator->GetSequenceType($type);
    3200     if ($sequenceType) {
    3201         return "toNativeArray<$sequenceType>(exec, $value)";
     3215    my $arrayOrSequenceType = $arrayType || $sequenceType;
     3216
     3217    if ($arrayOrSequenceType) {
     3218        if ($codeGenerator->IsRefPtrType($arrayOrSequenceType)) {
     3219            AddToImplIncludes("JS${arrayOrSequenceType}.h");
     3220            return "(toRefPtrNativeArray<${arrayOrSequenceType}, JS${arrayOrSequenceType}>(exec, $value, &to${arrayOrSequenceType}))";
     3221        }
     3222        return "toNativeArray<" . GetNativeVectorInnerType($arrayOrSequenceType) . ">(exec, $value)";
    32023223    }
    32033224
     
    32613282
    32623283    my $arrayType = $codeGenerator->GetArrayType($type);
    3263     if ($arrayType) {
    3264         if ($type eq "DOMString[]") {
     3284    my $sequenceType = $codeGenerator->GetSequenceType($type);
     3285    my $arrayOrSequenceType = $arrayType || $sequenceType;
     3286
     3287    if ($arrayOrSequenceType) {
     3288        if ($arrayType eq "DOMString") {
    32653289            AddToImplIncludes("JSDOMStringList.h", $conditional);
    32663290            AddToImplIncludes("DOMStringList.h", $conditional);
    3267         } elsif (!$codeGenerator->SkipIncludeHeader($arrayType)) {
    3268             AddToImplIncludes("JS$arrayType.h", $conditional);
    3269             AddToImplIncludes("$arrayType.h", $conditional);
    3270         }
    3271         AddToImplIncludes("<runtime/JSArray.h>", $conditional);
    3272         return "jsArray(exec, $thisValue->globalObject(), $value)";
    3273     }
    3274 
    3275     my $sequenceType = $codeGenerator->GetSequenceType($type);
    3276     if ($sequenceType) {
    3277         if (!$codeGenerator->SkipIncludeHeader($sequenceType)) {
    3278             AddToImplIncludes("JS$sequenceType.h", $conditional);
    3279             AddToImplIncludes("$sequenceType.h", $conditional);
     3291
     3292        } elsif ($codeGenerator->IsRefPtrType($arrayOrSequenceType)) {
     3293            AddToImplIncludes("JS${arrayOrSequenceType}.h", $conditional);
     3294            AddToImplIncludes("${arrayOrSequenceType}.h", $conditional);
    32803295        }
    32813296        AddToImplIncludes("<runtime/JSArray.h>", $conditional);
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm

    r136313 r136507  
    88# Copyright (C) Research In Motion Limited 2010. All rights reserved.
    99# Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
     10# Copyright (C) 2012 Ericsson AB. All rights reserved.
    1011#
    1112# This library is free software; you can redistribute it and/or
     
    10231024
    10241025        $result = "v";
    1025         $result .= ".release()" if (IsRefPtrType($returnType));
     1026        $result .= ".release()" if ($codeGenerator->IsRefPtrType($returnType));
    10261027    } else {
    10271028        # Can inline the function call into the return statement to avoid overhead of using a Ref<> temporary
     
    12661267    my $result = "v";
    12671268    my $returnType = $attribute->signature->type;
    1268     if (IsRefPtrType($returnType) && !$codeGenerator->GetArrayType($returnType)) {
     1269    if ($codeGenerator->IsRefPtrType($returnType) && !$codeGenerator->GetArrayType($returnType)) {
    12691270        $result = "WTF::getPtr(" . $result . ")";
    12701271    }
     
    14241425            push(@andExpression, "(${value}->IsNull() || ${value}->IsFunction())");
    14251426        } elsif ($codeGenerator->IsArrayType($type) || $codeGenerator->GetSequenceType($type)) {
    1426             # FIXME: Add proper support for T[], T[]?, sequence<T>.
    14271427            if ($parameter->isNullable) {
    14281428                push(@andExpression, "(${value}->IsNull() || ${value}->IsArray())");
     
    35983598
    35993599    my $return = "result";
    3600     my $returnIsRef = IsRefPtrType($returnType);
     3600    my $returnIsRef = $codeGenerator->IsRefPtrType($returnType);
    36013601
    36023602    if ($returnType eq "void") {
     
    36093609        $returnIsRef = 0;
    36103610
    3611         if ($interfaceName eq "SVGTransformList" and IsRefPtrType($returnType)) {
     3611        if ($interfaceName eq "SVGTransformList" and $codeGenerator->IsRefPtrType($returnType)) {
    36123612            $return = "WTF::getPtr(" . $return . ")";
    36133613        }
     
    36763676}
    36773677
    3678 sub IsRefPtrType
    3679 {
    3680     my $type = shift;
    3681 
    3682     return 0 if $type eq "boolean";
    3683     return 0 if $type eq "float";
    3684     return 0 if $type eq "int";
    3685     return 0 if $type eq "Date";
    3686     return 0 if $type eq "DOMString";
    3687     return 0 if $type eq "double";
    3688     return 0 if $type eq "short";
    3689     return 0 if $type eq "long";
    3690     return 0 if $type eq "unsigned";
    3691     return 0 if $type eq "unsigned long";
    3692     return 0 if $type eq "unsigned short";
    3693 
    3694     return 1;
    3695 }
    3696 
    36973678sub GetNativeType
    36983679{
     
    37083689        }
    37093690    }
    3710 
    3711     my $sequenceType = $codeGenerator->GetSequenceType($type);
    3712     return "Vector<${sequenceType}>" if $sequenceType;
    37133691
    37143692    if ($type eq "float" or $type eq "double") {
     
    37483726
    37493727    return "RefPtr<DOMStringList>" if $type eq "DOMString[]";
    3750     return "RefPtr<${type}>" if IsRefPtrType($type) and not $isParameter;
     3728    return "RefPtr<${type}>" if $codeGenerator->IsRefPtrType($type) and not $isParameter;
    37513729
    37523730    return "RefPtr<MediaQueryListListener>" if $type eq "MediaQueryListListener";
    37533731
    3754     # FIXME: Support T[], T[]?, sequence<T> generically
     3732    # FIXME: Consider replacing DOMStringList with DOMString[] or sequence<DOMString>.
    37553733    return "RefPtr<DOMStringList>" if $type eq "DOMStringList";
     3734
     3735    my $arrayType = $codeGenerator->GetArrayType($type);
     3736    my $sequenceType = $codeGenerator->GetSequenceType($type);
     3737    my $arrayOrSequenceType = $arrayType || $sequenceType;
     3738
     3739    if ($arrayOrSequenceType) {
     3740        my $nativeType = GetNativeType($arrayOrSequenceType);
     3741        $nativeType .= " " if ($nativeType =~ />$/);
     3742        return "Vector<${nativeType}>";
     3743    }
    37563744
    37573745    # Default, assume native type is a pointer with same type name as idl type
     
    38073795    return "toWebCoreDate($value)" if $type eq "Date";
    38083796    return "toDOMStringList($value)" if $type eq "DOMStringList";
    3809     # FIXME: Add proper support for T[], T[]? and sequence<T>.
     3797    # FIXME: Consider replacing DOMStringList with DOMString[] or sequence<DOMString>.
    38103798    return "toDOMStringList($value)" if $type eq "DOMString[]";
    38113799
     
    38593847
    38603848    my $arrayType = $codeGenerator->GetArrayType($type);
    3861     if ($arrayType) {
    3862         return "toNativeArray<$arrayType>($value)";
    3863     }
    3864 
    38653849    my $sequenceType = $codeGenerator->GetSequenceType($type);
    3866     if ($sequenceType) {
    3867         return "toNativeArray<$sequenceType>($value)";
     3850    my $arrayOrSequenceType = $arrayType || $sequenceType;
     3851
     3852    if ($arrayOrSequenceType) {
     3853        if ($codeGenerator->IsRefPtrType($arrayOrSequenceType)) {
     3854            AddToImplIncludes("V8${arrayOrSequenceType}.h");
     3855            return "(toRefPtrNativeArray<${arrayOrSequenceType}, V8${arrayOrSequenceType}>($value))";
     3856        }
     3857        return "toNativeArray<" . GetNativeType($arrayOrSequenceType) . ">($value)";
    38683858    }
    38693859
     
    39033893            } else {
    39043894                my $type = $parameter->type;
     3895
     3896                my $arrayType = $codeGenerator->GetArrayType($type);
    39053897                my $sequenceType = $codeGenerator->GetSequenceType($type);
    3906                 if ($sequenceType) {
    3907                     if ($codeGenerator->SkipIncludeHeader($sequenceType)) {
     3898                my $arrayOrSequenceType = $arrayType || $sequenceType;
     3899
     3900                if ($arrayOrSequenceType) {
     3901                    if ($arrayType eq "DOMString") {
     3902                        AddToImplIncludes("V8DOMStringList.h");
     3903                        AddToImplIncludes("DOMStringList.h");
     3904
     3905                    } elsif ($codeGenerator->IsRefPtrType($arrayOrSequenceType)) {
     3906                        AddToImplIncludes(GetV8HeaderName($arrayOrSequenceType));
     3907                        AddToImplIncludes("${arrayOrSequenceType}.h");
     3908                    } else {
    39083909                        $result .= "v8::Handle<v8::FunctionTemplate>()";
    39093910                        next;
    39103911                    }
    3911                     AddToImplIncludes("$sequenceType.h");
    39123912                } else {
    39133913                    AddToImplIncludes(GetV8HeaderName($type));
     
    40924092
    40934093    my $arrayType = $codeGenerator->GetArrayType($type);
    4094     if ($arrayType) {
    4095         if ($type eq "DOMString[]") {
     4094    my $sequenceType = $codeGenerator->GetSequenceType($type);
     4095    my $arrayOrSequenceType = $arrayType || $sequenceType;
     4096
     4097    if ($arrayOrSequenceType) {
     4098        if ($arrayType eq "DOMString") {
    40964099            AddToImplIncludes("V8DOMStringList.h");
    40974100            AddToImplIncludes("DOMStringList.h");
    4098         } elsif (!$codeGenerator->SkipIncludeHeader($arrayType)) {
    4099             AddToImplIncludes("V8$arrayType.h");
    4100             AddToImplIncludes("$arrayType.h");
    4101         }
    4102         return "v8Array($value$getIsolateArg)";
    4103     }
    4104 
    4105     my $sequenceType = $codeGenerator->GetSequenceType($type);
    4106     if ($sequenceType) {
    4107         if (!$codeGenerator->SkipIncludeHeader($sequenceType)) {
    4108             AddToImplIncludes("V8$sequenceType.h");
    4109             AddToImplIncludes("$sequenceType.h");
    4110         }
    4111         return "v8Array($value$getIsolateArg)";
     4101
     4102        } elsif ($codeGenerator->IsRefPtrType($arrayOrSequenceType)) {
     4103            AddToImplIncludes(GetV8HeaderName($arrayOrSequenceType));
     4104            AddToImplIncludes("${arrayOrSequenceType}.h");
     4105        }
     4106        return "v8Array(${value}${getIsolateArg})";
    41124107    }
    41134108
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp

    r134988 r136507  
    15371537    if (exec->argumentCount() < 1)
    15381538        return throwVMError(exec, createNotEnoughArgumentsError(exec));
    1539     Vector<ScriptProfile> sequenceArg(toNativeArray<ScriptProfile>(exec, MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined)));
     1539    Vector<RefPtr<ScriptProfile> > sequenceArg((toRefPtrNativeArray<ScriptProfile, JSScriptProfile>(exec, MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined), &toScriptProfile)));
    15401540    if (exec->hadException())
    15411541        return JSValue::encode(jsUndefined());
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp

    r135922 r136507  
    190190    TestObj* imp = V8TestObj::toNative(info.Holder());
    191191    long long v = toInt64(value);
    192     imp->setLongLongAttr(WTF::getPtr(v));
     192    imp->setLongLongAttr(v);
    193193    return;
    194194}
     
    206206    TestObj* imp = V8TestObj::toNative(info.Holder());
    207207    unsigned long long v = toInt64(value);
    208     imp->setUnsignedLongLongAttr(WTF::getPtr(v));
     208    imp->setUnsignedLongLongAttr(v);
    209209    return;
    210210}
     
    11091109        return throwNotEnoughArgumentsError(args.GetIsolate());
    11101110    TestObj* imp = V8TestObj::toNative(args.Holder());
    1111     V8TRYCATCH(Vector<ScriptProfile>, sequenceArg, toNativeArray<ScriptProfile>(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)));
     1111    V8TRYCATCH(Vector<RefPtr<ScriptProfile> >, sequenceArg, (toRefPtrNativeArray<ScriptProfile, V8ScriptProfile>(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined))));
    11121112    imp->methodWithSequenceArg(sequenceArg);
    11131113    return v8Undefined();
     
    16541654        return throwNotEnoughArgumentsError(args.GetIsolate());
    16551655    TestObj* imp = V8TestObj::toNative(args.Holder());
    1656     V8TRYCATCH(Vector<unsigned long>, arrayArg, toNativeArray<unsigned long>(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)));
     1656    V8TRYCATCH(Vector<unsigned>, arrayArg, toNativeArray<unsigned>(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)));
    16571657    imp->overloadedMethod(arrayArg);
    16581658    return v8Undefined();
  • trunk/Source/WebCore/bindings/v8/V8Binding.h

    r135847 r136507  
    11/*
    22* Copyright (C) 2009 Google Inc. All rights reserved.
     3* Copyright (C) 2012 Ericsson AB. All rights reserved.
    34*
    45* Redistribution and use in source and binary forms, with or without
     
    207208    };
    208209
     210    template <class T, class V8T>
     211    Vector<RefPtr<T> > toRefPtrNativeArray(v8::Handle<v8::Value> value)
     212    {
     213        if (!value->IsArray())
     214            return Vector<RefPtr<T> >();
     215
     216        Vector<RefPtr<T> > result;
     217        v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(value));
     218        v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(v8Value);
     219        size_t length = array->Length();
     220        for (size_t i = 0; i < length; ++i) {
     221            v8::Handle<v8::Value> element = array->Get(i);
     222
     223            if (V8T::HasInstance(element)) {
     224                v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(element);
     225                result.append(V8T::toNative(object));
     226            } else {
     227                throwTypeError("Invalid Array element type");
     228                return Vector<RefPtr<T> >();
     229            }
     230        }
     231        return result;
     232    }
    209233
    210234    template <class T>
  • trunk/Source/WebCore/testing/Internals.idl

    r136055 r136507  
    134134    long lastSpellCheckProcessedSequence(in Document document) raises (DOMException);
    135135
    136     sequence<String> userPreferredLanguages();
    137     void setUserPreferredLanguages(in sequence<String> languages);
     136    sequence<DOMString> userPreferredLanguages();
     137    void setUserPreferredLanguages(in sequence<DOMString> languages);
    138138
    139139    unsigned long wheelEventHandlerCount(in Document document) raises (DOMException);
     
    184184    [Conditional=INSPECTOR] unsigned long numberOfLiveNodes();
    185185    [Conditional=INSPECTOR] unsigned long numberOfLiveDocuments();
    186     [Conditional=INSPECTOR] sequence<String> consoleMessageArgumentCounts(in Document document);
     186    [Conditional=INSPECTOR] sequence<DOMString> consoleMessageArgumentCounts(in Document document);
    187187    [Conditional=INSPECTOR] DOMWindow openDummyInspectorFrontend(in DOMString url);
    188188    [Conditional=INSPECTOR] void closeDummyInspectorFrontend();
Note: See TracChangeset for help on using the changeset viewer.