/work/obj-fuzz/dist/include/mozilla/dom/CallbackFunction.h
Line | Count | Source (jump to first uncovered line) |
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/. */ |
6 | | |
7 | | /** |
8 | | * A common base class for representing WebIDL callback function types in C++. |
9 | | * |
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 |
14 | | * the call. |
15 | | */ |
16 | | |
17 | | #ifndef mozilla_dom_CallbackFunction_h |
18 | | #define mozilla_dom_CallbackFunction_h |
19 | | |
20 | | #include "mozilla/dom/CallbackObject.h" |
21 | | |
22 | | namespace mozilla { |
23 | | namespace dom { |
24 | | |
25 | | class CallbackFunction : public CallbackObject |
26 | | { |
27 | | public: |
28 | | // See CallbackObject for an explanation of the arguments. |
29 | | explicit CallbackFunction(JSContext* aCx, JS::Handle<JSObject*> aCallable, |
30 | | JS::Handle<JSObject*> aCallableGlobal, |
31 | | nsIGlobalObject* aIncumbentGlobal) |
32 | | : CallbackObject(aCx, aCallable, aCallableGlobal, aIncumbentGlobal) |
33 | 0 | { |
34 | 0 | } |
35 | | |
36 | | // See CallbackObject for an explanation of the arguments. |
37 | | explicit CallbackFunction(JSObject* aCallable, |
38 | | JSObject* aCallableGlobal, |
39 | | JSObject* aAsyncStack, |
40 | | nsIGlobalObject* aIncumbentGlobal) |
41 | | : CallbackObject(aCallable, aCallableGlobal, aAsyncStack, aIncumbentGlobal) |
42 | 0 | { |
43 | 0 | } |
44 | | |
45 | | JS::Handle<JSObject*> CallableOrNull() const |
46 | 0 | { |
47 | 0 | return CallbackOrNull(); |
48 | 0 | } |
49 | | |
50 | | JS::Handle<JSObject*> CallablePreserveColor() const |
51 | 0 | { |
52 | 0 | return CallbackPreserveColor(); |
53 | 0 | } |
54 | | |
55 | | bool HasGrayCallable() const |
56 | 0 | { |
57 | 0 | // Play it safe in case this gets called after unlink. |
58 | 0 | return mCallback && JS::ObjectIsMarkedGray(mCallback); |
59 | 0 | } |
60 | | |
61 | | protected: |
62 | | explicit CallbackFunction(CallbackFunction* aCallbackFunction) |
63 | | : CallbackObject(aCallbackFunction) |
64 | 0 | { |
65 | 0 | } |
66 | | |
67 | | // See CallbackObject for an explanation of the arguments. |
68 | | CallbackFunction(JSObject* aCallable, |
69 | | JSObject* aCallableGlobal, |
70 | | const FastCallbackConstructor&) |
71 | | : CallbackObject(aCallable, aCallableGlobal, FastCallbackConstructor()) |
72 | 0 | { |
73 | 0 | } |
74 | | }; |
75 | | |
76 | | } // namespace dom |
77 | | } // namespace mozilla |
78 | | |
79 | | #endif // mozilla_dom_CallbackFunction_h |