Diff
Modified: trunk/Source/WebCore/ChangeLog (107925 => 107926)
--- trunk/Source/WebCore/ChangeLog 2012-02-16 13:30:00 UTC (rev 107925)
+++ trunk/Source/WebCore/ChangeLog 2012-02-16 13:46:34 UTC (rev 107926)
@@ -1,3 +1,29 @@
+2012-02-16 Kihong Kwon <kihong.k...@samsung.com>
+
+ Add support for unsigned long[] to idl bindings to JSC.
+ https://bugs.webkit.org/show_bug.cgi?id=78210
+
+ 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:
+
2012-02-16 Vsevolod Vlasov <vse...@chromium.org>
Web Inspector: [InspectorIndexedDB] Add IndexedDB TreeElement to resources panel.
Modified: trunk/Source/WebCore/bindings/js/JSDOMBinding.h (107925 => 107926)
--- trunk/Source/WebCore/bindings/js/JSDOMBinding.h 2012-02-16 13:30:00 UTC (rev 107925)
+++ trunk/Source/WebCore/bindings/js/JSDOMBinding.h 2012-02-16 13:46:34 UTC (rev 107926)
@@ -38,6 +38,7 @@
#include <runtime/ObjectPrototype.h>
#include <wtf/Forward.h>
#include <wtf/Noncopyable.h>
+#include <wtf/Vector.h>
namespace WebCore {
@@ -342,6 +343,23 @@
return AtomicString(identifier.impl());
}
+ inline Vector<unsigned long> jsUnsignedLongArrayToVector(JSC::ExecState* exec, JSC::JSValue value)
+ {
+ unsigned length;
+ JSC::JSObject* object = toJSSequence(exec, value, length);
+ if (exec->hadException())
+ return Vector<unsigned long>();
+
+ Vector<unsigned long> result;
+ for (unsigned i = 0; i < length; i++) {
+ JSC::JSValue indexedValue;
+ indexedValue = object->get(exec, i);
+ if (exec->hadException() || indexedValue.isUndefinedOrNull() || !indexedValue.isNumber())
+ return Vector<unsigned long>();
+ result.append(indexedValue.toUInt32(exec));
+ }
+ return result;
+ }
} // namespace WebCore
#endif // JSDOMBinding_h
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (107925 => 107926)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2012-02-16 13:30:00 UTC (rev 107925)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2012-02-16 13:46:34 UTC (rev 107926)
@@ -274,6 +274,8 @@
} elsif ($type eq "DOMString[]") {
# FIXME: Add proper support for T[], T[]?, sequence<T>
$includesRef->{"JSDOMStringList.h"} = 1;
+ } elsif ($type eq "unsigned long[]") {
+ $includesRef->{"<wtf/Vector.h>"} = 1;
} elsif ($isCallback) {
$includesRef->{"JS${type}.h"} = 1;
} elsif (IsTypedArrayType($type)) {
@@ -2762,7 +2764,8 @@
"long long" => "long long",
"unsigned long long" => "unsigned long long",
"MediaQueryListListener" => "RefPtr<MediaQueryListListener>",
- "DOMTimeStamp" => "DOMTimeStamp"
+ "DOMTimeStamp" => "DOMTimeStamp",
+ "unsigned long[]" => "Vector<unsigned long>"
);
sub GetNativeType
@@ -2891,6 +2894,11 @@
return "toDOMStringList($value)";
}
+ if ($type eq "unsigned long[]") {
+ AddToImplIncludes("JSDOMBinding.h", $conditional);
+ return "jsUnsignedLongArrayToVector(exec, $value)";
+ }
+
AddToImplIncludes("HTMLOptionElement.h", $conditional) if $type eq "HTMLOptionElement";
AddToImplIncludes("JSCustomVoidCallback.h", $conditional) if $type eq "VoidCallback";
AddToImplIncludes("Event.h", $conditional) if $type eq "Event";
@@ -2967,6 +2975,8 @@
} elsif ($type eq "SerializedScriptValue" or $type eq "any") {
AddToImplIncludes("SerializedScriptValue.h", $conditional);
return "$value ? $value->deserialize(exec, castedThis->globalObject(), 0) : jsNull()";
+ } elsif ($type eq "unsigned long[]") {
+ AddToImplIncludes("<wrt/Vector.h>", $conditional);
} else {
# Default, include header with same name.
AddToImplIncludes("JS$type.h", $conditional);
Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (107925 => 107926)
--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp 2012-02-16 13:30:00 UTC (rev 107925)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp 2012-02-16 13:46:34 UTC (rev 107926)
@@ -287,6 +287,7 @@
{ "conditionalMethod3", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionConditionalMethod3), (intptr_t)0, NoIntrinsic },
#endif
{ "overloadedMethod", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionOverloadedMethod), (intptr_t)2, NoIntrinsic },
+ { "methodWithUnsignedLongArray", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithUnsignedLongArray), (intptr_t)1, NoIntrinsic },
{ "getSVGDocument", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionGetSVGDocument), (intptr_t)0, NoIntrinsic },
{ "convert1", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionConvert1), (intptr_t)1, NoIntrinsic },
{ "convert2", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionConvert2), (intptr_t)1, NoIntrinsic },
@@ -2130,6 +2131,23 @@
#endif
+EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithUnsignedLongArray(ExecState* exec)
+{
+ JSValue thisValue = exec->hostThisValue();
+ if (!thisValue.inherits(&JSTestObj::s_info))
+ return throwVMTypeError(exec);
+ JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
+ 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"));
+ Vector<unsigned long> unsignedLongArray(jsUnsignedLongArrayToVector(exec, MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined)));
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
+ impl->methodWithUnsignedLongArray(unsignedLongArray);
+ return JSValue::encode(jsUndefined());
+}
+
EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionGetSVGDocument(ExecState* exec)
{
JSValue thisValue = exec->hostThisValue();
Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h (107925 => 107926)
--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h 2012-02-16 13:30:00 UTC (rev 107925)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h 2012-02-16 13:46:34 UTC (rev 107926)
@@ -191,6 +191,7 @@
JSC::EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionClassMethod(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionClassMethodWithOptional(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionOverloadedMethod1(JSC::ExecState*);
+JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithUnsignedLongArray(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionGetSVGDocument(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionConvert1(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionConvert2(JSC::ExecState*);
Modified: trunk/Source/WebCore/bindings/scripts/test/TestObj.idl (107925 => 107926)
--- trunk/Source/WebCore/bindings/scripts/test/TestObj.idl 2012-02-16 13:30:00 UTC (rev 107925)
+++ trunk/Source/WebCore/bindings/scripts/test/TestObj.idl 2012-02-16 13:46:34 UTC (rev 107926)
@@ -194,6 +194,10 @@
attribute double[] doubleArray;
#endif
+#if defined(TESTING_JS)
+ void methodWithUnsignedLongArray(in unsigned long[] unsignedLongArray);
+#endif
+
readonly attribute [CheckAccessToNode] Document contentDocument;
[CheckAccessToNode] SVGDocument getSVGDocument()
raises(DOMException);