1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ----- BEGIN LICENSE BLOCK -----
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Mozilla Public License
6 * Version 1.1 (the "License"); you may not use this file except in
7 * compliance with the License. You may obtain a copy of the License
8 * at http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS"
11 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
12 * the License for the specific language governing rights and
13 * limitations under the License.
14 *
15 * The Original Code is Mozilla code.
16 *
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 2004
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 * Alex Fritze <alex@croczilla.com> (original author)
24 *
25 * Alternatively, the contents of this file may be used under the
26 * terms of either the GNU General Public License Version 2 or later
27 * (the "GPL"), or the GNU Lesser General Public License Version 2.1
28 * or later (the "LGPL"), in which case the provisions of the GPL or
29 * the LGPL are applicable instead of those above. If you wish to
30 * allow use of your version of this file only under the terms of
31 * either the GPL or the LGPL, and not to allow others to use your
32 * version of this file under the terms of the NPL, indicate your
33 * decision by deleting the provisions above and replace them with the
34 * notice and other provisions required by the GPL or the LGPL. If you
35 * do not delete the provisions above, a recipient may use your
36 * version of this file under the terms of any one of the MPL, the GPL
37 * or the LGPL.
38 *
39 * ----- END LICENSE BLOCK ----- */
40
41 #include "nsISupports.idl"
42
43 [ptr] native nsAXPCNativeCallContextPtr(nsAXPCNativeCallContext);
44
45 %{C++
46 struct JSObject;
47 %}
48
49 [ptr] native JSObjectPtr(JSObject);
50
51 [scriptable, uuid(89da3673-e699-4f26-9ed7-11a528011434)]
52 interface xpcIJSModuleLoader : nsISupports
53 {
54 /**
55 * To be called from JavaScript only.
56 *
57 * Synchronously loads and evaluates the js file located at
58 * 'registryLocation' with a new, fully privileged global object.
59 *
60 * If 'targetObj' is specified and equal to null, returns the
61 * module's global object. Otherwise (if 'targetObj' is not
62 * specified, or 'targetObj' is != null) looks for a property
63 * 'EXPORTED_SYMBOLS' on the new global object. 'EXPORTED_SYMBOLS'
64 * is expected to be an array of strings identifying properties on
65 * the global object. These properties will be installed as
66 * properties on 'targetObj', or, if 'targetObj' is not specified,
67 * on the caller's global object. If 'EXPORTED_SYMBOLS' is not
68 * found, an error is thrown.
69 *
70 * @param resourceURI A resource:// URI string to load the module from.
71 * @param targetObj the object to install the exported properties on.
72 * If this parameter is a primitive value, this method throws
73 * an exception.
74 * @returns the module code's global object.
75 *
76 * The implementation maintains a hash of registryLocation->global obj.
77 * Subsequent invocations of importModule with 'registryLocation'
78 * pointing to the same file will not cause the module to be re-evaluated,
79 * but the symbols in EXPORTED_SYMBOLS will be exported into the
80 * specified target object and the global object returned as above.
81 *
82 * (This comment is duplicated to nsIXPCComponents_Utils.)
83 */
84 void /* JSObject */ import(in AUTF8String aResourceURI
85 /* , [optional] in JSObject targetObj */);
86
87 /**
88 * Imports the JS module at 'registryLocation' to the JS object
89 * 'targetObj' (if != null) as described for importModule() and
90 * returns the module's global object.
91 */
92 [noscript] JSObjectPtr importInto(in AUTF8String aResourceURI,
93 in JSObjectPtr targetObj,
94 in nsAXPCNativeCallContextPtr cc);
95 };