tor-browser

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

ShellModuleObjectWrapper.h (1370B)


      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 shell_ShellModuleObjectWrapper_h
      8 #define shell_ShellModuleObjectWrapper_h
      9 
     10 #include "builtin/ModuleObject.h"  // js::ModuleObject
     11 #include "js/Class.h"              // JSClass
     12 #include "js/RootingAPI.h"         // JS::Handle
     13 #include "vm/NativeObject.h"       // js::NativeObject
     14 
     15 namespace js {
     16 
     17 namespace shell {
     18 
     19 // ModuleObject's accessors and methods are only for internal usage in
     20 // js/src/builtin/Module.js, and they don't check arguments types.
     21 //
     22 // To use ModuleObject in tests, add a wrapper that checks arguments types.
     23 class ShellModuleObjectWrapper : public js::NativeObject {
     24 public:
     25  using Target = ModuleObject;
     26  enum ModuleSlot { TargetSlot = 0, ModuleTypeSlot, SlotCount };
     27  static const JSClass class_;
     28  static ShellModuleObjectWrapper* create(
     29      JSContext* cx, JS::Handle<ModuleObject*> moduleObj,
     30      JS::ModuleType moduleType = JS::ModuleType::JavaScript);
     31  ModuleObject* get();
     32  JS::ModuleType getModuleType();
     33 };
     34 
     35 }  // namespace shell
     36 }  // namespace js
     37 
     38 #endif /* shell_ShellModuleObjectWrapper_h */