#include "unknown_source.hpp" namespace { // Dummy initializer (We don't support initializing this from the JVM) std::unique_ptr init(jni::JNIEnv&) { throw std::runtime_error("UnknownSource should not be initialized from the JVM"); } } // namespace namespace mbgl { namespace android { UnknownSource::UnknownSource(jni::JNIEnv& env, mbgl::style::Source& coreSource, AndroidRendererFrontend& frontend) : Source(env, coreSource, createJavaPeer(env), frontend) { } jni::Class UnknownSource::javaClass; jni::Object UnknownSource::createJavaPeer(jni::JNIEnv& env) { static auto constructor = UnknownSource::javaClass.template GetConstructor(env); return jni::Object(UnknownSource::javaClass.New(env, constructor, reinterpret_cast(this)).Get()); } void UnknownSource::registerNative(jni::JNIEnv& env) { // Lookup the class UnknownSource::javaClass = *jni::Class::Find(env).NewGlobalRef(env).release(); #define METHOD(MethodPtr, name) jni::MakeNativePeerMethod(name) // Register the peer jni::RegisterNativePeer( env, UnknownSource::javaClass, "nativePtr", init, "initialize", "finalize" ); } } // namespace android } // namespace mbgl