Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions | Variables
XPCDispObject.cpp File Reference

Contains the XPCDispObject class implementation, XPC_IDispatch_GetterSetter, and XPC_IDispatch_CallMethod. More...

#include "xpcprivate.h"
#include "nsIActiveXSecurityPolicy.h"

Go to the source code of this file.

Defines

#define THROW_AND_RETURN_IF_BAD_WRAPPER(cx, wrapper)

Functions

static JSBool GetMember (XPCCallContext &ccx, JSObject *funobj, XPCNativeInterface *&iface, XPCDispInterface::Member *&member)
JSBool JS_DLL_CALLBACK XPC_IDispatch_CallMethod (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *vp)
 Callback for functions This callback is called by JS when a function on a JSObject proxying for an IDispatch instance.
JSBool JS_DLL_CALLBACK XPC_IDispatch_GetterSetter (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *vp)
 Callback for properties This callback is called by JS when a property is set or retrieved on a JSObject proxying for an IDispatch instance.

Variables

const nsID NSID_IDISPATCH = { 0x00020400, 0x0000, 0x0000, { 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 } }
 This is COM's IDispatch IID, but in XPCOM's nsID type.

Detailed Description

Contains the XPCDispObject class implementation, XPC_IDispatch_GetterSetter, and XPC_IDispatch_CallMethod.

Definition in file XPCDispObject.cpp.


Define Documentation

#define THROW_AND_RETURN_IF_BAD_WRAPPER (   cx,
  wrapper 
)
Value:
PR_BEGIN_MACRO                                                           \
    if(!wrapper)                                                             \
    {                                                                        \
        XPCThrower::Throw(NS_ERROR_XPC_BAD_OP_ON_WN_PROTO, cx);              \
        return JS_FALSE;                                                     \
    }                                                                        \
    if(!wrapper->IsValid())                                                  \
    {                                                                        \
        XPCThrower::Throw(NS_ERROR_XPC_HAS_BEEN_SHUTDOWN, cx);               \
        return JS_FALSE;                                                     \
    }                                                                        \
    PR_END_MACRO

Definition at line 436 of file XPCDispObject.cpp.


Function Documentation

static JSBool GetMember ( XPCCallContext ccx,
JSObject funobj,
XPCNativeInterface *&  iface,
XPCDispInterface::Member *&  member 
) [static]

Definition at line 419 of file XPCDispObject.cpp.

{
    jsval val;
    if(!JS_GetReservedSlot(ccx, funobj, 1, &val))
        return JS_FALSE;
    if(!JSVAL_IS_INT(val))
        return JS_FALSE;
    iface = NS_REINTERPRET_CAST(XPCNativeInterface*,JSVAL_TO_PRIVATE(val));
    if(!JS_GetReservedSlot(ccx, funobj, 0, &val))
        return JS_FALSE;
    if(!JSVAL_IS_INT(val))
        return JS_FALSE;
    member = NS_REINTERPRET_CAST(XPCDispInterface::Member*,JSVAL_TO_PRIVATE(val));
    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSBool JS_DLL_CALLBACK XPC_IDispatch_CallMethod ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval vp 
)

Callback for functions This callback is called by JS when a function on a JSObject proxying for an IDispatch instance.

JS callback function that is called when a function is invoked.

Parameters:
cxA pointer to a JS context
objJS object that the parameterized property is on
argcNumber of arguments in this call
argvThe parameters passed in if any
vpThe return value
Returns:
Returns JS_TRUE if the operation succeeded

Definition at line 462 of file XPCDispObject.cpp.

{
    NS_ASSERTION(JS_TypeOfValue(cx, argv[-2]) == JSTYPE_FUNCTION, "bad function");
    JSObject* funobj = JSVAL_TO_OBJECT(argv[-2]);
    XPCCallContext ccx(JS_CALLER, cx, obj, funobj, 0, argc, argv, vp);
    XPCWrappedNative* wrapper = ccx.GetWrapper();
    THROW_AND_RETURN_IF_BAD_WRAPPER(cx, wrapper);
    ccx.SetArgsAndResultPtr(argc, argv, vp);

    XPCDispInterface::Member* member;
    XPCNativeInterface* iface;
#ifdef DEBUG
    PRBool ok =
#endif
    GetMember(ccx, funobj, iface, member);
    NS_ASSERTION(ok, "GetMember faild in XPC_IDispatch_CallMethod");
    ccx.SetIDispatchInfo(iface, member);

    return XPCDispObject::Invoke(ccx, XPCDispObject::CALL_METHOD);
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSBool JS_DLL_CALLBACK XPC_IDispatch_GetterSetter ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval vp 
)

Callback for properties This callback is called by JS when a property is set or retrieved on a JSObject proxying for an IDispatch instance.

JS callback function that is called when a getter/setter is invoked.

Parameters:
cxA pointer to a JS context
objJS object that the parameterized property is on
argcNumber of arguments in this call
argvThe parameters passed in if any
vpThe return value
Returns:
Returns JS_TRUE if the operation succeeded

Definition at line 496 of file XPCDispObject.cpp.

{
    NS_ASSERTION(JS_TypeOfValue(cx, argv[-2]) == JSTYPE_FUNCTION, "bad function");
    JSObject* funobj = JSVAL_TO_OBJECT(argv[-2]);

    XPCCallContext ccx(JS_CALLER, cx, obj, funobj);
    XPCWrappedNative* wrapper = ccx.GetWrapper();
    THROW_AND_RETURN_IF_BAD_WRAPPER(cx, wrapper);

    ccx.SetArgsAndResultPtr(argc, argv, vp);
    XPCDispInterface::Member* member;
    XPCNativeInterface* iface;
#ifdef DEBUG
    PRBool ok =
#endif
    GetMember(ccx, funobj, iface, member);
    NS_ASSERTION(ok, "GetMember faild in XPC_IDispatch_CallMethod");

    ccx.SetIDispatchInfo(iface, member);
    return XPCDispObject::Invoke(ccx, argc != 0 ? XPCDispObject::CALL_SETTER : XPCDispObject::CALL_GETTER);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

const nsID NSID_IDISPATCH = { 0x00020400, 0x0000, 0x0000, { 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 } }

This is COM's IDispatch IID, but in XPCOM's nsID type.

Definition at line 49 of file XPCDispObject.cpp.