Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes
XPCDispParams Class Reference

This is a helper class that factored out the parameter cleanup code. More...

#include <XPCDispPrivate.h>

List of all members.

Public Member Functions

 XPCDispParams (PRUint32 args)
 Initializes the parameters object.
 ~XPCDispParams ()
 Cleans up the parameters' data.
void SetNamedPropID ()
 This sets the named prop ID to our local mPropId.
VARIANT & GetParamRef (PRUint32 index)
 Returns a reference to a parameter.
_variant_t GetParam (PRUint32 index) const
 Returns the parameter by value.
voidGetOutputBuffer (PRUint32 index)
 Returns the output buffer for an output parameter.
DISPPARAMS * GetDispParams () const
 Returns a DISPPARAMS structure pointer for the parameters.
uintN GetParamCount () const
 Returns the number of parameters.
void InsertParam (_variant_t &var)
 Inserts a parameter This is mainly used for parameterized properties.

Private Types

enum  { DEFAULT_ARG_ARRAY_SIZE = 8, DEFAULT_REF_BUFFER_SIZE = 8 * sizeof(VARIANT) }

Private Member Functions

 XPCDispParams (const XPCDispParams &other)
 Don't allow copying.
XPCDispParamsoperator= (const XPCDispParams &)
 We don't allow assignments.

Static Private Member Functions

static PRUint32 RefBufferSize (PRUint32 args)

Private Attributes

DISPPARAMS mDispParams
char * mRefBuffer
VARIANT * mDispParamsAllocated
char * mRefBufferAllocated
char mStackRefBuffer [DEFAULT_REF_BUFFER_SIZE]
 Used by output/ref variant types.
VARIANT mStackArgs [DEFAULT_ARG_ARRAY_SIZE]
DISPID mPropID

Detailed Description

This is a helper class that factored out the parameter cleanup code.

Definition at line 1198 of file XPCDispPrivate.h.


Member Enumeration Documentation

anonymous enum [private]
Enumerator:
DEFAULT_ARG_ARRAY_SIZE 
DEFAULT_REF_BUFFER_SIZE 

Definition at line 1261 of file XPCDispPrivate.h.

    {
        DEFAULT_ARG_ARRAY_SIZE = 8,
        DEFAULT_REF_BUFFER_SIZE = 8 * sizeof(VARIANT)
    };

Constructor & Destructor Documentation

Initializes the parameters object.

Parameters:
argsthe number of parameters this object will hold

Definition at line 45 of file XPCDispParams.cpp.

                                          : 
    mRefBuffer(mStackRefBuffer + sizeof(VARIANT)),
    mDispParamsAllocated(nsnull),
    mRefBufferAllocated(nsnull),
    mPropID(DISPID_PROPERTYPUT)
#ifdef DEBUG
    ,mInserted(PR_FALSE)
#endif
{
    if(args >= DEFAULT_ARG_ARRAY_SIZE)
    {
        mRefBufferAllocated = new char[RefBufferSize(args)];
        mRefBuffer = mRefBufferAllocated + sizeof(VARIANT);
    }
    // Initialize the full buffer that was allocated
    memset(mRefBuffer - sizeof(VARIANT), 0, RefBufferSize(args));
    // Initialize the IDispatch parameters
    mDispParams.cArgs = args;
    if(args == 0)
        mDispParams.rgvarg = nsnull;
    else if (args <= DEFAULT_ARG_ARRAY_SIZE)
        mDispParams.rgvarg = mStackArgs + 1;
    else
    {
        mDispParamsAllocated = new VARIANT[args + 1];
        mDispParams.rgvarg =  mDispParamsAllocated + 1;
    }
    mDispParams.rgdispidNamedArgs = nsnull;
    mDispParams.cNamedArgs = 0;
}

Here is the call graph for this function:

Cleans up the parameters' data.

Definition at line 77 of file XPCDispParams.cpp.

{
    // Cleanup the variants
    for(PRUint32 index = 0; index < mDispParams.cArgs; ++index)
        VariantClear(mDispParams.rgvarg + index);
    // Cleanup if we allocated the variant array. Remember that
    // our buffer may point one element into the allocate buffer
    delete [] mRefBufferAllocated;
    delete [] mDispParamsAllocated;
}
XPCDispParams::XPCDispParams ( const XPCDispParams other) [inline, private]

Don't allow copying.

Definition at line 1253 of file XPCDispPrivate.h.

                                               {
        NS_ERROR("XPCDispParams can't be copied"); }

Member Function Documentation

DISPPARAMS* XPCDispParams::GetDispParams ( ) const [inline]

Returns a DISPPARAMS structure pointer for the parameters.

Returns:
a DISPPARAMS structure pointer for the parameters

Definition at line 1237 of file XPCDispPrivate.h.

{ return &NS_CONST_CAST(XPCDispParams*,this)->mDispParams; }

Here is the caller graph for this function:

Returns the output buffer for an output parameter.

Parameters:
indexindex of the output parameter
Returns:
a pointer to the buffer for the output parameter

Definition at line 614 of file XPCDispInlines.h.

{
    NS_ASSERTION(index < mDispParams.cArgs, "XPCDispParams::GetParam bounds error");
    return mRefBuffer + sizeof(VARIANT) * index;
}

Here is the caller graph for this function:

_variant_t XPCDispParams::GetParam ( PRUint32  index) const [inline]

Returns the parameter by value.

Parameters:
indexindex of the parameter
Returns:
a copy of the parameter

Definition at line 608 of file XPCDispInlines.h.

{
    return NS_CONST_CAST(XPCDispParams*,this)->GetParamRef(index);
}
uintN XPCDispParams::GetParamCount ( ) const [inline]

Returns the number of parameters.

Returns:
the number of parameters

Definition at line 1242 of file XPCDispPrivate.h.

{ return mDispParams.cArgs; }

Here is the caller graph for this function:

VARIANT & XPCDispParams::GetParamRef ( PRUint32  index) [inline]

Returns a reference to a parameter.

Parameters:
indexindex of the parameter
Returns:
a reference to the parameter at index

Definition at line 601 of file XPCDispInlines.h.

{
    NS_ASSERTION(index < mDispParams.cArgs, "XPCDispParams::GetParam bounds error");
    return mDispParams.rgvarg[mDispParams.cArgs - index - 1];
}

Here is the caller graph for this function:

void XPCDispParams::InsertParam ( _variant_t &  var)

Inserts a parameter This is mainly used for parameterized properties.

Parameters:
varthe parameter to insert

Definition at line 88 of file XPCDispParams.cpp.

{
#ifdef DEBUG
    NS_ASSERTION(!mInserted, 
                 "XPCDispParams::InsertParam cannot be called more than once");
    mInserted = PR_TRUE;
#endif
    // Bump the pointer back and increment the arg count
    --mDispParams.rgvarg;
    mRefBuffer -= sizeof(VARIANT);
    ++mDispParams.cArgs;
    // Assign the value
    mDispParams.rgvarg[0] = var.Detach();
    // initialize the ref buffer
    memset(mRefBuffer, 0, sizeof(VARIANT));
}

Here is the call graph for this function:

Here is the caller graph for this function:

XPCDispParams& XPCDispParams::operator= ( const XPCDispParams ) [inline, private]

We don't allow assignments.

Definition at line 1258 of file XPCDispPrivate.h.

                                                    {
        NS_ERROR("XPCDispParams can't be assigned"); }
static PRUint32 XPCDispParams::RefBufferSize ( PRUint32  args) [inline, static, private]

Definition at line 1267 of file XPCDispPrivate.h.

{ return (args + 1) * sizeof(VARIANT); }

Here is the caller graph for this function:

This sets the named prop ID to our local mPropId.

This is used for setters.

Definition at line 594 of file XPCDispInlines.h.

{
    mDispParams.rgdispidNamedArgs = &mPropID; 
    mDispParams.cNamedArgs = 1; 
}

Here is the caller graph for this function:


Member Data Documentation

DISPPARAMS XPCDispParams::mDispParams [private]

Definition at line 1269 of file XPCDispPrivate.h.

Definition at line 1271 of file XPCDispPrivate.h.

DISPID XPCDispParams::mPropID [private]

Definition at line 1278 of file XPCDispPrivate.h.

char* XPCDispParams::mRefBuffer [private]

Definition at line 1270 of file XPCDispPrivate.h.

Definition at line 1272 of file XPCDispPrivate.h.

Definition at line 1277 of file XPCDispPrivate.h.

Used by output/ref variant types.

Definition at line 1276 of file XPCDispPrivate.h.


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