93
edits
(→Flexible Membrane Functionality: added docs for membrane.enumerate()) |
(added docs for more membrane methods) |
||
| Line 18: | Line 18: | ||
The source code for this functionality is in [http://hg.mozilla.org/labs/jetpack/file/tip/components/src/wrapper.cpp wrapper.cpp]. | The source code for this functionality is in [http://hg.mozilla.org/labs/jetpack/file/tip/components/src/wrapper.cpp wrapper.cpp]. | ||
<code>nsJetpack.</code>'''wrap'''('' | <code>nsJetpack.</code>'''wrap'''(''wrappee'', ''membrane'') | ||
This function wraps '' | This function wraps ''wrappee'' with ''membrane'' (meaning that ''membrane'' mediates all access to and from ''wrappee''). The wrapped object is returned. | ||
''membrane'' should be a JavaScript object with any of the following methods defined: | ''membrane'' should be a JavaScript object with any of the following methods defined: | ||
| Line 31: | Line 31: | ||
::This is essentially a JavaScript version of [https://developer.mozilla.org/en/SpiderMonkey/JSAPI_Reference/JSClass.enumerate JSClass.enumerate]. It should return an iterator that iterates through all the property names in ''wrappee''. | ::This is essentially a JavaScript version of [https://developer.mozilla.org/en/SpiderMonkey/JSAPI_Reference/JSClass.enumerate JSClass.enumerate]. It should return an iterator that iterates through all the property names in ''wrappee''. | ||
::<code>membrane.</code>'''getProperty'''(''wrappee'', ''membrane'', ''name'', ''defaultValue'') | |||
::This is essentially a JavaScript version of [https://developer.mozilla.org/En/SpiderMonkey/JSAPI_Reference/JSPropertyOp JSClass.getProperty]; alternatively, it could be described as the analog of Python's <code>__getattr__</code> magic method. ''name'' is the name of the property being accessed, and ''defaultValue'' is the value that JavaScript would ordinarily return. This function should return the value of the property, which may be ''defaultValue'' or something different. | |||
=== unwrap() === | === unwrap() === | ||
edits