nsXBLSerialize.cpp 1.1 KB

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