Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM DataTransferItem.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #ifndef mozilla_dom_DataTransferItemBinding_h
4 : #define mozilla_dom_DataTransferItemBinding_h
5 :
6 : #include "js/RootingAPI.h"
7 : #include "jspubtd.h"
8 : #include "mozilla/ErrorResult.h"
9 : #include "mozilla/dom/BindingDeclarations.h"
10 : #include "mozilla/dom/CallbackFunction.h"
11 : #include "mozilla/dom/Nullable.h"
12 : #include "mozilla/dom/ToJSValue.h"
13 :
14 : namespace mozilla {
15 : namespace dom {
16 :
17 : class DataTransferItem;
18 : struct DataTransferItemAtoms;
19 : class FunctionStringCallback;
20 : struct NativePropertyHooks;
21 : class ProtoAndIfaceCache;
22 :
23 : } // namespace dom
24 : } // namespace mozilla
25 :
26 : namespace mozilla {
27 : namespace dom {
28 :
29 0 : class FunctionStringCallback : public CallbackFunction
30 : {
31 : public:
32 : explicit inline FunctionStringCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, nsIGlobalObject* aIncumbentGlobal)
33 : : CallbackFunction(aCx, aCallback, aIncumbentGlobal)
34 : {
35 : MOZ_ASSERT(JS::IsCallable(mCallback));
36 : }
37 :
38 0 : explicit inline FunctionStringCallback(JS::Handle<JSObject*> aCallback, const FastCallbackConstructor& )
39 0 : : CallbackFunction(aCallback, FastCallbackConstructor())
40 : {
41 0 : MOZ_ASSERT(JS::IsCallable(mCallback));
42 0 : }
43 :
44 : explicit inline FunctionStringCallback(JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aAsyncStack, nsIGlobalObject* aIncumbentGlobal)
45 : : CallbackFunction(aCallback, aAsyncStack, aIncumbentGlobal)
46 : {
47 : MOZ_ASSERT(JS::IsCallable(mCallback));
48 : }
49 :
50 : explicit inline FunctionStringCallback(CallbackFunction* aOther)
51 : : CallbackFunction(aOther)
52 : {
53 : }
54 :
55 : template <typename T>
56 : inline void
57 : Call(const T& thisVal, const nsAString& data, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JSCompartment* aCompartment = nullptr)
58 : {
59 : MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
60 : if (!aExecutionReason) {
61 : aExecutionReason = "FunctionStringCallback";
62 : }
63 : CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aCompartment);
64 : if (!s.GetContext()) {
65 : MOZ_ASSERT(aRv.Failed());
66 : return;
67 : }
68 : JS::Rooted<JS::Value> thisValJS(s.GetContext());
69 : if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) {
70 : aRv.Throw(NS_ERROR_FAILURE);
71 : return;
72 : }
73 : return Call(s.GetContext(), thisValJS, data, aRv);
74 : }
75 :
76 : inline void
77 0 : Call(const nsAString& data, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JSCompartment* aCompartment = nullptr)
78 : {
79 0 : MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
80 0 : if (!aExecutionReason) {
81 0 : aExecutionReason = "FunctionStringCallback";
82 : }
83 0 : CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aCompartment);
84 0 : if (!s.GetContext()) {
85 0 : MOZ_ASSERT(aRv.Failed());
86 0 : return;
87 : }
88 0 : return Call(s.GetContext(), JS::UndefinedHandleValue, data, aRv);
89 : }
90 :
91 : template <typename T>
92 : inline void
93 : Call(const T& thisVal, const nsAString& data, const char* aExecutionReason = nullptr)
94 : {
95 : IgnoredErrorResult rv;
96 : return Call(thisVal, data, rv, aExecutionReason);
97 : }
98 :
99 : inline void
100 : Call(const nsAString& data, const char* aExecutionReason = nullptr)
101 : {
102 : IgnoredErrorResult rv;
103 : return Call(data, rv, aExecutionReason, eReportExceptions, nullptr);
104 : }
105 :
106 : inline bool
107 : operator==(const FunctionStringCallback& aOther) const
108 : {
109 : return CallbackFunction::operator==(aOther);
110 : }
111 :
112 : private:
113 : void Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, const nsAString& data, ErrorResult& aRv);
114 : };
115 :
116 :
117 : namespace binding_detail {
118 0 : class FastFunctionStringCallback : public FunctionStringCallback
119 : {
120 : public:
121 0 : explicit inline FastFunctionStringCallback(JS::Handle<JSObject*> aCallback)
122 0 : : FunctionStringCallback(aCallback, FastCallbackConstructor())
123 : {
124 0 : }
125 :
126 : inline void
127 0 : Trace(JSTracer* aTracer)
128 : {
129 0 : FunctionStringCallback::Trace(aTracer);
130 0 : }
131 :
132 : inline void
133 0 : FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx)
134 : {
135 0 : FunctionStringCallback::FinishSlowJSInitIfMoreThanOneOwner(aCx);
136 0 : }
137 : };
138 : } // namespace binding_detail
139 :
140 :
141 : namespace DataTransferItemBinding {
142 :
143 : typedef mozilla::dom::DataTransferItem NativeType;
144 :
145 : JSObject*
146 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal);
147 :
148 : const JSClass*
149 : GetJSClass();
150 :
151 : bool
152 : Wrap(JSContext* aCx, mozilla::dom::DataTransferItem* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
153 :
154 : template <class T>
155 0 : inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto)
156 : {
157 0 : JS::Rooted<JSObject*> reflector(aCx);
158 0 : return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr;
159 : }
160 :
161 : // We declare this as an array so that retrieving a pointer to this
162 : // binding's property hooks only requires compile/link-time resolvable
163 : // address arithmetic. Declaring it as a pointer instead would require
164 : // doing a run-time load to fetch a pointer to this binding's property
165 : // hooks. And then structures which embedded a pointer to this structure
166 : // would require a run-time load for proper initialization, which would
167 : // then induce static constructors. Lots of static constructors.
168 : extern const NativePropertyHooks sNativePropertyHooks[];
169 :
170 : void
171 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal);
172 :
173 : JS::Handle<JSObject*>
174 : GetProtoObjectHandle(JSContext* aCx);
175 :
176 : JS::Handle<JSObject*>
177 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true);
178 :
179 : JSObject*
180 : GetConstructorObject(JSContext* aCx);
181 :
182 : } // namespace DataTransferItemBinding
183 :
184 :
185 :
186 : } // namespace dom
187 : } // namespace mozilla
188 :
189 : #endif // mozilla_dom_DataTransferItemBinding_h
|