Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 


Quelle  BindingCallContext.h   Sprache: C

 
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */


/**
 * A struct that encapsulates a JSContex and information about
 * which binding method was called.  The idea is to automatically annotate
 * exceptions thrown via the BindingCallContext with the method name.
 */


#ifndef mozilla_dom_BindingCallContext_h
#define mozilla_dom_BindingCallContext_h

#include <utility>

#include "js/TypeDecls.h"
#include "mozilla/Assertions.h"
#include "mozilla/Attributes.h"
#include "mozilla/ErrorResult.h"

namespace mozilla::dom {

class MOZ_NON_TEMPORARY_CLASS MOZ_STACK_CLASS BindingCallContext {
 public:
  // aCx is allowed to be null.  If it is, the BindingCallContext should
  // generally act like a null JSContext*: test false when tested as a boolean
  // and produce nullptr when used as a JSContext*.
  //
  // aMethodDescription should be something with longer lifetime than this
  // BindingCallContext.  Most simply, a string literal.  nullptr or "" is
  // allowed if we want to not have any particular message description.  This
  // argument corresponds to the "context" string used for DOM error codes that
  // support one.  See Errors.msg and the documentation for
  // ErrorResult::MaybeSetPendingException for details on he context arg.
  BindingCallContext(JSContext* aCx, const char* aMethodDescription)
      : mCx(aCx), mDescription(aMethodDescription) {}

  ~BindingCallContext() = default;

  // Allow passing a BindingCallContext as a JSContext*, as needed.
  operator JSContext*() const { return mCx; }

  // Allow testing a BindingCallContext for falsiness, just like a
  // JSContext* could be tested.
  explicit operator bool() const { return !!mCx; }

  // Allow throwing an error message, if it has a context.
  template <dom::ErrNum errorNumber, typename... Ts>
  bool ThrowErrorMessage(Ts&&... aMessageArgs) const {
    static_assert(ErrorFormatHasContext[errorNumber],
                  "We plan to add a context; it better be expected!");
    MOZ_ASSERT(mCx);
    return dom::ThrowErrorMessage<errorNumber>(
        mCx, mDescription, std::forward<Ts>(aMessageArgs)...);
  }

 private:
  JSContext* const mCx;
  const charconst mDescription;
};

}  // namespace mozilla::dom

#endif  // mozilla_dom_BindingCallContext_h

Messung V0.5
C=91 H=100 G=95

¤ Dauer der Verarbeitung: 0.11 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge