Back to index

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

#include <xpcprivate.h>

List of all members.

Public Member Functions

jsval GetName () const
PRUint16 GetIndex () const
JSBool GetValue (XPCCallContext &ccx, XPCNativeInterface *iface, jsval *pval)
JSBool IsMethod () const
JSBool IsConstant () const
JSBool IsAttribute () const
JSBool IsWritableAttribute () const
JSBool IsReadOnlyAttribute () const
void SetName (jsval a)
void SetMethod (PRUint16 index)
void SetConstant (PRUint16 index)
void SetReadOnlyAttribute (PRUint16 index)
void SetWritableAttribute ()
 XPCNativeMember ()
 ~XPCNativeMember ()
void DealWithDyingGCThings (JSContext *cx, XPCJSRuntime *rt)

Static Public Member Functions

static JSBool GetCallInfo (XPCCallContext &ccx, JSObject *funobj, XPCNativeInterface **pInterface, XPCNativeMember **pMember)

Private Types

enum  {
  RESOLVED = 0x01, METHOD = 0x02, CONSTANT = 0x04, GETTER = 0x08,
  SETTER_TOO = 0x10
}

Private Member Functions

JSBool IsResolved () const
JSBool Resolve (XPCCallContext &ccx, XPCNativeInterface *iface)

Private Attributes

jsval mName
jsval mVal
PRUint16 mIndex
PRUint16 mFlags

Detailed Description

Definition at line 1139 of file xpcprivate.h.


Member Enumeration Documentation

anonymous enum [private]
Enumerator:
RESOLVED 
METHOD 
CONSTANT 
GETTER 
SETTER_TOO 

Definition at line 1198 of file xpcprivate.h.

         {
        RESOLVED    = 0x01,
        METHOD      = 0x02,
        CONSTANT    = 0x04,
        GETTER      = 0x08,
        SETTER_TOO  = 0x10
    };

Constructor & Destructor Documentation

Definition at line 1186 of file xpcprivate.h.

Definition at line 1187 of file xpcprivate.h.


Member Function Documentation

Definition at line 1189 of file xpcprivate.h.

Here is the call graph for this function:

Here is the caller graph for this function:

JSBool XPCNativeMember::GetCallInfo ( XPCCallContext ccx,
JSObject funobj,
XPCNativeInterface **  pInterface,
XPCNativeMember **  pMember 
) [static]

Definition at line 91 of file xpcwrappednativeinfo.cpp.

{
    jsval ifaceVal;
    jsval memberVal;

    if(!JS_GetReservedSlot(ccx, funobj, 0, &ifaceVal) ||
       !JS_GetReservedSlot(ccx, funobj, 1, &memberVal) ||
       !JSVAL_IS_INT(ifaceVal) || !JSVAL_IS_INT(memberVal))
    {
        return JS_FALSE;
    }

    *pInterface = (XPCNativeInterface*) JSVAL_TO_PRIVATE(ifaceVal);
    *pMember = (XPCNativeMember*) JSVAL_TO_PRIVATE(memberVal);

    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRUint16 XPCNativeMember::GetIndex ( ) const [inline]

Definition at line 1149 of file xpcprivate.h.

{return mIndex;}

Here is the caller graph for this function:

jsval XPCNativeMember::GetName ( ) const [inline]

Definition at line 1147 of file xpcprivate.h.

{return mName;}

Here is the caller graph for this function:

JSBool XPCNativeMember::GetValue ( XPCCallContext ccx,
XPCNativeInterface iface,
jsval pval 
) [inline]

Definition at line 1151 of file xpcprivate.h.

        {if(!IsResolved() && !Resolve(ccx, iface)) return JS_FALSE;
         *pval = mVal; return JS_TRUE;}

Here is the caller graph for this function:

Definition at line 1161 of file xpcprivate.h.

        {return 0 != (mFlags & GETTER);}

Here is the caller graph for this function:

JSBool XPCNativeMember::IsConstant ( ) const [inline]

Definition at line 1158 of file xpcprivate.h.

        {return 0 != (mFlags & CONSTANT);}

Here is the caller graph for this function:

JSBool XPCNativeMember::IsMethod ( ) const [inline]

Definition at line 1155 of file xpcprivate.h.

        {return 0 != (mFlags & METHOD);}

Here is the caller graph for this function:

Definition at line 1167 of file xpcprivate.h.

        {return IsAttribute() && !IsWritableAttribute();}

Here is the caller graph for this function:

JSBool XPCNativeMember::IsResolved ( ) const [inline, private]

Definition at line 1195 of file xpcprivate.h.

{return mFlags & RESOLVED;}

Definition at line 1164 of file xpcprivate.h.

        {return 0 != (mFlags & SETTER_TOO);}

Here is the caller graph for this function:

Definition at line 113 of file xpcwrappednativeinfo.cpp.

{
    if(IsConstant())
    {
        const nsXPTConstant* constant;
        if(NS_FAILED(iface->GetInterfaceInfo()->GetConstant(mIndex, &constant)))
            return JS_FALSE;

        const nsXPTCMiniVariant& mv = *constant->GetValue();

        // XXX Big Hack!
        nsXPTCVariant v;
        v.flags = 0;
        v.type = constant->GetType();
        memcpy(&v.val, &mv.val, sizeof(mv.val));

        jsval resultVal;

        if(!XPCConvert::NativeData2JS(ccx, &resultVal, &v.val, v.type,
                                      nsnull, nsnull, nsnull))
            return JS_FALSE;

        {   // scoped lock
            XPCAutoLock lock(ccx.GetRuntime()->GetMapLock());
            mVal = resultVal;
            mFlags |= RESOLVED;
        }

        return JS_TRUE;
    }
    // else...

    // 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!

    JSContext* cx = ccx.GetSafeJSContext();
    if(!cx)
        return JS_FALSE;

    intN argc;
    intN flags;
    JSNative callback;

    if(IsMethod())
    {
        const nsXPTMethodInfo* info;
        if(NS_FAILED(iface->GetInterfaceInfo()->GetMethodInfo(mIndex, &info)))
            return JS_FALSE;

        // Note: ASSUMES that retval is last arg.
        argc = (intN) info->GetParamCount();
        if(argc && info->GetParam((uint8)(argc-1)).IsRetval())
            argc-- ;

        flags = 0;
        callback = XPC_WN_CallMethod;
    }
    else
    {
        if(IsWritableAttribute())
            flags = JSFUN_GETTER | JSFUN_SETTER;
        else
            flags = JSFUN_GETTER;
        argc = 0;
        callback = XPC_WN_GetterSetter;
    }

    JSFunction *fun = JS_NewFunction(cx, callback, argc, flags, nsnull,
                                     iface->GetMemberName(ccx, this));
    if(!fun)
        return JS_FALSE;

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

    AUTO_MARK_JSVAL(ccx, OBJECT_TO_JSVAL(funobj));

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

    {   // scoped lock
        XPCAutoLock lock(ccx.GetRuntime()->GetMapLock());
        mVal = OBJECT_TO_JSVAL(funobj);
        mFlags |= RESOLVED;
    }

    return JS_TRUE;
}

Here is the call graph for this function:

Definition at line 1176 of file xpcprivate.h.

Here is the caller graph for this function:

Definition at line 1173 of file xpcprivate.h.

Here is the caller graph for this function:

Definition at line 1171 of file xpcprivate.h.

{mName = a;}

Here is the caller graph for this function:

Definition at line 1179 of file xpcprivate.h.

Here is the caller graph for this function:

Definition at line 1182 of file xpcprivate.h.

Here is the caller graph for this function:


Member Data Documentation

Definition at line 1211 of file xpcprivate.h.

Definition at line 1210 of file xpcprivate.h.

Definition at line 1208 of file xpcprivate.h.

Definition at line 1209 of file xpcprivate.h.


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