JSBool QueryInterface(JSContext* cx, unsigned argc, JS::Value* vp) { JS::Value thisv = JS_THIS(cx, vp); if (thisv == JSVAL_NULL) return false; JSObject* obj = JSVAL_TO_OBJECT(thisv); JSClass* clasp = js::GetObjectJSClass(obj); if (!IsDOMClass(clasp) || !DOMJSClass::FromJSClass(clasp)->mDOMObjectIsISupports) { return Throw<true>(cx, NS_ERROR_FAILURE); } nsISupports* native = UnwrapDOMObject<nsISupports>(obj); if (argc < 1) { return Throw<true>(cx, NS_ERROR_XPC_NOT_ENOUGH_ARGS); } JS::Value* argv = JS_ARGV(cx, vp); if (!argv[0].isObject()) { return Throw<true>(cx, NS_ERROR_XPC_BAD_CONVERT_JS); } nsIJSIID* iid; xpc_qsSelfRef iidRef; if (NS_FAILED(xpc_qsUnwrapArg<nsIJSIID>(cx, argv[0], &iid, &iidRef.ptr, &argv[0]))) { return Throw<true>(cx, NS_ERROR_XPC_BAD_CONVERT_JS); } MOZ_ASSERT(iid); if (iid->GetID()->Equals(NS_GET_IID(nsIClassInfo))) { nsresult rv; nsCOMPtr<nsIClassInfo> ci = do_QueryInterface(native, &rv); if (NS_FAILED(rv)) { return Throw<true>(cx, rv); } return WrapObject(cx, obj, ci, &NS_GET_IID(nsIClassInfo), vp); } // Lie, otherwise we need to check classinfo or QI *vp = thisv; return true; }
JSBool RewrapIfNeeded(JSContext *cx, JSObject *outerObj, jsval *vp) { // Don't need to wrap primitive values. if (JSVAL_IS_PRIMITIVE(*vp)) { return JS_TRUE; } JSObject *obj = JSVAL_TO_OBJECT(*vp); if (JS_ObjectIsFunction(cx, obj)) { return WrapFunction(cx, outerObj, obj, vp); } XPCWrappedNative *wn = nsnull; if (obj->getClass() == &XOWClass && outerObj->getParent() != obj->getParent()) { *vp = OBJECT_TO_JSVAL(GetWrappedObject(cx, obj)); } else if (!(wn = XPCWrappedNative::GetAndMorphWrappedNativeOfJSObject(cx, obj))) { return JS_TRUE; } return WrapObject(cx, JS_GetGlobalForObject(cx, outerObj), vp, wn); }
bool WindowNamedPropertiesHandler::getOwnPropDescriptor(JSContext* aCx, JS::Handle<JSObject*> aProxy, JS::Handle<jsid> aId, bool /* unused */, JS::MutableHandle<JSPropertyDescriptor> aDesc) const { if (!JSID_IS_STRING(aId)) { // Nothing to do if we're resolving a non-string property. return true; } JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForObject(aCx, aProxy)); if (HasPropertyOnPrototype(aCx, aProxy, aId)) { return true; } nsAutoJSString str; if (!str.init(aCx, JSID_TO_STRING(aId))) { return false; } // Grab the DOM window. nsGlobalWindow* win = GetWindowFromGlobal(global); if (win->Length() > 0) { nsCOMPtr<nsIDOMWindow> childWin = win->GetChildWindow(str); if (childWin && ShouldExposeChildWindow(str, childWin)) { // We found a subframe of the right name. Shadowing via |var foo| in // global scope is still allowed, since |var| only looks up |own| // properties. But unqualified shadowing will fail, per-spec. JS::Rooted<JS::Value> v(aCx); if (!WrapObject(aCx, childWin, &v)) { return false; } aDesc.object().set(aProxy); aDesc.value().set(v); aDesc.setAttributes(JSPROP_ENUMERATE); return true; } } // The rest of this function is for HTML documents only. nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(win->GetExtantDoc()); if (!htmlDoc) { return true; } nsHTMLDocument* document = static_cast<nsHTMLDocument*>(htmlDoc.get()); Element* element = document->GetElementById(str); if (element) { JS::Rooted<JS::Value> v(aCx); if (!WrapObject(aCx, element, &v)) { return false; } aDesc.object().set(aProxy); aDesc.value().set(v); aDesc.setAttributes(JSPROP_ENUMERATE); return true; } nsWrapperCache* cache; nsISupports* result = document->ResolveName(str, &cache); if (!result) { return true; } JS::Rooted<JS::Value> v(aCx); if (!WrapObject(aCx, result, cache, nullptr, &v)) { return false; } aDesc.object().set(aProxy); aDesc.value().set(v); aDesc.setAttributes(JSPROP_ENUMERATE); return true; }
ClassOfIrrMaterialClass::ClassOfIrrMaterialClass(class ClassOfSRPInterface *In_SRPInterface,void *SRPObject) { if( In_SRPInterface == NULL ) return; WrapObject(In_SRPInterface,VS_FALSE,VS_FALSE,SRPObject); }
ClassOfIrrMaterialClass::ClassOfIrrMaterialClass(class ClassOfSRPInterface *In_SRPInterface) { if( In_SRPInterface == NULL ) return; WrapObject(In_SRPInterface,VS_TRUE,VS_FALSE,In_SRPInterface -> MallocObjectL(&VSOBJID_IrrMaterialClass,0,NULL)); }
ClassOfIrrCameraSceneNodeClass::ClassOfIrrCameraSceneNodeClass(class ClassOfSRPInterface *In_SRPInterface,void *SRPObject) { if( In_SRPInterface == NULL ) return; WrapObject(In_SRPInterface,VS_FALSE,VS_FALSE,SRPObject); }
ClassOfIrrAnimatedMeshSceneNodeClass::ClassOfIrrAnimatedMeshSceneNodeClass(class ClassOfSRPInterface *In_SRPInterface) { if( In_SRPInterface == NULL ) return; WrapObject(In_SRPInterface,VS_TRUE,VS_FALSE,In_SRPInterface -> MallocObjectL(&VSOBJID_IrrAnimatedMeshSceneNodeClass,0,NULL)); }