Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 : /* This Source Code Form is subject to the terms of the Mozilla Public
4 : * License, v. 2.0. If a copy of the MPL was not distributed with this
5 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : #include "nsXBLSerialize.h"
8 :
9 : #include "jsfriendapi.h"
10 : #include "nsXBLPrototypeBinding.h"
11 : #include "nsIXPConnect.h"
12 : #include "nsContentUtils.h"
13 :
14 : using namespace mozilla;
15 :
16 : nsresult
17 0 : XBL_SerializeFunction(nsIObjectOutputStream* aStream,
18 : JS::Handle<JSObject*> aFunction)
19 : {
20 0 : AssertInCompilationScope();
21 0 : AutoJSContext cx;
22 0 : MOZ_ASSERT(js::GetContextCompartment(cx) == js::GetObjectCompartment(aFunction));
23 0 : return nsContentUtils::XPConnect()->WriteFunction(aStream, cx, aFunction);
24 : }
25 :
26 : nsresult
27 1091 : XBL_DeserializeFunction(nsIObjectInputStream* aStream,
28 : JS::MutableHandle<JSObject*> aFunctionObjectp)
29 : {
30 1091 : AssertInCompilationScope();
31 2182 : AutoJSContext cx;
32 2182 : return nsContentUtils::XPConnect()->ReadFunction(aStream, cx,
33 3273 : aFunctionObjectp.address());
34 : }
|