js/xpconnect/idl/xpcIJSModuleLoader.idl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/xpconnect/idl/xpcIJSModuleLoader.idl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,70 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#include "nsISupports.idl"
    1.10 +
    1.11 +[ptr] native nsAXPCNativeCallContextPtr(nsAXPCNativeCallContext);
    1.12 +
    1.13 +%{C++
    1.14 +#include "js/TypeDecls.h"
    1.15 +
    1.16 +class nsAXPCNativeCallContext;
    1.17 +%}
    1.18 +
    1.19 +[ptr] native JSObjectPtr(JSObject);
    1.20 +
    1.21 +[scriptable, uuid(243d1a31-db9f-47a1-9922-55a1ad5515fb)]
    1.22 +interface xpcIJSModuleLoader : nsISupports
    1.23 +{
    1.24 +  /**
    1.25 +   * To be called from JavaScript only.
    1.26 +   *
    1.27 +   * Synchronously loads and evaluates the js file located at
    1.28 +   * aResourceURI with a new, fully privileged global object.
    1.29 +   *
    1.30 +   * If 'targetObj' is specified and equal to null, returns the
    1.31 +   * module's global object. Otherwise (if 'targetObj' is not
    1.32 +   * specified, or 'targetObj' is != null) looks for a property
    1.33 +   * 'EXPORTED_SYMBOLS' on the new global object. 'EXPORTED_SYMBOLS'
    1.34 +   * is expected to be an array of strings identifying properties on
    1.35 +   * the global object.  These properties will be installed as
    1.36 +   * properties on 'targetObj', or, if 'targetObj' is not specified,
    1.37 +   * on the caller's global object. If 'EXPORTED_SYMBOLS' is not
    1.38 +   * found, an error is thrown.
    1.39 +   *
    1.40 +   * @param resourceURI A resource:// URI string to load the module from.
    1.41 +   * @param targetObj  the object to install the exported properties on.
    1.42 +   *        If this parameter is a primitive value, this method throws
    1.43 +   *        an exception.
    1.44 +   * @returns the module code's global object.
    1.45 +   *
    1.46 +   * The implementation maintains a hash of registryLocation->global obj.
    1.47 +   * Subsequent invocations of importModule with 'registryLocation'
    1.48 +   * pointing to the same file will not cause the module to be re-evaluated,
    1.49 +   * but the symbols in EXPORTED_SYMBOLS will be exported into the
    1.50 +   * specified target object and the global object returned as above.
    1.51 +   *
    1.52 +   * (This comment is duplicated to nsIXPCComponents_Utils.)
    1.53 +   */
    1.54 +  [implicit_jscontext,optional_argc]
    1.55 +  jsval import(in AUTF8String aResourceURI, [optional] in jsval targetObj);
    1.56 +
    1.57 +  /**
    1.58 +   * Imports the JS module at aResourceURI to the JS object
    1.59 +   * 'targetObj' (if != null) as described for importModule() and
    1.60 +   * returns the module's global object.
    1.61 +   */
    1.62 +  [noscript] JSObjectPtr importInto(in AUTF8String aResourceURI,
    1.63 +                                    in JSObjectPtr targetObj,
    1.64 +                                    in nsAXPCNativeCallContextPtr cc);
    1.65 +
    1.66 +  /**
    1.67 +   * Unloads the JS module at aResourceURI. Existing references to the module
    1.68 +   * will continue to work but any subsequent import of the module will
    1.69 +   * reload it and give new reference. If the JS module hasn't yet been imported
    1.70 +   * then this method will do nothing.
    1.71 +   */
    1.72 +  void unload(in AUTF8String aResourceURI);
    1.73 +};

mercurial