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