2015-05-03 19:32:37 +00: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 11:12:37 +00: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 20:39:08 +00:00
|
|
|
|
|
|
|
#include "nsXBLSerialize.h"
|
2013-08-27 02:05:20 +00:00
|
|
|
|
|
|
|
#include "jsfriendapi.h"
|
2013-08-09 16:25:13 +00:00
|
|
|
#include "nsXBLPrototypeBinding.h"
|
2013-03-20 20:09:09 +00:00
|
|
|
#include "nsIXPConnect.h"
|
2011-11-03 20:39:08 +00:00
|
|
|
#include "nsContentUtils.h"
|
|
|
|
|
2013-02-26 19:04:13 +00:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2011-11-03 20:39:08 +00:00
|
|
|
nsresult
|
2013-08-09 16:25:13 +00:00
|
|
|
XBL_SerializeFunction(nsIObjectOutputStream* aStream,
|
2013-05-20 12:40:06 +00:00
|
|
|
JS::Handle<JSObject*> aFunction)
|
2011-11-03 20:39:08 +00:00
|
|
|
{
|
2013-08-09 16:25:13 +00:00
|
|
|
AssertInCompilationScope();
|
|
|
|
AutoJSContext cx;
|
|
|
|
MOZ_ASSERT(js::GetContextCompartment(cx) == js::GetObjectCompartment(aFunction));
|
2013-05-20 12:40:06 +00:00
|
|
|
return nsContentUtils::XPConnect()->WriteFunction(aStream, cx, aFunction);
|
2011-11-03 20:39:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2013-08-09 16:25:13 +00:00
|
|
|
XBL_DeserializeFunction(nsIObjectInputStream* aStream,
|
2013-04-05 13:21:03 +00:00
|
|
|
JS::MutableHandle<JSObject*> aFunctionObjectp)
|
2011-11-03 20:39:08 +00:00
|
|
|
{
|
2013-08-09 16:25:13 +00:00
|
|
|
AssertInCompilationScope();
|
|
|
|
AutoJSContext cx;
|
2013-05-21 04:34:17 +00:00
|
|
|
return nsContentUtils::XPConnect()->ReadFunction(aStream, cx,
|
|
|
|
aFunctionObjectp.address());
|
2011-11-03 20:39:08 +00:00
|
|
|
}
|