// This file was generated by
//     //third_party/jni_zero/jni_zero.py
// For
//     org.jni_zero.SampleModule

#ifndef org_jni_1zero_SampleModule_JNI
#define org_jni_1zero_SampleModule_JNI

#include <jni.h>

#include "overridden/jni_zero_internal.h"
#include "extra_include.h"
#include "SampleModule_shared_jni.h"

// Field, class, and method accessors use inline functions with static
// variables for caching.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunique-object-duplication"

// Example signatures (to be implemented by #including file).
// * JNIEnv* parameters are optional.
// * Types do not have to be exact; they must accept rvalues of the examples.
//
// static bool JNI_SampleModule_Bar(JNIEnv* env, bool a);
//
// static void JNI_SampleModule_Foo(JNIEnv* env);
//

// Triggers a compiler warning if DEFINE_JNI(SampleModule) is forgotten (requires -Wunused-function).
static void YouForgotToCallMacro_DEFINE_JNI_SampleModule() {}

// Java to native functions
#define DEFINE_JNI_FOR_SampleModule()                                                              \
  namespace {                                                                                      \
                                                                                                   \
  JNI_ZERO_BOUNDARY_EXPORT bool Java_J_module_1N_MejItBT4(JNIEnv* env, jclass jcaller, bool a) {   \
    /* Prevent -Wunused-function warning. */                                                       \
    YouForgotToCallMacro_DEFINE_JNI_SampleModule();                                                \
                                                                                                   \
    /* Lambda required to make "if constexpr" work properly. */                                    \
    auto dependent_context = [&](auto) {                                                           \
      /* Lambda required to disambiguate overloads. */                                             \
      auto func_wrapper = [&](auto&&... args) ->                                                   \
      decltype(JNI_SampleModule_Bar(std::forward<decltype(args)>(args)...)) {                      \
        return JNI_SampleModule_Bar(std::forward<decltype(args)>(args)...);                        \
      };                                                                                           \
      if constexpr (requires { func_wrapper(env, a); }) {                                          \
        return func_wrapper(env, a);                                                               \
      } else if constexpr (requires { func_wrapper(a); }) {                                        \
        return func_wrapper(a);                                                                    \
      } else {                                                                                     \
        static_assert(false, "JNI_SampleModule_Bar() is missing or has incorrect signature.\nIt should accept an optional JNIEnv* parameter as well as rvalues of the given types: (bool)\nSee SampleModule_jni.h for an example."); \
      }                                                                                            \
    };                                                                                             \
    auto return_value = dependent_context(0);                                                      \
    return return_value;                                                                           \
  }                                                                                                \
                                                                                                   \
  JNI_ZERO_BOUNDARY_EXPORT void Java_J_module_1N_MqDgXQiH(JNIEnv* env, jclass jcaller) {           \
    /* Lambda required to make "if constexpr" work properly. */                                    \
    auto dependent_context = [&](auto) {                                                           \
      /* Lambda required to disambiguate overloads. */                                             \
      auto func_wrapper = [&](auto&&... args) ->                                                   \
      decltype(JNI_SampleModule_Foo(std::forward<decltype(args)>(args)...)) {                      \
        return JNI_SampleModule_Foo(std::forward<decltype(args)>(args)...);                        \
      };                                                                                           \
      if constexpr (requires { func_wrapper(env); }) {                                             \
        return func_wrapper(env);                                                                  \
      } else if constexpr (requires { func_wrapper(); }) {                                         \
        return func_wrapper();                                                                     \
      } else {                                                                                     \
        static_assert(false, "JNI_SampleModule_Foo() is missing or has incorrect signature.\nIt should accept an optional JNIEnv* parameter as well as rvalues of the given types: ()\nSee SampleModule_jni.h for an example."); \
      }                                                                                            \
    };                                                                                             \
    dependent_context(0);                                                                          \
  }                                                                                                \
                                                                                                   \
                                                                                                   \
  }  /* namespace */

#pragma clang diagnostic pop
#endif  // org_jni_1zero_SampleModule_JNI
