Back to index

lightning-sunbird  0.9+nobinonly
Functions
XPCDispInterface.cpp File Reference

XPCDispInterface implementation This file contains the implementation of the XPCDispInterface class. More...

#include "xpcprivate.h"

Go to the source code of this file.

Functions

PRBool IsReflectable (FUNCDESC *pFuncDesc)
 Is this function reflectable This function determines if we should reflect a particular method of an interface.
static void ConvertInvokeKind (INVOKEKIND invokeKind, XPCDispInterface::Member &member)
 Sets a members type based on COM's INVOKEKIND.
static PRBool InitializeMember (JSContext *cx, ITypeInfo *pTypeInfo, FUNCDESC *pFuncDesc, XPCDispInterface::Member *pInfo)
static XPCDispInterface::MemberFindExistingMember (XPCDispInterface::Member *first, XPCDispInterface::Member *last, MEMBERID memberID)
PRBool CaseInsensitiveCompare (XPCCallContext &ccx, const PRUnichar *lhs, size_t lhsLength, jsval rhs)
 Compares a PRUnichar and a JS string ignoring case.

Detailed Description

XPCDispInterface implementation This file contains the implementation of the XPCDispInterface class.

Definition in file XPCDispInterface.cpp.


Function Documentation

PRBool CaseInsensitiveCompare ( XPCCallContext ccx,
const PRUnichar lhs,
size_t  lhsLength,
jsval  rhs 
) [inline]

Compares a PRUnichar and a JS string ignoring case.

Parameters:
ccxan XPConnect call context
lhrthe PRUnichar string to be compared
lhsLengththe length of the PRUnichar string
rhsthe JS value that is the other string to compare
Returns:
true if the strings are equal

Definition at line 290 of file XPCDispInterface.cpp.

{
    if(lhsLength == 0)
        return PR_FALSE;
    size_t rhsLength;
    PRUnichar* rhsString = xpc_JSString2PRUnichar(ccx, rhs, &rhsLength);
    return rhsString && 
        lhsLength == rhsLength &&
        _wcsnicmp(lhs, rhsString, lhsLength) == 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void ConvertInvokeKind ( INVOKEKIND  invokeKind,
XPCDispInterface::Member member 
) [static]

Sets a members type based on COM's INVOKEKIND.

Definition at line 139 of file XPCDispInterface.cpp.

{
    switch (invokeKind)
    {
        case INVOKE_FUNC:
        {
            member.SetFunction();
        }
        break;
        case INVOKE_PROPERTYGET:
        {
            member.MakeGetter();
        }
        break;
        case INVOKE_PROPERTYPUT:
        {
            member.MakeSetter();
        }
        break;
        // TODO: Handle putref
        default:
        {
            NS_ERROR("Invalid invoke kind found in COM type info");
        }
        break;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static XPCDispInterface::Member* FindExistingMember ( XPCDispInterface::Member first,
XPCDispInterface::Member last,
MEMBERID  memberID 
) [static]

Definition at line 201 of file XPCDispInterface.cpp.

{
    // Iterate backward since the last one in is the most likely match
    XPCDispInterface::Member * cur = last;
    if (cur != first)
    {
        do 
        {
            --cur;
            if(cur->GetMemID() == memberID)
                return cur;
        } while(cur != first);
    } 
    // no existing property, return the new one
    return last;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRBool InitializeMember ( JSContext cx,
ITypeInfo *  pTypeInfo,
FUNCDESC *  pFuncDesc,
XPCDispInterface::Member pInfo 
) [static]

Definition at line 168 of file XPCDispInterface.cpp.

{
    pInfo->SetMemID(pFuncDesc->memid);
    BSTR name;
    UINT nameCount;
    if(FAILED(pTypeInfo->GetNames(
        pFuncDesc->memid,
        &name,
        1,
        &nameCount)))
        return PR_FALSE;
    if(nameCount != 1)
        return PR_FALSE;
    JSString* str = JS_InternUCStringN(cx,
                                       NS_REINTERPRET_CAST(const jschar *, name),
                                       ::SysStringLen(name));
    ::SysFreeString(name);
    if(!str)
        return PR_FALSE;
    // Initialize
    pInfo = new (pInfo) XPCDispInterface::Member;
    if(!pInfo)
        return PR_FALSE;
    pInfo->SetName(STRING_TO_JSVAL(str));
    pInfo->ResetType();
    ConvertInvokeKind(pFuncDesc->invkind, *pInfo);
    pInfo->SetTypeInfo(pFuncDesc->memid, pTypeInfo, pFuncDesc);
    return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool IsReflectable ( FUNCDESC *  pFuncDesc) [inline]

Is this function reflectable This function determines if we should reflect a particular method of an interface.

Definition at line 51 of file XPCDispInterface.cpp.

{
    return (pFuncDesc->wFuncFlags&FUNCFLAG_FRESTRICTED) == 0 &&
           pFuncDesc->funckind == FUNC_DISPATCH || 
           pFuncDesc->funckind == FUNC_PUREVIRTUAL ||
           pFuncDesc->funckind == FUNC_VIRTUAL;
}

Here is the caller graph for this function: