CallbackInterface.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. /**
  6. * A common base class for representing WebIDL callback interface types in C++.
  7. *
  8. * This class implements common functionality like lifetime management,
  9. * initialization with the callback object, and setup of the call environment.
  10. * Subclasses corresponding to particular callback interface types should
  11. * provide methods that actually do the various necessary calls.
  12. */
  13. #ifndef mozilla_dom_CallbackInterface_h
  14. #define mozilla_dom_CallbackInterface_h
  15. #include "mozilla/dom/CallbackObject.h"
  16. namespace mozilla {
  17. namespace dom {
  18. class CallbackInterface : public CallbackObject
  19. {
  20. public:
  21. // See CallbackObject for an explanation of the arguments.
  22. explicit CallbackInterface(JSContext* aCx, JS::Handle<JSObject*> aCallback,
  23. nsIGlobalObject* aIncumbentGlobal)
  24. : CallbackObject(aCx, aCallback, aIncumbentGlobal)
  25. {
  26. }
  27. // See CallbackObject for an explanation of the arguments.
  28. explicit CallbackInterface(JS::Handle<JSObject*> aCallback,
  29. JS::Handle<JSObject*> aAsyncStack,
  30. nsIGlobalObject* aIncumbentGlobal)
  31. : CallbackObject(aCallback, aAsyncStack, aIncumbentGlobal)
  32. {
  33. }
  34. protected:
  35. bool GetCallableProperty(JSContext* cx, JS::Handle<jsid> aPropId,
  36. JS::MutableHandle<JS::Value> aCallable);
  37. // See CallbackObject for an explanation of the arguments.
  38. CallbackInterface(JSContext* aCx, JS::Handle<JSObject*> aCallable,
  39. nsIGlobalObject* aIncumbentGlobal,
  40. const FastCallbackConstructor&)
  41. : CallbackObject(aCx, aCallable, aIncumbentGlobal,
  42. FastCallbackConstructor())
  43. {
  44. }
  45. };
  46. } // namespace dom
  47. } // namespace mozilla
  48. #endif // mozilla_dom_CallbackFunction_h