tor-browser

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

location.h (2015B)


      1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=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 https://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef DOM_MEDIA_WEBRTC_LIBWEBRTCOVERRIDES_API_WEBRTCLOCATION_H_
      8 #define DOM_MEDIA_WEBRTC_LIBWEBRTCOVERRIDES_API_WEBRTCLOCATION_H_
      9 
     10 // See bug 1973646 for moving this file to use std::source_location.
     11 
     12 #ifdef __has_builtin
     13 #  define MOZ_HAS_BUILTIN(bi) __has_builtin(bi)
     14 #else
     15 // Note: For toolchains without __has_builtin, we define MOZ_HAS_BUILTIN to
     16 // return true on modern-enough MSVC, and otherwise false.
     17 #  define MOZ_HAS_BUILTIN(bi) _MSC_VER >= 1926
     18 #endif
     19 
     20 #if MOZ_HAS_BUILTIN(__builtin_FUNCTION)
     21 #  define MOZ_BUILTIN_FUNCTION __builtin_FUNCTION
     22 #else
     23 #  define MOZ_BUILTIN_FUNCTION() nullptr
     24 #endif
     25 
     26 #if MOZ_HAS_BUILTIN(__builtin_FILE)
     27 #  define MOZ_BUILTIN_FILE __builtin_FILE
     28 #else
     29 #  define MOZ_BUILTIN_FILE() nullptr
     30 #endif
     31 
     32 #if MOZ_HAS_BUILTIN(__builtin_LINE)
     33 #  define MOZ_BUILTIN_LINE __builtin_LINE
     34 #else
     35 #  define MOZ_BUILTIN_LINE() 0
     36 #endif
     37 
     38 namespace mozilla {
     39 class WebrtcLocation {
     40 private:
     41  WebrtcLocation(const char* aFunction, const char* aFile, int aLine)
     42      : mFunction(aFunction), mFile(aFile), mLine(aLine) {}
     43 
     44 public:
     45  static WebrtcLocation Current(const char* aFunction = MOZ_BUILTIN_FUNCTION(),
     46                                const char* aFile = MOZ_BUILTIN_FILE(),
     47                                int aLine = MOZ_BUILTIN_LINE()) {
     48    return WebrtcLocation(aFunction, aFile, aLine);
     49  }
     50 
     51  const char* const mFunction;
     52  const char* const mFile;
     53  const int mLine;
     54 };
     55 
     56 }  // namespace mozilla
     57 
     58 namespace webrtc {
     59 using Location = mozilla::WebrtcLocation;
     60 }  // namespace webrtc
     61 
     62 #undef MOZ_BUILTIN_FUNCTION
     63 #undef MOZ_BUILTIN_FILE
     64 #undef MOZ_BUILTIN_LINE
     65 #undef MOZ_HAS_BUILTIN
     66 
     67 #endif  // DOM_MEDIA_WEBRTC_LIBWEBRTCOVERRIDES_API_WEBRTCLOCATION_H_