if(XPCNativeWrapper::IsNativeWrapperClass(clazz)) { return XPCNativeWrapper::GetWrappedNative(cx, cur); }
XPCWrappedNative::GetWrappedNativeOfJSObject(JSContext* cx,                                             JSObject* obj,                                             JSObject* funobj,                                             JSObject** pobj2,                                             XPCWrappedNativeTearOff** pTearOff){    NS_PRECONDITION(obj, "bad param");    JSObject* cur;    XPCWrappedNativeProto* proto = nsnull;    // If we were passed a function object then we need to find the correct    // wrapper out of those that might be in the callee obj's proto chain.    if(funobj)    {        JSObject* funObjParent = JS_GetParent(cx, funobj);        NS_ASSERTION(funObjParent, "funobj has no parent");        JSClass* funObjParentClass = JS_GET_CLASS(cx, funObjParent);        if(IS_PROTO_CLASS(funObjParentClass))        {            NS_ASSERTION(JS_GetParent(cx, funObjParent), "funobj's parent (proto) is global");            proto = (XPCWrappedNativeProto*) JS_GetPrivate(cx, funObjParent);        }        else if(IS_WRAPPER_CLASS(funObjParentClass))        {            cur = funObjParent;            goto return_wrapper;        }        else if(IS_TEAROFF_CLASS(funObjParentClass))        {            NS_ASSERTION(JS_GetParent(cx, funObjParent), "funobj's parent (tearoff) is global");            cur = funObjParent;            goto return_tearoff;        }        else        {            NS_ERROR("function object has parent of unknown class!");            return nsnull;        }    }    for(cur = obj; cur; cur = JS_GetPrototype(cx, cur))    {        // this is on two lines to make the compiler happy given the goto.        JSClass* clazz;        clazz = JS_GET_CLASS(cx, cur);        if(IS_WRAPPER_CLASS(clazz))        {return_wrapper:            XPCWrappedNative* wrapper =                (XPCWrappedNative*) JS_GetPrivate(cx, cur);            if(proto && proto != wrapper->GetProto())                continue;            if(pobj2)                *pobj2 = cur;            return wrapper;        }        if(IS_TEAROFF_CLASS(clazz))        {return_tearoff:            XPCWrappedNative* wrapper =                (XPCWrappedNative*) JS_GetPrivate(cx, JS_GetParent(cx,cur));            if(proto && proto != wrapper->GetProto())                continue;            if(pobj2)                *pobj2 = cur;            XPCWrappedNativeTearOff* to =                (XPCWrappedNativeTearOff*) JS_GetPrivate(cx, cur);            if(!to)                return nsnull;            if(pTearOff)                *pTearOff = to;            return wrapper;        }        if(XPCNativeWrapper::IsNativeWrapperClass(clazz))        {            return XPCNativeWrapper::GetWrappedNative(cx, cur);        }    }    return nsnull;}