Changeset 107926 in webkit


Ignore:
Timestamp:
Feb 16, 2012 5:46:34 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Add support for unsigned long[] to idl bindings to JSC.
https://bugs.webkit.org/show_bug.cgi?id=78210

Patch by Kihong Kwon <kihong.kwon@samsung.com> on 2012-02-16
Reviewed by Kentaro Hara.

Add support for unsigned long[] parameter type in idl.
This patch adds support just for unsigned long[] parameter type.
(support for other types of array should be done in another patch.)

tests added to TestObj.idl.

  • bindings/js/JSDOMBinding.h:

(WebCore::jsUnsignedLongArrayToVector):

  • bindings/scripts/CodeGeneratorJS.pm:

(AddIncludesForType):
(JSValueToNative):
(NativeToJSValue):

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

(WebCore):
(WebCore::jsTestObjPrototypeFunctionMethodWithUnsignedLongArray):

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

(WebCore):

  • bindings/scripts/test/TestObj.idl:
Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r107925 r107926  
     12012-02-16  Kihong Kwon  <kihong.kwon@samsung.com>
     2
     3        Add support for unsigned long[] to idl bindings to JSC.
     4        https://bugs.webkit.org/show_bug.cgi?id=78210
     5
     6        Reviewed by Kentaro Hara.
     7
     8        Add support for unsigned long[] parameter type in idl.
     9        This patch adds support just for unsigned long[] parameter type.
     10        (support for other types of array should be done in another patch.)
     11
     12        tests added to TestObj.idl.
     13
     14        * bindings/js/JSDOMBinding.h:
     15        (WebCore::jsUnsignedLongArrayToVector):
     16        * bindings/scripts/CodeGeneratorJS.pm:
     17        (AddIncludesForType):
     18        (JSValueToNative):
     19        (NativeToJSValue):
     20        * bindings/scripts/test/JS/JSTestObj.cpp:
     21        (WebCore):
     22        (WebCore::jsTestObjPrototypeFunctionMethodWithUnsignedLongArray):
     23        * bindings/scripts/test/JS/JSTestObj.h:
     24        (WebCore):
     25        * bindings/scripts/test/TestObj.idl:
     26
    1272012-02-16  Vsevolod Vlasov  <vsevik@chromium.org>
    228
  • trunk/Source/WebCore/bindings/js/JSDOMBinding.h

    r107304 r107926  
    3939#include <wtf/Forward.h>
    4040#include <wtf/Noncopyable.h>
     41#include <wtf/Vector.h>
    4142
    4243namespace WebCore {
     
    343344    }
    344345
     346    inline Vector<unsigned long> jsUnsignedLongArrayToVector(JSC::ExecState* exec, JSC::JSValue value)
     347    {
     348        unsigned length;
     349        JSC::JSObject* object = toJSSequence(exec, value, length);
     350        if (exec->hadException())
     351            return Vector<unsigned long>();
     352
     353        Vector<unsigned long> result;
     354        for (unsigned i = 0; i < length; i++) {
     355            JSC::JSValue indexedValue;
     356            indexedValue = object->get(exec, i);
     357            if (exec->hadException() || indexedValue.isUndefinedOrNull() || !indexedValue.isNumber())
     358                return Vector<unsigned long>();
     359            result.append(indexedValue.toUInt32(exec));
     360        }
     361        return result;
     362    }
    345363} // namespace WebCore
    346364
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r107772 r107926  
    275275        # FIXME: Add proper support for T[], T[]?, sequence<T>
    276276        $includesRef->{"JSDOMStringList.h"} = 1;
     277    } elsif ($type eq "unsigned long[]") {
     278        $includesRef->{"<wtf/Vector.h>"} = 1;
    277279    } elsif ($isCallback) {
    278280        $includesRef->{"JS${type}.h"} = 1;
     
    27632765    "unsigned long long" => "unsigned long long",
    27642766    "MediaQueryListListener" => "RefPtr<MediaQueryListListener>",
    2765     "DOMTimeStamp" => "DOMTimeStamp"
     2767    "DOMTimeStamp" => "DOMTimeStamp",
     2768    "unsigned long[]" => "Vector<unsigned long>"
    27662769);
    27672770
     
    28922895    }
    28932896
     2897    if ($type eq "unsigned long[]") {
     2898        AddToImplIncludes("JSDOMBinding.h", $conditional);
     2899        return "jsUnsignedLongArrayToVector(exec, $value)";
     2900    }
     2901
    28942902    AddToImplIncludes("HTMLOptionElement.h", $conditional) if $type eq "HTMLOptionElement";
    28952903    AddToImplIncludes("JSCustomVoidCallback.h", $conditional) if $type eq "VoidCallback";
     
    29682976        AddToImplIncludes("SerializedScriptValue.h", $conditional);
    29692977        return "$value ? $value->deserialize(exec, castedThis->globalObject(), 0) : jsNull()";
     2978    } elsif ($type eq "unsigned long[]") {
     2979        AddToImplIncludes("<wrt/Vector.h>", $conditional);
    29702980    } else {
    29712981        # Default, include header with same name.
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp

    r107520 r107926  
    288288#endif
    289289    { "overloadedMethod", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionOverloadedMethod), (intptr_t)2, NoIntrinsic },
     290    { "methodWithUnsignedLongArray", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithUnsignedLongArray), (intptr_t)1, NoIntrinsic },
    290291    { "getSVGDocument", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionGetSVGDocument), (intptr_t)0, NoIntrinsic },
    291292    { "convert1", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionConvert1), (intptr_t)1, NoIntrinsic },
     
    21312132#endif
    21322133
     2134EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithUnsignedLongArray(ExecState* exec)
     2135{
     2136    JSValue thisValue = exec->hostThisValue();
     2137    if (!thisValue.inherits(&JSTestObj::s_info))
     2138        return throwVMTypeError(exec);
     2139    JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
     2140    ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info);
     2141    TestObj* impl = static_cast<TestObj*>(castedThis->impl());
     2142    if (exec->argumentCount() < 1)
     2143        return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
     2144    Vector<unsigned long> unsignedLongArray(jsUnsignedLongArrayToVector(exec, MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined)));
     2145    if (exec->hadException())
     2146        return JSValue::encode(jsUndefined());
     2147    impl->methodWithUnsignedLongArray(unsignedLongArray);
     2148    return JSValue::encode(jsUndefined());
     2149}
     2150
    21332151EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionGetSVGDocument(ExecState* exec)
    21342152{
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h

    r107520 r107926  
    192192JSC::EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionClassMethodWithOptional(JSC::ExecState*);
    193193JSC::EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionOverloadedMethod1(JSC::ExecState*);
     194JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithUnsignedLongArray(JSC::ExecState*);
    194195JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionGetSVGDocument(JSC::ExecState*);
    195196JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionConvert1(JSC::ExecState*);
  • trunk/Source/WebCore/bindings/scripts/test/TestObj.idl

    r107396 r107926  
    195195#endif
    196196
     197#if defined(TESTING_JS)
     198        void methodWithUnsignedLongArray(in unsigned long[] unsignedLongArray);
     199#endif
     200
    197201        readonly attribute [CheckAccessToNode] Document contentDocument;
    198202        [CheckAccessToNode] SVGDocument getSVGDocument()
Note: See TracChangeset for help on using the changeset viewer.