Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/widget/android/jni/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 1 kB image not shown  

Quelle  GeckoResultUtils.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/. */


#ifndef mozilla_jni_GeckoResultUtils_h
#define mozilla_jni_GeckoResultUtils_h

#include "mozilla/java/GeckoResultNatives.h"
#include "mozilla/jni/Conversions.h"

namespace mozilla {
namespace jni {

// C++-side object bound to Java's GeckoResult.GeckoCallback.
//
// Note that we can't template this class because that breaks JNI dispatch
// (surprisingly: it compiles, but selects the wrong method specialization
// during dispatch). So instead we use a templated factory function, which
// bundles the per-ArgType conversion logic into the callback.
class GeckoResultCallback final
    : public java::GeckoResult::GeckoCallback::Natives<GeckoResultCallback> {
 public:
  typedef java::GeckoResult::GeckoCallback::Natives<GeckoResultCallback> Base;
  typedef std::function<void(mozilla::jni::Object::Param)> OuterCallback;

  void Call(mozilla::jni::Object::Param aArg) { mCallback(aArg); }

  template <typename ArgType>
  static java::GeckoResult::GeckoCallback::LocalRef CreateAndAttach(
      std::function<void(ArgType)>&& aInnerCallback) {
    auto java = java::GeckoResult::GeckoCallback::New();
    OuterCallback outerCallback =
        [inner{std::move(aInnerCallback)}](mozilla::jni::Object::Param aParam) {
          ArgType converted = Java2Native<ArgType>(aParam);
          inner(std::move(converted));
        };
    auto native = MakeUnique<GeckoResultCallback>(std::move(outerCallback));
    Base::AttachNative(java, std::move(native));
    return java;
  }

  explicit GeckoResultCallback(OuterCallback&& aCallback)
      : mCallback(std::move(aCallback)) {}

 private:
  OuterCallback mCallback;
};

}  // namespace jni
}  // namespace mozilla

#endif  // mozilla_jni_GeckoResultUtils_h

Messung V0.5
C=85 H=100 G=92

¤ 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.