michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsXBLSerialize.h" michael@0: michael@0: #include "jsfriendapi.h" michael@0: #include "js/OldDebugAPI.h" michael@0: #include "nsXBLPrototypeBinding.h" michael@0: #include "nsIXPConnect.h" michael@0: #include "nsContentUtils.h" michael@0: #include "nsCxPusher.h" michael@0: michael@0: using namespace mozilla; michael@0: michael@0: nsresult michael@0: XBL_SerializeFunction(nsIObjectOutputStream* aStream, michael@0: JS::Handle aFunction) michael@0: { michael@0: AssertInCompilationScope(); michael@0: AutoJSContext cx; michael@0: MOZ_ASSERT(js::GetContextCompartment(cx) == js::GetObjectCompartment(aFunction)); michael@0: return nsContentUtils::XPConnect()->WriteFunction(aStream, cx, aFunction); michael@0: } michael@0: michael@0: nsresult michael@0: XBL_DeserializeFunction(nsIObjectInputStream* aStream, michael@0: JS::MutableHandle aFunctionObjectp) michael@0: { michael@0: AssertInCompilationScope(); michael@0: AutoJSContext cx; michael@0: return nsContentUtils::XPConnect()->ReadFunction(aStream, cx, michael@0: aFunctionObjectp.address()); michael@0: }