|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #include "nsISupports.idl" |
|
7 |
|
8 [ptr] native nsAXPCNativeCallContextPtr(nsAXPCNativeCallContext); |
|
9 |
|
10 %{C++ |
|
11 #include "js/TypeDecls.h" |
|
12 |
|
13 class nsAXPCNativeCallContext; |
|
14 %} |
|
15 |
|
16 [ptr] native JSObjectPtr(JSObject); |
|
17 |
|
18 [scriptable, uuid(243d1a31-db9f-47a1-9922-55a1ad5515fb)] |
|
19 interface xpcIJSModuleLoader : nsISupports |
|
20 { |
|
21 /** |
|
22 * To be called from JavaScript only. |
|
23 * |
|
24 * Synchronously loads and evaluates the js file located at |
|
25 * aResourceURI with a new, fully privileged global object. |
|
26 * |
|
27 * If 'targetObj' is specified and equal to null, returns the |
|
28 * module's global object. Otherwise (if 'targetObj' is not |
|
29 * specified, or 'targetObj' is != null) looks for a property |
|
30 * 'EXPORTED_SYMBOLS' on the new global object. 'EXPORTED_SYMBOLS' |
|
31 * is expected to be an array of strings identifying properties on |
|
32 * the global object. These properties will be installed as |
|
33 * properties on 'targetObj', or, if 'targetObj' is not specified, |
|
34 * on the caller's global object. If 'EXPORTED_SYMBOLS' is not |
|
35 * found, an error is thrown. |
|
36 * |
|
37 * @param resourceURI A resource:// URI string to load the module from. |
|
38 * @param targetObj the object to install the exported properties on. |
|
39 * If this parameter is a primitive value, this method throws |
|
40 * an exception. |
|
41 * @returns the module code's global object. |
|
42 * |
|
43 * The implementation maintains a hash of registryLocation->global obj. |
|
44 * Subsequent invocations of importModule with 'registryLocation' |
|
45 * pointing to the same file will not cause the module to be re-evaluated, |
|
46 * but the symbols in EXPORTED_SYMBOLS will be exported into the |
|
47 * specified target object and the global object returned as above. |
|
48 * |
|
49 * (This comment is duplicated to nsIXPCComponents_Utils.) |
|
50 */ |
|
51 [implicit_jscontext,optional_argc] |
|
52 jsval import(in AUTF8String aResourceURI, [optional] in jsval targetObj); |
|
53 |
|
54 /** |
|
55 * Imports the JS module at aResourceURI to the JS object |
|
56 * 'targetObj' (if != null) as described for importModule() and |
|
57 * returns the module's global object. |
|
58 */ |
|
59 [noscript] JSObjectPtr importInto(in AUTF8String aResourceURI, |
|
60 in JSObjectPtr targetObj, |
|
61 in nsAXPCNativeCallContextPtr cc); |
|
62 |
|
63 /** |
|
64 * Unloads the JS module at aResourceURI. Existing references to the module |
|
65 * will continue to work but any subsequent import of the module will |
|
66 * reload it and give new reference. If the JS module hasn't yet been imported |
|
67 * then this method will do nothing. |
|
68 */ |
|
69 void unload(in AUTF8String aResourceURI); |
|
70 }; |