Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Member Functions | Private Attributes
XPCDispInterface::Allocator Class Reference

Small utility to count members needed for XPConnect XPConnect has one entry for a property while IDispatch can have two Generally interfaces are small enough, that linear searching should be ok. More...

Collaboration diagram for XPCDispInterface::Allocator:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Allocator (JSContext *cx, ITypeInfo *pTypeInfo)
 Constructor, creates the initial buffer.
 ~Allocator ()
 Destructor, frees the buffer we allocated.
XPCDispInterfaceAllocate ()
 Returns the allocated XPCDispInterface object.

Private Member Functions

PRUint32 Count () const
 Returns the number of members found.
void Add (DISPID memID)
 Adds the member ID to the list.
PRBool Valid () const
 Allows our caller to handle unexpected problems like out of memory.
 Allocator (const Allocator &)
Allocatoroperator= (const Allocator &)

Private Attributes

DISPID * mMemIDs
PRUint32 mCount
PRUint32 mIDispatchMembers
JSContextmCX
ITypeInfo * mTypeInfo

Detailed Description

Small utility to count members needed for XPConnect XPConnect has one entry for a property while IDispatch can have two Generally interfaces are small enough, that linear searching should be ok.

Definition at line 1002 of file XPCDispPrivate.h.


Constructor & Destructor Documentation

XPCDispInterface::Allocator::Allocator ( JSContext cx,
ITypeInfo *  pTypeInfo 
)

Constructor, creates the initial buffer.

Parameters:
cxa JS context
pTypeInfopointer to IDispatch type info, our caller holds the reference we don't need to

Definition at line 59 of file XPCDispInterface.cpp.

                                                                          :
    mMemIDs(nsnull), mCount(0), mIDispatchMembers(0), mCX(cx), 
    mTypeInfo(pTypeInfo)
{
    TYPEATTR * attr;
    HRESULT hr = pTypeInfo->GetTypeAttr(&attr);
    if(SUCCEEDED(hr))
    {
        mIDispatchMembers = attr->cFuncs;
        mMemIDs = new DISPID[mIDispatchMembers];
        pTypeInfo->ReleaseTypeAttr(attr);
        // Bail if we couldn't create the buffer
        if(!mMemIDs)
            return;
    }
    for(UINT iMethod = 0; iMethod < mIDispatchMembers; iMethod++ )
    {
        FUNCDESC* pFuncDesc;
        if(SUCCEEDED(pTypeInfo->GetFuncDesc(iMethod, &pFuncDesc)))
        {
            // Only add the function to our list if it is at least at nesting level
            // 2 (i.e. defined in an interface derived from IDispatch).
            if(IsReflectable(pFuncDesc))
                Add(pFuncDesc->memid);
            pTypeInfo->ReleaseFuncDesc(pFuncDesc);
        }
    }
}

Here is the call graph for this function:

Destructor, frees the buffer we allocated.

Definition at line 287 of file XPCDispInlines.h.

{
    delete [] mMemIDs;
}

Member Function Documentation

void XPCDispInterface::Allocator::Add ( DISPID  memID) [private]

Adds the member ID to the list.

Parameters:
memIDThe member ID to test

Definition at line 88 of file XPCDispInterface.cpp.

{
    NS_ASSERTION(Valid(), "Add should never be called if out of memory");
    // Start from the end and work backwards, the last item is the most
    // likely to match
    PRUint32 index = mCount;
    while(index > 0)
    {
        if(mMemIDs[--index] == memID)
            return;
    };
    NS_ASSERTION(Count() < mIDispatchMembers, "mCount should always be less "
                                             "than the IDispatch member count "
                                             "here");
    mMemIDs[mCount++] = memID;
    return;
}

Here is the caller graph for this function:

Returns the allocated XPCDispInterface object.

Returns:
the allocated XPCDispInterface object

Definition at line 281 of file XPCDispInlines.h.

Here is the call graph for this function:

Here is the caller graph for this function:

PRUint32 XPCDispInterface::Allocator::Count ( ) const [inline, private]

Returns the number of members found.

Returns:
The number of members found

Definition at line 107 of file XPCDispInterface.cpp.

{
    return mCount;
}
Allocator& XPCDispInterface::Allocator::operator= ( const Allocator ) [private]
PRBool XPCDispInterface::Allocator::Valid ( ) const [inline, private]

Allows our caller to handle unexpected problems like out of memory.

Returns:
PR_TRUE if the buffer was allocated

Definition at line 292 of file XPCDispInlines.h.

{
    return mMemIDs ? PR_TRUE : PR_FALSE;
}

Member Data Documentation

Definition at line 1025 of file XPCDispPrivate.h.

Definition at line 1027 of file XPCDispPrivate.h.

Definition at line 1026 of file XPCDispPrivate.h.

Definition at line 1024 of file XPCDispPrivate.h.

Definition at line 1028 of file XPCDispPrivate.h.


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