LCOV - code coverage report
Current view: top level - obj-x86_64-pc-linux-gnu/dist/include/mozilla/dom - FunctionBinding.h (source / functions) Hit Total Coverage
Test: output.info Lines: 18 47 38.3 %
Date: 2017-07-14 16:53:18 Functions: 4 19 21.1 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM Function.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #ifndef mozilla_dom_FunctionBinding_h
       4             : #define mozilla_dom_FunctionBinding_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 Function;
      18             : struct NativePropertyHooks;
      19             : class ProtoAndIfaceCache;
      20             : class VoidFunction;
      21             : 
      22             : } // namespace dom
      23             : } // namespace mozilla
      24             : 
      25             : namespace mozilla {
      26             : namespace dom {
      27             : 
      28           0 : class Function : public CallbackFunction
      29             : {
      30             : public:
      31           0 :   explicit inline Function(JSContext* aCx, JS::Handle<JSObject*> aCallback, nsIGlobalObject* aIncumbentGlobal)
      32           0 :     : CallbackFunction(aCx, aCallback, aIncumbentGlobal)
      33             :   {
      34           0 :     MOZ_ASSERT(JS::IsCallable(mCallback));
      35           0 :   }
      36             : 
      37          11 :   explicit inline Function(JS::Handle<JSObject*> aCallback, const FastCallbackConstructor& )
      38          11 :     : CallbackFunction(aCallback, FastCallbackConstructor())
      39             :   {
      40          11 :     MOZ_ASSERT(JS::IsCallable(mCallback));
      41          11 :   }
      42             : 
      43             :   explicit inline Function(JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aAsyncStack, nsIGlobalObject* aIncumbentGlobal)
      44             :     : CallbackFunction(aCallback, aAsyncStack, aIncumbentGlobal)
      45             :   {
      46             :     MOZ_ASSERT(JS::IsCallable(mCallback));
      47             :   }
      48             : 
      49             :   explicit inline Function(CallbackFunction* aOther)
      50             :     : CallbackFunction(aOther)
      51             :   {
      52             :   }
      53             : 
      54             :   template <typename T>
      55             :   inline void
      56           7 :   Call(const T& thisVal, const nsTArray<JS::Value>& arguments, JS::MutableHandle<JS::Value> aRetVal, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JSCompartment* aCompartment = nullptr)
      57             :   {
      58           7 :     MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
      59           7 :     if (!aExecutionReason) {
      60           0 :       aExecutionReason = "Function";
      61             :     }
      62          14 :     CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aCompartment);
      63           7 :     if (!s.GetContext()) {
      64           0 :       MOZ_ASSERT(aRv.Failed());
      65           0 :       return;
      66             :     }
      67          14 :     JS::Rooted<JS::Value> thisValJS(s.GetContext());
      68           7 :     if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) {
      69           0 :       aRv.Throw(NS_ERROR_FAILURE);
      70           0 :       return;
      71             :     }
      72           7 :     return Call(s.GetContext(), thisValJS, arguments, aRetVal, aRv);
      73             :   }
      74             : 
      75             :   inline void
      76             :   Call(const nsTArray<JS::Value>& arguments, JS::MutableHandle<JS::Value> aRetVal, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JSCompartment* aCompartment = nullptr)
      77             :   {
      78             :     MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
      79             :     if (!aExecutionReason) {
      80             :       aExecutionReason = "Function";
      81             :     }
      82             :     CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aCompartment);
      83             :     if (!s.GetContext()) {
      84             :       MOZ_ASSERT(aRv.Failed());
      85             :       return;
      86             :     }
      87             :     return Call(s.GetContext(), JS::UndefinedHandleValue, arguments, aRetVal, aRv);
      88             :   }
      89             : 
      90             :   template <typename T>
      91             :   inline void
      92             :   Call(const T& thisVal, const nsTArray<JS::Value>& arguments, JS::MutableHandle<JS::Value> aRetVal, const char* aExecutionReason = nullptr)
      93             :   {
      94             :     IgnoredErrorResult rv;
      95             :     return Call(thisVal, arguments, aRetVal, rv, aExecutionReason);
      96             :   }
      97             : 
      98             :   inline void
      99             :   Call(const nsTArray<JS::Value>& arguments, JS::MutableHandle<JS::Value> aRetVal, const char* aExecutionReason = nullptr)
     100             :   {
     101             :     IgnoredErrorResult rv;
     102             :     return Call(arguments, aRetVal, rv, aExecutionReason, eReportExceptions, nullptr);
     103             :   }
     104             : 
     105             :   inline bool
     106             :   operator==(const Function& aOther) const
     107             :   {
     108             :     return CallbackFunction::operator==(aOther);
     109             :   }
     110             : 
     111             : private:
     112             :   void Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, const nsTArray<JS::Value>& arguments, JS::MutableHandle<JS::Value> aRetVal, ErrorResult& aRv);
     113             : };
     114             : 
     115             : 
     116           0 : class VoidFunction : public CallbackFunction
     117             : {
     118             : public:
     119             :   explicit inline VoidFunction(JSContext* aCx, JS::Handle<JSObject*> aCallback, nsIGlobalObject* aIncumbentGlobal)
     120             :     : CallbackFunction(aCx, aCallback, aIncumbentGlobal)
     121             :   {
     122             :     MOZ_ASSERT(JS::IsCallable(mCallback));
     123             :   }
     124             : 
     125           0 :   explicit inline VoidFunction(JS::Handle<JSObject*> aCallback, const FastCallbackConstructor& )
     126           0 :     : CallbackFunction(aCallback, FastCallbackConstructor())
     127             :   {
     128           0 :     MOZ_ASSERT(JS::IsCallable(mCallback));
     129           0 :   }
     130             : 
     131             :   explicit inline VoidFunction(JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aAsyncStack, nsIGlobalObject* aIncumbentGlobal)
     132             :     : CallbackFunction(aCallback, aAsyncStack, aIncumbentGlobal)
     133             :   {
     134             :     MOZ_ASSERT(JS::IsCallable(mCallback));
     135             :   }
     136             : 
     137             :   explicit inline VoidFunction(CallbackFunction* aOther)
     138             :     : CallbackFunction(aOther)
     139             :   {
     140             :   }
     141             : 
     142             :   template <typename T>
     143             :   inline void
     144             :   Call(const T& thisVal, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JSCompartment* aCompartment = nullptr)
     145             :   {
     146             :     MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
     147             :     if (!aExecutionReason) {
     148             :       aExecutionReason = "VoidFunction";
     149             :     }
     150             :     CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aCompartment);
     151             :     if (!s.GetContext()) {
     152             :       MOZ_ASSERT(aRv.Failed());
     153             :       return;
     154             :     }
     155             :     JS::Rooted<JS::Value> thisValJS(s.GetContext());
     156             :     if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) {
     157             :       aRv.Throw(NS_ERROR_FAILURE);
     158             :       return;
     159             :     }
     160             :     return Call(s.GetContext(), thisValJS, aRv);
     161             :   }
     162             : 
     163             :   inline void
     164             :   Call(ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JSCompartment* aCompartment = nullptr)
     165             :   {
     166             :     MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
     167             :     if (!aExecutionReason) {
     168             :       aExecutionReason = "VoidFunction";
     169             :     }
     170             :     CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aCompartment);
     171             :     if (!s.GetContext()) {
     172             :       MOZ_ASSERT(aRv.Failed());
     173             :       return;
     174             :     }
     175             :     return Call(s.GetContext(), JS::UndefinedHandleValue, aRv);
     176             :   }
     177             : 
     178             :   template <typename T>
     179             :   inline void
     180             :   Call(const T& thisVal, const char* aExecutionReason = nullptr)
     181             :   {
     182             :     IgnoredErrorResult rv;
     183             :     return Call(thisVal, rv, aExecutionReason);
     184             :   }
     185             : 
     186             :   inline void
     187             :   Call(const char* aExecutionReason = nullptr)
     188             :   {
     189             :     IgnoredErrorResult rv;
     190             :     return Call(rv, aExecutionReason, eReportExceptions, nullptr);
     191             :   }
     192             : 
     193             :   inline bool
     194             :   operator==(const VoidFunction& aOther) const
     195             :   {
     196             :     return CallbackFunction::operator==(aOther);
     197             :   }
     198             : 
     199             : private:
     200             :   void Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, ErrorResult& aRv);
     201             : };
     202             : 
     203             : 
     204             : namespace binding_detail {
     205           0 : class FastFunction : public Function
     206             : {
     207             : public:
     208          11 :   explicit inline FastFunction(JS::Handle<JSObject*> aCallback)
     209          11 :     : Function(aCallback, FastCallbackConstructor())
     210             :   {
     211          11 :   }
     212             : 
     213             :   inline void
     214           0 :   Trace(JSTracer* aTracer)
     215             :   {
     216           0 :     Function::Trace(aTracer);
     217           0 :   }
     218             : 
     219             :   inline void
     220          11 :   FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx)
     221             :   {
     222          11 :     Function::FinishSlowJSInitIfMoreThanOneOwner(aCx);
     223          11 :   }
     224             : };
     225             : } // namespace binding_detail
     226             : 
     227             : 
     228             : namespace binding_detail {
     229           0 : class FastVoidFunction : public VoidFunction
     230             : {
     231             : public:
     232           0 :   explicit inline FastVoidFunction(JS::Handle<JSObject*> aCallback)
     233           0 :     : VoidFunction(aCallback, FastCallbackConstructor())
     234             :   {
     235           0 :   }
     236             : 
     237             :   inline void
     238           0 :   Trace(JSTracer* aTracer)
     239             :   {
     240           0 :     VoidFunction::Trace(aTracer);
     241           0 :   }
     242             : 
     243             :   inline void
     244           0 :   FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx)
     245             :   {
     246           0 :     VoidFunction::FinishSlowJSInitIfMoreThanOneOwner(aCx);
     247           0 :   }
     248             : };
     249             : } // namespace binding_detail
     250             : 
     251             : 
     252             : } // namespace dom
     253             : } // namespace mozilla
     254             : 
     255             : #endif // mozilla_dom_FunctionBinding_h

Generated by: LCOV version 1.13