tor-browser

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

WellKnownAtom.h (1579B)


      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_WellKnownAtom_h
      8 #define vm_WellKnownAtom_h
      9 
     10 #include "mozilla/HashFunctions.h"  // mozilla::HashNumber, mozilla::HashStringKnownLength
     11 
     12 #include <stdint.h>  // uint32_t
     13 
     14 #include "js/ProtoKey.h"             // JS_FOR_EACH_PROTOTYPE
     15 #include "js/Symbol.h"               // JS_FOR_EACH_WELL_KNOWN_SYMBOL
     16 #include "vm/CommonPropertyNames.h"  // FOR_EACH_COMMON_PROPERTYNAME
     17 
     18 namespace js {
     19 
     20 // An index for well-known atoms.
     21 //
     22 // GetWellKnownAtom in ParserAtom.cpp relies on the fact that
     23 // JSAtomState fields and this enum variants use the same order.
     24 enum class WellKnownAtomId : uint32_t {
     25 #define ENUM_ENTRY_(NAME, _) NAME,
     26  FOR_EACH_COMMON_PROPERTYNAME(ENUM_ENTRY_)
     27 #undef ENUM_ENTRY_
     28 
     29 #define ENUM_ENTRY_(NAME, _) NAME,
     30      JS_FOR_EACH_PROTOTYPE(ENUM_ENTRY_)
     31 #undef ENUM_ENTRY_
     32 
     33 #define ENUM_ENTRY_(NAME) NAME,
     34          JS_FOR_EACH_WELL_KNOWN_SYMBOL(ENUM_ENTRY_)
     35 #undef ENUM_ENTRY_
     36 
     37              Limit,
     38 };
     39 
     40 struct WellKnownAtomInfo {
     41  uint32_t length;
     42  mozilla::HashNumber hash;
     43  const char* content;
     44 };
     45 
     46 extern WellKnownAtomInfo wellKnownAtomInfos[];
     47 
     48 inline const WellKnownAtomInfo& GetWellKnownAtomInfo(WellKnownAtomId atomId) {
     49  return wellKnownAtomInfos[uint32_t(atomId)];
     50 }
     51 
     52 } /* namespace js */
     53 
     54 #endif  // vm_WellKnownAtom_h