nsIXPCScriptable

Note: This is not really an XPCOM interface. For example, callers must guarantee that they set the *_retval of the various methods that return a boolean to PR_TRUE before making the call. Implementations may skip writing to *_retval unless they want to return PR_FALSE.

Please add a summary to this article.
  Last changed in Gecko 1.9.1 (Firefox 3.5 / Thunderbird 3.0 / SeaMonkey 2.0)

Inherits from: nsISupports

Method overview

void preCreate(in nsISupports nativeObj, in JSContextPtr cx, in JSObjectPtr globalObj, out JSObjectPtr parentObj);
void create(in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj);
void postCreate(in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj);
PRBool addProperty(in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in JSVal id, in JSValPtr vp);
PRBool delProperty(in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in JSVal id, in JSValPtr vp);
PRBool getProperty(in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in JSVal id, in JSValPtr vp);
PRBool setProperty(in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in JSVal id, in JSValPtr vp);
PRBool enumerate(in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj);
PRBool newEnumerate(in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in PRUint32 enum_op, in JSValPtr statep, out JSID idp);
PRBool newResolve(in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in JSVal id, in PRUint32 flags, out JSObjectPtr objp);
PRBool convert(in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in PRUint32 type, in JSValPtr vp);
void finalize(in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj);
PRBool checkAccess(in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in JSVal id, in PRUint32 mode, in JSValPtr vp);
PRBool call(in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in PRUint32 argc, in JSValPtr argv, in JSValPtr vp);
PRBool construct(in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in PRUint32 argc, in JSValPtr argv, in JSValPtr vp);
PRBool hasInstance(in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in JSVal val, out PRBool bp);
void trace(in nsIXPConnectWrappedNative wrapper, in JSTracerPtr trc, in JSObjectPtr obj);
PRBool equality(in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in JSVal val);
JSObjectPtr outerObject(in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj);
JSObjectPtr innerObject(in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj);
void postCreatePrototype(in JSContextPtr cx, in JSObjectPtr proto);

 

Attributes

Attribute Type Description
className string  
scriptableFlags PRUint32  The bitwise or'd set of flags (define below) that indicate the behavior of this object.

Constants

Constant Value Description
WANT_PRECREATE 1 << 0  
WANT_CREATE 1 << 1  
WANT_POSTCREATE 1 << 2  
WANT_ADDPROPERTY 1 << 3  
WANT_DELPROPERTY 1 << 4  
WANT_GETPROPERTY 1 << 5  
WANT_SETPROPERTY 1 << 6  
WANT_ENUMERATE 1 << 7  
WANT_NEWENUMERATE 1 << 8  Indicates that the object wants to have its newEnumerate method called.
WANT_NEWRESOLVE 1 << 9  Indicates that the object wants to have its newResolve method called.
WANT_CONVERT 1 << 10  
WANT_FINALIZE 1 << 11  
WANT_CHECKACCESS 1 << 12  
WANT_CALL 1 << 13  
WANT_CONSTRUCT 1 << 14  
WANT_HASINSTANCE 1 << 15  
WANT_TRACE 1 << 16  
USE_JSSTUB_FOR_ADDPROPERTY 1 << 17  
USE_JSSTUB_FOR_DELPROPERTY 1 << 18  
USE_JSSTUB_FOR_SETPROPERTY 1 << 19  
DONT_ENUM_STATIC_PROPS 1 << 20  
DONT_ENUM_QUERY_INTERFACE 1 << 21  
DONT_ASK_INSTANCE_FOR_SCRIPTABLE 1 << 22  
CLASSINFO_INTERFACES_ONLY 1 << 23  
ALLOW_PROP_MODS_DURING_RESOLVE 1 << 24  
ALLOW_PROP_MODS_TO_PROTOTYPE 1 << 25  
DONT_SHARE_PROTOTYPE 1 << 26  
DONT_REFLECT_INTERFACE_NAMES 1 << 27  
WANT_EQUALITY 1 << 28  
WANT_OUTER_OBJECT 1 << 29  
WANT_INNER_OBJECT 1 << 30  
RESERVED 1 << 31 The high order bit is RESERVED for consumers of these flags. No implementor of this interface should ever return flags with this bit set.

 

Methods

preCreate()

 void preCreate(
   in nsISupports nativeObj,
   in JSContextPtr cx,
   in JSObjectPtr globalObj,
   out JSObjectPtr parentObj
 );
Parameters
nativeObj
cx
globalObj
parentObj

create()

 void create(
   in nsIXPConnectWrappedNative wrapper,
   in JSContextPtr cx,
   in JSObjectPtr obj
 );
Parameters
wrapper
cx
obj

postCreate()

 void postCreate(
   in nsIXPConnectWrappedNative wrapper,
   in JSContextPtr cx,
   in JSObjectPtr obj
 );
Parameters
wrapper
cx
obj

addProperty()

 PRBool addProperty(
   in nsIXPConnectWrappedNative wrapper,
   in JSContextPtr cx,
   in JSObjectPtr obj,
   in JSVal id,
   in JSValPtr vp
 );
Parameters
wrapper
cx
obj
id
vp
Return value

 

delProperty()

 PRBool delProperty(
   in nsIXPConnectWrappedNative wrapper,
   in JSContextPtr cx,
   in JSObjectPtr obj,
   in JSVal id,
   in JSValPtr vp
 );
Parameters
wrapper
cx
obj
id
vp
Return value

 

getProperty()

 PRBool getProperty(
   in nsIXPConnectWrappedNative wrapper,
   in JSContextPtr cx,
   in JSObjectPtr obj,
   in JSVal id,
   in JSValPtr vp
 );
Parameters
wrapper
cx
obj
id
vp
Return value

NS_SUCCESS_I_DID_SOMETHING if this method does something.

 

setProperty()

 PRBool setProperty(
   in nsIXPConnectWrappedNative wrapper,
   in JSContextPtr cx,
   in JSObjectPtr obj,
   in JSVal id,
   in JSValPtr vp
 );
Parameters
wrapper
cx
obj
id
vp
Return value

NS_SUCCESS_I_DID_SOMETHING if this method does something.

 

enumerate()

 PRBool enumerate(
   in nsIXPConnectWrappedNative wrapper,
   in JSContextPtr cx,
   in JSObjectPtr obj
 );
Parameters
wrapper
cx
obj
Return value

 

newEnumerate()

This method is called when the WANT_NEWENUMERATE flag is set.  It allows the object to implement the for..in enumeration in JavaScript.

This is very similar to JSClass.enumerate.
 PRBool newEnumerate(
   in nsIXPConnectWrappedNative wrapper,
   in JSContextPtr cx,
   in JSObjectPtr obj,
   in PRUint32 enum_op,
   in JSValPtr statep,
   out JSID idp
 );
Parameters
wrapper
cx
The pointer to the JSContext newEnumerate is being called from.
obj
The pointer to the JSObject being enumerated.
enum_op
Indicates what statep and idp represent, as well as indicates how the function should behave.  This will always be one of three values:

JSENUMERATE_INIT

A new, opaque iterator state should be allocated and stored in statep.  You can use PRIVATE_TO_JSVAL() to tag the pointer to be stored.  If idp is non-null, and provided the number of enumerable properties is known, the number of properties that will be enumerated should be returned as an integer jsval in idp. If idp is non-null and the number of enumerable properties cannot be computed in advance, idp should be set to JSVAL_ZERO.

Your function might be passed a null pointer for idp.

JSENUMERATE_NEXT

A previously allocated opaque iterator state is passed in via statep. Return the next jsid in the iteration using idp. The opaque iterator state pointed at by statep is destroyed and *statep is set to JSVAL_NULL if there are no properties left to enumerate.

JSENUMERATE_DESTROY

This function should destroy the opaque iterator state previously allocated in statep by this function when enum_op was JSENUMERATE_INIT.

statep
An in/out pointer to a jsval whose meaning depends on the value of enum_op.
idp
An in/out pointer to a jsid whose meaning depends on the value of enum_op.

Return value

 This should (although does not need to) return PR_TRUE to indicate success or must return PR_FALSE to indicate failure.

newResolve()

This method is called when the WANT_NEWRESOLVE flag is set.  When this method is called, XPConnect is attempting to resolve a lazy property named by id on obj.  The JS engine will check if the property named by id is defined after this method has been called.

This is very similar to JSNewResolveOp.
If an implementation of this method throws an error code, the prototype chain will not be checked for the property.
 PRBool newResolve(
   in nsIXPConnectWrappedNative wrapper,
   in JSContextPtr cx,
   in JSObjectPtr obj,
   in JSVal id,
   in PRUint32 flags,
   out JSObjectPtr objp
 );
Parameters
wrapper
cx
The pointer to the JSContext newResolve is being called from.
obj
The pointer to the JSObject that the property named by id that is being accessed.
id
The name or index of the property being accessed as a jsval.
flags
The flags that describe the access to the property named by id.  See JS_LookupProperty for the flags and their meaning.
objp
An out parameter that, on success, points to the JSObject that the property named by id has been defined on.  If the property named by id was not defined, this should be set to NULL.
Return value

 This should (although does not need to) return PR_TRUE to indicate success or must return PR_FALSE to indicate failure.

convert()

 PRBool convert(
   in nsIXPConnectWrappedNative wrapper,
   in JSContextPtr cx,
   in JSObjectPtr obj,
   in PRUint32 type,
   in JSValPtr vp
 );
Parameters
wrapper
cx
obj
type
vp
Return value

 

finalize()

 void finalize(
   in nsIXPConnectWrappedNative wrapper,
   in JSContextPtr cx,
   in JSObjectPtr obj
 );
Parameters
wrapper
cx
obj

checkAccess()

 PRBool checkAccess(
   in nsIXPConnectWrappedNative wrapper,
   in JSContextPtr cx,
   in JSObjectPtr obj,
   in JSVal id,
   in PRUint32 mode,
   in JSValPtr vp
 );
Parameters
wrapper
cx
obj
id
mode
vp
Return value

 

call()

 PRBool call(
   in nsIXPConnectWrappedNative wrapper,
   in JSContextPtr cx,
   in JSObjectPtr obj,
   in PRUint32 argc,
   in JSValPtr argv,
   in JSValPtr vp
 );
Parameters
wrapper
cx
obj
argc
argv
vp
Return value

 

construct()

 PRBool construct(
   in nsIXPConnectWrappedNative wrapper,
   in JSContextPtr cx,
   in JSObjectPtr obj,
   in PRUint32 argc,
   in JSValPtr argv,
   in JSValPtr vp
 );
Parameters
wrapper
cx
obj
argc
argv
vp
Return value

 

hasInstance()

 PRBool hasInstance(
   in nsIXPConnectWrappedNative wrapper,
   in JSContextPtr cx,
   in JSObjectPtr obj,
   in JSVal val,
   out PRBool bp
 );
Parameters
wrapper
cx
obj
val
bp
Return value

 

trace()

 void trace(
   in nsIXPConnectWrappedNative wrapper,
   in JSTracerPtr trc,
   in JSObjectPtr obj
 );
Parameters
wrapper
trc
obj

equality()

 PRBool equality(
   in nsIXPConnectWrappedNative wrapper,
   in JSContextPtr cx,
   in JSObjectPtr obj,
   in JSVal val
 );
Parameters
wrapper
cx
obj
val
Return value

 

outerObject()

 JSObjectPtr outerObject(
   in nsIXPConnectWrappedNative wrapper,
   in JSContextPtr cx,
   in JSObjectPtr obj
 );
Parameters
wrapper
cx
obj
Return value

 

innerObject()

 JSObjectPtr innerObject(
   in nsIXPConnectWrappedNative wrapper,
   in JSContextPtr cx,
   in JSObjectPtr obj
 );
Parameters
wrapper
cx
obj
Return value

 

Document Tags and Contributors

 Contributors to this page: Sheppy, Jürgen Jeka, sdwilsh, Eff2k5
 Last updated by: Sheppy,