tor-browser

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

RustTypes.h (2095B)


      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 mozilla_dom_RustTypes_h
      8 #define mozilla_dom_RustTypes_h
      9 
     10 #include "nsDebug.h"
     11 
     12 #define STATE_HELPERS(Type)                                    \
     13  using InternalType = decltype(bits);                         \
     14                                                               \
     15  constexpr Type() : bits{0} {}                                \
     16                                                               \
     17  explicit constexpr Type(InternalType aBits) : bits{aBits} {} \
     18                                                               \
     19  bool IsEmpty() const { return bits == 0; }                   \
     20                                                               \
     21  bool HasAtLeastOneOfStates(Type aStates) const {             \
     22    return bool((*this) & aStates);                            \
     23  }                                                            \
     24                                                               \
     25  bool HasState(Type aState) const {                           \
     26    NS_ASSERTION(!(aState.bits & (aState.bits - 1)),           \
     27                 "When calling HasState, "                     \
     28                 "argument has to contain only one state!");   \
     29    return HasAtLeastOneOfStates(aState);                      \
     30  }                                                            \
     31                                                               \
     32  bool HasAllStates(Type aStates) const {                      \
     33    return ((*this) & aStates) == aStates;                     \
     34  }                                                            \
     35                                                               \
     36  InternalType GetInternalValue() const { return bits; }
     37 
     38 #include "mozilla/dom/GeneratedElementDocumentState.h"
     39 
     40 #endif