tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

DisposableRecord-inl.h (1205B)


      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 #ifndef vm_DisposableRecord_inl_h
      8 #define vm_DisposableRecord_inl_h
      9 
     10 #include "vm/DisposableRecord.h"
     11 
     12 #include "vm/JSObject-inl.h"
     13 #include "vm/NativeObject-inl.h"
     14 
     15 inline /* static */ js::DisposableRecordObject*
     16 js::DisposableRecordObject::create(JSContext* cx, JS::Handle<JS::Value> value,
     17                                   JS::Handle<JS::Value> method,
     18                                   UsingHint hint) {
     19  JS::Rooted<DisposableRecordObject*> obj(
     20      cx, NewObjectWithGivenProto<DisposableRecordObject>(cx, nullptr));
     21  if (!obj) {
     22    return nullptr;
     23  }
     24 
     25  obj->initReservedSlot(VALUE_SLOT, value);
     26  obj->initReservedSlot(METHOD_SLOT, method);
     27  obj->initReservedSlot(HINT_SLOT, JS::Int32Value(int32_t(hint)));
     28 
     29  if (!SharedShape::ensureInitialCustomShape<DisposableRecordObject>(cx, obj)) {
     30    return nullptr;
     31  }
     32 
     33  return obj;
     34 }
     35 
     36 #endif  // vm_DisposableRecord_inl_h