Changeset 111416 in webkit
- Timestamp:
- Mar 20, 2012 11:26:51 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r111415 r111416 1 2012-03-20 Vineet Chaudhary <rgf748@motorola.com> 2 3 https://bugs.webkit.org/show_bug.cgi?id=80696 4 Remove custom bindings for attribute type Array. 5 6 Reviewed by Kentaro Hara. 7 8 No new tests. 9 10 * bindings/js/JSConsoleCustom.cpp: Removed custom function. 11 (WebCore): 12 * bindings/js/JSDOMBinding.h: Added template jsArray and toNativeArray. 13 (WebCore): 14 (WebCore::jsArray): 15 (WebCore::toNativeArray): 16 * bindings/scripts/CodeGenerator.pm: Modified codegenerators to generate appropriate code. 17 (GetArrayType): Added GetArrayType to get return type of attribute interface. 18 * bindings/scripts/CodeGeneratorGObject.pm: Modified codegenerators to generate appropriate code. 19 (SkipAttribute): 20 * bindings/scripts/CodeGeneratorJS.pm: Modified codegenerators to generate appropriate code. 21 (AddIncludesForType): 22 (JSValueToNative): 23 (NativeToJSValue): 24 * bindings/scripts/CodeGeneratorV8.pm: Modified codegenerators to generate appropriate code. 25 (GenerateNormalAttrGetter): 26 (GenerateNormalAttrSetter): 27 (JSValueToNative): 28 (NativeToJSValue): 29 * bindings/scripts/test/GObject/WebKitDOMTestObj.cpp: Updated results from running binding tests. 30 (webkit_dom_test_obj_get_property): 31 (webkit_dom_test_obj_class_init): 32 * bindings/scripts/test/GObject/WebKitDOMTestObj.h: Ditto. 33 * bindings/scripts/test/JS/JSTestObj.cpp: Ditto. 34 (WebCore::jsTestObjSequenceAttr): 35 (WebCore::setJSTestObjSequenceAttr): 36 (WebCore::jsTestObjPrototypeFunctionMethodReturningSequence): 37 * bindings/scripts/test/V8/V8TestObj.cpp: Ditto. 38 (WebCore::TestObjInternal::sequenceAttrAttrGetter): 39 (WebCore::TestObjInternal::sequenceAttrAttrSetter): 40 (WebCore::TestObjInternal::methodReturningSequenceCallback): 41 * bindings/v8/V8Binding.h: Added template v8Array and toNativeArray. 42 (WebCore): 43 (WebCore::v8Array): 44 (WebCore::toNativeArray): 45 * bindings/v8/custom/V8ConsoleCustom.cpp: Removed custom function. 46 (WebCore): 47 * page/Console.idl: Replaced attribute type Array to sequence<SriptProfile> to remove 48 custom bindings. 49 1 50 2012-03-20 Sheriff Bot <webkit.review.bot@gmail.com> 2 51 -
trunk/Source/WebCore/bindings/js/JSConsoleCustom.cpp
r95901 r111416 31 31 32 32 #include "Console.h" 33 #include "JSScriptProfile.h"34 33 #include "ScriptCallStack.h" 35 34 #include "ScriptCallStackFactory.h" 36 #include "ScriptProfile.h"37 #include <runtime/JSArray.h>38 35 #include <wtf/OwnPtr.h> 39 36 … … 41 38 42 39 namespace WebCore { 43 44 typedef Vector<RefPtr<ScriptProfile> > ProfilesArray;45 46 JSValue JSConsole::profiles(ExecState* exec) const47 {48 const ProfilesArray& profiles = impl()->profiles();49 MarkedArgumentBuffer list;50 51 ProfilesArray::const_iterator end = profiles.end();52 for (ProfilesArray::const_iterator iter = profiles.begin(); iter != end; ++iter)53 list.append(toJS(exec, globalObject(), iter->get()));54 55 return constructArray(exec, globalObject(), list);56 }57 40 58 41 JSValue JSConsole::profile(ExecState* exec) -
trunk/Source/WebCore/bindings/js/JSDOMBinding.h
r108385 r111416 36 36 #include <heap/Weak.h> 37 37 #include <runtime/FunctionPrototype.h> 38 #include <runtime/JSArray.h> 38 39 #include <runtime/Lookup.h> 39 40 #include <runtime/ObjectPrototype.h> … … 279 280 } 280 281 282 template <typename Iterable> 283 JSC::JSValue jsArray(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, const Iterable& iterator) 284 { 285 JSC::MarkedArgumentBuffer list; 286 typename Iterable::const_iterator end = iterator.end(); 287 288 for (typename Iterable::const_iterator iter = iterator.begin(); iter != end; ++iter) 289 list.append(toJS(exec, globalObject, WTF::getPtr(*iter))); 290 291 return JSC::constructArray(exec, list); 292 } 293 294 template <class T> 295 Vector<T> toNativeArray(JSC::ExecState* exec, JSC::JSValue value) 296 { 297 if (!isJSArray(value)) 298 return Vector<T>(); 299 300 Vector<T> result; 301 JSC::JSArray* array = asArray(value); 302 303 for (unsigned i = 0; i < array->length(); ++i) { 304 String indexedValue = ustringToString(array->getIndex(i).toString(exec)->value(exec)); 305 result.append(indexedValue); 306 } 307 return result; 308 } 309 281 310 // Validates that the passed object is a sequence type per section 4.1.13 of the WebIDL spec. 282 311 JSC::JSObject* toJSSequence(JSC::ExecState*, JSC::JSValue, unsigned&); -
trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm
r108669 r111416 446 446 } 447 447 448 sub GetArrayType 449 { 450 my $object = shift; 451 my $type = shift; 452 453 return $1 if $type =~ /^sequence<([\w\d_]+)>.*/; 454 return ""; 455 } 456 448 457 # Uppercase the first letter while respecting WebKit style guidelines. 449 458 # E.g., xmlEncoding becomes XMLEncoding, but xmlllang becomes Xmllang. -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm
r110504 r111416 162 162 my $propType = $attribute->signature->type; 163 163 if ($propType =~ /Constructor$/) { 164 return 1; 165 } 166 167 if ($codeGenerator->GetArrayType($propType)) { 164 168 return 1; 165 169 } -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r110788 r111416 267 267 } elsif (IsTypedArrayType($type)) { 268 268 $includesRef->{"<wtf/${type}.h>"} = 1; 269 } elsif ($codeGenerator->GetArrayType($type)) { 269 270 } else { 270 271 # default, include the same named file … … 2946 2947 AddToImplIncludes("Event.h", $conditional) if $type eq "Event"; 2947 2948 2949 if ($codeGenerator->GetArrayType($type)) { 2950 return "toNativeArray(exec, $value)"; 2951 } 2952 2948 2953 # Default, assume autogenerated type conversion routines 2949 2954 AddToImplIncludes("JS$type.h", $conditional); … … 3003 3008 if ($type eq "NodeList") { 3004 3009 AddToImplIncludes("NameNodeList.h", $conditional); 3010 } 3011 3012 my $arrayType = $codeGenerator->GetArrayType($type); 3013 if ($arrayType) { 3014 AddToImplIncludes("<runtime/JSArray.h>", $conditional); 3015 AddToImplIncludes("JS$arrayType.h", $conditional); 3016 AddToImplIncludes("$arrayType.h", $conditional); 3017 return "jsArray(exec, $thisValue->globalObject(), $value)"; 3005 3018 } 3006 3019 -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm
r110972 r111416 924 924 && $returnType ne "EventTarget" && $returnType ne "SerializedScriptValue" && $returnType ne "DOMWindow" 925 925 && $returnType !~ /SVG/ && $returnType !~ /HTML/ && !IsDOMNodeType($returnType))) { 926 927 my $arrayType = $codeGenerator->GetArrayType($returnType); 928 if ($arrayType) { 929 AddToImplIncludes("V8$arrayType.h"); 930 AddToImplIncludes("$arrayType.h"); 931 push(@implContentDecls, " const Vector<RefPtr<$arrayType> > vector = ${getterString};\n"); 932 push(@implContentDecls, " return v8Array(vector);\n"); 933 push(@implContentDecls, "}\n\n"); 934 return; 935 } 936 926 937 AddIncludesForType($returnType); 927 938 # Check for a wrapper in the wrapper cache. If there is one, we know that a hidden reference has already … … 1098 1109 } else { 1099 1110 my $value = JSValueToNative($attribute->signature, "value"); 1111 my $arrayType = $codeGenerator->GetArrayType($nativeType); 1112 1100 1113 if ($nativeType =~ /^V8Parameter/) { 1101 push(@implContentDecls, " " . ConvertToV8Parameter($attribute->signature, $nativeType, "v", $value, "VOID") . "\n"); 1114 push(@implContentDecls, " " . ConvertToV8Parameter($attribute->signature, $nativeType, "v", $value, "VOID") . "\n"); 1115 } elsif ($arrayType) { 1116 push(@implContentDecls, " Vector<$arrayType> v = $value;\n"); 1102 1117 } else { 1103 push(@implContentDecls, " $nativeType v = $value;\n");1118 push(@implContentDecls, " $nativeType v = $value;\n"); 1104 1119 } 1105 1120 } … … 1107 1122 my $result = "v"; 1108 1123 my $returnType = GetTypeFromSignature($attribute->signature); 1109 if (IsRefPtrType($returnType) ) {1124 if (IsRefPtrType($returnType) && !$codeGenerator->GetArrayType($returnType)) { 1110 1125 $result = "WTF::getPtr(" . $result . ")"; 1111 1126 } … … 3555 3570 } 3556 3571 3572 if ($codeGenerator->GetArrayType($type)) { 3573 return "toNativeArray($value)"; 3574 } 3575 3557 3576 AddIncludesForType($type); 3558 3577 … … 3768 3787 } 3769 3788 3789 my $arrayType = $codeGenerator->GetArrayType($type); 3790 if ($arrayType) { 3791 AddToImplIncludes("V8$arrayType.h"); 3792 AddToImplIncludes("$arrayType.h"); 3793 return "v8Array($value)"; 3794 } 3795 3770 3796 AddIncludesForType($type); 3771 3797 -
trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp
r111004 r111416 811 811 } 812 812 813 WebKitDOMsequence<ScriptProfile>*814 webkit_dom_test_obj_get_sequence_attr(WebKitDOMTestObj* self)815 {816 g_return_val_if_fail(self, 0);817 WebCore::JSMainThreadNullState state;818 WebCore::TestObj * item = WebKit::core(self);819 PassRefPtr<WebCore::sequence<ScriptProfile>> g_res = WTF::getPtr(item->sequenceAttr());820 WebKitDOMsequence<ScriptProfile>* res = WebKit::kit(g_res.get());821 return res;822 }823 824 void825 webkit_dom_test_obj_set_sequence_attr(WebKitDOMTestObj* self, WebKitDOMsequence<ScriptProfile>* value)826 {827 g_return_if_fail(self);828 WebCore::JSMainThreadNullState state;829 WebCore::TestObj * item = WebKit::core(self);830 g_return_if_fail(value);831 WebCore::sequence<ScriptProfile> * converted_value = NULL;832 if (value != NULL) {833 converted_value = WebKit::core(value);834 g_return_if_fail(converted_value);835 }836 item->setSequenceAttr(converted_value);837 }838 839 813 WebKitDOMTestObj* 840 814 webkit_dom_test_obj_get_xml_obj_attr(WebKitDOMTestObj* self) … … 1596 1570 PROP_STRING_ATTR, 1597 1571 PROP_TEST_OBJ_ATTR, 1598 PROP_SEQUENCE_ATTR,1599 1572 PROP_XML_OBJ_ATTR, 1600 1573 PROP_CREATE, … … 1856 1829 break; 1857 1830 } 1858 case PROP_SEQUENCE_ATTR:1859 {1860 RefPtr<WebCore::sequence<ScriptProfile>> ptr = coreSelf->sequenceAttr();1861 g_value_set_object(value, WebKit::kit(ptr.get()));1862 break;1863 }1864 1831 case PROP_XML_OBJ_ATTR: 1865 1832 { … … 2154 2121 WEBKIT_PARAM_READWRITE)); 2155 2122 g_object_class_install_property(gobjectClass, 2156 PROP_SEQUENCE_ATTR,2157 g_param_spec_object("sequence-attr", /* name */2158 "test_obj_sequence-attr", /* short description */2159 "read-write WebKitDOMsequence<ScriptProfile>* TestObj.sequence-attr", /* longer - could do with some extra doc stuff here */2160 WEBKIT_TYPE_DOM_SEQUENCE<SCRIPT_PROFILE>, /* gobject type */2161 WEBKIT_PARAM_READWRITE));2162 g_object_class_install_property(gobjectClass,2163 2123 PROP_XML_OBJ_ATTR, 2164 2124 g_param_spec_object("xml-obj-attr", /* name */ -
trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h
r111004 r111416 698 698 699 699 /** 700 * webkit_dom_test_obj_get_sequence_attr:701 * @self: A #WebKitDOMTestObj702 *703 * Returns: (transfer none):704 *705 **/706 WEBKIT_API WebKitDOMsequence<ScriptProfile>*707 webkit_dom_test_obj_get_sequence_attr(WebKitDOMTestObj* self);708 709 /**710 * webkit_dom_test_obj_set_sequence_attr:711 * @self: A #WebKitDOMTestObj712 * @value: A #WebKitDOMsequence<ScriptProfile>713 *714 * Returns: (transfer none):715 *716 **/717 WEBKIT_API void718 webkit_dom_test_obj_set_sequence_attr(WebKitDOMTestObj* self, WebKitDOMsequence<ScriptProfile>* value);719 720 /**721 700 * webkit_dom_test_obj_get_xml_obj_attr: 722 701 * @self: A #WebKitDOMTestObj -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
r111004 r111416 34 34 #include "JSSVGDocument.h" 35 35 #include "JSSVGPoint.h" 36 #include "JSScriptProfile.h" 36 37 #include "JSTestCallback.h" 37 38 #include "JSTestObj.h" … … 44 45 #include "JSint.h" 45 46 #include "JSsequence.h" 46 #include "JSsequence<ScriptProfile>.h"47 47 #include "KURL.h" 48 48 #include "SVGDocument.h" … … 51 51 #include "ScriptCallStack.h" 52 52 #include "ScriptCallStackFactory.h" 53 #include "ScriptProfile.h" 53 54 #include "SerializedScriptValue.h" 54 55 #include "TestObj.h" 55 56 #include "bool.h" 56 #include "sequence<ScriptProfile>.h"57 57 #include <runtime/Error.h> 58 #include <runtime/JSArray.h> 58 59 #include <runtime/JSString.h> 59 60 #include <wtf/GetPtr.h> … … 478 479 UNUSED_PARAM(exec); 479 480 TestObj* impl = static_cast<TestObj*>(castedThis->impl()); 480 JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->sequenceAttr()));481 JSValue result = jsArray(exec, castedThis->globalObject(), impl->sequenceAttr()); 481 482 return result; 482 483 } … … 966 967 JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); 967 968 TestObj* impl = static_cast<TestObj*>(castedThis->impl()); 968 impl->setSequenceAttr(to sequence<ScriptProfile>(value));969 impl->setSequenceAttr(toNativeArray(exec, value)); 969 970 } 970 971 … … 1424 1425 return JSValue::encode(jsUndefined()); 1425 1426 1426 JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->methodReturningSequence(intArg)));1427 JSC::JSValue result = jsArray(exec, castedThis->globalObject(), impl->methodReturningSequence(intArg)); 1427 1428 return JSValue::encode(result); 1428 1429 } -
trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp
r111004 r111416 33 33 #include "ScriptCallStack.h" 34 34 #include "ScriptCallStackFactory.h" 35 #include "ScriptProfile.h" 35 36 #include "SerializedScriptValue.h" 36 37 #include "V8Binding.h" … … 43 44 #include "V8SVGDocument.h" 44 45 #include "V8SVGPoint.h" 46 #include "V8ScriptProfile.h" 45 47 #include "V8TestCallback.h" 46 48 #include "V8a.h" … … 53 55 #include "V8int.h" 54 56 #include "V8sequence.h" 55 #include "V8sequence<ScriptProfile>.h"56 57 #include <wtf/GetPtr.h> 57 58 #include <wtf/RefCounted.h> … … 224 225 INC_STATS("DOM.TestObj.sequenceAttr._get"); 225 226 TestObj* imp = V8TestObj::toNative(info.Holder()); 226 return toV8(imp->sequenceAttr());227 return v8Array(imp->sequenceAttr()); 227 228 } 228 229 … … 231 232 INC_STATS("DOM.TestObj.sequenceAttr._set"); 232 233 TestObj* imp = V8TestObj::toNative(info.Holder()); 233 sequence<ScriptProfile>* v = V8sequence<ScriptProfile>::HasInstance(value) ? V8sequence<ScriptProfile>::toNative(v8::Handle<v8::Object>::Cast(value)) : 0;234 imp->setSequenceAttr( WTF::getPtr(v));234 Vector<ScriptProfile> v = toNativeArray(value); 235 imp->setSequenceAttr(v); 235 236 return; 236 237 } … … 1072 1073 TestObj* imp = V8TestObj::toNative(args.Holder()); 1073 1074 EXCEPTION_BLOCK(int, intArg, toInt32(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined))); 1074 return toV8(imp->methodReturningSequence(intArg));1075 return v8Array(imp->methodReturningSequence(intArg)); 1075 1076 } 1076 1077 -
trunk/Source/WebCore/bindings/v8/V8Binding.h
r111258 r111416 287 287 } 288 288 289 template<typename Iterable> 290 v8::Handle<v8::Value> v8Array(const Iterable& iterator) 291 { 292 v8::Local<v8::Array> result = v8::Array::New(iterator.size()); 293 int index = 0; 294 typename Iterable::const_iterator end = iterator.end(); 295 for (typename Iterable::const_iterator iter = iterator.begin(); iter != end; ++iter) 296 result->Set(v8::Integer::New(index++), toV8(WTF::getPtr(*iter))); 297 return result; 298 } 299 300 template <class T> 301 Vector<T> toNativeArray(v8::Handle<v8::Value> value) 302 { 303 if (!value->IsArray()) 304 return Vector<T>(); 305 306 Vector<T> result; 307 v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(value)); 308 v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(v8Value); 309 size_t length = array->Length(); 310 311 for (size_t i = 0; i < length; ++i) { 312 String indexedValue = v8StringToWebCoreString(array->Get(i)); 313 result.append(indexedValue); 314 } 315 return result; 316 } 317 289 318 // Enables caching v8 wrappers created for WTF::StringImpl. Currently this cache requires 290 319 // all the calls (both to convert WTF::String to v8::String and to GC the handle) -
trunk/Source/WebCore/bindings/v8/custom/V8ConsoleCustom.cpp
r107396 r111416 37 37 #include "ScriptCallStack.h" 38 38 #include "ScriptCallStackFactory.h" 39 #include "ScriptProfile.h"40 39 #include "V8Binding.h" 41 40 #include "V8BindingMacros.h" 42 41 #include "V8MemoryInfo.h" 43 42 #include "V8Proxy.h" 44 #include "V8ScriptProfile.h"45 43 46 44 namespace WebCore { 47 48 typedef Vector<RefPtr<ScriptProfile> > ProfilesArray;49 50 #if ENABLE(JAVASCRIPT_DEBUGGER)51 v8::Handle<v8::Value> V8Console::profilesAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)52 {53 INC_STATS("DOM.Console.profilesAccessorGetter");54 Console* imp = V8Console::toNative(info.Holder());55 const ProfilesArray& profiles = imp->profiles();56 v8::Handle<v8::Array> result = v8::Array::New(profiles.size());57 int index = 0;58 ProfilesArray::const_iterator end = profiles.end();59 for (ProfilesArray::const_iterator iter = profiles.begin(); iter != end; ++iter)60 result->Set(v8::Integer::New(index++), toV8(iter->get()));61 return result;62 }63 #endif64 45 65 46 v8::Handle<v8::Value> V8Console::traceCallback(const v8::Arguments& args) -
trunk/Source/WebCore/page/Console.idl
r107396 r111416 47 47 48 48 #if defined(ENABLE_JAVASCRIPT_DEBUGGER) && ENABLE_JAVASCRIPT_DEBUGGER 49 readonly attribute [CustomGetter] Arrayprofiles;49 readonly attribute sequence<ScriptProfile> profiles; 50 50 [Custom] void profile(in DOMString title); 51 51 [Custom] void profileEnd(in DOMString title);
Note: See TracChangeset
for help on using the changeset viewer.