Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Attributes
XPCDispIDArray Class Reference

This class represents an array of JSID's. More...

#include <XPCDispPrivate.h>

List of all members.

Public Member Functions

 XPCDispIDArray (XPCCallContext &ccx, JSIdArray *array)
 Initializes the array from the JSIdArray passed in.
PRUint32 Length () const
 Returns the length of the array.
jsval Item (JSContext *cx, PRUint32 index) const
 Returns an ID within the array.
void Mark ()
 Called to mark the ID's during GC.
void Unmark ()
 Called to unmark the ID's after GC has been done.
JSBool IsMarked () const
 Tests whether the ID is marked.
void MarkBeforeJSFinalize (JSContext *)
 NOP.

Private Attributes

JSBool mMarked
nsVoidArray mIDArray

Detailed Description

This class represents an array of JSID's.

It takes care of marking the ID's during GC

Definition at line 291 of file XPCDispPrivate.h.


Constructor & Destructor Documentation

Initializes the array from the JSIdArray passed in.

Parameters:
ccxXPConnect call context
arraya JS array of ID's

Definition at line 438 of file XPCDispTypeInfo.cpp.

                                                                    : 
    mMarked(JS_FALSE), mIDArray(array->length)
{
    // copy the JS ID Array to our internal array
    for(jsint index = 0; index < array->length; ++index)
    {
        mIDArray.ReplaceElementAt(NS_REINTERPRET_CAST(void*,
                                                      array->vector[index]), 
                                  index);
    }   
}

Member Function Documentation

JSBool XPCDispIDArray::IsMarked ( ) const [inline]

Tests whether the ID is marked.

Definition at line 459 of file XPCDispInlines.h.

{
    return mMarked;
}

Here is the caller graph for this function:

jsval XPCDispIDArray::Item ( JSContext cx,
PRUint32  index 
) const [inline]

Returns an ID within the array.

Parameters:
cxa JS context
indexindex into the array
Returns:
the ID as a jsval

Definition at line 442 of file XPCDispInlines.h.

{
    jsval val;
    if(!JS_IdToValue(cx, 
                     NS_REINTERPRET_CAST(jsid, 
                                         mIDArray.ElementAt(index)), &val))
        return JSVAL_NULL;
    return val;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRUint32 XPCDispIDArray::Length ( ) const [inline]

Returns the length of the array.

Returns:
length of the array

Definition at line 436 of file XPCDispInlines.h.

{
    return mIDArray.Count();
}

Here is the caller graph for this function:

Called to mark the ID's during GC.

Definition at line 450 of file XPCDispTypeInfo.cpp.

{
    // If already marked nothing to do
    if(IsMarked())
        return;
    mMarked = JS_TRUE;
    XPCCallContext ccx(NATIVE_CALLER);
    // Bail if our call context is bad
    if(!ccx.IsValid())
        return;

    PRInt32 count = Length();
    jsval val;
    JSContext* cx = ccx;
    // Iterate each of the ID's and mark them
    for(PRInt32 index = 0; index < count; ++index)
    {
        if(JS_IdToValue(cx,
                        NS_REINTERPRET_CAST(jsid,
                                            mIDArray.ElementAt(index)),
                        &val) &&
            JSVAL_IS_GCTHING(val))
        {
            JS_MarkGCThing(cx, NS_REINTERPRET_CAST(void*,val),
                           nsnull, nsnull);
        }
    }
}

Here is the call graph for this function:

NOP.

This is just here to make the AutoMarkingPtr code compile.

Definition at line 466 of file XPCDispInlines.h.

{
}

Called to unmark the ID's after GC has been done.

Definition at line 453 of file XPCDispInlines.h.


Member Data Documentation

Definition at line 332 of file XPCDispPrivate.h.

Definition at line 331 of file XPCDispPrivate.h.


The documentation for this class was generated from the following files: