/* SPDX-FileCopyrightText: 2021-2022 Volker Krause SPDX-License-Identifier: LGPL-2.0-or-later */ #ifndef KANDROIDEXTRAS_JNIARGUMENTVALUE_H #define KANDROIDEXTRAS_JNIARGUMENTVALUE_H #include "jniobject.h" #include "jnitypetraits.h" namespace KAndroidExtras { namespace Jni { template class Array; } ///@cond internal namespace Internal { /** Call argument wrapper. */ template> struct argument { static_assert(!is_invalid_primitive_type::value, "Using an incompatible primitive type!"); typedef std::conditional_t::value, T, const Jni::Object &> type; static inline constexpr auto toCallArgument(type value) { if constexpr (Jni::is_primitive_type::value) { return primitive_value::toJni(value); } else { return value.jniHandle().object(); } } }; template struct argument> { typedef const T &type; static inline auto toCallArgument(const T &value) { return Jni::handle(value).object(); } }; template struct argument> { typedef const Jni::Array &type; static inline auto toCallArgument(const Jni::Array &value) { return value.jniHandle().object(); } }; } ///@endcond } #endif