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

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM Blob.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #ifndef mozilla_dom_BlobBinding_h
       4             : #define mozilla_dom_BlobBinding_h
       5             : 
       6             : #include "js/RootingAPI.h"
       7             : #include "jsfriendapi.h"
       8             : #include "jspubtd.h"
       9             : #include "mozilla/ErrorResult.h"
      10             : #include "mozilla/dom/BindingDeclarations.h"
      11             : #include "mozilla/dom/FakeString.h"
      12             : #include "mozilla/dom/Nullable.h"
      13             : #include "mozilla/dom/TypedArray.h"
      14             : #include "mozilla/dom/UnionMember.h"
      15             : 
      16             : namespace mozilla {
      17             : namespace dom {
      18             : 
      19             : class Blob;
      20             : struct BlobAtoms;
      21             : struct BlobPropertyBagAtoms;
      22             : struct NativePropertyHooks;
      23             : class OwningArrayBufferViewOrArrayBufferOrBlobOrUSVString;
      24             : class ProtoAndIfaceCache;
      25             : 
      26             : } // namespace dom
      27             : } // namespace mozilla
      28             : 
      29             : namespace mozilla {
      30             : namespace dom {
      31             : 
      32             : enum class EndingTypes : uint8_t {
      33             :   Transparent,
      34             :   Native,
      35             :   EndGuard_
      36             : };
      37             : 
      38             : namespace EndingTypesValues {
      39             : extern const EnumEntry strings[3];
      40             : } // namespace EndingTypesValues
      41             : 
      42             : bool
      43             : ToJSValue(JSContext* aCx, EndingTypes aArgument, JS::MutableHandle<JS::Value> aValue);
      44             : 
      45             : 
      46             : void
      47             : ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningArrayBufferViewOrArrayBufferOrBlobOrUSVString& aUnion, const char* aName, uint32_t aFlags = 0);
      48             : 
      49             : 
      50             : void
      51             : ImplCycleCollectionUnlink(OwningArrayBufferViewOrArrayBufferOrBlobOrUSVString& aUnion);
      52             : 
      53             : 
      54             : class ArrayBufferViewOrArrayBufferOrBlobOrUSVString
      55             : {
      56             :   friend class ArrayBufferViewOrArrayBufferOrBlobOrUSVStringArgument;
      57             :   enum Type
      58             :   {
      59             :     eUninitialized,
      60             :     eArrayBufferView,
      61             :     eArrayBuffer,
      62             :     eBlob,
      63             :     eUSVString
      64             :   };
      65             : 
      66             :   union Value
      67             :   {
      68             :     UnionMember<RootedTypedArray<ArrayBufferView> > mArrayBufferView;
      69             :     UnionMember<RootedTypedArray<ArrayBuffer> > mArrayBuffer;
      70             :     UnionMember<NonNull<mozilla::dom::Blob> > mBlob;
      71             :     UnionMember<binding_detail::FakeString > mUSVString;
      72             : 
      73             :   };
      74             : 
      75             :   Type mType;
      76             :   Value mValue;
      77             : 
      78             :   ArrayBufferViewOrArrayBufferOrBlobOrUSVString(const ArrayBufferViewOrArrayBufferOrBlobOrUSVString&) = delete;
      79             :   ArrayBufferViewOrArrayBufferOrBlobOrUSVString& operator=(const ArrayBufferViewOrArrayBufferOrBlobOrUSVString&) = delete;
      80             : public:
      81             :   explicit inline ArrayBufferViewOrArrayBufferOrBlobOrUSVString()
      82             :     : mType(eUninitialized)
      83             :   {
      84             :   }
      85             : 
      86             :   inline ~ArrayBufferViewOrArrayBufferOrBlobOrUSVString()
      87             :   {
      88             :     Uninit();
      89             :   }
      90             : 
      91             :   inline RootedTypedArray<ArrayBufferView>&
      92             :   RawSetAsArrayBufferView(JSContext* cx)
      93             :   {
      94             :     if (mType == eArrayBufferView) {
      95             :       return mValue.mArrayBufferView.Value();
      96             :     }
      97             :     MOZ_ASSERT(mType == eUninitialized);
      98             :     mType = eArrayBufferView;
      99             :     return mValue.mArrayBufferView.SetValue(cx);
     100             :   }
     101             : 
     102             :   inline RootedTypedArray<ArrayBufferView>&
     103             :   SetAsArrayBufferView(JSContext* cx)
     104             :   {
     105             :     if (mType == eArrayBufferView) {
     106             :       return mValue.mArrayBufferView.Value();
     107             :     }
     108             :     Uninit();
     109             :     mType = eArrayBufferView;
     110             :     return mValue.mArrayBufferView.SetValue(cx);
     111             :   }
     112             : 
     113             :   inline bool
     114             :   IsArrayBufferView() const
     115             :   {
     116             :     return mType == eArrayBufferView;
     117             :   }
     118             : 
     119             :   inline RootedTypedArray<ArrayBufferView>&
     120             :   GetAsArrayBufferView()
     121             :   {
     122             :     MOZ_ASSERT(IsArrayBufferView(), "Wrong type!");
     123             :     return mValue.mArrayBufferView.Value();
     124             :   }
     125             : 
     126             :   inline ArrayBufferView const &
     127             :   GetAsArrayBufferView() const
     128             :   {
     129             :     MOZ_ASSERT(IsArrayBufferView(), "Wrong type!");
     130             :     return mValue.mArrayBufferView.Value();
     131             :   }
     132             : 
     133             :   inline RootedTypedArray<ArrayBuffer>&
     134             :   RawSetAsArrayBuffer(JSContext* cx)
     135             :   {
     136             :     if (mType == eArrayBuffer) {
     137             :       return mValue.mArrayBuffer.Value();
     138             :     }
     139             :     MOZ_ASSERT(mType == eUninitialized);
     140             :     mType = eArrayBuffer;
     141             :     return mValue.mArrayBuffer.SetValue(cx);
     142             :   }
     143             : 
     144             :   inline RootedTypedArray<ArrayBuffer>&
     145             :   SetAsArrayBuffer(JSContext* cx)
     146             :   {
     147             :     if (mType == eArrayBuffer) {
     148             :       return mValue.mArrayBuffer.Value();
     149             :     }
     150             :     Uninit();
     151             :     mType = eArrayBuffer;
     152             :     return mValue.mArrayBuffer.SetValue(cx);
     153             :   }
     154             : 
     155             :   inline bool
     156             :   IsArrayBuffer() const
     157             :   {
     158             :     return mType == eArrayBuffer;
     159             :   }
     160             : 
     161             :   inline RootedTypedArray<ArrayBuffer>&
     162             :   GetAsArrayBuffer()
     163             :   {
     164             :     MOZ_ASSERT(IsArrayBuffer(), "Wrong type!");
     165             :     return mValue.mArrayBuffer.Value();
     166             :   }
     167             : 
     168             :   inline ArrayBuffer const &
     169             :   GetAsArrayBuffer() const
     170             :   {
     171             :     MOZ_ASSERT(IsArrayBuffer(), "Wrong type!");
     172             :     return mValue.mArrayBuffer.Value();
     173             :   }
     174             : 
     175             :   inline NonNull<mozilla::dom::Blob>&
     176             :   RawSetAsBlob()
     177             :   {
     178             :     if (mType == eBlob) {
     179             :       return mValue.mBlob.Value();
     180             :     }
     181             :     MOZ_ASSERT(mType == eUninitialized);
     182             :     mType = eBlob;
     183             :     return mValue.mBlob.SetValue();
     184             :   }
     185             : 
     186             :   inline NonNull<mozilla::dom::Blob>&
     187             :   SetAsBlob()
     188             :   {
     189             :     if (mType == eBlob) {
     190             :       return mValue.mBlob.Value();
     191             :     }
     192             :     Uninit();
     193             :     mType = eBlob;
     194             :     return mValue.mBlob.SetValue();
     195             :   }
     196             : 
     197             :   inline bool
     198             :   IsBlob() const
     199             :   {
     200             :     return mType == eBlob;
     201             :   }
     202             : 
     203             :   inline NonNull<mozilla::dom::Blob>&
     204             :   GetAsBlob()
     205             :   {
     206             :     MOZ_ASSERT(IsBlob(), "Wrong type!");
     207             :     return mValue.mBlob.Value();
     208             :   }
     209             : 
     210             :   inline mozilla::dom::Blob&
     211             :   GetAsBlob() const
     212             :   {
     213             :     MOZ_ASSERT(IsBlob(), "Wrong type!");
     214             :     return mValue.mBlob.Value();
     215             :   }
     216             : 
     217             :   inline binding_detail::FakeString&
     218             :   RawSetAsUSVString()
     219             :   {
     220             :     if (mType == eUSVString) {
     221             :       return mValue.mUSVString.Value();
     222             :     }
     223             :     MOZ_ASSERT(mType == eUninitialized);
     224             :     mType = eUSVString;
     225             :     return mValue.mUSVString.SetValue();
     226             :   }
     227             : 
     228             :   inline binding_detail::FakeString&
     229             :   SetAsUSVString()
     230             :   {
     231             :     if (mType == eUSVString) {
     232             :       return mValue.mUSVString.Value();
     233             :     }
     234             :     Uninit();
     235             :     mType = eUSVString;
     236             :     return mValue.mUSVString.SetValue();
     237             :   }
     238             : 
     239             :   inline bool
     240             :   IsUSVString() const
     241             :   {
     242             :     return mType == eUSVString;
     243             :   }
     244             : 
     245             :   inline binding_detail::FakeString&
     246             :   GetAsUSVString()
     247             :   {
     248             :     MOZ_ASSERT(IsUSVString(), "Wrong type!");
     249             :     return mValue.mUSVString.Value();
     250             :   }
     251             : 
     252             :   inline const nsAString&
     253             :   GetAsUSVString() const
     254             :   {
     255             :     MOZ_ASSERT(IsUSVString(), "Wrong type!");
     256             :     return mValue.mUSVString.Value();
     257             :   }
     258             : 
     259             :   inline void
     260             :   Uninit()
     261             :   {
     262             :     switch (mType) {
     263             :       case eUninitialized: {
     264             :         break;
     265             :       }
     266             :       case eArrayBufferView: {
     267             :         DestroyArrayBufferView();
     268             :         break;
     269             :       }
     270             :       case eArrayBuffer: {
     271             :         DestroyArrayBuffer();
     272             :         break;
     273             :       }
     274             :       case eBlob: {
     275             :         DestroyBlob();
     276             :         break;
     277             :       }
     278             :       case eUSVString: {
     279             :         DestroyUSVString();
     280             :         break;
     281             :       }
     282             :     }
     283             :   }
     284             : 
     285             :   bool
     286             :   ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
     287             : 
     288             : private:
     289             :   inline void
     290             :   DestroyArrayBufferView()
     291             :   {
     292             :     MOZ_ASSERT(IsArrayBufferView(), "Wrong type!");
     293             :     mValue.mArrayBufferView.Destroy();
     294             :     mType = eUninitialized;
     295             :   }
     296             : 
     297             :   inline void
     298             :   DestroyArrayBuffer()
     299             :   {
     300             :     MOZ_ASSERT(IsArrayBuffer(), "Wrong type!");
     301             :     mValue.mArrayBuffer.Destroy();
     302             :     mType = eUninitialized;
     303             :   }
     304             : 
     305             :   inline void
     306             :   DestroyBlob()
     307             :   {
     308             :     MOZ_ASSERT(IsBlob(), "Wrong type!");
     309             :     mValue.mBlob.Destroy();
     310             :     mType = eUninitialized;
     311             :   }
     312             : 
     313             :   inline void
     314             :   DestroyUSVString()
     315             :   {
     316             :     MOZ_ASSERT(IsUSVString(), "Wrong type!");
     317             :     mValue.mUSVString.Destroy();
     318             :     mType = eUninitialized;
     319             :   }
     320             : };
     321             : 
     322             : 
     323             : class OwningArrayBufferViewOrArrayBufferOrBlobOrUSVString : public AllOwningUnionBase
     324             : {
     325             :   friend void ImplCycleCollectionUnlink(OwningArrayBufferViewOrArrayBufferOrBlobOrUSVString& aUnion);
     326             :   enum Type
     327             :   {
     328             :     eUninitialized,
     329             :     eArrayBufferView,
     330             :     eArrayBuffer,
     331             :     eBlob,
     332             :     eUSVString
     333             :   };
     334             : 
     335           0 :   union Value
     336             :   {
     337             :     UnionMember<ArrayBufferView > mArrayBufferView;
     338             :     UnionMember<ArrayBuffer > mArrayBuffer;
     339             :     UnionMember<OwningNonNull<mozilla::dom::Blob> > mBlob;
     340             :     UnionMember<nsString > mUSVString;
     341             : 
     342             :   };
     343             : 
     344             :   Type mType;
     345             :   Value mValue;
     346             : 
     347             :   OwningArrayBufferViewOrArrayBufferOrBlobOrUSVString(const OwningArrayBufferViewOrArrayBufferOrBlobOrUSVString&) = delete;
     348             :   OwningArrayBufferViewOrArrayBufferOrBlobOrUSVString& operator=(const OwningArrayBufferViewOrArrayBufferOrBlobOrUSVString&) = delete;
     349             : public:
     350           0 :   explicit inline OwningArrayBufferViewOrArrayBufferOrBlobOrUSVString()
     351           0 :     : mType(eUninitialized)
     352             :   {
     353           0 :   }
     354             : 
     355           0 :   inline ~OwningArrayBufferViewOrArrayBufferOrBlobOrUSVString()
     356           0 :   {
     357           0 :     Uninit();
     358           0 :   }
     359             : 
     360             :   ArrayBufferView&
     361             :   RawSetAsArrayBufferView();
     362             : 
     363             :   ArrayBufferView&
     364             :   SetAsArrayBufferView();
     365             : 
     366             :   bool
     367             :   TrySetToArrayBufferView(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
     368             : 
     369             :   inline bool
     370           0 :   IsArrayBufferView() const
     371             :   {
     372           0 :     return mType == eArrayBufferView;
     373             :   }
     374             : 
     375             :   inline ArrayBufferView&
     376           0 :   GetAsArrayBufferView()
     377             :   {
     378           0 :     MOZ_ASSERT(IsArrayBufferView(), "Wrong type!");
     379           0 :     return mValue.mArrayBufferView.Value();
     380             :   }
     381             : 
     382             :   inline ArrayBufferView const &
     383           0 :   GetAsArrayBufferView() const
     384             :   {
     385           0 :     MOZ_ASSERT(IsArrayBufferView(), "Wrong type!");
     386           0 :     return mValue.mArrayBufferView.Value();
     387             :   }
     388             : 
     389             :   ArrayBuffer&
     390             :   RawSetAsArrayBuffer();
     391             : 
     392             :   ArrayBuffer&
     393             :   SetAsArrayBuffer();
     394             : 
     395             :   bool
     396             :   TrySetToArrayBuffer(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
     397             : 
     398             :   inline bool
     399           0 :   IsArrayBuffer() const
     400             :   {
     401           0 :     return mType == eArrayBuffer;
     402             :   }
     403             : 
     404             :   inline ArrayBuffer&
     405           0 :   GetAsArrayBuffer()
     406             :   {
     407           0 :     MOZ_ASSERT(IsArrayBuffer(), "Wrong type!");
     408           0 :     return mValue.mArrayBuffer.Value();
     409             :   }
     410             : 
     411             :   inline ArrayBuffer const &
     412           0 :   GetAsArrayBuffer() const
     413             :   {
     414           0 :     MOZ_ASSERT(IsArrayBuffer(), "Wrong type!");
     415           0 :     return mValue.mArrayBuffer.Value();
     416             :   }
     417             : 
     418             :   OwningNonNull<mozilla::dom::Blob>&
     419             :   RawSetAsBlob();
     420             : 
     421             :   OwningNonNull<mozilla::dom::Blob>&
     422             :   SetAsBlob();
     423             : 
     424             :   bool
     425             :   TrySetToBlob(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
     426             : 
     427             :   inline bool
     428           0 :   IsBlob() const
     429             :   {
     430           0 :     return mType == eBlob;
     431             :   }
     432             : 
     433             :   inline OwningNonNull<mozilla::dom::Blob>&
     434           0 :   GetAsBlob()
     435             :   {
     436           0 :     MOZ_ASSERT(IsBlob(), "Wrong type!");
     437           0 :     return mValue.mBlob.Value();
     438             :   }
     439             : 
     440             :   inline OwningNonNull<mozilla::dom::Blob> const &
     441           0 :   GetAsBlob() const
     442             :   {
     443           0 :     MOZ_ASSERT(IsBlob(), "Wrong type!");
     444           0 :     return mValue.mBlob.Value();
     445             :   }
     446             : 
     447             :   nsString&
     448             :   RawSetAsUSVString();
     449             : 
     450             :   nsString&
     451             :   SetAsUSVString();
     452             : 
     453             :   bool
     454             :   TrySetToUSVString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
     455             : 
     456             :   inline void
     457             :   SetStringData(const nsString::char_type* aData, nsString::size_type aLength)
     458             :   {
     459             :     RawSetAsUSVString().Assign(aData, aLength);
     460             :   }
     461             : 
     462             :   inline bool
     463           0 :   IsUSVString() const
     464             :   {
     465           0 :     return mType == eUSVString;
     466             :   }
     467             : 
     468             :   inline nsString&
     469             :   GetAsUSVString()
     470             :   {
     471             :     MOZ_ASSERT(IsUSVString(), "Wrong type!");
     472             :     return mValue.mUSVString.Value();
     473             :   }
     474             : 
     475             :   inline nsString const &
     476           0 :   GetAsUSVString() const
     477             :   {
     478           0 :     MOZ_ASSERT(IsUSVString(), "Wrong type!");
     479           0 :     return mValue.mUSVString.Value();
     480             :   }
     481             : 
     482             :   void
     483             :   Uninit();
     484             : 
     485             :   bool
     486             :   ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
     487             : 
     488             :   void
     489             :   TraceUnion(JSTracer* trc);
     490             : 
     491             : private:
     492             :   void
     493             :   DestroyArrayBufferView();
     494             : 
     495             :   void
     496             :   DestroyArrayBuffer();
     497             : 
     498             :   void
     499             :   DestroyBlob();
     500             : 
     501             :   void
     502             :   DestroyUSVString();
     503             : };
     504             : 
     505             : 
     506           0 : struct BlobPropertyBag : public DictionaryBase
     507             : {
     508             :   MOZ_INIT_OUTSIDE_CTOR EndingTypes mEndings;
     509             :   MOZ_INIT_OUTSIDE_CTOR nsString mType;
     510             : 
     511             :   BlobPropertyBag();
     512             : 
     513           0 :   explicit inline BlobPropertyBag(const FastDictionaryInitializer& )
     514           0 :   {
     515             :     // Do nothing here; this is used by our "Fast" subclass
     516           0 :   }
     517             : 
     518             :   explicit inline BlobPropertyBag(const BlobPropertyBag& aOther)
     519             :   {
     520             :     *this = aOther;
     521             :   }
     522             : 
     523             :   bool
     524             :   Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
     525             : 
     526             :   bool
     527             :   Init(const nsAString& aJSON);
     528             : 
     529             :   bool
     530             :   ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
     531             : 
     532             :   bool
     533             :   ToJSON(nsAString& aJSON) const;
     534             : 
     535             :   void
     536             :   TraceDictionary(JSTracer* trc);
     537             : 
     538             :   BlobPropertyBag&
     539             :   operator=(const BlobPropertyBag& aOther);
     540             : 
     541             : private:
     542             :   static bool
     543             :   InitIds(JSContext* cx, BlobPropertyBagAtoms* atomsCache);
     544             : };
     545             : 
     546             : namespace binding_detail {
     547           0 : struct FastBlobPropertyBag : public BlobPropertyBag
     548             : {
     549           0 :   inline FastBlobPropertyBag()
     550           0 :     : BlobPropertyBag(FastDictionaryInitializer())
     551             :   {
     552             :     // Doesn't matter what int we pass to the parent constructor
     553           0 :   }
     554             : };
     555             : } // namespace binding_detail
     556             : 
     557             : 
     558             : namespace BlobBinding {
     559             : 
     560             :   typedef mozilla::dom::Blob NativeType;
     561             : 
     562             :   JSObject*
     563             :   DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal);
     564             : 
     565             :   const JSClass*
     566             :   GetJSClass();
     567             : 
     568             :   bool
     569             :   Wrap(JSContext* aCx, mozilla::dom::Blob* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
     570             : 
     571             :   template <class T>
     572           0 :   inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto)
     573             :   {
     574           0 :     JS::Rooted<JSObject*> reflector(aCx);
     575           0 :     return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr;
     576             :   }
     577             : 
     578             :   // We declare this as an array so that retrieving a pointer to this
     579             :   // binding's property hooks only requires compile/link-time resolvable
     580             :   // address arithmetic.  Declaring it as a pointer instead would require
     581             :   // doing a run-time load to fetch a pointer to this binding's property
     582             :   // hooks.  And then structures which embedded a pointer to this structure
     583             :   // would require a run-time load for proper initialization, which would
     584             :   // then induce static constructors.  Lots of static constructors.
     585             :   extern const NativePropertyHooks sNativePropertyHooks[];
     586             : 
     587             :   void
     588             :   CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal);
     589             : 
     590             :   JS::Handle<JSObject*>
     591             :   GetProtoObjectHandle(JSContext* aCx);
     592             : 
     593             :   JSObject*
     594             :   GetProtoObject(JSContext* aCx);
     595             : 
     596             :   JS::Handle<JSObject*>
     597             :   GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true);
     598             : 
     599             :   JSObject*
     600             :   GetConstructorObject(JSContext* aCx);
     601             : 
     602             : } // namespace BlobBinding
     603             : 
     604             : 
     605             : 
     606             : } // namespace dom
     607             : } // namespace mozilla
     608             : 
     609             : #endif // mozilla_dom_BlobBinding_h

Generated by: LCOV version 1.13