1582 | | == `[JSBuiltin]`(m,a) `[JSBuiltinConstructor]`(i) == #JSBuiltin |
1583 | | |
1584 | | Standard: This is a non-standard attribute. |
1585 | | |
1586 | | Summary: If JSBuiltin is set, it tells the code generator to implement the corresponding method (or attribute getter) as a JS builtin. If JSBuiltinConstructor is set, a JS builtin constructor function is called. |
1587 | | |
1588 | | Usage: given a IDL file called XX.idl, a corresponding XX.js file should be created containing a JS function with the same method name in the case of JSBuiltin or a JS function with the name 'initializeXX' in the case of JSBuiltinConstructor. |
1589 | | |
| 1582 | == `[JSBuiltin]`(m,a, i) `[Private]`(m) == #JSBuiltin |
| 1583 | |
| 1584 | Standard: These are non-standard attributes. |
| 1585 | |
| 1586 | Summary: If JSBuiltin is set on a method, it tells the code generator to implement the corresponding method as a JS builtin. |
| 1587 | |
| 1588 | Usage: given a IDL file called XX.idl, a corresponding XX.js file should be created containing a JS function with the same method name in the case of JSBuiltin. JSBuiltin can also be set for read-only attributes (JS Builtin setter not yet supported), in which case the attribute getter should be implemented as JS builtin in the corresponding XX.js file. |
| 1589 | |
| 1590 | JSBuiltin may also be set at the interface level. In that case, all methods and attributes are considered as JS builtins, except if the method or attribute is set as Custom, CustomGetter or CustomSetter. Such an interface does not need any corresponding DOM class. |
| 1591 | An interface setting both JSBuiltin and Constructor will need to implement a 'initializeXX' JS builtin function. |
| 1592 | |
| 1593 | Private attribute is used to add C++ implemented functions to the JS prototype as private slots. These functions can then be called from JS builtin functions. |
| 1594 | |
| 1595 | {{{ |
| 1596 | |
| 1597 | interface YYY { |
| 1598 | // Implemented as JS builtin |
| 1599 | [JSBuiltin] readonly attribute unsigned long length; |
| 1600 | // Implemented as JS builtin |
| 1601 | [JSBuiltin] DOMString getString(DOMString key); |
| 1602 | // Implemented as C++ YYY::setString(...) |
| 1603 | void setString(DOMString key, DOMString value); |
| 1604 | // Implemented as C++ YYY::doSomething. Can be used within JS Builtin code as this.@doSomething |
| 1605 | [Private] void doSomething(DOMString action); |
| 1606 | }; |
| 1607 | |
| 1608 | [JSBuiltin] |
| 1609 | interface XXX { |
| 1610 | // Implemented as JS builtin |
| 1611 | readonly attribute unsigned long length; |
| 1612 | // Implemented as JS builtin |
| 1613 | DOMString getString(DOMString key); |
| 1614 | // Implemented as C++ JSXXX::setString(...) |
| 1615 | [Custom] void setString(DOMString key, DOMString value); |
| 1616 | }; |
| 1617 | }}} |