Changeset 58333 in webkit
- Timestamp:
- Apr 27, 2010 1:55:11 PM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 1 deleted
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r58330 r58333 1 2010-04-27 Adam Barth <abarth@webkit.org> 2 3 Reviewed by Eric Seidel. 4 5 Remove custom NodeIterator bindings 6 https://bugs.webkit.org/show_bug.cgi?id=38188 7 8 Another example of CallWith=ScriptState. This case shows us the right 9 way to handle the interaction with exception codes. 10 11 In my previous patch, I put the exception code handling after the 12 ScriptState exception handling. It turns out this was a mistake 13 (although a harmless one at the time because no IDL caused us to 14 generate that code). Now that we're generating both kinds of exception 15 handling, we need to generate them in the right order. 16 17 * WebCore.gypi: 18 * bindings/js/JSNodeIteratorCustom.cpp: 19 * bindings/scripts/CodeGeneratorJS.pm: 20 * bindings/scripts/CodeGeneratorV8.pm: 21 * bindings/scripts/test/GObject/WebKitDOMTestObj.cpp: 22 (webkit_dom_test_obj_with_script_state_void_exception): 23 (webkit_dom_test_obj_with_script_state_obj_exception): 24 * bindings/scripts/test/GObject/WebKitDOMTestObj.h: 25 * bindings/scripts/test/JS/JSTestObj.cpp: 26 (WebCore::): 27 (WebCore::jsTestObjPrototypeFunctionWithScriptStateVoidException): 28 (WebCore::jsTestObjPrototypeFunctionWithScriptStateObjException): 29 * bindings/scripts/test/JS/JSTestObj.h: 30 * bindings/scripts/test/ObjC/DOMTestObj.h: 31 * bindings/scripts/test/ObjC/DOMTestObj.mm: 32 (-[DOMTestObj withScriptStateVoidException]): 33 (-[DOMTestObj withScriptStateObjException]): 34 * bindings/scripts/test/TestObj.idl: 35 * bindings/scripts/test/V8/V8TestObj.cpp: 36 (WebCore::TestObjInternal::withScriptStateVoidCallback): 37 (WebCore::TestObjInternal::withScriptStateObjCallback): 38 (WebCore::TestObjInternal::withScriptStateVoidExceptionCallback): 39 (WebCore::TestObjInternal::withScriptStateObjExceptionCallback): 40 (WebCore::): 41 * bindings/v8/custom/V8NodeIteratorCustom.cpp: Removed. 42 * dom/NodeIterator.idl: 43 1 44 2010-04-27 Adam Barth <abarth@webkit.org> 2 45 -
trunk/WebCore/WebCore.gypi
r58298 r58333 771 771 'bindings/v8/custom/V8NodeCustom.cpp', 772 772 'bindings/v8/custom/V8NodeFilterCustom.cpp', 773 'bindings/v8/custom/V8NodeIteratorCustom.cpp',774 773 'bindings/v8/custom/V8NodeListCustom.cpp', 775 774 'bindings/v8/custom/V8NotificationCenterCustom.cpp', -
trunk/WebCore/bindings/js/JSNodeIteratorCustom.cpp
r47022 r58333 38 38 } 39 39 40 JSValue JSNodeIterator::nextNode(ExecState* exec, const ArgList&)41 {42 ExceptionCode ec = 0;43 RefPtr<Node> node = impl()->nextNode(exec, ec);44 if (ec) {45 setDOMException(exec, ec);46 return jsUndefined();47 }48 49 if (exec->hadException())50 return jsUndefined();51 52 return toJS(exec, node.get());53 40 } 54 55 JSValue JSNodeIterator::previousNode(ExecState* exec, const ArgList&)56 {57 ExceptionCode ec = 0;58 RefPtr<Node> node = impl()->previousNode(exec, ec);59 if (ec) {60 setDOMException(exec, ec);61 return jsUndefined();62 }63 64 if (exec->hadException())65 return jsUndefined();66 67 return toJS(exec, node.get());68 }69 70 } -
trunk/WebCore/bindings/scripts/CodeGeneratorJS.pm
r58330 r58333 1917 1917 } else { 1918 1918 push(@implContent, "\n" . $indent . "JSC::JSValue result = " . NativeToJSValue($function->signature, 1, $implClassName, "", $functionString, "castedThisObj") . ";\n"); 1919 push(@implContent, $indent . "setDOMException(exec, ec);\n") if @{$function->raisesExceptions}; 1920 1919 1921 $callWith = $function->signature->extendedAttributes->{"CallWith"}; 1920 1922 if ($callWith and $callWith eq "ScriptState") { … … 1922 1924 push(@implContent, $indent . " return jsUndefined();\n"); 1923 1925 } 1924 push(@implContent, $indent . "setDOMException(exec, ec);\n") if @{$function->raisesExceptions};1925 1926 1926 1927 if ($podType and not $function->signature->extendedAttributes->{"Immutable"}) { -
trunk/WebCore/bindings/scripts/CodeGeneratorV8.pm
r58298 r58333 2415 2415 } 2416 2416 2417 if (@{$function->raisesExceptions}) { 2418 $result .= $indent . "if (UNLIKELY(ec))\n"; 2419 $result .= $indent . " goto fail;\n"; 2420 } 2421 2417 2422 if ($hasScriptState) { 2418 2423 $result .= $indent . "if (state.hadException())\n"; 2419 2424 $result .= $indent . " return throwError(state.exception());\n" 2420 }2421 2422 if (@{$function->raisesExceptions}) {2423 $result .= $indent . "if (UNLIKELY(ec))\n";2424 $result .= $indent . " goto fail;\n";2425 2425 } 2426 2426 -
trunk/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp
r58330 r58333 208 208 WebCore::TestObj * item = WebKit::core(self); 209 209 PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->withScriptStateObj()); 210 WebKitDOMTestObj* res = static_cast<WebKitDOMTestObj* >(WebKit::kit(g_res.get())); 211 return res; 212 213 } 214 215 void 216 webkit_dom_test_obj_with_script_state_void_exception (WebKitDOMTestObj *self, GError **error) 217 { 218 g_return_if_fail (self); 219 WebCore::TestObj * item = WebKit::core(self); 220 WebCore::ExceptionCode ec = 0; 221 item->withScriptStateVoidException(ec); 222 if (ec) { 223 WebCore::ExceptionCodeDescription ecdesc; 224 WebCore::getExceptionCodeDescription(ec, ecdesc); 225 g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); 226 } 227 228 } 229 230 WebKitDOMTestObj* 231 webkit_dom_test_obj_with_script_state_obj_exception (WebKitDOMTestObj *self, GError **error) 232 { 233 g_return_val_if_fail (self, 0); 234 WebCore::TestObj * item = WebKit::core(self); 235 WebCore::ExceptionCode ec = 0; 236 PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->withScriptStateObjException(ec)); 237 if (ec) { 238 WebCore::ExceptionCodeDescription ecdesc; 239 WebCore::getExceptionCodeDescription(ec, ecdesc); 240 g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); 241 } 210 242 WebKitDOMTestObj* res = static_cast<WebKitDOMTestObj* >(WebKit::kit(g_res.get())); 211 243 return res; -
trunk/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h
r58330 r58333 99 99 100 100 WEBKIT_API void 101 webkit_dom_test_obj_with_script_state_void_exception (WebKitDOMTestObj *self, GError **error); 102 103 WEBKIT_API WebKitDOMTestObj* 104 webkit_dom_test_obj_with_script_state_obj_exception (WebKitDOMTestObj *self, GError **error); 105 106 WEBKIT_API void 101 107 webkit_dom_test_obj_method_with_optional_arg (WebKitDOMTestObj *self, glong opt); 102 108 -
trunk/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
r58330 r58333 130 130 #endif 131 131 132 static const HashTableValue JSTestObjPrototypeTableValues[2 3] =132 static const HashTableValue JSTestObjPrototypeTableValues[25] = 133 133 { 134 134 { "voidMethod", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionVoidMethod), (intptr_t)0 THUNK_GENERATOR(0) }, … … 151 151 { "withScriptStateVoid", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithScriptStateVoid), (intptr_t)0 THUNK_GENERATOR(0) }, 152 152 { "withScriptStateObj", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithScriptStateObj), (intptr_t)0 THUNK_GENERATOR(0) }, 153 { "withScriptStateVoidException", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithScriptStateVoidException), (intptr_t)0 THUNK_GENERATOR(0) }, 154 { "withScriptStateObjException", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithScriptStateObjException), (intptr_t)0 THUNK_GENERATOR(0) }, 153 155 { "methodWithOptionalArg", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalArg), (intptr_t)1 THUNK_GENERATOR(0) }, 154 156 { "methodWithNonOptionalArgAndOptionalArg", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndOptionalArg), (intptr_t)2 THUNK_GENERATOR(0) }, … … 162 164 { 8191, JSTestObjPrototypeTableValues, 0 }; 163 165 #else 164 { 6 6, 63, JSTestObjPrototypeTableValues, 0 };166 { 67, 63, JSTestObjPrototypeTableValues, 0 }; 165 167 #endif 166 168 … … 642 644 } 643 645 646 JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateVoidException(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) 647 { 648 UNUSED_PARAM(args); 649 if (!thisValue.inherits(&JSTestObj::s_info)) 650 return throwError(exec, TypeError); 651 JSTestObj* castedThisObj = static_cast<JSTestObj*>(asObject(thisValue)); 652 TestObj* imp = static_cast<TestObj*>(castedThisObj->impl()); 653 ExceptionCode ec = 0; 654 655 imp->withScriptStateVoidException(exec, ec); 656 setDOMException(exec, ec); 657 return jsUndefined(); 658 } 659 660 JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateObjException(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) 661 { 662 UNUSED_PARAM(args); 663 if (!thisValue.inherits(&JSTestObj::s_info)) 664 return throwError(exec, TypeError); 665 JSTestObj* castedThisObj = static_cast<JSTestObj*>(asObject(thisValue)); 666 TestObj* imp = static_cast<TestObj*>(castedThisObj->impl()); 667 ExceptionCode ec = 0; 668 669 670 JSC::JSValue result = toJS(exec, castedThisObj->globalObject(), WTF::getPtr(imp->withScriptStateObjException(exec, ec))); 671 setDOMException(exec, ec); 672 if (exec->hadException()) 673 return jsUndefined(); 674 return result; 675 } 676 644 677 JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalArg(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) 645 678 { -
trunk/WebCore/bindings/scripts/test/JS/JSTestObj.h
r58330 r58333 105 105 JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateVoid(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); 106 106 JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateObj(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); 107 JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateVoidException(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); 108 JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateObjException(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); 107 109 JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalArg(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); 108 110 JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndOptionalArg(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); -
trunk/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h
r58330 r58333 71 71 - (void)withScriptStateVoid; 72 72 - (DOMTestObj *)withScriptStateObj; 73 - (void)withScriptStateVoidException; 74 - (DOMTestObj *)withScriptStateObjException; 73 75 - (void)methodWithOptionalArg:(int)opt; 74 76 - (void)methodWithNonOptionalArgAndOptionalArg:(int)nonOpt opt:(int)opt; -
trunk/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm
r58330 r58333 258 258 } 259 259 260 - (void)withScriptStateVoidException 261 { 262 WebCore::ExceptionCode ec = 0; 263 IMPL->withScriptStateVoidException(ec); 264 WebCore::raiseOnDOMError(ec); 265 } 266 267 - (DOMTestObj *)withScriptStateObjException 268 { 269 WebCore::ExceptionCode ec = 0; 270 DOMTestObj *result = kit(WTF::getPtr(IMPL->withScriptStateObjException(ec))); 271 WebCore::raiseOnDOMError(ec); 272 return result; 273 } 274 260 275 - (void)methodWithOptionalArg:(int)opt 261 276 { -
trunk/WebCore/bindings/scripts/test/TestObj.idl
r58330 r58333 76 76 [CallWith=ScriptState] void withScriptStateVoid(); 77 77 [CallWith=ScriptState] TestObj withScriptStateObj(); 78 [CallWith=ScriptState] void withScriptStateVoidException() 79 raises(DOMException); 80 [CallWith=ScriptState] TestObj withScriptStateObjException() 81 raises(DOMException); 78 82 79 83 // 'Optional' extended attribute -
trunk/WebCore/bindings/scripts/test/V8/V8TestObj.cpp
r58330 r58333 373 373 return throwError(state.exception()); 374 374 return toV8(result.release()); 375 } 376 377 static v8::Handle<v8::Value> withScriptStateVoidExceptionCallback(const v8::Arguments& args) 378 { 379 INC_STATS("DOM.TestObj.withScriptStateVoidException"); 380 TestObj* imp = V8TestObj::toNative(args.Holder()); 381 ExceptionCode ec = 0; 382 { 383 EmptyScriptState state; 384 imp->withScriptStateVoidException(&state, ec); 385 if (UNLIKELY(ec)) 386 goto fail; 387 if (state.hadException()) 388 return throwError(state.exception()); 389 return v8::Handle<v8::Value>(); 390 } 391 fail: 392 V8Proxy::setDOMException(ec); 393 return v8::Handle<v8::Value>(); 394 } 395 396 static v8::Handle<v8::Value> withScriptStateObjExceptionCallback(const v8::Arguments& args) 397 { 398 INC_STATS("DOM.TestObj.withScriptStateObjException"); 399 TestObj* imp = V8TestObj::toNative(args.Holder()); 400 ExceptionCode ec = 0; 401 { 402 EmptyScriptState state; 403 RefPtr<TestObj> result = imp->withScriptStateObjException(&state, ec); 404 if (UNLIKELY(ec)) 405 goto fail; 406 if (state.hadException()) 407 return throwError(state.exception()); 408 return toV8(result.release()); 409 } 410 fail: 411 V8Proxy::setDOMException(ec); 412 return v8::Handle<v8::Value>(); 375 413 } 376 414 … … 514 552 {"withScriptStateVoid", TestObjInternal::withScriptStateVoidCallback}, 515 553 {"withScriptStateObj", TestObjInternal::withScriptStateObjCallback}, 554 {"withScriptStateVoidException", TestObjInternal::withScriptStateVoidExceptionCallback}, 555 {"withScriptStateObjException", TestObjInternal::withScriptStateObjExceptionCallback}, 516 556 {"methodWithOptionalArg", TestObjInternal::methodWithOptionalArgCallback}, 517 557 {"methodWithNonOptionalArgAndOptionalArg", TestObjInternal::methodWithNonOptionalArgAndOptionalArgCallback}, -
trunk/WebCore/dom/NodeIterator.idl
r52537 r58333 32 32 readonly attribute boolean pointerBeforeReferenceNode; 33 33 34 [C ustom] Node nextNode()34 [CallWith=ScriptState] Node nextNode() 35 35 raises (DOMException); 36 [C ustom] Node previousNode()36 [CallWith=ScriptState] Node previousNode() 37 37 raises (DOMException); 38 38 void detach();
Note: See TracChangeset
for help on using the changeset viewer.