Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Member Functions | Private Attributes
XPCDispTypeInfo::FuncDescArray Class Reference

Manages an array of FUNCDESC structs. More...

#include <XPCDispPrivate.h>

List of all members.

Public Member Functions

 FuncDescArray (XPCCallContext &ccx, JSObject *obj, const XPCDispIDArray &array, XPCDispNameArray &names)
 Initializes the function description array.
 ~FuncDescArray ()
 cleans up the function description array
FUNCDESC * Get (PRUint32 index)
 Retrieves a function description from the array.
void Release (FUNCDESC *)
 Releases a function description object.
PRUint32 Length () const
 Returns the length of the array.

Private Member Functions

PRBool BuildFuncDesc (XPCCallContext &ccx, JSObject *obj, XPCDispJSPropertyInfo &propInfo)
 Initializes a function description object.

Private Attributes

nsVoidArray mArray

Detailed Description

Manages an array of FUNCDESC structs.

Definition at line 345 of file XPCDispPrivate.h.


Constructor & Destructor Documentation

Initializes the function description array.

Definition at line 191 of file XPCDispTypeInfo.cpp.

{
    PRUint32 size = array.Length();
    names.SetSize(size);
    PRUint32 memid = 0;
    JSContext* cx = ccx;
    // Initialize each function description in the array
    for(PRUint32 index = 0; index < size; ++index)
    {
        XPCDispJSPropertyInfo propInfo(cx, ++memid, obj, array.Item(cx, index));
        names.SetName(index + 1, propInfo.GetName());
        if(!BuildFuncDesc(ccx, obj, propInfo))
            return;
        // non-readonly Properties get two function descriptions
        if(propInfo.IsProperty() && !propInfo.IsReadOnly())
        {
            propInfo.SetSetter();
            if(!BuildFuncDesc(ccx, obj, propInfo))
                return;
        }
    }
}

Here is the call graph for this function:

cleans up the function description array

Definition at line 214 of file XPCDispTypeInfo.cpp.

{
    PRUint32 size = mArray.Count();
    for(PRUint32 index = 0; index < size; ++index)
    {
        FUNCDESC* funcDesc = NS_REINTERPRET_CAST(FUNCDESC*,mArray.ElementAt(index));
        delete [] funcDesc->lprgelemdescParam;
        delete funcDesc;
    }
}

Member Function Documentation

Initializes a function description object.

Parameters:
ccxXPConnect context
objArray to used for the initialization
propInfoproperty information for the element/function

Definition at line 164 of file XPCDispTypeInfo.cpp.

{
    // While this memory is passed out, we're ultimately responsible to free it
    FUNCDESC* funcDesc = new FUNCDESC;
    if(!funcDesc)
        return PR_FALSE;
    mArray.AppendElement(funcDesc);
    // zero is reserved
    funcDesc->memid = propInfo.GetMemID();
    funcDesc->lprgscode = 0; // Not used (for 16 bit systems)
    funcDesc->funckind = FUNC_DISPATCH;
    funcDesc->invkind = propInfo.GetInvokeKind();
    funcDesc->callconv = CC_STDCALL;
    funcDesc->cParams = propInfo.GetParamCount();
    funcDesc->lprgelemdescParam = propInfo.GetParamInfo();
    // We might want to make all parameters optional since JS can handle that
    funcDesc->cParamsOpt = 0; // Optional parameters
    // This could be a problem, supposed to be used for functions of
    // type FUNC_VIRTUAL which we aren't, so zero should be ok
    funcDesc->oVft = 0;         // Specifies offset in VTBL for FUNC_VIRTUAL
    funcDesc->cScodes = 0;      // Counts the permitted return values.
    funcDesc->wFuncFlags = 0;   // Indicates the FUNCFLAGS of a function.
    propInfo.GetReturnType(ccx, funcDesc->elemdescFunc);
    return PR_TRUE;
}

Here is the call graph for this function:

FUNCDESC * XPCDispTypeInfo::FuncDescArray::Get ( PRUint32  index) [inline]

Retrieves a function description from the array.

Parameters:
indexindex into the array
Returns:
pointer to the function description

Definition at line 474 of file XPCDispInlines.h.

{
    return NS_REINTERPRET_CAST(FUNCDESC*,mArray[index]);
}

Returns the length of the array.

Returns:
the length of the array

Definition at line 485 of file XPCDispInlines.h.

{
    return mArray.Count();
}
void XPCDispTypeInfo::FuncDescArray::Release ( FUNCDESC *  ) [inline]

Releases a function description object.

Currently there is nothing to do as ownership is maintained by the object and the objects returned never live longer than the FuncDescArray instance they were created on

Definition at line 480 of file XPCDispInlines.h.

{
}

Member Data Documentation

Definition at line 376 of file XPCDispPrivate.h.


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