Changes between Version 124 and Version 125 of WebKitIDL


Ignore:
Timestamp:
Jun 11, 2013 11:38:54 PM (8 years ago)
Author:
Christophe Dumez
Comment:

Bring back [ConstructorRaisesException]

Legend:

Unmodified
Added
Removed
Modified
  • WebKitIDL

    v124 v125  
    2222 - [#CachedAttribute CachedAttribute(a)][[br]]
    2323 - [#JSWindowEventListener JSWindowEventListener(a)][[br]]
    24  - [#Constructor Constructor(i), CallWith(i,m,a)][[br]]
     24 - [#Constructor Constructor(i), CallWith(i,m,a), ConstructorRaisesException(i)][[br]]
    2525 - [#ConstructorTemplate ConstructorTemplate(i), InitializedByEventConstructor(a)][[br]]
    2626 - [#NamedConstructor NamedConstructor(i)][[br]]
     
    5555 - [#NoInterfaceObject NoInterfaceObject(i), GlobalContext(i)][[br]]
    5656 - [#EnabledAtRuntime EnabledAtRuntime(i)][[br]]
    57  - [#RaisesException RaisesException(i,m) GetterRaisesException(a), SetterRaisesException(a)][[br]]
     57 - [#RaisesException RaisesException(m) GetterRaisesException(a), SetterRaisesException(a)][[br]]
    5858
    5959= Overview = #Overview
     
    648648ADD EXPLANATIONS
    649649
    650 == `[Constructor]`(i), `[CallWith]`(i,m,a) == #Constructor
     650== `[Constructor]`(i), `[CallWith]`(i,m,a), `[ConstructorRaisesException](i)` == #Constructor
    651651
    652652 * [http://dev.w3.org/2006/webapi/WebIDL/#Constructor The spec of Constructor]
    653653
    654654Summary: `[Constructor]` indicates that the interface should have constructor, i.e. "new XXX()".
    655 `[CallWith]`adds information when the constructor callback is called in WebCore.
    656 
    657 Usage: `[Constructor]` and `[CallWith]` can be specified on interfaces:
     655`[CallWith]` and `[ConstructorRaisesException]` add information when the constructor callback is called in WebCore.
     656
     657Usage: `[Constructor]`, `[CallWith]` and `[ConstructorRaisesException]` can be specified on interfaces:
    658658{{{
    659659    [
    660660        Constructor(float x, float y, DOMString str),
    661         CallWith=ScriptExecutionContext|ScriptState
     661        ConstructorRaisesException,
     662        CallWith=ScriptExecutionContext
    662663    ] interface XXX {
    663664    };
     
    681682`[Constructor()]` is equivalent to `[Constructor]`.
    682683
    683 If `XXX::create(...)` needs additional information like ScriptExecutionContext and ScriptState,
    684 you can specify `[CallWith=ScriptExecutionContext|ScriptState]`.
     684If `XXX::create(...)` can throw Exception, you can use `[ConstructorRaisesException]`.
     685With `[ConstructorRaisesException]`, a placeholder for ExceptionCode is added to the tail argument of `XXX::create(...)`.
     686{{{
     687    PassRefPtr<XXX> XXX::create(float x, float y, String str, ExceptionCode& ec)
     688    {
     689        ...;
     690        if (...) {
     691            ec = TYPE_MATCH_ERR;
     692            return 0;
     693        }
     694    }
     695}}}
     696
     697If `XXX::create(...)` needs additional information like ScriptExecutionContext,
     698you can specify `[CallWith=ScriptExecutionContext]`.
    685699Then `XXX::create(...)` can have the following signature:
    686700{{{
    687     PassRefPtr<XXX> XXX::create(ScriptExecutionContext* context, ScriptState* state, float x, float y, String str)
     701    PassRefPtr<XXX> XXX::create(ScriptExecutionContext* context, float x, float y, String str)
    688702    {
    689703        ...;
     
    14641478}}}
    14651479
    1466 == `[RaisesException]`(i,m), `[GetterRaisesException]`(a), `[SetterRaisesException]`(a) == #RaisesException
     1480== `[RaisesException]`(m), `[GetterRaisesException]`(a), `[SetterRaisesException]`(a) == #RaisesException
    14671481
    14681482Standard: This is a non-standard attribute.
     
    14721486Implementations may assign a DOMException code to this reference parameter, and the generated binding code will create and throw the appropriate exception type.
    14731487
    1474 Usage: [RaisesException] can be specified on methods and interfaces, and [GetterRaisesException] and [SetterRaisesException] can be specified on attributes. On methods and attributes, the IDL looks like:
     1488Usage: [RaisesException] can be specified on methods, and [GetterRaisesException] and [SetterRaisesException] can be specified on attributes. On methods and attributes, the IDL looks like:
    14751489{{{
    14761490    interface XXX {
     
    15071521}}}
    15081522
    1509 If [RaisesException] is specified on an interface and [Constructor] is also specified then an ExceptionCode& argument is added when calling the XXX::create(...) constructor callback.
    1510 {{{
    1511     [
    1512         Constructor(float x),
    1513         RaisesException
    1514     ]
    1515     interface XXX {
    1516         ...
    1517     };
    1518 }}}
    1519 
    1520 WebCore needs to implement the following method as a constructor callback:
    1521 {{{
    1522 PassRefPtr<XXX> XXX::create(float x, ExceptionCode& ec)
    1523 {
    1524         ...;
    1525         if (...) {
    1526             ec = TYPE_MATCH_ERR;
    1527             return 0;
    1528         }
    1529         ...;
    1530     }
    1531 }}}
     1523See [ConstructorRaisesException] to specify that a constructor throws exceptions.