#pragma once #include "conversion.hpp" #include #include #include #include #include namespace mbgl { namespace android { namespace conversion { template <> struct Converter { Result operator()(jni::JNIEnv& env, const bool& value) const; }; template <> struct Converter { Result operator()(jni::JNIEnv& env, const float& value) const; }; template <> struct Converter { Result operator()(jni::JNIEnv& env, const double& value) const; }; /** * All integrals. java is limited to 64 bit signed, so... * TODO: use BigDecimal for > 64 / unsigned? */ template struct Converter::value>::type> { Result operator()(jni::JNIEnv& env, const T& value) const { static jni::jclass* javaClass = jni::NewGlobalRef(env, &jni::FindClass(env, "java/lang/Long")).release(); static jni::jmethodID* constructor = &jni::GetMethodID(env, *javaClass, "", "(J)V"); return {&jni::NewObject(env, *javaClass, *constructor, (jlong) value)}; } }; // TODO: convert integral types to primitive jni types template <> struct Converter { Result operator()(jni::JNIEnv& env, const std::string& value) const; }; template <> struct Converter { Result operator()(jni::JNIEnv& env, const Color& value) const; }; template struct Converter> { Result operator()(jni::JNIEnv& env, const std::array& value) const { std::vector v; for (const float& id : value) { v.push_back(id); } return convert>(env, v); } }; template <> struct Converter> { Result operator()(jni::JNIEnv& env, const std::vector& value) const; }; template <> struct Converter> { Result operator()(jni::JNIEnv& env, const std::vector& value) const; }; // Java -> C++ template <> struct Converter { Result operator()(jni::JNIEnv& env, const jni::String& value) const; }; } // namespace conversion } // namespace style } // namespace mbgl