1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 * A common base class for representing WebIDL callback function types in C++.
10 * This class implements common functionality like lifetime
11 * management, initialization with the callable, and setup of the call
12 * environment. Subclasses corresponding to particular callback
13 * function types should provide a Call() method that actually does
17 #ifndef mozilla_dom_CallbackFunction_h
18 #define mozilla_dom_CallbackFunction_h
20 #include "mozilla/dom/CallbackObject.h"
22 namespace mozilla::dom
{
24 class CallbackFunction
: public CallbackObject
{
26 // See CallbackObject for an explanation of the arguments.
27 explicit CallbackFunction(JSContext
* aCx
, JS::Handle
<JSObject
*> aCallable
,
28 JS::Handle
<JSObject
*> aCallableGlobal
,
29 nsIGlobalObject
* aIncumbentGlobal
)
30 : CallbackObject(aCx
, aCallable
, aCallableGlobal
, aIncumbentGlobal
) {}
32 // See CallbackObject for an explanation of the arguments.
33 explicit CallbackFunction(JSObject
* aCallable
, JSObject
* aCallableGlobal
,
34 JSObject
* aAsyncStack
,
35 nsIGlobalObject
* aIncumbentGlobal
)
36 : CallbackObject(aCallable
, aCallableGlobal
, aAsyncStack
,
39 JSObject
* CallableOrNull() const { return CallbackOrNull(); }
41 JSObject
* CallablePreserveColor() const { return CallbackPreserveColor(); }
44 explicit CallbackFunction(CallbackFunction
* aCallbackFunction
)
45 : CallbackObject(aCallbackFunction
) {}
47 // See CallbackObject for an explanation of the arguments.
48 CallbackFunction(JSObject
* aCallable
, JSObject
* aCallableGlobal
,
49 const FastCallbackConstructor
&)
50 : CallbackObject(aCallable
, aCallableGlobal
, FastCallbackConstructor()) {}
53 } // namespace mozilla::dom
55 #endif // mozilla_dom_CallbackFunction_h