Labs/Jetpack/Binary Components: Difference between revisions

< Labs‎ | Jetpack
(→‎Flexible Membrane Functionality: added docs for membrane.enumerate())
(Redirect to memory profiler page)
 
(26 intermediate revisions by 2 users not shown)
Line 1: Line 1:
= nsJetpack =
#REDIRECT [[Labs/Memory_Profiler]]
 
<code>nsJetpack</code> is a binary component used to provide services to Jetpack that aren't otherwise available to scripted chrome code in the Mozilla platform.
 
== Accessing the Component ==
 
Because the goal of <code>nsJetpack</code> is to provide functionality to scripted code, and because much of its functionality is concerned with providing access to SpiderMonkey internals, the XPCOM interface for the component is rather [http://hg.mozilla.org/labs/jetpack/file/tip/components/public/nsIJetpack.idl trivial].  To obtain the component, simply do:
 
  var nsJetpack = Cc["@labs.mozilla.com/jetpackdi;1"]
                  .createInstance(Ci.nsIJetpack).get();
 
This will give you the <code>nsJetpack</code> native JavaScript object, which provides access to all the component's functionality.
 
== Flexible Membrane Functionality ==
 
<code>nsJetpack</code> contains functionality that exposes many SpiderMonkey C API calls to JavaScript, allowing chrome code to create custom wrappers (aka membranes) that allow trusted and untrusted code to interoperate.
 
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'''(''object'', ''membrane'')
 
This function wraps ''object'' with ''membrane'', meaning that ''membrane'' mediates all access to and from ''object''.
 
''membrane'' should be a JavaScript object with any of the following methods defined:
 
::<code>membrane.</code>'''resolve'''(''wrappee'', ''membrane'', ''name'')
 
::This is essentially a JavaScript version of [https://developer.mozilla.org/en/SpiderMonkey/JSAPI_Reference/JSClass.resolve JSClass.resolve].  It's called when the property identified by ''name'' doesn't exist on ''wrappee''.  The membrane should either define ''name'' on ''wrappee'' and return ''wrappee'', or&mdash;if ''name'' doesn't exist&mdash;it should return <code>undefined</code>.
 
::<code>membrane.</code>'''enumerate'''(''wrappee'', ''membrane'')
 
::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''.
 
=== unwrap() ===
 
=== getWrapper() ===
 
== Memory Profiling ==
 
<code>nsJetpack</code> contains functionality allowing chrome code to examine the JavaScript heap. The semantics of this are described at a high level in Atul's blog post entitled [http://www.toolness.com/wp/?p=604 Fun with SpiderMonkey].
 
The source code for this functionality is in [http://hg.mozilla.org/labs/jetpack/file/tip/components/src/memory_profiler.cpp memory_profiler.cpp].
 
=== profileMemory() ===
 
== Miscellaneous Functions ==
 
The source code for this functionality is in [http://hg.mozilla.org/labs/jetpack/file/tip/components/src/tcb.cpp tcb.cpp].
 
=== functionInfo() ===
 
=== seal() ===

Latest revision as of 22:09, 22 April 2010