LCOV - code coverage report
Current view: top level - obj-x86_64-pc-linux-gnu/dom/bindings - FileReaderSyncBinding.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 21 188 11.2 %
Date: 2017-07-14 16:53:18 Functions: 3 12 25.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM FileReaderSync.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "FileReaderSyncBinding.h"
       4             : #include "WrapperFactory.h"
       5             : #include "jsfriendapi.h"
       6             : #include "mozilla/OwningNonNull.h"
       7             : #include "mozilla/dom/BindingUtils.h"
       8             : #include "mozilla/dom/Blob.h"
       9             : #include "mozilla/dom/DOMJSClass.h"
      10             : #include "mozilla/dom/FileReaderSync.h"
      11             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      12             : #include "mozilla/dom/TypedArray.h"
      13             : 
      14             : namespace mozilla {
      15             : namespace dom {
      16             : 
      17             : namespace FileReaderSyncBinding {
      18             : 
      19             : static bool
      20           0 : readAsArrayBuffer(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FileReaderSync* self, const JSJitMethodCallArgs& args)
      21             : {
      22           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
      23           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "FileReaderSync.readAsArrayBuffer");
      24             :   }
      25           0 :   Maybe<JS::Rooted<JSObject*> > unwrappedObj;
      26           0 :   bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
      27           0 :   if (objIsXray) {
      28           0 :     unwrappedObj.emplace(cx, obj);
      29             :   }
      30           0 :   NonNull<mozilla::dom::Blob> arg0;
      31           0 :   if (args[0].isObject()) {
      32             :     {
      33           0 :       nsresult rv = UnwrapObject<prototypes::id::Blob, mozilla::dom::Blob>(args[0], arg0);
      34           0 :       if (NS_FAILED(rv)) {
      35           0 :         ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of FileReaderSync.readAsArrayBuffer", "Blob");
      36           0 :         return false;
      37             :       }
      38             :     }
      39             :   } else {
      40           0 :     ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of FileReaderSync.readAsArrayBuffer");
      41           0 :     return false;
      42             :   }
      43           0 :   if (objIsXray) {
      44           0 :     unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref());
      45           0 :     if (!unwrappedObj.ref()) {
      46           0 :       return false;
      47             :     }
      48             :   }
      49           0 :   binding_detail::FastErrorResult rv;
      50           0 :   JS::Rooted<JSObject*> result(cx);
      51           0 :   self->ReadAsArrayBuffer(cx, unwrappedObj ? *unwrappedObj : obj, NonNullHelper(arg0), &result, rv);
      52           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
      53           0 :     return false;
      54             :   }
      55           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      56           0 :   JS::ExposeObjectToActiveJS(result);
      57           0 :   args.rval().setObject(*result);
      58           0 :   if (!MaybeWrapNonDOMObjectValue(cx, args.rval())) {
      59           0 :     return false;
      60             :   }
      61           0 :   return true;
      62             : }
      63             : 
      64             : static const JSJitInfo readAsArrayBuffer_methodinfo = {
      65             :   { (JSJitGetterOp)readAsArrayBuffer },
      66             :   { prototypes::id::FileReaderSync },
      67             :   { PrototypeTraits<prototypes::id::FileReaderSync>::Depth },
      68             :   JSJitInfo::Method,
      69             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
      70             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
      71             :   false,  /* isInfallible. False in setters. */
      72             :   false,  /* isMovable.  Not relevant for setters. */
      73             :   false, /* isEliminatable.  Not relevant for setters. */
      74             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
      75             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
      76             :   false,  /* isTypedMethod.  Only relevant for methods. */
      77             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
      78             : };
      79             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
      80             : static_assert(0 < 1, "There is no slot for us");
      81             : 
      82             : static bool
      83           0 : readAsBinaryString(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FileReaderSync* self, const JSJitMethodCallArgs& args)
      84             : {
      85           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
      86           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "FileReaderSync.readAsBinaryString");
      87             :   }
      88           0 :   NonNull<mozilla::dom::Blob> arg0;
      89           0 :   if (args[0].isObject()) {
      90             :     {
      91           0 :       nsresult rv = UnwrapObject<prototypes::id::Blob, mozilla::dom::Blob>(args[0], arg0);
      92           0 :       if (NS_FAILED(rv)) {
      93           0 :         ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of FileReaderSync.readAsBinaryString", "Blob");
      94           0 :         return false;
      95             :       }
      96             :     }
      97             :   } else {
      98           0 :     ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of FileReaderSync.readAsBinaryString");
      99           0 :     return false;
     100             :   }
     101           0 :   binding_detail::FastErrorResult rv;
     102           0 :   DOMString result;
     103           0 :   self->ReadAsBinaryString(NonNullHelper(arg0), result, rv);
     104           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     105           0 :     return false;
     106             :   }
     107           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     108           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
     109           0 :     return false;
     110             :   }
     111           0 :   return true;
     112             : }
     113             : 
     114             : static const JSJitInfo readAsBinaryString_methodinfo = {
     115             :   { (JSJitGetterOp)readAsBinaryString },
     116             :   { prototypes::id::FileReaderSync },
     117             :   { PrototypeTraits<prototypes::id::FileReaderSync>::Depth },
     118             :   JSJitInfo::Method,
     119             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     120             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
     121             :   false,  /* isInfallible. False in setters. */
     122             :   false,  /* isMovable.  Not relevant for setters. */
     123             :   false, /* isEliminatable.  Not relevant for setters. */
     124             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     125             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     126             :   false,  /* isTypedMethod.  Only relevant for methods. */
     127             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     128             : };
     129             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     130             : static_assert(0 < 1, "There is no slot for us");
     131             : 
     132             : static bool
     133           0 : readAsText(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FileReaderSync* self, const JSJitMethodCallArgs& args)
     134             : {
     135           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
     136           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "FileReaderSync.readAsText");
     137             :   }
     138           0 :   NonNull<mozilla::dom::Blob> arg0;
     139           0 :   if (args[0].isObject()) {
     140             :     {
     141           0 :       nsresult rv = UnwrapObject<prototypes::id::Blob, mozilla::dom::Blob>(args[0], arg0);
     142           0 :       if (NS_FAILED(rv)) {
     143           0 :         ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of FileReaderSync.readAsText", "Blob");
     144           0 :         return false;
     145             :       }
     146             :     }
     147             :   } else {
     148           0 :     ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of FileReaderSync.readAsText");
     149           0 :     return false;
     150             :   }
     151           0 :   Optional<nsAString> arg1;
     152           0 :   binding_detail::FakeString arg1_holder;
     153           0 :   if (args.hasDefined(1)) {
     154           0 :     if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1_holder)) {
     155           0 :       return false;
     156             :     }
     157           0 :     arg1 = &arg1_holder;
     158             :   }
     159           0 :   binding_detail::FastErrorResult rv;
     160           0 :   DOMString result;
     161           0 :   self->ReadAsText(NonNullHelper(arg0), NonNullHelper(Constify(arg1)), result, rv);
     162           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     163           0 :     return false;
     164             :   }
     165           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     166           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
     167           0 :     return false;
     168             :   }
     169           0 :   return true;
     170             : }
     171             : 
     172             : static const JSJitInfo readAsText_methodinfo = {
     173             :   { (JSJitGetterOp)readAsText },
     174             :   { prototypes::id::FileReaderSync },
     175             :   { PrototypeTraits<prototypes::id::FileReaderSync>::Depth },
     176             :   JSJitInfo::Method,
     177             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     178             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
     179             :   false,  /* isInfallible. False in setters. */
     180             :   false,  /* isMovable.  Not relevant for setters. */
     181             :   false, /* isEliminatable.  Not relevant for setters. */
     182             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     183             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     184             :   false,  /* isTypedMethod.  Only relevant for methods. */
     185             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     186             : };
     187             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     188             : static_assert(0 < 1, "There is no slot for us");
     189             : 
     190             : static bool
     191           0 : readAsDataURL(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FileReaderSync* self, const JSJitMethodCallArgs& args)
     192             : {
     193           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
     194           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "FileReaderSync.readAsDataURL");
     195             :   }
     196           0 :   NonNull<mozilla::dom::Blob> arg0;
     197           0 :   if (args[0].isObject()) {
     198             :     {
     199           0 :       nsresult rv = UnwrapObject<prototypes::id::Blob, mozilla::dom::Blob>(args[0], arg0);
     200           0 :       if (NS_FAILED(rv)) {
     201           0 :         ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of FileReaderSync.readAsDataURL", "Blob");
     202           0 :         return false;
     203             :       }
     204             :     }
     205             :   } else {
     206           0 :     ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of FileReaderSync.readAsDataURL");
     207           0 :     return false;
     208             :   }
     209           0 :   binding_detail::FastErrorResult rv;
     210           0 :   DOMString result;
     211           0 :   self->ReadAsDataURL(NonNullHelper(arg0), result, rv);
     212           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     213           0 :     return false;
     214             :   }
     215           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     216           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
     217           0 :     return false;
     218             :   }
     219           0 :   return true;
     220             : }
     221             : 
     222             : static const JSJitInfo readAsDataURL_methodinfo = {
     223             :   { (JSJitGetterOp)readAsDataURL },
     224             :   { prototypes::id::FileReaderSync },
     225             :   { PrototypeTraits<prototypes::id::FileReaderSync>::Depth },
     226             :   JSJitInfo::Method,
     227             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     228             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
     229             :   false,  /* isInfallible. False in setters. */
     230             :   false,  /* isMovable.  Not relevant for setters. */
     231             :   false, /* isEliminatable.  Not relevant for setters. */
     232             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     233             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     234             :   false,  /* isTypedMethod.  Only relevant for methods. */
     235             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     236             : };
     237             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     238             : static_assert(0 < 1, "There is no slot for us");
     239             : 
     240             : static void
     241           0 : _finalize(js::FreeOp* fop, JSObject* obj)
     242             : {
     243           0 :   mozilla::dom::FileReaderSync* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::FileReaderSync>(obj);
     244           0 :   if (self) {
     245           0 :     AddForDeferredFinalization<mozilla::dom::FileReaderSync>(self);
     246             :   }
     247           0 : }
     248             : 
     249             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     250             : #if defined(__clang__)
     251             : #pragma clang diagnostic push
     252             : #pragma clang diagnostic ignored "-Wmissing-braces"
     253             : #endif
     254             : static const JSFunctionSpec sMethods_specs[] = {
     255             :   JS_FNSPEC("readAsArrayBuffer", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&readAsArrayBuffer_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
     256             :   JS_FNSPEC("readAsBinaryString", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&readAsBinaryString_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
     257             :   JS_FNSPEC("readAsText", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&readAsText_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
     258             :   JS_FNSPEC("readAsDataURL", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&readAsDataURL_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
     259             :   JS_FS_END
     260             : };
     261             : #if defined(__clang__)
     262             : #pragma clang diagnostic pop
     263             : #endif
     264             : 
     265             : 
     266             : // Can't be const because the pref-enabled boolean needs to be writable
     267             : static Prefable<const JSFunctionSpec> sMethods[] = {
     268             :   { nullptr, &sMethods_specs[0] },
     269             :   { nullptr, nullptr }
     270             : };
     271             : 
     272             : 
     273             : static const NativePropertiesN<1> sNativeProperties = {
     274             :   false, 0,
     275             :   false, 0,
     276             :   true,  0 /* sMethods */,
     277             :   false, 0,
     278             :   false, 0,
     279             :   false, 0,
     280             :   false, 0,
     281             :   -1,
     282             :   0,
     283             :   nullptr,
     284             :   {
     285             :     { sMethods, nullptr }
     286             :   }
     287             : };
     288             : 
     289             : static bool
     290           0 : _constructor(JSContext* cx, unsigned argc, JS::Value* vp)
     291             : {
     292           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
     293           0 :   JS::Rooted<JSObject*> obj(cx, &args.callee());
     294           0 :   if (!args.isConstructing()) {
     295             :     // XXXbz wish I could get the name from the callee instead of
     296             :     // Adding more relocations
     297           0 :     return ThrowConstructorWithoutNew(cx, "FileReaderSync");
     298             :   }
     299             : 
     300           0 :   GlobalObject global(cx, obj);
     301           0 :   if (global.Failed()) {
     302           0 :     return false;
     303             :   }
     304             : 
     305           0 :   JS::Rooted<JSObject*> desiredProto(cx);
     306           0 :   if (!GetDesiredProto(cx, args, &desiredProto)) {
     307           0 :     return false;
     308             :   }
     309             : 
     310           0 :   bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
     311           0 :   Maybe<JSAutoCompartment> ac;
     312           0 :   if (objIsXray) {
     313           0 :     obj = js::CheckedUnwrap(obj);
     314           0 :     if (!obj) {
     315           0 :       return false;
     316             :     }
     317           0 :     ac.emplace(cx, obj);
     318           0 :     if (!JS_WrapObject(cx, &desiredProto)) {
     319           0 :       return false;
     320             :     }
     321             :   }
     322           0 :   binding_detail::FastErrorResult rv;
     323           0 :   auto result(StrongOrRawPtr<mozilla::dom::FileReaderSync>(mozilla::dom::FileReaderSync::Constructor(global, rv)));
     324           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     325           0 :     return false;
     326             :   }
     327           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     328             :   static_assert(!IsPointer<decltype(result)>::value,
     329             :                 "NewObject implies that we need to keep the object alive with a strong reference.");
     330           0 :   if (!WrapNewBindingNonWrapperCachedObject(cx, obj, result, args.rval(), desiredProto)) {
     331           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     332           0 :     return false;
     333             :   }
     334           0 :   return true;
     335             : }
     336             : 
     337             : static const js::ClassOps sInterfaceObjectClassOps = {
     338             :     nullptr,               /* addProperty */
     339             :     nullptr,               /* delProperty */
     340             :     nullptr,               /* getProperty */
     341             :     nullptr,               /* setProperty */
     342             :     nullptr,               /* enumerate */
     343             :     nullptr,               /* newEnumerate */
     344             :     nullptr,               /* resolve */
     345             :     nullptr,               /* mayResolve */
     346             :     nullptr,               /* finalize */
     347             :     _constructor, /* call */
     348             :     nullptr,               /* hasInstance */
     349             :     _constructor, /* construct */
     350             :     nullptr,               /* trace */
     351             : };
     352             : 
     353             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
     354             :   {
     355             :     "Function",
     356             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
     357             :     &sInterfaceObjectClassOps,
     358             :     JS_NULL_CLASS_SPEC,
     359             :     JS_NULL_CLASS_EXT,
     360             :     &sInterfaceObjectClassObjectOps
     361             :   },
     362             :   eInterface,
     363             :   true,
     364             :   prototypes::id::FileReaderSync,
     365             :   PrototypeTraits<prototypes::id::FileReaderSync>::Depth,
     366             :   &sEmptyNativePropertyHooks,
     367             :   "function FileReaderSync() {\n    [native code]\n}",
     368             :   JS::GetRealmFunctionPrototype
     369             : };
     370             : 
     371             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
     372             :   {
     373             :     "FileReaderSyncPrototype",
     374             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
     375             :     JS_NULL_CLASS_OPS,
     376             :     JS_NULL_CLASS_SPEC,
     377             :     JS_NULL_CLASS_EXT,
     378             :     JS_NULL_OBJECT_OPS
     379             :   },
     380             :   eInterfacePrototype,
     381             :   false,
     382             :   prototypes::id::FileReaderSync,
     383             :   PrototypeTraits<prototypes::id::FileReaderSync>::Depth,
     384             :   &sEmptyNativePropertyHooks,
     385             :   "[object FileReaderSyncPrototype]",
     386             :   JS::GetRealmObjectPrototype
     387             : };
     388             : 
     389             : static const js::ClassOps sClassOps = {
     390             :   nullptr, /* addProperty */
     391             :   nullptr,               /* delProperty */
     392             :   nullptr,               /* getProperty */
     393             :   nullptr,               /* setProperty */
     394             :   nullptr,               /* enumerate */
     395             :   nullptr, /* newEnumerate */
     396             :   nullptr, /* resolve */
     397             :   nullptr, /* mayResolve */
     398             :   _finalize, /* finalize */
     399             :   nullptr, /* call */
     400             :   nullptr,               /* hasInstance */
     401             :   nullptr,               /* construct */
     402             :   nullptr, /* trace */
     403             : };
     404             : 
     405             : static const js::ClassExtension sClassExtension = {
     406             :   nullptr, /* weakmapKeyDelegateOp */
     407             :   nullptr /* objectMovedOp */
     408             : };
     409             : 
     410             : static const DOMJSClass sClass = {
     411             :   { "FileReaderSync",
     412             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
     413             :     &sClassOps,
     414             :     JS_NULL_CLASS_SPEC,
     415             :     &sClassExtension,
     416             :     JS_NULL_OBJECT_OPS
     417             :   },
     418             :   { prototypes::id::FileReaderSync, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
     419             :   IsBaseOf<nsISupports, mozilla::dom::FileReaderSync >::value,
     420             :   &sEmptyNativePropertyHooks,
     421             :   FindAssociatedGlobalForNative<mozilla::dom::FileReaderSync>::Get,
     422             :   GetProtoObjectHandle,
     423             :   GetCCParticipant<mozilla::dom::FileReaderSync>::Get()
     424             : };
     425             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
     426             :               "Must have the right minimal number of reserved slots.");
     427             : static_assert(1 >= 1,
     428             :               "Must have enough reserved slots.");
     429             : 
     430             : const JSClass*
     431           0 : GetJSClass()
     432             : {
     433           0 :   return sClass.ToJSClass();
     434             : }
     435             : 
     436             : bool
     437           0 : Wrap(JSContext* aCx, mozilla::dom::FileReaderSync* aObject, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
     438             : {
     439             :   MOZ_ASSERT(static_cast<mozilla::dom::FileReaderSync*>(aObject) ==
     440             :              reinterpret_cast<mozilla::dom::FileReaderSync*>(aObject),
     441             :              "Multiple inheritance for mozilla::dom::FileReaderSync is broken.");
     442           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
     443           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
     444             : 
     445           0 :   JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
     446           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
     447           0 :   if (!canonicalProto) {
     448           0 :     return false;
     449             :   }
     450           0 :   JS::Rooted<JSObject*> proto(aCx);
     451           0 :   if (aGivenProto) {
     452           0 :     proto = aGivenProto;
     453             :     // Unfortunately, while aGivenProto was in the compartment of aCx
     454             :     // coming in, we changed compartments to that of "parent" so may need
     455             :     // to wrap the proto here.
     456           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
     457           0 :       if (!JS_WrapObject(aCx, &proto)) {
     458           0 :         return false;
     459             :       }
     460             :     }
     461             :   } else {
     462           0 :     proto = canonicalProto;
     463             :   }
     464             : 
     465           0 :   BindingJSObjectCreator<mozilla::dom::FileReaderSync> creator(aCx);
     466           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
     467           0 :   if (!aReflector) {
     468           0 :     return false;
     469             :   }
     470             : 
     471             : 
     472             : 
     473           0 :   creator.InitializationSucceeded();
     474           0 :   return true;
     475             : }
     476             : 
     477             : void
     478           1 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
     479             : {
     480           2 :   JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
     481           1 :   if (!parentProto) {
     482           0 :     return;
     483             :   }
     484             : 
     485           2 :   JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
     486           1 :   if (!constructorProto) {
     487           0 :     return;
     488             :   }
     489             : 
     490           1 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::FileReaderSync);
     491           1 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::FileReaderSync);
     492           2 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
     493             :                               &sPrototypeClass.mBase, protoCache,
     494             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
     495             :                               interfaceCache,
     496             :                               sNativeProperties.Upcast(),
     497             :                               nullptr,
     498             :                               "FileReaderSync", aDefineOnGlobal,
     499             :                               nullptr,
     500           1 :                               false);
     501             : }
     502             : 
     503             : JS::Handle<JSObject*>
     504           0 : GetProtoObjectHandle(JSContext* aCx)
     505             : {
     506             :   /* Get the interface prototype object for this class.  This will create the
     507             :      object as needed. */
     508           0 :   bool aDefineOnGlobal = true;
     509             : 
     510             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     511           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     512           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     513           0 :     return nullptr;
     514             :   }
     515             : 
     516             :   /* Check to see whether the interface objects are already installed */
     517           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     518           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::FileReaderSync)) {
     519           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     520           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     521             :   }
     522             : 
     523             :   /*
     524             :    * The object might _still_ be null, but that's OK.
     525             :    *
     526             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     527             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     528             :    * changed after they have been set.
     529             :    *
     530             :    * Calling address() avoids the read read barrier that does gray
     531             :    * unmarking, but it's not possible for the object to be gray here.
     532             :    */
     533             : 
     534           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::FileReaderSync);
     535           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     536           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     537             : }
     538             : 
     539             : JS::Handle<JSObject*>
     540           1 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
     541             : {
     542             :   /* Get the interface object for this class.  This will create the object as
     543             :      needed. */
     544             : 
     545             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     546           1 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     547           1 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     548           0 :     return nullptr;
     549             :   }
     550             : 
     551             :   /* Check to see whether the interface objects are already installed */
     552           1 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     553           1 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::FileReaderSync)) {
     554           2 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     555           1 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     556             :   }
     557             : 
     558             :   /*
     559             :    * The object might _still_ be null, but that's OK.
     560             :    *
     561             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     562             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     563             :    * changed after they have been set.
     564             :    *
     565             :    * Calling address() avoids the read read barrier that does gray
     566             :    * unmarking, but it's not possible for the object to be gray here.
     567             :    */
     568             : 
     569           1 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::FileReaderSync);
     570           1 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     571           1 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     572             : }
     573             : 
     574             : JSObject*
     575           1 : GetConstructorObject(JSContext* aCx)
     576             : {
     577           1 :   return GetConstructorObjectHandle(aCx);
     578             : }
     579             : 
     580             : } // namespace FileReaderSyncBinding
     581             : 
     582             : 
     583             : 
     584             : } // namespace dom
     585             : } // namespace mozilla

Generated by: LCOV version 1.13