[uuid(deb1d48e-7469-4b01-b186-d9854c7d3f2d)]
interface nsIXPConnect : nsISupports
Constants
const
PRUint32
INIT_JS_STANDARD_CLASSES = 1
const
PRUint32
FLAG_SYSTEM_GLOBAL_OBJECT = 2
Attributes
attribute
PRBool
collectGarbageOnMainThreadOnly
readonly attribute
nsIStackFrame
CurrentJSStack
readonly attribute
nsIXPCNativeCallContext
CurrentNativeCallContext
attribute
PRBool
deferReleasesUntilAfterGarbageCollection
attribute
nsIException
PendingException
Methods
void
clearAllWrappedNativeSecurityPolicies()
nsIStackFrame
createStackFrameLocation(in PRUint32 aLanguage, in string aFilename, in string aFunctionName, in PRInt32 aLineNumber, in nsIStackFrame aCaller)
void
debugDump(in short depth)
void
debugDumpEvalInJSStackFrame(in PRUint32 aFrameNumber, in string aSourceText)
void
debugDumpJSStack(in PRBool showArgs, in PRBool showLocals, in PRBool showThisProps)
void
debugDumpObject(in nsISupports aCOMObj, in short depth)
Preconfigure XPCNativeWrapper automation so that when a scripted
caller whose filename starts with filenamePrefix accesses a wrapped
native that is not flagged as "system", the wrapped native will be
automatically wrapped with an XPCNativeWrapper.
@param aFilenamePrefix the UTF-8 filename prefix to match, which
should end with a slash (/) character
void
flagSystemFilenamePrefix(in string aFilenamePrefix)
void
getDefaultSecurityManager(out nsIXPCSecurityManager aManager, out PRUint16 flags)
nsIXPCFunctionThisTranslator
getFunctionThisTranslator(in nsIIDRef aIID)
void
getSecurityManagerForJSContext(in JSContextPtr aJSContext, out nsIXPCSecurityManager aManager, out PRUint16 flags)
This only succeeds if the JSObject is a nsIXPConnectWrappedNative. A new wrapper is *never* constructed.
nsIXPConnectWrappedNative
getWrappedNativeOfJSObject(in JSContextPtr aJSContext, in JSObjectPtr aJSObj)
This only succeeds if the native object is already wrapped by xpconnect. A new wrapper is *never* constructed.
nsIXPConnectWrappedNative
getWrappedNativeOfNativeObject(in JSContextPtr aJSContext, in JSObjectPtr aScope, in nsISupports aCOMObj, in nsIIDRef aIID)
nsIXPConnectJSObjectHolder
getWrappedNativePrototype(in JSContextPtr aJSContext, in JSObjectPtr aScope, in nsIClassInfo aClassInfo)
void
initClasses(in JSContextPtr aJSContext, in JSObjectPtr aGlobalJSObj)
nsIXPConnectJSObjectHolder
initClassesWithNewWrappedGlobal(in JSContextPtr aJSContext, in nsISupports aCOMObj, in nsIIDRef aIID, in PRUint32 aFlags)
nsIVariant
JSToVariant(in JSContextPtr ctx, in JSVal value)
void
releaseJSContext(in JSContextPtr aJSContext, in PRBool noGC)
nsIXPConnectJSObjectHolder
reparentWrappedNativeIfFound(in JSContextPtr aJSContext, in JSObjectPtr aScope, in JSObjectPtr aNewParent, in nsISupports aCOMObj)
Restore an old prototype for wrapped natives of type aClassInfo. This should be used only when restoring an old scope into a state close to where it was prior to being reinitialized.
void
restoreWrappedNativePrototype(in JSContextPtr aJSContext, in JSObjectPtr aScope, in nsIClassInfo aClassInfo, in nsIXPConnectJSObjectHolder aPrototype)
The security manager to use when the current JSContext has no security manager.
void
setDefaultSecurityManager(in nsIXPCSecurityManager aManager, in PRUint16 flags)
nsIXPCFunctionThisTranslator
setFunctionThisTranslator(in nsIIDRef aIID, in nsIXPCFunctionThisTranslator aTranslator)
Set fallback JSContext to use when xpconnect can't find an appropriate
context to use to execute JavaScript.
NOTE: This method is DEPRECATED.
Use nsIThreadJSContextStack::safeJSContext instead.
void
setSafeJSContextForCurrentThread(in JSContextPtr cx)
void
setSecurityManagerForJSContext(in JSContextPtr aJSContext, in nsIXPCSecurityManager aManager, in PRUint16 flags)
XPConnect builds internal objects that parallel, and are one-to-one with, the JSContexts in the JSRuntime. It builds these objects as needed. This method tells XPConnect to resynchronize its representations with the list of JSContexts currently 'alive' in the JSRuntime. This allows it to cleanup any representations of JSContexts that are no longer valid.
void
syncJSContexts()
JSVal
variantToJS(in JSContextPtr ctx, in JSObjectPtr scope, in nsIVariant value)
wrapJS will yield a new or previously existing xpcom interface pointer
to represent the JSObject passed in.
This method now correctly deals with cases where the passed in JSObject
already has an associated xpcom interface for the cases:
1) The JSObject has already been wrapped as a nsIXPConnectWrappedJS.
2) The JSObject is in fact a nsIXPConnectWrappedNative and thus already
has an underlying xpcom object.
3) The JSObject is of a jsclass which supports getting the nsISupports
from the JSObject directly. This is used for idlc style objects
(e.g. DOM objects).
It *might* be possible to QueryInterface the resulting interface pointer
to nsIXPConnectWrappedJS.
Returns:
success:
NS_OK
failure:
NS_ERROR_XPC_BAD_CONVERT_JS
NS_ERROR_FAILURE
void
wrapJS(in JSContextPtr aJSContext, in JSObjectPtr aJSObj, in nsIIDRef aIID, [iid_is(aIID), retval] out nsQIResult result)
wrapJSAggregatedToNative is just like wrapJS except it is used in cases
where the JSObject is also aggregated to some native xpcom Object.
At present XBL is the only system that might want to do this.
XXX write more!
Returns:
success:
NS_OK
failure:
NS_ERROR_XPC_BAD_CONVERT_JS
NS_ERROR_FAILURE
void
wrapJSAggregatedToNative(in nsISupports aOuter, in JSContextPtr aJSContext, in JSObjectPtr aJSObj, in nsIIDRef aIID, [iid_is(aIID), retval] out nsQIResult result)
wrapNative will create a new JSObject or return an existing one.
The JSObject is returned inside a refcounted nsIXPConnectJSObjectHolder.
As long as this holder is held the JSObject will be protected from
collection by JavaScript's garbage collector. It is a good idea to
transfer the JSObject to some equally protected place before releasing
the holder (i.e. use JS_SetProperty to make this object a property of
some other JSObject).
This method now correctly deals with cases where the passed in xpcom
object already has an associated JSObject for the cases:
1) The xpcom object has already been wrapped for use in the same scope
as an nsIXPConnectWrappedNative.
2) The xpcom object is in fact a nsIXPConnectWrappedJS and thus already
has an underlying JSObject.
3) The xpcom object implements nsIScriptObjectOwner; i.e. is an idlc
style DOM object for which we can call GetScriptObject to get the
JSObject it uses to represent itself into JavaScript.
It *might* be possible to QueryInterface the nsIXPConnectJSObjectHolder
returned by the method into a nsIXPConnectWrappedNative or a
nsIXPConnectWrappedJS.
This method will never wrap the JSObject involved in an
XPCNativeWrapper before returning.
Returns:
success:
NS_OK
failure:
NS_ERROR_XPC_BAD_CONVERT_NATIVE
NS_ERROR_XPC_CANT_GET_JSOBJECT_OF_DOM_OBJECT
NS_ERROR_FAILURE
nsIXPConnectJSObjectHolder
wrapNative(in JSContextPtr aJSContext, in JSObjectPtr aScope, in nsISupports aCOMObj, in nsIIDRef aIID)
Compare to: