Back to index

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

Member information. More...

#include <XPCDispPrivate.h>

List of all members.

Classes

class  ParamInfo
 Parameter Information. More...

Public Member Functions

 Member ()
 ~Member ()
voidoperator new (size_t, Member *p) CPP_THROW_NEW
 Placement new is needed to initialize array in class XPCDispInterface.
PRBool IsSetter () const
 Is this a setter.
PRBool IsGetter () const
 Is this a getter.
PRBool IsProperty () const
 Is this a property.
PRBool IsParameterizedSetter () const
 Is this a parameterized setter.
PRBool IsParameterizedGetter () const
 Is this a parameterized getter.
PRBool IsParameterizedProperty () const
 Is this a parameterized property.
PRBool IsFunction () const
 Is this a function.
jsval GetName () const
 Returns the name of the method as a jsval.
JSBool GetValue (XPCCallContext &ccx, XPCNativeInterface *iface, jsval *retval) const
 Returns the function object as a value for the method.
PRUint32 GetDispID () const
 returns the dispid of the method
PRUint32 GetParamCount (PRBool getter=PR_FALSE) const
 returns the number of parameters of the method
ParamInfo GetParamInfo (PRUint32 index, PRBool getter=PR_FALSE) const
 Returns parameter information for the specified parameter.
void SetName (jsval name)
 Sets the name of the method.
void MakeGetter ()
 Marks the member as a getter.
void MakeSetter ()
 Marks the member as a setter.
void SetFunction ()
 Marks the member as a function Should not be called if MakeGetter/Setter is called.
void ResetType ()
 Used to reset the type of of member.
void SetTypeInfo (DISPID dispID, ITypeInfo *pTypeInfo, FUNCDESC *funcdesc)
 Sets the type information for the parameter.
void SetGetterFuncDesc (FUNCDESC *funcdesc)
 Sets the function description for the getter version of the function.
void SetMemID (DISPID memID)
 Sets the member ID.
DISPID GetMemID () const
 Returns the IDispatch ID of the member.

Private Types

enum  member_type {
  UNINITIALIZED = 0, SET_PROPERTY = 1, GET_PROPERTY = 2, FUNCTION = 4,
  RESOLVED = 8
}
 Our internal flags identify the type of member A member can be both getter/setter. More...

Private Member Functions

PRUint16 GetParamType (PRUint32 index) const
 Helper function to return the parameter type.
PRBool IsFlagSet (unsigned short flag) const
 Helper function to test if a flag is set in mType.

Private Attributes

DISPID mMemID
PRUint16 mType
jsval mVal
jsval mName
CComPtr< ITypeInfo > mTypeInfo
FUNCDESC * mFuncDesc
FUNCDESC * mGetterFuncDesc

Detailed Description

Member information.

This class is used within the XPCDispInterface to describe a specific method of an IDispatch interface.

Definition at line 694 of file XPCDispPrivate.h.


Member Enumeration Documentation

Our internal flags identify the type of member A member can be both getter/setter.

Enumerator:
UNINITIALIZED 
SET_PROPERTY 
GET_PROPERTY 
FUNCTION 
RESOLVED 

Definition at line 880 of file XPCDispPrivate.h.


Constructor & Destructor Documentation

Definition at line 117 of file XPCDispInlines.h.

{
    if(mTypeInfo)
    {
        // Test to see if we have a separate getter. If we only have a getter they can
        // be the same
        PRBool releaseGetter = mGetterFuncDesc != nsnull && mFuncDesc != mGetterFuncDesc;
        if(mFuncDesc) 
            mTypeInfo->ReleaseFuncDesc(mFuncDesc);
        if(releaseGetter)
            mTypeInfo->ReleaseFuncDesc(mGetterFuncDesc);
    }
}

Here is the caller graph for this function:


Member Function Documentation

returns the dispid of the method

Returns:
the dispid of the method

Definition at line 226 of file XPCDispInlines.h.

{
    return mFuncDesc->memid;
}

Here is the caller graph for this function:

DISPID XPCDispInterface::Member::GetMemID ( ) const [inline]

Returns the IDispatch ID of the member.

Returns:
the IDispatch ID of the member

Definition at line 272 of file XPCDispInlines.h.

{
    return mMemID;
}

Here is the caller graph for this function:

Returns the name of the method as a jsval.

Returns:
the name of the method as a jsval

Definition at line 214 of file XPCDispInlines.h.

{
    return mName;
}

Here is the caller graph for this function:

returns the number of parameters of the method

Parameters:
Askfrom getter instead of setter version of the function
Returns:
the number of parameters of the method

Definition at line 232 of file XPCDispInlines.h.

{
    return (getter && mGetterFuncDesc) ? mGetterFuncDesc->cParams : mFuncDesc->cParams;
}

Here is the caller graph for this function:

Returns parameter information for the specified parameter.

Parameters:
indexthe index of the parameter
Askfrom getter instead of setter version of the function
Returns:
Parameter information

Definition at line 238 of file XPCDispInlines.h.

{
    NS_ASSERTION(index < GetParamCount(getter), "Array bounds error");
    return ParamInfo(((getter && mGetterFuncDesc) ? mGetterFuncDesc->lprgelemdescParam : mFuncDesc->lprgelemdescParam) + index);
}

Here is the caller graph for this function:

PRUint16 XPCDispInterface::Member::GetParamType ( PRUint32  index) const [inline, private]

Helper function to return the parameter type.

Parameters:
indexindex of the parameter to return the type of
Returns:
The parameter type

Definition at line 260 of file XPCDispInlines.h.

{
    return mFuncDesc->lprgelemdescParam[index].paramdesc.wParamFlags; 
}

Returns the function object as a value for the method.

Parameters:
ccxan XPConnect call context
ifaceThe native interface of the function
retvalpointer to the jsval to receive the name
Returns:
JS_TRUE if the function object was return

Definition at line 320 of file XPCDispInterface.cpp.

{
    // This is a method or attribute - we'll be needing a function object

    // We need to use the safe context for this thread because we don't want
    // to parent the new (and cached forever!) function object to the current
    // JSContext's global object. That would be bad!
    if((mType & RESOLVED) == 0)
    {
        JSContext* cx = ccx.GetSafeJSContext();
        if(!cx)
            return JS_FALSE;

        intN argc;
        intN flags;
        JSNative callback;
        // Is this a function or a parameterized getter/setter
        if(IsFunction() || IsParameterizedProperty())
        {
            argc = GetParamCount();
            flags = 0;
            callback = XPC_IDispatch_CallMethod;
        }
        else
        {
            if(IsSetter())
            {
                flags = JSFUN_GETTER | JSFUN_SETTER;
            }
            else
            {
                flags = JSFUN_GETTER;
            }
            argc = 0;
            callback = XPC_IDispatch_GetterSetter;
        }

        JSFunction *fun = JS_NewFunction(cx, callback, argc, flags, nsnull,
                                         JS_GetStringBytes(JSVAL_TO_STRING(mName)));
        if(!fun)
            return JS_FALSE;

        JSObject* funobj = JS_GetFunctionObject(fun);
        if(!funobj)
            return JS_FALSE;

        // Store ourselves and our native interface within the JSObject
        if(!JS_SetReservedSlot(ccx, funobj, 0, PRIVATE_TO_JSVAL(this)))
            return JS_FALSE;

        if(!JS_SetReservedSlot(ccx, funobj, 1, PRIVATE_TO_JSVAL(iface)))
            return JS_FALSE;

        {   // scoped lock
            XPCAutoLock lock(ccx.GetRuntime()->GetMapLock());
            NS_CONST_CAST(Member*,this)->mVal = OBJECT_TO_JSVAL(funobj);
            NS_CONST_CAST(Member*,this)->mType |= RESOLVED;
        }
    }
    *retval = mVal;
    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool XPCDispInterface::Member::IsFlagSet ( unsigned short  flag) const [inline, private]

Helper function to test if a flag is set in mType.

Parameters:
flagthe flag to test for
Returns:
true if the flag is set

Definition at line 165 of file XPCDispInlines.h.

{
    return mType & flag ? PR_TRUE : PR_FALSE; 
}

Here is the caller graph for this function:

Is this a function.

Returns:
true if this is a function

Definition at line 189 of file XPCDispInlines.h.

{
    return IsFlagSet(FUNCTION);
}

Here is the caller graph for this function:

Is this a getter.

Returns:
true if this is a getter

Definition at line 177 of file XPCDispInlines.h.

{
    return IsFlagSet(GET_PROPERTY);
}

Is this a parameterized getter.

Returns:
true if this is a parameterized property

Definition at line 201 of file XPCDispInlines.h.

{
    return IsGetter() && (GetParamCount(PR_TRUE) > 1 ||
        (GetParamCount(PR_TRUE) == 1 && !GetParamInfo(0, PR_TRUE).IsRetVal()));
}

Is this a parameterized property.

Returns:
true if this is a parameterized property

Definition at line 208 of file XPCDispInlines.h.

Here is the caller graph for this function:

Is this a parameterized setter.

Returns:
true if this is a parameterized property

Definition at line 195 of file XPCDispInlines.h.

{
    return IsSetter() && GetParamCount() > 1;
}

Is this a property.

Returns:
true if this is a property

Definition at line 183 of file XPCDispInlines.h.

{
    return IsSetter() || IsGetter(); 
}

Here is the caller graph for this function:

Is this a setter.

Returns:
true if this is a setter

Definition at line 171 of file XPCDispInlines.h.

{
    return IsFlagSet(SET_PROPERTY);
}

Here is the caller graph for this function:

Marks the member as a getter.

Both MakeGetter and MakeSetter can be called, making it a setter/getter

Definition at line 138 of file XPCDispInlines.h.

{
    NS_ASSERTION(!IsFunction(), "Can't be function and property"); 
    mType |= GET_PROPERTY; 
}

Here is the caller graph for this function:

Marks the member as a setter.

Definition at line 145 of file XPCDispInlines.h.

{ 
    NS_ASSERTION(!IsFunction(), "Can't be function and property"); 
    mType |= SET_PROPERTY; 
}

Here is the caller graph for this function:

void * XPCDispInterface::Member::operator new ( size_t  ,
Member p 
) [inline]

Placement new is needed to initialize array in class XPCDispInterface.

Parameters:
pthe address of the member to construct
Returns:
p

Definition at line 132 of file XPCDispInlines.h.

{
    return p;
}

Used to reset the type of of member.

Definition at line 152 of file XPCDispInlines.h.

Here is the caller graph for this function:

Marks the member as a function Should not be called if MakeGetter/Setter is called.

Will assert

Definition at line 158 of file XPCDispInlines.h.

{ 
    NS_ASSERTION(!IsProperty(), "Can't be function and property"); 
    mType = FUNCTION; 
}

Here is the caller graph for this function:

void XPCDispInterface::Member::SetGetterFuncDesc ( FUNCDESC *  funcdesc) [inline]

Sets the function description for the getter version of the function.

Parameters:
funcdescfunction description

Definition at line 254 of file XPCDispInlines.h.

{
    mGetterFuncDesc = funcdesc;
}

Here is the caller graph for this function:

void XPCDispInterface::Member::SetMemID ( DISPID  memID) [inline]

Sets the member ID.

Parameters:
memIDthe IDispatch ID of the member

Definition at line 266 of file XPCDispInlines.h.

{
    mMemID = memID;
}

Here is the caller graph for this function:

Sets the name of the method.

Parameters:
namethe name to assign

Definition at line 220 of file XPCDispInlines.h.

{
    mName = name;
}

Here is the caller graph for this function:

void XPCDispInterface::Member::SetTypeInfo ( DISPID  dispID,
ITypeInfo *  pTypeInfo,
FUNCDESC *  funcdesc 
) [inline]

Sets the type information for the parameter.

Parameters:
dispIDthe DISPID of the member
pTypeInfoPointer to the COM type information
fundescfunction description

Definition at line 245 of file XPCDispInlines.h.

{
    mTypeInfo = pTypeInfo; 
    mFuncDesc = funcdesc;
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 892 of file XPCDispPrivate.h.

Definition at line 893 of file XPCDispPrivate.h.

Definition at line 875 of file XPCDispPrivate.h.

Definition at line 890 of file XPCDispPrivate.h.

Definition at line 888 of file XPCDispPrivate.h.

CComPtr<ITypeInfo> XPCDispInterface::Member::mTypeInfo [private]

Definition at line 891 of file XPCDispPrivate.h.

Definition at line 889 of file XPCDispPrivate.h.


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