2015-05-03 12:32:37 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2011-11-03 13:39:08 -07:00
|
|
|
|
|
|
|
#include "nsXBLSerialize.h"
|
2013-08-26 19:05:20 -07:00
|
|
|
|
|
|
|
#include "jsfriendapi.h"
|
2013-08-09 09:25:13 -07:00
|
|
|
#include "nsXBLPrototypeBinding.h"
|
2013-03-20 13:09:09 -07:00
|
|
|
#include "nsIXPConnect.h"
|
2011-11-03 13:39:08 -07:00
|
|
|
#include "nsContentUtils.h"
|
|
|
|
|
2013-02-26 11:04:13 -08:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2011-11-03 13:39:08 -07:00
|
|
|
nsresult
|
2013-08-09 09:25:13 -07:00
|
|
|
XBL_SerializeFunction(nsIObjectOutputStream* aStream,
|
2013-05-20 05:40:06 -07:00
|
|
|
JS::Handle<JSObject*> aFunction)
|
2011-11-03 13:39:08 -07:00
|
|
|
{
|
2013-08-09 09:25:13 -07:00
|
|
|
AssertInCompilationScope();
|
|
|
|
AutoJSContext cx;
|
|
|
|
MOZ_ASSERT(js::GetContextCompartment(cx) == js::GetObjectCompartment(aFunction));
|
2013-05-20 05:40:06 -07:00
|
|
|
return nsContentUtils::XPConnect()->WriteFunction(aStream, cx, aFunction);
|
2011-11-03 13:39:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2013-08-09 09:25:13 -07:00
|
|
|
XBL_DeserializeFunction(nsIObjectInputStream* aStream,
|
2013-04-05 06:21:03 -07:00
|
|
|
JS::MutableHandle<JSObject*> aFunctionObjectp)
|
2011-11-03 13:39:08 -07:00
|
|
|
{
|
2013-08-09 09:25:13 -07:00
|
|
|
AssertInCompilationScope();
|
|
|
|
AutoJSContext cx;
|
2013-05-20 21:34:17 -07:00
|
|
|
return nsContentUtils::XPConnect()->ReadFunction(aStream, cx,
|
|
|
|
aFunctionObjectp.address());
|
2011-11-03 13:39:08 -07:00
|
|
|
}
|