nsIXPConnect

IID:DEB1D48E-7469-4B01-B186-D9854C7D3F2D
Inherits From:nsISupports

Constants

PRUint32 INIT_JS_STANDARD_CLASSES = 1
PRUint32 FLAG_SYSTEM_GLOBAL_OBJECT = 2

Properties

PRBool collectGarbageOnMainThreadOnly

readonly nsIStackFrame CurrentJSStack

readonly nsIXPCNativeCallContext CurrentNativeCallContext

PRBool deferReleasesUntilAfterGarbageCollection

nsIException PendingException


Methods

void clearAllWrappedNativeSecurityPolicies ( ) nsIStackFrame createStackFrameLocation ( PRUint32 language , char* filename , char* functionName , PRInt32 lineNumber , nsIStackFrame caller ) void debugDump ( PRInt16 depth ) void debugDumpEvalInJSStackFrame ( PRUint32 frameNumber , char* sourceText ) void debugDumpJSStack ( PRBool showArgs , PRBool showLocals , PRBool showThisProps ) void debugDumpObject ( nsISupports COMObj , PRInt16 depth ) void flagSystemFilenamePrefix ( char* filenamePrefix ) void getDefaultSecurityManager ( out nsIXPCSecurityManager manager , out PRUint16 flags ) nsIXPCFunctionThisTranslator getFunctionThisTranslator ( nsIIDRef IID ) void getSecurityManagerForJSContext ( JSContextPtr* JSContext , out nsIXPCSecurityManager manager , out PRUint16 flags ) nsIXPConnectWrappedNative getWrappedNativeOfJSObject ( JSContextPtr* JSContext , JSObjectPtr* JSObj ) nsIXPConnectWrappedNative getWrappedNativeOfNativeObject ( JSContextPtr* JSContext , JSObjectPtr* scope , nsISupports COMObj , nsIIDRef IID ) nsIXPConnectJSObjectHolder getWrappedNativePrototype ( JSContextPtr* JSContext , JSObjectPtr* scope , nsIClassInfo classInfo ) void initClasses ( JSContextPtr* JSContext , JSObjectPtr* globalJSObj ) nsIXPConnectJSObjectHolder initClassesWithNewWrappedGlobal ( JSContextPtr* JSContext , nsISupports COMObj , nsIIDRef IID , PRUint32 flags ) nsIVariant JSToVariant ( JSContextPtr* ctx , JSVal value ) void releaseJSContext ( JSContextPtr* JSContext , PRBool noGC ) nsIXPConnectJSObjectHolder reparentWrappedNativeIfFound ( JSContextPtr* JSContext , JSObjectPtr* scope , JSObjectPtr* newParent , nsISupports COMObj ) void restoreWrappedNativePrototype ( JSContextPtr* JSContext , JSObjectPtr* scope , nsIClassInfo classInfo , nsIXPConnectJSObjectHolder prototype ) void setDefaultSecurityManager ( nsIXPCSecurityManager manager , PRUint16 flags ) nsIXPCFunctionThisTranslator setFunctionThisTranslator ( nsIIDRef IID , nsIXPCFunctionThisTranslator translator ) void setSafeJSContextForCurrentThread ( JSContextPtr* cx ) void setSecurityManagerForJSContext ( JSContextPtr* JSContext , nsIXPCSecurityManager manager , PRUint16 flags ) void syncJSContexts ( ) JSVal variantToJS ( JSContextPtr* ctx , JSObjectPtr* scope , nsIVariant value ) void wrapJS ( JSContextPtr* JSContext , JSObjectPtr* JSObj , nsIIDRef IID , out nsQIResult* result ) void wrapJSAggregatedToNative ( nsISupports outer , JSContextPtr* JSContext , JSObjectPtr* JSObj , nsIIDRef IID , out nsQIResult* result ) nsIXPConnectJSObjectHolder wrapNative ( JSContextPtr* JSContext , JSObjectPtr* scope , nsISupports COMObj , nsIIDRef IID )

void clearAllWrappedNativeSecurityPolicies ( )


nsIStackFrame createStackFrameLocation ( PRUint32 language , char* filename , char* functionName , PRInt32 lineNumber , nsIStackFrame caller )

Arguments:
language
filename
functionName
lineNumber
caller

void debugDump ( PRInt16 depth )

Arguments:
depth

void debugDumpEvalInJSStackFrame ( PRUint32 frameNumber , char* sourceText )

Arguments:
frameNumber
sourceText

void debugDumpJSStack ( PRBool showArgs , PRBool showLocals , PRBool showThisProps )

Arguments:
showArgs
showLocals
showThisProps

void debugDumpObject ( nsISupports COMObj , PRInt16 depth )

Arguments:
COMObj
depth

void flagSystemFilenamePrefix ( char* filenamePrefix )

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.

Arguments:
filenamePrefix: the UTF-8 filename prefix to match, which should end with a slash (/) character

void getDefaultSecurityManager ( out nsIXPCSecurityManager manager , out PRUint16 flags )

Arguments:
manager
flags

nsIXPCFunctionThisTranslator getFunctionThisTranslator ( nsIIDRef IID )

Arguments:
IID

void getSecurityManagerForJSContext ( JSContextPtr* JSContext , out nsIXPCSecurityManager manager , out PRUint16 flags )

Arguments:
JSContext
manager
flags

nsIXPConnectWrappedNative getWrappedNativeOfJSObject ( JSContextPtr* JSContext , JSObjectPtr* JSObj )

This only succeeds if the JSObject is a nsIXPConnectWrappedNative. A new wrapper is *never* constructed.

Arguments:
JSContext
JSObj

nsIXPConnectWrappedNative getWrappedNativeOfNativeObject ( JSContextPtr* JSContext , JSObjectPtr* scope , nsISupports COMObj , nsIIDRef IID )

This only succeeds if the native object is already wrapped by xpconnect. A new wrapper is *never* constructed.

Arguments:
JSContext
scope
COMObj
IID

nsIXPConnectJSObjectHolder getWrappedNativePrototype ( JSContextPtr* JSContext , JSObjectPtr* scope , nsIClassInfo classInfo )

Arguments:
JSContext
scope
classInfo

void initClasses ( JSContextPtr* JSContext , JSObjectPtr* globalJSObj )

Arguments:
JSContext
globalJSObj

nsIXPConnectJSObjectHolder initClassesWithNewWrappedGlobal ( JSContextPtr* JSContext , nsISupports COMObj , nsIIDRef IID , PRUint32 flags )

Arguments:
JSContext
COMObj
IID
flags

nsIVariant JSToVariant ( JSContextPtr* ctx , JSVal value )

Arguments:
ctx
value

void releaseJSContext ( JSContextPtr* JSContext , PRBool noGC )

Arguments:
JSContext
noGC

nsIXPConnectJSObjectHolder reparentWrappedNativeIfFound ( JSContextPtr* JSContext , JSObjectPtr* scope , JSObjectPtr* newParent , nsISupports COMObj )

Arguments:
JSContext
scope
newParent
COMObj

void restoreWrappedNativePrototype ( JSContextPtr* JSContext , JSObjectPtr* scope , nsIClassInfo classInfo , nsIXPConnectJSObjectHolder prototype )

Restore an old prototype for wrapped natives of type classInfo. This should be used only when restoring an old scope into a state close to where it was prior to being reinitialized.

Arguments:
JSContext
scope
classInfo
prototype

void setDefaultSecurityManager ( nsIXPCSecurityManager manager , PRUint16 flags )

The security manager to use when the current JSContext has no security manager.

Arguments:
manager
flags

nsIXPCFunctionThisTranslator setFunctionThisTranslator ( nsIIDRef IID , nsIXPCFunctionThisTranslator translator )

Arguments:
IID
translator

void setSafeJSContextForCurrentThread ( JSContextPtr* cx )

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.

Arguments:
cx

void setSecurityManagerForJSContext ( JSContextPtr* JSContext , nsIXPCSecurityManager manager , PRUint16 flags )

Arguments:
JSContext
manager
flags

void syncJSContexts ( )

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.


JSVal variantToJS ( JSContextPtr* ctx , JSObjectPtr* scope , nsIVariant value )

Arguments:
ctx
scope
value

void wrapJS ( JSContextPtr* JSContext , JSObjectPtr* JSObj , nsIIDRef IID , out nsQIResult* result )

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

Arguments:
JSContext
JSObj
IID
result

void wrapJSAggregatedToNative ( nsISupports outer , JSContextPtr* JSContext , JSObjectPtr* JSObj , nsIIDRef IID , 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

Arguments:
outer
JSContext
JSObj
IID
result

nsIXPConnectJSObjectHolder wrapNative ( JSContextPtr* JSContext , JSObjectPtr* scope , nsISupports COMObj , nsIIDRef IID )

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

Arguments:
JSContext
scope
COMObj
IID

References

This interface is the type of the following properties:

nsIXPConnectWrappedNative.XPConnect

Reference documentation is generated from Mozilla's source.

Add a note User Contributed Notes
No comments available

Copyright © 1999 - 2005 XULPlanet.com