Back to index

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

#include <xpcprivate.h>

Inheritance diagram for nsXPCWrappedJSClass:
Inheritance graph
[legend]
Collaboration diagram for nsXPCWrappedJSClass:
Collaboration graph
[legend]

List of all members.

Public Member Functions

REFNSIID GetIID () const
XPCJSRuntimeGetRuntime () const
nsIInterfaceInfoGetInterfaceInfo () const
const char * GetInterfaceName ()
NS_IMETHOD DelegatedQueryInterface (nsXPCWrappedJS *self, REFNSIID aIID, void **aInstancePtr)
JSObjectGetRootJSObject (XPCCallContext &ccx, JSObject *aJSObj)
NS_IMETHOD CallMethod (nsXPCWrappedJS *wrapper, uint16 methodIndex, const nsXPTMethodInfo *info, nsXPTCMiniVariant *params)
JSObjectCallQueryInterfaceOnJSObject (XPCCallContext &ccx, JSObject *jsobj, REFNSIID aIID)
virtual ~nsXPCWrappedJSClass ()

Static Public Member Functions

static nsresult GetNewOrUsed (XPCCallContext &ccx, REFNSIID aIID, nsXPCWrappedJSClass **clazz)
static JSBool IsWrappedJS (nsISupports *aPtr)
static nsresult BuildPropertyEnumerator (XPCCallContext &ccx, JSObject *aJSObj, nsISimpleEnumerator **aEnumerate)
static nsresult GetNamedPropertyAsVariant (XPCCallContext &ccx, JSObject *aJSObj, jsval aName, nsIVariant **aResult)
static nsresult CheckForException (XPCCallContext &ccx, const char *aPropertyName, const char *anInterfaceName)

Private Types

enum  SizeMode { GET_SIZE, GET_LENGTH }

Private Member Functions

NS_DECL_ISUPPORTS NS_IMETHOD DebugDump (PRInt16 depth)
 nsXPCWrappedJSClass ()
 nsXPCWrappedJSClass (XPCCallContext &ccx, REFNSIID aIID, nsIInterfaceInfo *aInfo)
JSObjectNewOutObject (JSContext *cx)
JSBool IsReflectable (uint16 i) const
void SetReflectable (uint16 i, JSBool b)
JSBool GetArraySizeFromParam (JSContext *cx, const nsXPTMethodInfo *method, const nsXPTParamInfo &param, uint16 methodIndex, uint8 paramIndex, SizeMode mode, nsXPTCMiniVariant *params, JSUint32 *result)
JSBool GetInterfaceTypeFromParam (JSContext *cx, const nsXPTMethodInfo *method, const nsXPTParamInfo &param, uint16 methodIndex, const nsXPTType &type, nsXPTCMiniVariant *params, nsID *result)
void CleanupPointerArray (const nsXPTType &datum_type, JSUint32 array_count, void **arrayp)
void CleanupPointerTypeObject (const nsXPTType &type, void **pp)

Private Attributes

XPCJSRuntimemRuntime
nsIInterfaceInfomInfo
char * mName
nsIID mIID
uint32mDescriptors

Detailed Description

Definition at line 2117 of file xpcprivate.h.


Member Enumeration Documentation

Enumerator:
GET_SIZE 
GET_LENGTH 

Definition at line 2175 of file xpcprivate.h.


Constructor & Destructor Documentation

Definition at line 214 of file xpcwrappedjsclass.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 164 of file xpcwrappedjsclass.cpp.

    : mRuntime(ccx.GetRuntime()),
      mInfo(aInfo),
      mName(nsnull),
      mIID(aIID),
      mDescriptors(nsnull)
{
    NS_ADDREF(mInfo);
    NS_ADDREF_THIS();

    {   // scoped lock
        XPCAutoLock lock(mRuntime->GetMapLock());
        mRuntime->GetWrappedJSClassMap()->Add(this);
    }

    uint16 methodCount;
    if(NS_SUCCEEDED(mInfo->GetMethodCount(&methodCount)))
    {
        if(methodCount)
        {
            int wordCount = (methodCount/32)+1;
            if(nsnull != (mDescriptors = new uint32[wordCount]))
            {
                int i;
                // init flags to 0;
                for(i = wordCount-1; i >= 0; i--)
                    mDescriptors[i] = 0;

                for(i = 0; i < methodCount; i++)
                {
                    const nsXPTMethodInfo* info;
                    if(NS_SUCCEEDED(mInfo->GetMethodInfo(i, &info)))
                        SetReflectable(i, XPCConvert::IsMethodReflectable(*info));
                    else
                    {
                        delete [] mDescriptors;
                        mDescriptors = nsnull;
                        break;
                    }
                }
            }
        }
        else
        {
            mDescriptors = &zero_methods_descriptor;
        }
    }
}

Here is the call graph for this function:


Member Function Documentation

Definition at line 329 of file xpcwrappedjsclass.cpp.

{
    JSContext* cx = ccx.GetJSContext();
    nsresult retval = NS_ERROR_FAILURE;
    JSIdArray* idArray = nsnull;
    xpcPropertyBagEnumerator* enumerator = nsnull;
    int i;

    // Saved state must be restored, all exits through 'out'...
    AutoScriptEvaluate scriptEval(cx);
    scriptEval.StartEvaluating();

    idArray = JS_Enumerate(cx, aJSObj);
    if(!idArray)
        goto out;
    
    enumerator = new xpcPropertyBagEnumerator(idArray->length);
    if(!enumerator)
        goto out;
    NS_ADDREF(enumerator);
        
    for(i = 0; i < idArray->length; i++)
    {
        nsCOMPtr<nsIVariant> value;
        jsid idName = idArray->vector[i];
        nsresult rv;

        if(!GetNamedPropertyAsVariantRaw(ccx, aJSObj, idName, 
                                         getter_AddRefs(value), &rv))
        {
            if(NS_FAILED(rv))
                retval = rv;                                        
            goto out;
        }

        jsval jsvalName;
        if(!JS_IdToValue(cx, idName, &jsvalName))
            goto out;

        JSString* name = JS_ValueToString(cx, jsvalName);
        if(!name)
            goto out;

        nsCOMPtr<nsIProperty> property = 
            new xpcProperty((const PRUnichar*) JS_GetStringChars(name), 
                            (PRUint32) JS_GetStringLength(name),
                            value);
        if(!property)
            goto out;

        if(!enumerator->AppendElement(property))
            goto out;
    }

    NS_ADDREF(*aEnumerate = enumerator);
    retval = NS_OK;

out:
    NS_IF_RELEASE(enumerator);
    if(idArray)
        JS_DestroyIdArray(cx, idArray);

    return retval;
}

Here is the call graph for this function:

Definition at line 1018 of file xpcwrappedjsclass.cpp.

{
    jsval* stackbase;
    jsval* sp = nsnull;
    uint8 i;
    uint8 argc=0;
    uint8 stack_size;
    jsval result;
    uint8 paramCount=0;
    nsresult retval = NS_ERROR_FAILURE;
    nsresult pending_result = NS_OK;
    JSBool success;
    JSBool readyToDoTheCall = JS_FALSE;
    nsID  param_iid;
    uint8 outConversionFailedIndex;
    JSObject* obj;
    const char* name = info->GetName();
    jsval fval;
    void* mark;
    JSBool foundDependentParam;
    XPCContext* xpcc;
    JSContext* cx;
    JSObject* thisObj;

    // Make sure not to set the callee on ccx until after we've gone through
    // the whole nsIXPCFunctionThisTranslator bit.  That code uses ccx to
    // convert natives to JSObjects, but we do NOT plan to pass those JSObjects
    // to our real callee.
    XPCCallContext ccx(NATIVE_CALLER);
    if(ccx.IsValid())
    {
        xpcc = ccx.GetXPCContext();
        cx = ccx.GetJSContext();
    }
    else
    {
        xpcc = nsnull;
        cx = nsnull;
    }

    AutoScriptEvaluate scriptEval(cx);
#ifdef DEBUG_stats_jband
    PRIntervalTime startTime = PR_IntervalNow();
    PRIntervalTime endTime = 0;
    static int totalTime = 0;


    static int count = 0;
    static const int interval = 10;
    if(0 == (++count % interval))
        printf("<<<<<<<< %d calls on nsXPCWrappedJSs made.  (%d)\n", count, PR_IntervalToMilliseconds(totalTime));
#endif

    obj = thisObj = wrapper->GetJSObject();

    // XXX ASSUMES that retval is last arg. The xpidl compiler ensures this.
    paramCount = info->GetParamCount();
    argc = paramCount -
            (paramCount && info->GetParam(paramCount-1).IsRetval() ? 1 : 0);

    if(!cx || !xpcc || !IsReflectable(methodIndex))
        goto pre_call_clean_up;

    scriptEval.StartEvaluating(xpcWrappedJSErrorReporter);

    xpcc->SetPendingResult(pending_result);
    xpcc->SetException(nsnull);
    ccx.GetThreadData()->SetException(nsnull);

    // We use js_AllocStack, js_Invoke, and js_FreeStack so that the gcthings
    // we use as args will be rooted by the engine as we do conversions and
    // prepare to do the function call. This adds a fair amount of complexity,
    // but is a good optimization compared to calling JS_AddRoot for each item.

    // setup stack

    // if this isn't a function call then we don't need to push extra stuff
    if(info->IsGetter() || info->IsSetter())
    {
        stack_size = argc;
    }
    else
    {
        // allocate extra space for function and 'this'
        stack_size = argc + 2;

        // We get fval before allocating the stack to avoid gc badness that can
        // happen if the GetProperty call leaves our request and the gc runs
        // while the stack we allocate contains garbage.

        // If the interface is marked as a [function] then we will assume that
        // our JSObject is a function and not an object with a named method.

        PRBool isFunction;
        if(NS_FAILED(mInfo->IsFunction(&isFunction)))
            goto pre_call_clean_up;

        // In the xpidl [function] case we are making sure now that the 
        // JSObject is callable. If it is *not* callable then we silently 
        // fallback to looking up the named property...
        // (because jst says he thinks this fallback is 'The Right Thing'.)
        //
        // In the normal (non-function) case we just lookup the property by 
        // name and as long as the object has such a named property we go ahead
        // and try to make the call. If it turns out the named property is not
        // a callable object then the JS engine will throw an error and we'll
        // pass this along to the caller as an exception/result code.

        if(isFunction && 
           JS_TypeOfValue(ccx, OBJECT_TO_JSVAL(obj)) == JSTYPE_FUNCTION)
        {
            fval = OBJECT_TO_JSVAL(obj);

            // We may need to translate the 'this' for the function object.

            if(paramCount)
            {
                const nsXPTParamInfo& firstParam = info->GetParam(0);
                if(firstParam.IsIn())
                {
                    const nsXPTType& firstType = firstParam.GetType();
                    if(firstType.IsPointer() && firstType.IsInterfacePointer())
                    {
                        nsIXPCFunctionThisTranslator* translator;

                        IID2ThisTranslatorMap* map =
                            mRuntime->GetThisTranslatorMap();

                        {
                            XPCAutoLock lock(mRuntime->GetMapLock()); // scoped lock
                            translator = map->Find(mIID);
                        }

                        if(translator)
                        {
                            PRBool hideFirstParamFromJS = PR_FALSE;
                            nsIID* newWrapperIID = nsnull;
                            nsCOMPtr<nsISupports> newThis;

                            if(NS_FAILED(translator->
                              TranslateThis((nsISupports*)nativeParams[0].val.p,
                                            mInfo, methodIndex,
                                            &hideFirstParamFromJS,
                                            &newWrapperIID,
                                            getter_AddRefs(newThis))))
                            {
                                goto pre_call_clean_up;
                            }
                            if(hideFirstParamFromJS)
                            {
                                NS_ERROR("HideFirstParamFromJS not supported");
                                goto pre_call_clean_up;
                            }
                            if(newThis)
                            {
                                if(!newWrapperIID)
                                    newWrapperIID =
                                        NS_CONST_CAST(nsIID*,
                                                      &NS_GET_IID(nsISupports));
                                nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
                                JSBool ok =
                                  XPCConvert::NativeInterface2JSObject(ccx,
                                        getter_AddRefs(holder), newThis,
                                        newWrapperIID, obj, PR_FALSE, PR_FALSE,
                                        nsnull);
                                if(newWrapperIID != &NS_GET_IID(nsISupports))
                                    nsMemory::Free(newWrapperIID);
                                if(!ok ||
                                    NS_FAILED(holder->GetJSObject(&thisObj)))
                                {
                                    goto pre_call_clean_up;
                                }
                            }
                        }
                    }
                }
            }
        }
        else if(!JS_GetMethod(cx, obj, name, &thisObj, &fval))
        {
            // XXX We really want to factor out the error reporting better and
            // specifically report the failure to find a function with this name.
            // This is what we do below if the property is found but is not a
            // function. We just need to factor better so we can get to that
            // reporting path from here.
            goto pre_call_clean_up;
        }
    }

    // if stack_size is zero then we won't be needing a stack
    if(stack_size && !(stackbase = sp = js_AllocStack(cx, stack_size, &mark)))
    {
        retval = NS_ERROR_OUT_OF_MEMORY;
        goto pre_call_clean_up;
    }

    NS_ASSERTION(info->IsGetter() || sp, "Only a getter needs no stack.");

    // this is a function call, so push function and 'this'
    if(stack_size != argc)
    {
        *sp++ = fval;
        *sp++ = OBJECT_TO_JSVAL(thisObj);
    }

    // make certain we leave no garbage in the stack
    for(i = 0; i < argc; i++)
    {
        sp[i] = JSVAL_VOID;
    }

    // build the args
    for(i = 0; i < argc; i++)
    {
        const nsXPTParamInfo& param = info->GetParam(i);
        const nsXPTType& type = param.GetType();
        nsXPTType datum_type;
        JSUint32 array_count;
        PRBool isArray = type.IsArray();
        jsval val = JSVAL_NULL;
        AUTO_MARK_JSVAL(ccx, &val);
        PRBool isSizedString = isArray ?
                JS_FALSE :
                type.TagPart() == nsXPTType::T_PSTRING_SIZE_IS ||
                type.TagPart() == nsXPTType::T_PWSTRING_SIZE_IS;


        // verify that null was not passed for 'out' param
        if(param.IsOut() && !nativeParams[i].val.p)
        {
            retval = NS_ERROR_INVALID_ARG;
            goto pre_call_clean_up;
        }

        if(isArray)
        {
            if(NS_FAILED(mInfo->GetTypeForParam(methodIndex, &param, 1,
                                                &datum_type)))
                goto pre_call_clean_up;
        }
        else
            datum_type = type;

        if(param.IsIn())
        {
            nsXPTCMiniVariant* pv;

            if(param.IsOut())
                pv = (nsXPTCMiniVariant*) nativeParams[i].val.p;
            else
                pv = &nativeParams[i];

            if(datum_type.IsInterfacePointer() &&
               !GetInterfaceTypeFromParam(cx, info, param, methodIndex,
                                          datum_type, nativeParams,
                                          &param_iid))
                goto pre_call_clean_up;

            if(isArray || isSizedString)
            {
                if(!GetArraySizeFromParam(cx, info, param, methodIndex,
                                          i, GET_LENGTH, nativeParams,
                                          &array_count))
                    goto pre_call_clean_up;
            }

            // Figure out what our callee is
            if(info->IsGetter() || info->IsSetter())
            {
                // Pull the getter or setter off of |obj|
                uintN attrs;
                JSBool found;
                JSPropertyOp getter;
                JSPropertyOp setter;
                JSBool ok =
                    JS_GetPropertyAttrsGetterAndSetter(cx, obj, name,
                                                       &attrs, &found,
                                                       &getter, &setter);
                if(ok)
                {
                    if(info->IsGetter() && (attrs & JSPROP_GETTER))
                    {
                        // JSPROP_GETTER means the getter is actually a
                        // function object.
                        ccx.SetCallee((JSObject*)getter);
                    }
                    else if(info->IsSetter() && (attrs & JSPROP_SETTER))
                    {
                        // JSPROP_SETTER means the setter is actually a
                        // function object.
                        ccx.SetCallee((JSObject*)setter);
                    }
                }
            }
            else if(JSVAL_IS_OBJECT(fval))
            {
                ccx.SetCallee(JSVAL_TO_OBJECT(fval));
            }

            if(isArray)
            {

                if(!XPCConvert::NativeArray2JS(ccx, &val, (const void**)&pv->val,
                                               datum_type, &param_iid,
                                               array_count, obj, nsnull))
                    goto pre_call_clean_up;
            }
            else if(isSizedString)
            {
                if(!XPCConvert::NativeStringWithSize2JS(ccx, &val,
                                               (const void*)&pv->val,
                                               datum_type,
                                               array_count, nsnull))
                    goto pre_call_clean_up;
            }
            else
            {
                if(!XPCConvert::NativeData2JS(ccx, &val, &pv->val, type,
                                              &param_iid, obj, nsnull))
                    goto pre_call_clean_up;
            }
        }

        if(param.IsOut())
        {
            // create an 'out' object
            JSObject* out_obj = NewOutObject(cx);
            if(!out_obj)
            {
                retval = NS_ERROR_OUT_OF_MEMORY;
                goto pre_call_clean_up;
            }

            if(param.IsIn())
            {
                if(!OBJ_SET_PROPERTY(cx, out_obj,
                        mRuntime->GetStringID(XPCJSRuntime::IDX_VALUE),
                        &val))
                {
                    goto pre_call_clean_up;
                }
            }
            *sp++ = OBJECT_TO_JSVAL(out_obj);
        }
        else
            *sp++ = val;
    }



    readyToDoTheCall = JS_TRUE;

pre_call_clean_up:
    // clean up any 'out' params handed in
    for(i = 0; i < paramCount; i++)
    {
        const nsXPTParamInfo& param = info->GetParam(i);
        if(!param.IsOut())
            continue;

        const nsXPTType& type = param.GetType();
        if(!type.IsPointer())
            continue;
        void* p;
        if(!(p = nativeParams[i].val.p))
            continue;

        if(param.IsIn())
        {
            if(type.IsArray())
            {
                void** pp;
                if(nsnull != (pp = *((void***)p)))
                {

                    // we need to get the array length and iterate the items
                    JSUint32 array_count;
                    nsXPTType datum_type;

                    if(NS_SUCCEEDED(mInfo->GetTypeForParam(methodIndex, &param,
                                                           1, &datum_type)) &&
                       datum_type.IsPointer() &&
                       GetArraySizeFromParam(cx, info, param, methodIndex,
                                             i, GET_LENGTH, nativeParams,
                                             &array_count) && array_count)
                    {
                        CleanupPointerArray(datum_type, array_count, pp);
                    }
                    // always release the array if it is inout
                    nsMemory::Free(pp);
                }
            }
            else
                CleanupPointerTypeObject(type, (void**)p);
        }
        *((void**)p) = nsnull;
    }

    // Make sure "this" doesn't get deleted during this call.
    nsCOMPtr<nsIXPCWrappedJSClass> kungFuDeathGrip(this);

    result = JSVAL_NULL;
    AUTO_MARK_JSVAL(ccx, &result);

    if(!readyToDoTheCall)
        goto done;

    // do the deed - note exceptions

    JS_ClearPendingException(cx);

    if(info->IsGetter())
        success = JS_GetProperty(cx, obj, name, &result);
    else if(info->IsSetter())
        success = JS_SetProperty(cx, obj, name, sp-1);
    else
    {
        if(!JSVAL_IS_PRIMITIVE(fval))
        {
            // Lift current frame (or make new one) to include the args
            // and do the call.
            JSStackFrame *fp, *oldfp, frame;
            jsval *oldsp;

            fp = oldfp = cx->fp;
            if(!fp)
            {
                memset(&frame, 0, sizeof frame);
                cx->fp = fp = &frame;
            }
            oldsp = fp->sp;
            fp->sp = sp;

            success = js_Invoke(cx, argc, JSINVOKE_INTERNAL);

            result = fp->sp[-1];
            fp->sp = oldsp;
            if(oldfp != fp)
                cx->fp = oldfp;
        }
        else
        {
            // The property was not an object so can't be a function.
            // Let's build and 'throw' an exception.

            static const nsresult code =
                    NS_ERROR_XPC_JSOBJECT_HAS_NO_FUNCTION_NAMED;
            static const char format[] = "%s \"%s\"";
            const char * msg;
            char* sz = nsnull;

            if(nsXPCException::NameAndFormatForNSResult(code, nsnull, &msg) && msg)
                sz = JS_smprintf(format, msg, name);

            nsCOMPtr<nsIException> e;

            XPCConvert::ConstructException(code, sz, GetInterfaceName(), name,
                                           nsnull, getter_AddRefs(e));
            xpcc->SetException(e);
            if(sz)
                JS_smprintf_free(sz);
            success = JS_FALSE;
        }
    }

    if (!success)
    {
        retval = CheckForException(ccx, name, GetInterfaceName());
        goto done;
    }

    ccx.GetThreadData()->SetException(nsnull); // XXX necessary?

#define HANDLE_OUT_CONVERSION_FAILURE       \
        {outConversionFailedIndex = i; break;}

    // convert out args and result
    // NOTE: this is the total number of native params, not just the args
    // Convert independent params only.
    // When we later convert the dependent params (if any) we will know that
    // the params upon which they depend will have already been converted -
    // regardless of ordering.

    outConversionFailedIndex = paramCount;
    foundDependentParam = JS_FALSE;
    for(i = 0; i < paramCount; i++)
    {
        const nsXPTParamInfo& param = info->GetParam(i);
        if(!param.IsOut() && !param.IsDipper())
            continue;

        const nsXPTType& type = param.GetType();
        if(type.IsDependent())
        {
            foundDependentParam = JS_TRUE;
            continue;
        }

        jsval val;
        uint8 type_tag = type.TagPart();
        JSBool useAllocator = JS_FALSE;
        nsXPTCMiniVariant* pv;

        if(param.IsDipper())
            pv = (nsXPTCMiniVariant*) &nativeParams[i].val.p;
        else
            pv = (nsXPTCMiniVariant*) nativeParams[i].val.p;

        if(param.IsRetval())
            val = result;
        else if(JSVAL_IS_PRIMITIVE(stackbase[i+2]) ||
                !OBJ_GET_PROPERTY(cx, JSVAL_TO_OBJECT(stackbase[i+2]),
                    mRuntime->GetStringID(XPCJSRuntime::IDX_VALUE),
                    &val))
            HANDLE_OUT_CONVERSION_FAILURE

        // setup allocator and/or iid

        if(type_tag == nsXPTType::T_INTERFACE)
        {
            if(NS_FAILED(GetInterfaceInfo()->
                            GetIIDForParamNoAlloc(methodIndex, &param,
                                                  &param_iid)))
                HANDLE_OUT_CONVERSION_FAILURE
        }
        else if(type.IsPointer() && !param.IsShared() && !param.IsDipper())
            useAllocator = JS_TRUE;

        if(!XPCConvert::JSData2Native(ccx, &pv->val, val, type,
                                      useAllocator, &param_iid, nsnull))
            HANDLE_OUT_CONVERSION_FAILURE
    }

    // if any params were dependent, then we must iterate again to convert them.
    if(foundDependentParam && outConversionFailedIndex == paramCount)
    {
        for(i = 0; i < paramCount; i++)
        {
            const nsXPTParamInfo& param = info->GetParam(i);
            if(!param.IsOut())
                continue;

            const nsXPTType& type = param.GetType();
            if(!type.IsDependent())
                continue;

            jsval val;
            nsXPTCMiniVariant* pv;
            nsXPTType datum_type;
            JSBool useAllocator = JS_FALSE;
            JSUint32 array_count;
            PRBool isArray = type.IsArray();
            PRBool isSizedString = isArray ?
                    JS_FALSE :
                    type.TagPart() == nsXPTType::T_PSTRING_SIZE_IS ||
                    type.TagPart() == nsXPTType::T_PWSTRING_SIZE_IS;

            pv = (nsXPTCMiniVariant*) nativeParams[i].val.p;

            if(param.IsRetval())
                val = result;
            else if(!OBJ_GET_PROPERTY(cx, JSVAL_TO_OBJECT(stackbase[i+2]),
                        mRuntime->GetStringID(XPCJSRuntime::IDX_VALUE),
                        &val))
                HANDLE_OUT_CONVERSION_FAILURE

            // setup allocator and/or iid

            if(isArray)
            {
                if(NS_FAILED(mInfo->GetTypeForParam(methodIndex, &param, 1,
                                                    &datum_type)))
                    HANDLE_OUT_CONVERSION_FAILURE
            }
            else
                datum_type = type;

            if(datum_type.IsInterfacePointer())
            {
               if(!GetInterfaceTypeFromParam(cx, info, param, methodIndex,
                                             datum_type, nativeParams,
                                             &param_iid))
                    HANDLE_OUT_CONVERSION_FAILURE
            }
            else if(type.IsPointer() && !param.IsShared())
                useAllocator = JS_TRUE;

            if(isArray || isSizedString)
            {
                if(!GetArraySizeFromParam(cx, info, param, methodIndex,
                                          i, GET_LENGTH, nativeParams,
                                          &array_count))
                    HANDLE_OUT_CONVERSION_FAILURE
            }

            if(isArray)
            {
                if(array_count &&
                   !XPCConvert::JSArray2Native(ccx, (void**)&pv->val, val,
                                               array_count, array_count,
                                               datum_type,
                                               useAllocator, &param_iid,
                                               nsnull))
                    HANDLE_OUT_CONVERSION_FAILURE
            }
            else if(isSizedString)
            {
                if(!XPCConvert::JSStringWithSize2Native(ccx,
                                                   (void*)&pv->val, val,
                                                   array_count, array_count,
                                                   datum_type, useAllocator,
                                                   nsnull))
                    HANDLE_OUT_CONVERSION_FAILURE
            }
            else
            {
                if(!XPCConvert::JSData2Native(ccx, &pv->val, val, type,
                                              useAllocator, &param_iid,
                                              nsnull))
                    HANDLE_OUT_CONVERSION_FAILURE
            }
        }
    }

    if(outConversionFailedIndex != paramCount)
    {
        // We didn't manage all the result conversions!
        // We have to cleanup any junk that *did* get converted.

        for(uint8 k = 0; k < i; k++)
        {
            const nsXPTParamInfo& param = info->GetParam(k);
            if(!param.IsOut())
                continue;
            const nsXPTType& type = param.GetType();
            if(!type.IsPointer())
                continue;
            void* p;
            if(!(p = nativeParams[k].val.p))
                continue;

            if(type.IsArray())
            {
                void** pp;
                if(nsnull != (pp = *((void***)p)))
                {
                    // we need to get the array length and iterate the items
                    JSUint32 array_count;
                    nsXPTType datum_type;

                    if(NS_SUCCEEDED(mInfo->GetTypeForParam(methodIndex, &param,
                                                           1, &datum_type)) &&
                       datum_type.IsPointer() &&
                       GetArraySizeFromParam(cx, info, param, methodIndex,
                                             k, GET_LENGTH, nativeParams,
                                             &array_count) && array_count)
                    {
                        CleanupPointerArray(datum_type, array_count, pp);
                    }
                    nsMemory::Free(pp);
                }
            }
            else
                CleanupPointerTypeObject(type, (void**)p);
            *((void**)p) = nsnull;
        }
    }
    else
    {
        // set to whatever the JS code might have set as the result
        retval = pending_result;
    }

done:
    if(sp)
        js_FreeStack(cx, mark);

#ifdef DEBUG_stats_jband
    endTime = PR_IntervalNow();
    printf("%s::%s %d ( c->js ) \n", GetInterfaceName(), info->GetName(), PR_IntervalToMilliseconds(endTime-startTime));
    totalTime += endTime-startTime;
#endif
    return retval;
}

Here is the caller graph for this function:

Definition at line 229 of file xpcwrappedjsclass.cpp.

{
    JSContext* cx = ccx.GetJSContext();
    JSObject* id;
    jsval retval;
    JSObject* retObj;
    JSBool success = JS_FALSE;
    jsid funid;
    jsval fun;

    // check upfront for the existence of the function property
    funid = mRuntime->GetStringID(XPCJSRuntime::IDX_QUERY_INTERFACE);
    if(!OBJ_GET_PROPERTY(cx, jsobj, funid, &fun) || JSVAL_IS_PRIMITIVE(fun))
        return nsnull;

    // protect fun so that we're sure it's alive when we call it
    AUTO_MARK_JSVAL(ccx, fun);

    // Ensure that we are asking for a scriptable interface.
    // NB:  It's important for security that this check is here rather
    // than later, since it prevents untrusted objects from implementing
    // some interfaces in JS and aggregating a trusted object to
    // implement intentionally (for security) unscriptable interfaces.
    // We so often ask for nsISupports that we can short-circuit the test...
    if(!aIID.Equals(NS_GET_IID(nsISupports)))
    {
        nsCOMPtr<nsIInterfaceInfo> info;
        ccx.GetXPConnect()->GetInfoForIID(&aIID, getter_AddRefs(info));
        if(!info)
            return nsnull;
        PRBool canScript;
        if(NS_FAILED(info->IsScriptable(&canScript)) || !canScript)
            return nsnull;
    }

    // OK, it looks like we'll be calling into JS code.

    AutoScriptEvaluate scriptEval(cx);

    // XXX we should install an error reporter that will send reports to
    // the JS error console service.
    scriptEval.StartEvaluating();

    id = xpc_NewIDObject(cx, jsobj, aIID);
    if(id)
    {
        jsval args[1] = {OBJECT_TO_JSVAL(id)};
        success = JS_CallFunctionValue(cx, jsobj, fun, 1, args, &retval);
    }

    if(success)
        success = JS_ValueToObject(cx, retval, &retObj);

    return success ? retObj : nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsXPCWrappedJSClass::CheckForException ( XPCCallContext ccx,
const char *  aPropertyName,
const char *  anInterfaceName 
) [static]

Definition at line 875 of file xpcwrappedjsclass.cpp.

{
    XPCContext * xpcc = ccx.GetXPCContext();
    JSContext * cx = ccx.GetJSContext();
    nsCOMPtr<nsIException> xpc_exception;
    /* this one would be set by our error reporter */

    xpcc->GetException(getter_AddRefs(xpc_exception));
    if(xpc_exception)
        xpcc->SetException(nsnull);

    // get this right away in case we do something below to cause JS code
    // to run on this JSContext
    nsresult pending_result = xpcc->GetPendingResult();

    jsval js_exception;
    /* JS might throw an expection whether the reporter was called or not */
    if(JS_GetPendingException(cx, &js_exception))
    {
        if(!xpc_exception)
            XPCConvert::JSValToXPCException(ccx, js_exception, anInterfaceName,
                                            aPropertyName, getter_AddRefs(xpc_exception));

        /* cleanup and set failed even if we can't build an exception */
        if(!xpc_exception)
        {
            ccx.GetThreadData()->SetException(nsnull); // XXX necessary?
        }
        JS_ClearPendingException(cx);
    }

    if(xpc_exception)
    {
        nsresult e_result;
        if(NS_SUCCEEDED(xpc_exception->GetResult(&e_result)))
        {
            if(xpc_IsReportableErrorCode(e_result))
            {
#ifdef DEBUG
                static const char line[] =
                    "************************************************************\n";
                static const char preamble[] =
                    "* Call to xpconnect wrapped JSObject produced this error:  *\n";
                static const char cant_get_text[] =
                    "FAILED TO GET TEXT FROM EXCEPTION\n";

                fputs(line, stdout);
                fputs(preamble, stdout);
                char* text;
                if(NS_SUCCEEDED(xpc_exception->ToString(&text)) && text)
                {
                    fputs(text, stdout);
                    fputs("\n", stdout);
                    nsMemory::Free(text);
                }
                else
                    fputs(cant_get_text, stdout);
                fputs(line, stdout);
#endif

                // Log the exception to the JS Console, so that users can do
                // something with it.
                nsCOMPtr<nsIConsoleService> consoleService
                    (do_GetService(XPC_CONSOLE_CONTRACTID));
                if(nsnull != consoleService)
                {
                    nsresult rv;
                    nsCOMPtr<nsIScriptError> scriptError;
                    nsCOMPtr<nsISupports> errorData;
                    rv = xpc_exception->GetData(getter_AddRefs(errorData));
                    if(NS_SUCCEEDED(rv))
                        scriptError = do_QueryInterface(errorData);

                    if(nsnull == scriptError)
                    {
                        // No luck getting one from the exception, so
                        // try to cook one up.
                        scriptError = do_CreateInstance(XPC_SCRIPT_ERROR_CONTRACTID);
                        if(nsnull != scriptError)
                        {
                            char* exn_string;
                            rv = xpc_exception->ToString(&exn_string);
                            if(NS_SUCCEEDED(rv))
                            {
                                // use toString on the exception as the message
                                nsAutoString newMessage;
                                newMessage.AssignWithConversion(exn_string);
                                nsMemory::Free((void *) exn_string);

                                // try to get filename, lineno from the first
                                // stack frame location.
                                PRInt32 lineNumber = 0;
                                nsXPIDLCString sourceName;

                                nsCOMPtr<nsIStackFrame> location;
                                xpc_exception->
                                    GetLocation(getter_AddRefs(location));
                                if(location)
                                {
                                    // Get line number w/o checking; 0 is ok.
                                    location->GetLineNumber(&lineNumber);

                                    // get a filename.
                                    rv = location->GetFilename(getter_Copies(sourceName));
                                }

                                rv = scriptError->Init(newMessage.get(),
                                                       NS_ConvertASCIItoUCS2(sourceName).get(),
                                                       nsnull,
                                                       lineNumber, 0, 0,
                                                       "XPConnect JavaScript");
                                if(NS_FAILED(rv))
                                    scriptError = nsnull;
                            }
                        }
                    }
                    if(nsnull != scriptError)
                        consoleService->LogMessage(scriptError);
                }
            }
            // Whether or not it passes the 'reportable' test, it might
            // still be an error and we have to do the right thing here...
            if(NS_FAILED(e_result))
            {
                ccx.GetThreadData()->SetException(xpc_exception);
                return e_result;
            }
        }
    }
    else
    {
        // see if JS code signaled failure result without throwing exception
        if(NS_FAILED(pending_result))
        {
            return pending_result;
        }
    }
    return NS_ERROR_FAILURE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsXPCWrappedJSClass::CleanupPointerArray ( const nsXPTType datum_type,
JSUint32  array_count,
void **  arrayp 
) [private]

Definition at line 833 of file xpcwrappedjsclass.cpp.

{
    if(datum_type.IsInterfacePointer())
    {
        nsISupports** pp = (nsISupports**) arrayp;
        for(JSUint32 k = 0; k < array_count; k++)
        {
            nsISupports* p = pp[k];
            NS_IF_RELEASE(p);
        }
    }
    else
    {
        void** pp = (void**) arrayp;
        for(JSUint32 k = 0; k < array_count; k++)
        {
            void* p = pp[k];
            if(p) nsMemory::Free(p);
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 858 of file xpcwrappedjsclass.cpp.

{
    NS_ASSERTION(pp,"null pointer");
    if(type.IsInterfacePointer())
    {
        nsISupports* p = *((nsISupports**)pp);
        if(p) p->Release();
    }
    else
    {
        void* p = *((void**)pp);
        if(p) nsMemory::Free(p);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsXPCWrappedJSClass::DebugDump ( PRInt16  depth) [private, virtual]

Implements nsIXPCWrappedJSClass.

Definition at line 1721 of file xpcwrappedjsclass.cpp.

{
#ifdef DEBUG
    depth-- ;
    XPC_LOG_ALWAYS(("nsXPCWrappedJSClass @ %x with mRefCnt = %d", this, mRefCnt.get()));
    XPC_LOG_INDENT();
        char* name;
        mInfo->GetName(&name);
        XPC_LOG_ALWAYS(("interface name is %s", name));
        if(name)
            nsMemory::Free(name);
        char * iid = mIID.ToString();
        XPC_LOG_ALWAYS(("IID number is %s", iid ? iid : "invalid"));
        if(iid)
            PR_Free(iid);
        XPC_LOG_ALWAYS(("InterfaceInfo @ %x", mInfo));
        uint16 methodCount = 0;
        if(depth)
        {
            uint16 i;
            nsIInterfaceInfo* parent;
            XPC_LOG_INDENT();
            mInfo->GetParent(&parent);
            XPC_LOG_ALWAYS(("parent @ %x", parent));
            mInfo->GetMethodCount(&methodCount);
            XPC_LOG_ALWAYS(("MethodCount = %d", methodCount));
            mInfo->GetConstantCount(&i);
            XPC_LOG_ALWAYS(("ConstantCount = %d", i));
            XPC_LOG_OUTDENT();
        }
        XPC_LOG_ALWAYS(("mRuntime @ %x", mRuntime));
        XPC_LOG_ALWAYS(("mDescriptors @ %x count = %d", mDescriptors, methodCount));
        if(depth && mDescriptors && methodCount)
        {
            depth--;
            XPC_LOG_INDENT();
            for(uint16 i = 0; i < methodCount; i++)
            {
                XPC_LOG_ALWAYS(("Method %d is %s%s", \
                        i, IsReflectable(i) ? "":" NOT ","reflectable"));
            }
            XPC_LOG_OUTDENT();
            depth++;
        }
    XPC_LOG_OUTDENT();
#endif
    return NS_OK;
}

Here is the call graph for this function:

Definition at line 501 of file xpcwrappedjsclass.cpp.

{
    if(aIID.Equals(NS_GET_IID(nsIXPConnectJSObjectHolder)))
    {
        NS_ADDREF(self);
        *aInstancePtr = (void*) NS_STATIC_CAST(nsIXPConnectJSObjectHolder*,self);
        return NS_OK;
    }

    // Objects internal to xpconnect are the only objects that even know *how*
    // to ask for this iid. And none of them bother refcoutning the thing.
    if(aIID.Equals(NS_GET_IID(WrappedJSIdentity)))
    {
        // asking to find out if this is a wrapper object
        *aInstancePtr = WrappedJSIdentity::GetSingleton();
        return NS_OK;
    }

#ifdef XPC_IDISPATCH_SUPPORT
    // If IDispatch is enabled and we're QI'ing to IDispatch
    if(nsXPConnect::IsIDispatchEnabled() && aIID.Equals(NSID_IDISPATCH))
    {
        return XPCIDispatchExtension::IDispatchQIWrappedJS(self, aInstancePtr);
    }
#endif
    if(aIID.Equals(NS_GET_IID(nsIPropertyBag)))
    {
        // We only want to expose one implementation from our aggregate.
        nsXPCWrappedJS* root = self->GetRootWrapper();

        if(!root->IsValid())
        {
            *aInstancePtr = nsnull;
            return NS_NOINTERFACE;
        }

        NS_ADDREF(root);
        *aInstancePtr = (void*) NS_STATIC_CAST(nsIPropertyBag*,root);
        return NS_OK;
    }

    XPCCallContext ccx(NATIVE_CALLER);
    if(!ccx.IsValid())
    {
        *aInstancePtr = nsnull;
        return NS_NOINTERFACE;
    }

    // We support nsISupportsWeakReference iff the root wrapped JSObject
    // claims to support it in its QueryInterface implementation.
    if(aIID.Equals(NS_GET_IID(nsISupportsWeakReference)))
    {
        // We only want to expose one implementation from our aggregate.
        nsXPCWrappedJS* root = self->GetRootWrapper();

        // Fail if JSObject doesn't claim support for nsISupportsWeakReference
        if(!root->IsValid() ||
           !CallQueryInterfaceOnJSObject(ccx, root->GetJSObject(), aIID))
        {
            *aInstancePtr = nsnull;
            return NS_NOINTERFACE;
        }

        NS_ADDREF(root);
        *aInstancePtr = (void*) NS_STATIC_CAST(nsISupportsWeakReference*,root);
        return NS_OK;
    }

    nsXPCWrappedJS* sibling;

    // Checks for any existing wrapper explicitly constructed for this iid.
    // This includes the current 'self' wrapper. This also deals with the
    // nsISupports case (for which it returns mRoot).
    if(nsnull != (sibling = self->Find(aIID)))
    {
        NS_ADDREF(sibling);
        *aInstancePtr = (void*) sibling;
        return NS_OK;
    }

    // Check if asking for an interface from which one of our wrappers inherits.
    if(nsnull != (sibling = self->FindInherited(aIID)))
    {
        NS_ADDREF(sibling);
        *aInstancePtr = (void*) sibling;
        return NS_OK;
    }

    // else we do the more expensive stuff...

#ifndef XPCONNECT_STANDALONE
    // Before calling out, ensure that we're not about to claim to implement
    // nsISecurityCheckedComponent for an untrusted object. Doing so causes
    // problems. See bug 352882.

    if(aIID.Equals(NS_GET_IID(nsISecurityCheckedComponent)))
    {
        // XXX This code checks to see if the given object has chrome (also
        // known as system) principals. It really wants to do a
        // UniversalXPConnect type check.

        nsXPConnect *xpc = nsXPConnect::GetXPConnect();
        nsCOMPtr<nsIScriptSecurityManager> secMan =
            do_QueryInterface(xpc->GetDefaultSecurityManager());
        if(!secMan)
        {
            *aInstancePtr = nsnull;
            return NS_NOINTERFACE;
        }
        nsCOMPtr<nsIPrincipal> objPrin;
        nsresult rv = secMan->GetObjectPrincipal(ccx, self->GetJSObject(),
                                                 getter_AddRefs(objPrin));
        if(NS_SUCCEEDED(rv))
        {
            nsCOMPtr<nsIPrincipal> systemPrin;
            rv = secMan->GetSystemPrincipal(getter_AddRefs(systemPrin));
            if(systemPrin != objPrin)
                rv = NS_NOINTERFACE;
        }

        if(NS_FAILED(rv))
        {
            *aInstancePtr = nsnull;
            return rv;
        }
    }
#endif

    // check if the JSObject claims to implement this interface
    JSObject* jsobj = CallQueryInterfaceOnJSObject(ccx, self->GetJSObject(),
                                                   aIID);
    if(jsobj)
    {
        // protect jsobj until it is actually attached
        AUTO_MARK_JSVAL(ccx, OBJECT_TO_JSVAL(jsobj));

        // We can't use XPConvert::JSObject2NativeInterface() here
        // since that can find a XPCWrappedNative directly on the
        // proto chain, and we don't want that here. We need to find
        // the actual JS object that claimed it supports the interface
        // we're looking for or we'll potentially bypass security
        // checks etc by calling directly through to a native found on
        // the prototype chain.
        //
        // Instead, simply do the nsXPCWrappedJS part of
        // XPConvert::JSObject2NativeInterface() here to make sure we
        // get a new (or used) nsXPCWrappedJS.
        nsXPCWrappedJS* wrapper;
        nsresult rv = nsXPCWrappedJS::GetNewOrUsed(ccx, jsobj, aIID, nsnull,
                                                   &wrapper);
        if(NS_SUCCEEDED(rv) && wrapper)
        {
            // We need to go through the QueryInterface logic to make
            // this return the right thing for the various 'special'
            // interfaces; e.g.  nsIPropertyBag.
            rv = wrapper->QueryInterface(aIID, aInstancePtr);
            NS_RELEASE(wrapper);
            return rv;
        }
    }

    // else...
    // no can do
    *aInstancePtr = nsnull;
    return NS_NOINTERFACE;
}

Here is the call graph for this function:

JSBool nsXPCWrappedJSClass::GetArraySizeFromParam ( JSContext cx,
const nsXPTMethodInfo method,
const nsXPTParamInfo param,
uint16  methodIndex,
uint8  paramIndex,
SizeMode  mode,
nsXPTCMiniVariant params,
JSUint32 *  result 
) [private]

Definition at line 745 of file xpcwrappedjsclass.cpp.

{
    uint8 argnum;
    nsresult rv;

    if(mode == GET_SIZE)
        rv = mInfo->GetSizeIsArgNumberForParam(methodIndex, &param, 0, &argnum);
    else
        rv = mInfo->GetLengthIsArgNumberForParam(methodIndex, &param, 0, &argnum);
    if(NS_FAILED(rv))
        return JS_FALSE;

    const nsXPTParamInfo& arg_param = method->GetParam(argnum);
    const nsXPTType& arg_type = arg_param.GetType();

    // The xpidl compiler ensures this. We reaffirm it for safety.
    if(arg_type.IsPointer() || arg_type.TagPart() != nsXPTType::T_U32)
        return JS_FALSE;

    if(arg_param.IsOut())
        *result = *(JSUint32*)nativeParams[argnum].val.p;
    else
        *result = nativeParams[argnum].val.u32;

    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2129 of file xpcprivate.h.

{return mIID;}

Here is the caller graph for this function:

Definition at line 2131 of file xpcprivate.h.

{return mInfo;}

Here is the caller graph for this function:

Definition at line 1706 of file xpcwrappedjsclass.cpp.

{
    if(!mName)
        mInfo->GetName(&mName);
    return mName;
}

Here is the caller graph for this function:

JSBool nsXPCWrappedJSClass::GetInterfaceTypeFromParam ( JSContext cx,
const nsXPTMethodInfo method,
const nsXPTParamInfo param,
uint16  methodIndex,
const nsXPTType type,
nsXPTCMiniVariant params,
nsID result 
) [private]

Definition at line 780 of file xpcwrappedjsclass.cpp.

{
    uint8 type_tag = type.TagPart();

    if(type_tag == nsXPTType::T_INTERFACE)
    {
        if(NS_SUCCEEDED(GetInterfaceInfo()->
                GetIIDForParamNoAlloc(methodIndex, &param, result)))
        {
            return JS_TRUE;
        }
    }
    else if(type_tag == nsXPTType::T_INTERFACE_IS)
    {
        uint8 argnum;
        nsresult rv;
        rv = mInfo->GetInterfaceIsArgNumberForParam(methodIndex,
                                                    &param, &argnum);
        if(NS_FAILED(rv))
            return JS_FALSE;

        const nsXPTParamInfo& arg_param = method->GetParam(argnum);
        const nsXPTType& arg_type = arg_param.GetType();
        if(arg_type.IsPointer() &&
           arg_type.TagPart() == nsXPTType::T_IID)
        {
            if(arg_param.IsOut())
            {
                nsID** p = (nsID**) nativeParams[argnum].val.p;
                if(!p || !*p)
                    return JS_FALSE;
                *result = **p;
            }
            else
            {
                nsID* p = (nsID*) nativeParams[argnum].val.p;
                if(!p)
                    return JS_FALSE;
                *result = *p;
            }
            return JS_TRUE;
        }
    }
    return JS_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsXPCWrappedJSClass::GetNamedPropertyAsVariant ( XPCCallContext ccx,
JSObject aJSObj,
jsval  aName,
nsIVariant **  aResult 
) [static]

Definition at line 306 of file xpcwrappedjsclass.cpp.

{
    JSContext* cx = ccx.GetJSContext();
    JSBool ok;
    jsid id;
    nsresult rv;

    AutoScriptEvaluate scriptEval(cx);
    scriptEval.StartEvaluating();

    ok = JS_ValueToId(cx, aName, &id) && 
         GetNamedPropertyAsVariantRaw(ccx, aJSObj, id, aResult, &rv);

    return ok ? NS_OK : NS_FAILED(rv) ? rv : NS_ERROR_FAILURE;
}

Here is the call graph for this function:

Definition at line 131 of file xpcwrappedjsclass.cpp.

{
    nsXPCWrappedJSClass* clazz = nsnull;
    XPCJSRuntime* rt = ccx.GetRuntime();

    {   // scoped lock
        XPCAutoLock lock(rt->GetMapLock());
        IID2WrappedJSClassMap* map = rt->GetWrappedJSClassMap();
        clazz = map->Find(aIID);
        NS_IF_ADDREF(clazz);
    }

    if(!clazz)
    {
        nsCOMPtr<nsIInterfaceInfo> info;
        ccx.GetXPConnect()->GetInfoForIID(&aIID, getter_AddRefs(info));
        if(info)
        {
            PRBool canScript;
            if(NS_SUCCEEDED(info->IsScriptable(&canScript)) && canScript &&
               nsXPConnect::IsISupportsDescendant(info))
            {
                clazz = new nsXPCWrappedJSClass(ccx, aIID, info);
                if(clazz && !clazz->mDescriptors)
                    NS_RELEASE(clazz);  // sets clazz to nsnull
            }
        }
    }
    *resultClazz = clazz;
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 671 of file xpcwrappedjsclass.cpp.

{
    JSObject* result = CallQueryInterfaceOnJSObject(ccx, aJSObj,
                                                    NS_GET_IID(nsISupports));
    return result ? result : aJSObj;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2130 of file xpcprivate.h.

{return mRuntime;}
JSBool nsXPCWrappedJSClass::IsReflectable ( uint16  i) const [inline, private]

Definition at line 2169 of file xpcprivate.h.

        {return (JSBool)(mDescriptors[i/32] & (1 << (i%32)));}

Here is the caller graph for this function:

JSBool nsXPCWrappedJSClass::IsWrappedJS ( nsISupports *  aPtr) [static]

Definition at line 491 of file xpcwrappedjsclass.cpp.

{
    void* result;
    NS_PRECONDITION(aPtr, "null pointer");
    return aPtr &&
           NS_OK == aPtr->QueryInterface(NS_GET_IID(WrappedJSIdentity), &result) &&
           result == WrappedJSIdentity::GetSingleton();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1714 of file xpcwrappedjsclass.cpp.

{
    return JS_NewObject(cx, nsnull, nsnull, nsnull);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsXPCWrappedJSClass::SetReflectable ( uint16  i,
JSBool  b 
) [inline, private]

Definition at line 2171 of file xpcprivate.h.

        {if(b) mDescriptors[i/32] |= (1 << (i%32));
         else mDescriptors[i/32] &= ~(1 << (i%32));}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 2206 of file xpcprivate.h.

Definition at line 2205 of file xpcprivate.h.

Definition at line 2203 of file xpcprivate.h.

char* nsXPCWrappedJSClass::mName [private]

Definition at line 2204 of file xpcprivate.h.

Definition at line 2202 of file xpcprivate.h.


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