summaryrefslogtreecommitdiff
path: root/platform/android/src/style/layers/layer.cpp.ejs
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android/src/style/layers/layer.cpp.ejs')
-rw-r--r--platform/android/src/style/layers/layer.cpp.ejs28
1 files changed, 13 insertions, 15 deletions
diff --git a/platform/android/src/style/layers/layer.cpp.ejs b/platform/android/src/style/layers/layer.cpp.ejs
index 7dbb031b25..875bc88bc0 100644
--- a/platform/android/src/style/layers/layer.cpp.ejs
+++ b/platform/android/src/style/layers/layer.cpp.ejs
@@ -18,13 +18,13 @@ namespace android {
/**
* Creates an owning peer object (for layers not attached to the map) from the JVM side
*/
- <%- camelize(type) %>Layer::<%- camelize(type) %>Layer(jni::JNIEnv& env, jni::String layerId)
+ <%- camelize(type) %>Layer::<%- camelize(type) %>Layer(jni::JNIEnv& env, jni::String& layerId)
: Layer(env, std::make_unique<mbgl::style::<%- camelize(type) %>Layer>(jni::Make<std::string>(env, layerId))) {
<% } else { -%>
/**
* Creates an owning peer object (for layers not attached to the map) from the JVM side
*/
- <%- camelize(type) %>Layer::<%- camelize(type) %>Layer(jni::JNIEnv& env, jni::String layerId, jni::String sourceId)
+ <%- camelize(type) %>Layer::<%- camelize(type) %>Layer(jni::JNIEnv& env, jni::String& layerId, jni::String& sourceId)
: Layer(env, std::make_unique<mbgl::style::<%- camelize(type) %>Layer>(jni::Make<std::string>(env, layerId), jni::Make<std::string>(env, sourceId))) {
<% } -%>
}
@@ -49,29 +49,27 @@ namespace android {
<% for (const property of properties) { -%>
<% if (property.name != 'heatmap-color') { -%>
- jni::Object<jni::ObjectTag> <%- camelize(type) %>Layer::get<%- camelize(property.name) %>(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> <%- camelize(type) %>Layer::get<%- camelize(property.name) %>(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::<%- camelize(type) %>Layer>()-><%- camelize(type) %>Layer::get<%- camelize(property.name) %>());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::<%- camelize(type) %>Layer>()-><%- camelize(type) %>Layer::get<%- camelize(property.name) %>()));
}
<% } else { -%>
- jni::Object<jni::ObjectTag> HeatmapLayer::getHeatmapColor(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> HeatmapLayer::getHeatmapColor(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
auto propertyValue = layer.as<mbgl::style::HeatmapLayer>()->HeatmapLayer::getHeatmapColor();
if (propertyValue.isUndefined()) {
propertyValue = layer.as<mbgl::style::HeatmapLayer>()->HeatmapLayer::getDefaultHeatmapColor();
}
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, propertyValue);
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, propertyValue));
}
<% } -%>
<% if (property.transition) { -%>
- jni::Object<TransitionOptions> <%- camelize(type) %>Layer::get<%- camelize(property.name) %>Transition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> <%- camelize(type) %>Layer::get<%- camelize(property.name) %>Transition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::<%- camelize(type) %>Layer>()-><%- camelize(type) %>Layer::get<%- camelize(property.name) %>Transition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void <%- camelize(type) %>Layer::set<%- camelize(property.name) %>Transition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -84,15 +82,15 @@ namespace android {
<% } -%>
<% } -%>
- jni::jobject* <%- camelize(type) %>Layer::createJavaPeer(jni::JNIEnv& env) {
- static auto javaClass = jni::Class<<%- camelize(type) %>Layer>::Singleton(env);
+ jni::Local<jni::Object<Layer>> <%- camelize(type) %>Layer::createJavaPeer(jni::JNIEnv& env) {
+ static auto& javaClass = jni::Class<<%- camelize(type) %>Layer>::Singleton(env);
static auto constructor = javaClass.GetConstructor<jni::jlong>(env);
return javaClass.New(env, constructor, reinterpret_cast<jni::jlong>(this));
}
void <%- camelize(type) %>Layer::registerNative(jni::JNIEnv& env) {
// Lookup the class
- static auto javaClass = jni::Class<<%- camelize(type) %>Layer>::Singleton(env);
+ static auto& javaClass = jni::Class<<%- camelize(type) %>Layer>::Singleton(env);
#define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
@@ -100,9 +98,9 @@ namespace android {
jni::RegisterNativePeer<<%- camelize(type) %>Layer>(
env, javaClass, "nativePtr",
<% if (type === 'background') { -%>
- std::make_unique<<%- camelize(type) %>Layer, JNIEnv&, jni::String>,
+ jni::MakePeer<<%- camelize(type) %>Layer, jni::String&>,
<% } else { -%>
- std::make_unique<<%- camelize(type) %>Layer, JNIEnv&, jni::String, jni::String>,
+ jni::MakePeer<<%- camelize(type) %>Layer, jni::String&, jni::String&>,
<% } -%>
"initialize",
"finalize",<% for(var i = 0; i < properties.length; i++) {%>