summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmake/mason-dependencies.cmake2
-rwxr-xr-xplatform/android/scripts/generate-style-code.js4
-rw-r--r--platform/android/src/annotation/marker.cpp12
-rw-r--r--platform/android/src/annotation/marker.hpp4
-rw-r--r--platform/android/src/annotation/multi_point.hpp8
-rw-r--r--platform/android/src/annotation/polygon.cpp15
-rw-r--r--platform/android/src/annotation/polygon.hpp2
-rw-r--r--platform/android/src/annotation/polyline.cpp6
-rw-r--r--platform/android/src/annotation/polyline.hpp2
-rw-r--r--platform/android/src/asset_manager_file_source.cpp6
-rw-r--r--platform/android/src/asset_manager_file_source.hpp2
-rw-r--r--platform/android/src/bitmap.cpp84
-rw-r--r--platform/android/src/bitmap.hpp14
-rw-r--r--platform/android/src/bitmap_factory.cpp10
-rw-r--r--platform/android/src/bitmap_factory.hpp4
-rw-r--r--platform/android/src/connectivity_listener.cpp2
-rw-r--r--platform/android/src/conversion/collection.cpp8
-rw-r--r--platform/android/src/conversion/collection.hpp4
-rw-r--r--platform/android/src/conversion/constant.cpp58
-rw-r--r--platform/android/src/conversion/constant.hpp57
-rw-r--r--platform/android/src/file_source.cpp39
-rw-r--r--platform/android/src/file_source.hpp16
-rw-r--r--platform/android/src/geojson/feature.cpp26
-rw-r--r--platform/android/src/geojson/feature.hpp6
-rw-r--r--platform/android/src/geojson/feature_collection.cpp14
-rw-r--r--platform/android/src/geojson/feature_collection.hpp7
-rw-r--r--platform/android/src/geojson/geometry.cpp38
-rw-r--r--platform/android/src/geojson/geometry.hpp6
-rw-r--r--platform/android/src/geojson/geometry_collection.cpp22
-rw-r--r--platform/android/src/geojson/geometry_collection.hpp8
-rw-r--r--platform/android/src/geojson/line_string.cpp23
-rw-r--r--platform/android/src/geojson/line_string.hpp12
-rw-r--r--platform/android/src/geojson/multi_line_string.cpp24
-rw-r--r--platform/android/src/geojson/multi_line_string.hpp12
-rw-r--r--platform/android/src/geojson/multi_point.cpp14
-rw-r--r--platform/android/src/geojson/multi_point.hpp10
-rw-r--r--platform/android/src/geojson/multi_polygon.cpp26
-rw-r--r--platform/android/src/geojson/multi_polygon.hpp10
-rw-r--r--platform/android/src/geojson/point.cpp8
-rw-r--r--platform/android/src/geojson/point.hpp7
-rw-r--r--platform/android/src/geojson/polygon.cpp16
-rw-r--r--platform/android/src/geojson/polygon.hpp12
-rw-r--r--platform/android/src/geojson/util.hpp16
-rw-r--r--platform/android/src/geometry/lat_lng.cpp10
-rw-r--r--platform/android/src/geometry/lat_lng.hpp6
-rw-r--r--platform/android/src/geometry/lat_lng_bounds.cpp8
-rw-r--r--platform/android/src/geometry/lat_lng_bounds.hpp4
-rw-r--r--platform/android/src/geometry/lat_lng_quad.cpp8
-rw-r--r--platform/android/src/geometry/lat_lng_quad.hpp4
-rw-r--r--platform/android/src/geometry/projected_meters.cpp4
-rw-r--r--platform/android/src/geometry/projected_meters.hpp2
-rw-r--r--platform/android/src/graphics/pointf.cpp8
-rw-r--r--platform/android/src/graphics/pointf.hpp4
-rw-r--r--platform/android/src/graphics/rectf.cpp16
-rw-r--r--platform/android/src/graphics/rectf.hpp8
-rw-r--r--platform/android/src/gson/json_array.cpp16
-rw-r--r--platform/android/src/gson/json_array.hpp7
-rw-r--r--platform/android/src/gson/json_element.cpp29
-rw-r--r--platform/android/src/gson/json_element.hpp7
-rw-r--r--platform/android/src/gson/json_object.cpp30
-rw-r--r--platform/android/src/gson/json_object.hpp7
-rw-r--r--platform/android/src/gson/json_primitive.hpp3
-rw-r--r--platform/android/src/http_file_source.cpp39
-rw-r--r--platform/android/src/image.cpp7
-rw-r--r--platform/android/src/java/util.hpp30
-rw-r--r--platform/android/src/jni/generic_global_ref_deleter.hpp45
-rw-r--r--platform/android/src/logger.cpp14
-rw-r--r--platform/android/src/map/camera_position.cpp10
-rw-r--r--platform/android/src/map/camera_position.hpp4
-rw-r--r--platform/android/src/map/image.cpp14
-rw-r--r--platform/android/src/map/image.hpp2
-rw-r--r--platform/android/src/map_renderer.cpp30
-rw-r--r--platform/android/src/map_renderer.hpp14
-rw-r--r--platform/android/src/map_renderer_runnable.cpp6
-rwxr-xr-xplatform/android/src/native_map_view.cpp166
-rwxr-xr-xplatform/android/src/native_map_view.hpp104
-rw-r--r--platform/android/src/offline/offline_manager.cpp79
-rw-r--r--platform/android/src/offline/offline_manager.hpp24
-rw-r--r--platform/android/src/offline/offline_region.cpp127
-rw-r--r--platform/android/src/offline/offline_region.hpp28
-rw-r--r--platform/android/src/offline/offline_region_definition.cpp38
-rw-r--r--platform/android/src/offline/offline_region_definition.hpp16
-rw-r--r--platform/android/src/offline/offline_region_error.cpp8
-rw-r--r--platform/android/src/offline/offline_region_error.hpp2
-rw-r--r--platform/android/src/offline/offline_region_status.cpp4
-rw-r--r--platform/android/src/offline/offline_region_status.hpp2
-rw-r--r--platform/android/src/snapshotter/map_snapshot.cpp10
-rw-r--r--platform/android/src/snapshotter/map_snapshot.hpp6
-rw-r--r--platform/android/src/snapshotter/map_snapshotter.cpp35
-rw-r--r--platform/android/src/snapshotter/map_snapshotter.hpp25
-rw-r--r--platform/android/src/style/conversion/filter.cpp4
-rw-r--r--platform/android/src/style/conversion/filter.hpp2
-rw-r--r--platform/android/src/style/conversion/position.cpp2
-rw-r--r--platform/android/src/style/conversion/position.hpp4
-rw-r--r--platform/android/src/style/conversion/property_expression.hpp4
-rw-r--r--platform/android/src/style/conversion/property_value.hpp22
-rw-r--r--platform/android/src/style/conversion/transition_options.cpp2
-rw-r--r--platform/android/src/style/conversion/transition_options.hpp4
-rw-r--r--platform/android/src/style/layers/background_layer.cpp37
-rw-r--r--platform/android/src/style/layers/background_layer.hpp18
-rw-r--r--platform/android/src/style/layers/circle_layer.cpp97
-rw-r--r--platform/android/src/style/layers/circle_layer.hpp44
-rw-r--r--platform/android/src/style/layers/custom_layer.cpp10
-rw-r--r--platform/android/src/style/layers/custom_layer.hpp5
-rw-r--r--platform/android/src/style/layers/fill_extrusion_layer.cpp69
-rw-r--r--platform/android/src/style/layers/fill_extrusion_layer.hpp32
-rw-r--r--platform/android/src/style/layers/fill_layer.cpp65
-rw-r--r--platform/android/src/style/layers/fill_layer.hpp30
-rw-r--r--platform/android/src/style/layers/heatmap_layer.cpp47
-rw-r--r--platform/android/src/style/layers/heatmap_layer.hpp22
-rw-r--r--platform/android/src/style/layers/hillshade_layer.cpp56
-rw-r--r--platform/android/src/style/layers/hillshade_layer.hpp26
-rw-r--r--platform/android/src/style/layers/layer.cpp30
-rw-r--r--platform/android/src/style/layers/layer.cpp.ejs28
-rw-r--r--platform/android/src/style/layers/layer.hpp20
-rw-r--r--platform/android/src/style/layers/layer.hpp.ejs12
-rw-r--r--platform/android/src/style/layers/layers.cpp8
-rw-r--r--platform/android/src/style/layers/layers.hpp4
-rw-r--r--platform/android/src/style/layers/line_layer.cpp121
-rw-r--r--platform/android/src/style/layers/line_layer.hpp54
-rw-r--r--platform/android/src/style/layers/raster_layer.cpp74
-rw-r--r--platform/android/src/style/layers/raster_layer.hpp34
-rw-r--r--platform/android/src/style/layers/symbol_layer.cpp308
-rw-r--r--platform/android/src/style/layers/symbol_layer.hpp130
-rw-r--r--platform/android/src/style/layers/unknown_layer.cpp6
-rw-r--r--platform/android/src/style/layers/unknown_layer.hpp4
-rw-r--r--platform/android/src/style/light.cpp38
-rw-r--r--platform/android/src/style/light.cpp.ejs122
-rw-r--r--platform/android/src/style/light.hpp26
-rw-r--r--platform/android/src/style/light.hpp.ejs59
-rw-r--r--platform/android/src/style/position.cpp16
-rw-r--r--platform/android/src/style/position.hpp8
-rw-r--r--platform/android/src/style/sources/custom_geometry_source.cpp56
-rw-r--r--platform/android/src/style/sources/custom_geometry_source.hpp18
-rw-r--r--platform/android/src/style/sources/geojson_source.cpp53
-rw-r--r--platform/android/src/style/sources/geojson_source.hpp25
-rw-r--r--platform/android/src/style/sources/image_source.cpp22
-rw-r--r--platform/android/src/style/sources/image_source.hpp14
-rw-r--r--platform/android/src/style/sources/raster_dem_source.cpp18
-rw-r--r--platform/android/src/style/sources/raster_dem_source.hpp7
-rw-r--r--platform/android/src/style/sources/raster_source.cpp18
-rw-r--r--platform/android/src/style/sources/raster_source.hpp7
-rw-r--r--platform/android/src/style/sources/source.cpp25
-rw-r--r--platform/android/src/style/sources/source.hpp12
-rw-r--r--platform/android/src/style/sources/unknown_source.cpp8
-rw-r--r--platform/android/src/style/sources/unknown_source.hpp4
-rw-r--r--platform/android/src/style/sources/vector_source.cpp26
-rw-r--r--platform/android/src/style/sources/vector_source.hpp11
-rw-r--r--platform/android/src/style/transition_options.cpp4
-rw-r--r--platform/android/src/style/transition_options.hpp2
-rw-r--r--platform/android/src/style/value.cpp35
-rw-r--r--platform/android/src/style/value.hpp1
-rw-r--r--platform/android/src/test/main.jni.cpp4
-rw-r--r--platform/android/src/text/collator.cpp71
-rw-r--r--platform/android/src/text/collator_jni.hpp16
-rw-r--r--platform/android/src/text/local_glyph_rasterizer.cpp19
156 files changed, 1765 insertions, 2161 deletions
diff --git a/cmake/mason-dependencies.cmake b/cmake/mason-dependencies.cmake
index 7330f2f3a2..6c571db259 100644
--- a/cmake/mason-dependencies.cmake
+++ b/cmake/mason-dependencies.cmake
@@ -19,7 +19,7 @@ mason_use(cheap-ruler VERSION 2.5.3 HEADER_ONLY)
mason_use(vector-tile VERSION 1.0.2 HEADER_ONLY)
if(MBGL_PLATFORM STREQUAL "android")
- mason_use(jni.hpp VERSION 4.0.0-rc8 HEADER_ONLY)
+ mason_use(jni.hpp VERSION 4.0.0 HEADER_ONLY)
elseif(MBGL_PLATFORM STREQUAL "ios")
mason_use(icu VERSION 58.1-min-size)
elseif(MBGL_PLATFORM STREQUAL "linux")
diff --git a/platform/android/scripts/generate-style-code.js b/platform/android/scripts/generate-style-code.js
index 0825ef1c26..4a35b2d6a6 100755
--- a/platform/android/scripts/generate-style-code.js
+++ b/platform/android/scripts/generate-style-code.js
@@ -335,12 +335,8 @@ global.supportsPropertyFunction = function (property) {
// Template processing //
// Java + JNI Light (Peer model)
-const lightHpp = ejs.compile(fs.readFileSync('platform/android/src/style/light.hpp.ejs', 'utf8'), {strict: true});;
-const lightCpp = ejs.compile(fs.readFileSync('platform/android/src/style/light.cpp.ejs', 'utf8'), {strict: true});;
const lightJava = ejs.compile(fs.readFileSync('platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/light.java.ejs', 'utf8'), {strict: true});
const lightJavaUnitTests = ejs.compile(fs.readFileSync('platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/light.junit.ejs', 'utf8'), {strict: true});
-writeIfModified(`platform/android/src/style/light.hpp`, lightHpp({properties: lightProperties}));
-writeIfModified(`platform/android/src/style/light.cpp`, lightCpp({properties: lightProperties}));
writeIfModified(`platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/Light.java`, lightJava({properties: lightProperties}));
writeIfModified(`platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LightTest.java`, lightJavaUnitTests({properties: lightProperties}));
diff --git a/platform/android/src/annotation/marker.cpp b/platform/android/src/annotation/marker.cpp
index b9a8c714a1..899f87a74f 100644
--- a/platform/android/src/annotation/marker.cpp
+++ b/platform/android/src/annotation/marker.cpp
@@ -3,16 +3,16 @@
namespace mbgl {
namespace android {
-mbgl::Point<double> Marker::getPosition(jni::JNIEnv& env, jni::Object<Marker> marker) {
- static auto javaClass = jni::Class<Marker>::Singleton(env);
+mbgl::Point<double> Marker::getPosition(jni::JNIEnv& env, const jni::Object<Marker>& marker) {
+ static auto& javaClass = jni::Class<Marker>::Singleton(env);
static auto positionField = javaClass.GetField<jni::Object<LatLng>>(env, "position");
- return LatLng::getGeometry(env, *jni::SeizeLocal(env, marker.Get(env, positionField)));
+ return LatLng::getGeometry(env, marker.Get(env, positionField));
}
-std::string Marker::getIconId(jni::JNIEnv& env, jni::Object<Marker> marker) {
- static auto javaClass = jni::Class<Marker>::Singleton(env);
+std::string Marker::getIconId(jni::JNIEnv& env, const jni::Object<Marker>& marker) {
+ static auto& javaClass = jni::Class<Marker>::Singleton(env);
static auto iconIdField = javaClass.GetField<jni::String>(env, "iconId");
- return jni::Make<std::string>(env, *jni::SeizeLocal(env, marker.Get(env, iconIdField)));
+ return jni::Make<std::string>(env, marker.Get(env, iconIdField));
}
void Marker::registerNative(jni::JNIEnv& env) {
diff --git a/platform/android/src/annotation/marker.hpp b/platform/android/src/annotation/marker.hpp
index d03c244921..b38a25b4fb 100644
--- a/platform/android/src/annotation/marker.hpp
+++ b/platform/android/src/annotation/marker.hpp
@@ -15,9 +15,9 @@ public:
static constexpr auto Name() { return "com/mapbox/mapboxsdk/annotations/Marker"; };
- static mbgl::Point<double> getPosition(jni::JNIEnv&, jni::Object<Marker>);
+ static mbgl::Point<double> getPosition(jni::JNIEnv&, const jni::Object<Marker>&);
- static std::string getIconId(jni::JNIEnv&, jni::Object<Marker>);
+ static std::string getIconId(jni::JNIEnv&, const jni::Object<Marker>&);
static void registerNative(jni::JNIEnv&);
diff --git a/platform/android/src/annotation/multi_point.hpp b/platform/android/src/annotation/multi_point.hpp
index 1a6b945261..20f1b3eaf2 100644
--- a/platform/android/src/annotation/multi_point.hpp
+++ b/platform/android/src/annotation/multi_point.hpp
@@ -14,16 +14,16 @@ class MultiPoint : protected mbgl::util::noncopyable {
protected:
template <class Geometry>
- static Geometry toGeometry(JNIEnv& env, jni::Object<java::util::List> pointsList) {
- auto jarray = jni::SeizeLocal(env, java::util::List::toArray<LatLng>(env, pointsList));
+ static Geometry toGeometry(JNIEnv& env, const jni::Object<java::util::List>& pointsList) {
+ auto jarray = java::util::List::toArray<LatLng>(env, pointsList);
- std::size_t size = jarray->Length(env);
+ std::size_t size = jarray.Length(env);
Geometry geometry;
geometry.reserve(size);
for (std::size_t i = 0; i < size; i++) {
- geometry.push_back(LatLng::getGeometry(env, *jni::SeizeLocal(env, jarray->Get(env, i))));
+ geometry.push_back(LatLng::getGeometry(env, jarray.Get(env, i)));
}
return geometry;
diff --git a/platform/android/src/annotation/polygon.cpp b/platform/android/src/annotation/polygon.cpp
index 4168c3ceef..f22cffb100 100644
--- a/platform/android/src/annotation/polygon.cpp
+++ b/platform/android/src/annotation/polygon.cpp
@@ -5,8 +5,8 @@
namespace mbgl {
namespace android {
-mbgl::FillAnnotation Polygon::toAnnotation(jni::JNIEnv& env, jni::Object<Polygon> polygon) {
- static auto javaClass = jni::Class<Polygon>::Singleton(env);
+mbgl::FillAnnotation Polygon::toAnnotation(jni::JNIEnv& env, const jni::Object<Polygon>& polygon) {
+ static auto& javaClass = jni::Class<Polygon>::Singleton(env);
static auto points = javaClass.GetField<jni::Object<java::util::List>>(env, "points");
static auto holes = javaClass.GetField<jni::Object<java::util::List>>(env, "holes");
static auto alpha = javaClass.GetField<float>(env, "alpha");
@@ -14,17 +14,14 @@ mbgl::FillAnnotation Polygon::toAnnotation(jni::JNIEnv& env, jni::Object<Polygon
static auto strokeColor = javaClass.GetField<int>(env, "strokeColor");
mbgl::Polygon<double> geometry {
- MultiPoint::toGeometry<mbgl::LinearRing<double>>(env, *jni::SeizeLocal(env, polygon.Get(env, points)))
+ MultiPoint::toGeometry<mbgl::LinearRing<double>>(env, polygon.Get(env, points))
};
- auto jHoleListsArray = jni::SeizeLocal(env,
- java::util::List::toArray<java::util::List>(env,
- *jni::SeizeLocal(env, polygon.Get(env, holes))));
+ auto jHoleListsArray = java::util::List::toArray<java::util::List>(env, polygon.Get(env, holes));
- std::size_t jHoleListsSize = jHoleListsArray->Length(env);
+ std::size_t jHoleListsSize = jHoleListsArray.Length(env);
for (std::size_t i = 0; i < jHoleListsSize; i++) {
- geometry.push_back(MultiPoint::toGeometry<mbgl::LinearRing<double>>(env,
- *jni::SeizeLocal(env, jHoleListsArray->Get(env, i))));
+ geometry.push_back(MultiPoint::toGeometry<mbgl::LinearRing<double>>(env, jHoleListsArray.Get(env, i)));
}
mbgl::FillAnnotation annotation { geometry };
diff --git a/platform/android/src/annotation/polygon.hpp b/platform/android/src/annotation/polygon.hpp
index 92d3fe0a71..bc21878ef3 100644
--- a/platform/android/src/annotation/polygon.hpp
+++ b/platform/android/src/annotation/polygon.hpp
@@ -11,7 +11,7 @@ class Polygon : private MultiPoint {
public:
static constexpr auto Name() { return "com/mapbox/mapboxsdk/annotations/Polygon"; };
- static mbgl::FillAnnotation toAnnotation(jni::JNIEnv&, jni::Object<Polygon>);
+ static mbgl::FillAnnotation toAnnotation(jni::JNIEnv&, const jni::Object<Polygon>&);
static void registerNative(jni::JNIEnv&);
};
diff --git a/platform/android/src/annotation/polyline.cpp b/platform/android/src/annotation/polyline.cpp
index 080efa1960..d6161e856e 100644
--- a/platform/android/src/annotation/polyline.cpp
+++ b/platform/android/src/annotation/polyline.cpp
@@ -5,15 +5,15 @@
namespace mbgl {
namespace android {
-mbgl::LineAnnotation Polyline::toAnnotation(jni::JNIEnv& env, jni::Object<Polyline> polyline) {
- static auto javaClass = jni::Class<Polyline>::Singleton(env);
+mbgl::LineAnnotation Polyline::toAnnotation(jni::JNIEnv& env, const jni::Object<Polyline>& polyline) {
+ static auto& javaClass = jni::Class<Polyline>::Singleton(env);
static auto points = javaClass.GetField<jni::Object<java::util::List>>(env, "points");
static auto alpha = javaClass.GetField<float>(env, "alpha");
static auto color = javaClass.GetField<int>(env, "color");
static auto width = javaClass.GetField<float>(env, "width");
mbgl::LineAnnotation annotation {
- MultiPoint::toGeometry<mbgl::LineString<double>>(env, *jni::SeizeLocal(env, polyline.Get(env, points)))
+ MultiPoint::toGeometry<mbgl::LineString<double>>(env, polyline.Get(env, points))
};
annotation.opacity = polyline.Get(env, alpha);
diff --git a/platform/android/src/annotation/polyline.hpp b/platform/android/src/annotation/polyline.hpp
index 36c2d49e6d..6178e98cfc 100644
--- a/platform/android/src/annotation/polyline.hpp
+++ b/platform/android/src/annotation/polyline.hpp
@@ -11,7 +11,7 @@ class Polyline : private MultiPoint {
public:
static constexpr auto Name() { return "com/mapbox/mapboxsdk/annotations/Polyline"; };
- static mbgl::LineAnnotation toAnnotation(jni::JNIEnv&, jni::Object<Polyline>);
+ static mbgl::LineAnnotation toAnnotation(jni::JNIEnv&, const jni::Object<Polyline>&);
static void registerNative(jni::JNIEnv&);
};
diff --git a/platform/android/src/asset_manager_file_source.cpp b/platform/android/src/asset_manager_file_source.cpp
index aa65e3ff48..b9150deef9 100644
--- a/platform/android/src/asset_manager_file_source.cpp
+++ b/platform/android/src/asset_manager_file_source.cpp
@@ -38,10 +38,10 @@ private:
AAssetManager* assetManager;
};
-AssetManagerFileSource::AssetManagerFileSource(jni::JNIEnv& env, jni::Object<android::AssetManager> assetManager_)
- : assetManager(assetManager_.NewGlobalRef(env)),
+AssetManagerFileSource::AssetManagerFileSource(jni::JNIEnv& env, const jni::Object<android::AssetManager>& assetManager_)
+ : assetManager(jni::NewGlobal(env, assetManager_)),
impl(std::make_unique<util::Thread<Impl>>("AssetManagerFileSource",
- AAssetManager_fromJava(&env, jni::Unwrap(**assetManager)))) {
+ AAssetManager_fromJava(&env, jni::Unwrap(assetManager.get())))) {
}
AssetManagerFileSource::~AssetManagerFileSource() = default;
diff --git a/platform/android/src/asset_manager_file_source.hpp b/platform/android/src/asset_manager_file_source.hpp
index bb0809a442..4ec5b4c30e 100644
--- a/platform/android/src/asset_manager_file_source.hpp
+++ b/platform/android/src/asset_manager_file_source.hpp
@@ -14,7 +14,7 @@ template <typename T> class Thread;
class AssetManagerFileSource : public FileSource {
public:
- AssetManagerFileSource(jni::JNIEnv&, jni::Object<android::AssetManager>);
+ AssetManagerFileSource(jni::JNIEnv&, const jni::Object<android::AssetManager>&);
~AssetManagerFileSource() override;
std::unique_ptr<AsyncRequest> request(const Resource&, Callback) override;
diff --git a/platform/android/src/bitmap.cpp b/platform/android/src/bitmap.cpp
index 53136b868e..eb7c676b12 100644
--- a/platform/android/src/bitmap.cpp
+++ b/platform/android/src/bitmap.cpp
@@ -8,7 +8,7 @@ namespace android {
class PixelGuard {
public:
- PixelGuard(jni::JNIEnv& env_, jni::Object<Bitmap> bitmap_) : env(env_), bitmap(bitmap_) {
+ PixelGuard(jni::JNIEnv& env_, const jni::Object<Bitmap>& bitmap_) : env(env_), bitmap(bitmap_) {
const int result = AndroidBitmap_lockPixels(&env, jni::Unwrap(*bitmap),
reinterpret_cast<void**>(&address));
if (result != ANDROID_BITMAP_RESULT_SUCCESS) {
@@ -29,25 +29,21 @@ public:
private:
jni::JNIEnv& env;
- jni::Object<Bitmap> bitmap;
+ const jni::Object<Bitmap>& bitmap;
uint8_t* address;
};
-jni::Object<Bitmap::Config> Bitmap::Config::Create(jni::JNIEnv& env, Value value) {
- static auto _class = jni::Class<Config>::Singleton(env);
+jni::Local<jni::Object<Bitmap::Config>> Bitmap::Config::Create(jni::JNIEnv& env, Value value) {
+ static auto& _class = jni::Class<Config>::Singleton(env);
switch (value) {
case ALPHA_8:
- return _class.Get(env,
- jni::StaticField<Config, jni::Object<Config>>(env, _class, "ALPHA_8"));
+ return _class.Get(env, _class.GetStaticField<jni::Object<Config>>(env, "ALPHA_8"));
case ARGB_4444:
- return _class.Get(env,
- jni::StaticField<Config, jni::Object<Config>>(env, _class, "ARGB_4444"));
+ return _class.Get(env, _class.GetStaticField<jni::Object<Config>>(env, "ARGB_4444"));
case ARGB_8888:
- return _class.Get(env,
- jni::StaticField<Config, jni::Object<Config>>(env, _class, "ARGB_8888"));
+ return _class.Get(env, _class.GetStaticField<jni::Object<Config>>(env, "ARGB_8888"));
case RGB_565:
- return _class.Get(env,
- jni::StaticField<Config, jni::Object<Config>>(env, _class, "RGB_565"));
+ return _class.Get(env, _class.GetStaticField<jni::Object<Config>>(env, "RGB_565"));
default:
throw std::runtime_error("invalid enum value for Bitmap.Config");
}
@@ -58,17 +54,41 @@ void Bitmap::registerNative(jni::JNIEnv& env) {
jni::Class<Bitmap::Config>::Singleton(env);
}
-jni::Object<Bitmap> Bitmap::CreateBitmap(jni::JNIEnv& env,
- jni::jint width,
- jni::jint height,
- jni::Object<Config> config) {
- static auto _class = jni::Class<Bitmap>::Singleton(env);
+jni::Local<jni::Object<Bitmap>> Bitmap::CreateBitmap(jni::JNIEnv& env,
+ jni::jint width,
+ jni::jint height,
+ const jni::Object<Config>& config) {
+ static auto& _class = jni::Class<Bitmap>::Singleton(env);
static auto method = _class.GetStaticMethod<jni::Object<Bitmap> (jni::jint, jni::jint, jni::Object<Config>)>(env, "createBitmap");
return _class.Call(env, method, width, height, config);
}
-jni::Object<Bitmap> Bitmap::CreateBitmap(jni::JNIEnv& env, const PremultipliedImage& image) {
+PremultipliedImage Bitmap::GetImage(jni::JNIEnv& env, const jni::Object<Bitmap>& bitmap) {
+ AndroidBitmapInfo info;
+ const int result = AndroidBitmap_getInfo(&env, jni::Unwrap(*bitmap), &info);
+ if (result != ANDROID_BITMAP_RESULT_SUCCESS) {
+ throw std::runtime_error("bitmap decoding: couldn't get bitmap info");
+ }
+ if (info.format != ANDROID_BITMAP_FORMAT_RGBA_8888) {
+ return Bitmap::GetImage(env, Bitmap::Copy(env, bitmap));
+ }
+
+ PixelGuard guard(env, bitmap);
+
+ // Copy the Android Bitmap into the PremultipliedImage.
+ auto pixels =
+ std::make_unique<uint8_t[]>(info.width * info.height * PremultipliedImage::channels);
+ for (uint32_t y = 0; y < info.height; y++) {
+ auto begin = guard.get() + y * info.stride;
+ std::copy(begin, begin + info.width * PremultipliedImage::channels,
+ pixels.get() + y * info.width * PremultipliedImage::channels);
+ }
+
+ return { Size{ info.width, info.height }, std::move(pixels) };
+}
+
+jni::Local<jni::Object<Bitmap>> Bitmap::CreateBitmap(jni::JNIEnv& env, const PremultipliedImage& image) {
auto bitmap = CreateBitmap(env, image.size.width, image.size.height, Config::ARGB_8888);
AndroidBitmapInfo info;
@@ -93,32 +113,8 @@ jni::Object<Bitmap> Bitmap::CreateBitmap(jni::JNIEnv& env, const PremultipliedIm
return bitmap;
}
-PremultipliedImage Bitmap::GetImage(jni::JNIEnv& env, jni::Object<Bitmap> bitmap) {
- AndroidBitmapInfo info;
- const int result = AndroidBitmap_getInfo(&env, jni::Unwrap(*bitmap), &info);
- if (result != ANDROID_BITMAP_RESULT_SUCCESS) {
- throw std::runtime_error("bitmap decoding: couldn't get bitmap info");
- }
- if (info.format != ANDROID_BITMAP_FORMAT_RGBA_8888) {
- return Bitmap::GetImage(env, Bitmap::Copy(env, bitmap));
- }
-
- PixelGuard guard(env, bitmap);
-
- // Copy the Android Bitmap into the PremultipliedImage.
- auto pixels =
- std::make_unique<uint8_t[]>(info.width * info.height * PremultipliedImage::channels);
- for (uint32_t y = 0; y < info.height; y++) {
- auto begin = guard.get() + y * info.stride;
- std::copy(begin, begin + info.width * PremultipliedImage::channels,
- pixels.get() + y * info.width * PremultipliedImage::channels);
- }
-
- return { Size{ info.width, info.height }, std::move(pixels) };
-}
-
-jni::Object<Bitmap> Bitmap::Copy(jni::JNIEnv& env, jni::Object<Bitmap> bitmap) {
- static auto klass = jni::Class<Bitmap>::Singleton(env);
+jni::Local<jni::Object<Bitmap>> Bitmap::Copy(jni::JNIEnv& env, const jni::Object<Bitmap>& bitmap) {
+ static auto& klass = jni::Class<Bitmap>::Singleton(env);
static auto copy = klass.GetMethod<jni::Object<Bitmap> (jni::Object<Config>, jni::jboolean)>(env, "copy");
return bitmap.Call(env, copy, Bitmap::Config::Create(env, Bitmap::Config::Value::ARGB_8888), jni::jni_false);
diff --git a/platform/android/src/bitmap.hpp b/platform/android/src/bitmap.hpp
index 2266bc0e67..9d96405c26 100644
--- a/platform/android/src/bitmap.hpp
+++ b/platform/android/src/bitmap.hpp
@@ -20,23 +20,23 @@ public:
RGB_565,
};
- static jni::Object<Config> Create(jni::JNIEnv&, Value);
+ static jni::Local<jni::Object<Config>> Create(jni::JNIEnv&, Value);
};
static constexpr auto Name() { return "android/graphics/Bitmap"; };
static void registerNative(jni::JNIEnv&);
- static jni::Object<Bitmap>
- CreateBitmap(jni::JNIEnv&, jni::jint width, jni::jint height, jni::Object<Config>);
+ static jni::Local<jni::Object<Bitmap>>
+ CreateBitmap(jni::JNIEnv&, jni::jint width, jni::jint height, const jni::Object<Config>&);
- static jni::Object<Bitmap>
+ static jni::Local<jni::Object<Bitmap>>
CreateBitmap(jni::JNIEnv& env, jni::jint width, jni::jint height, Config::Value config) {
return CreateBitmap(env, width, height, Config::Create(env, config));
}
- static PremultipliedImage GetImage(jni::JNIEnv&, jni::Object<Bitmap>);
- static jni::Object<Bitmap> CreateBitmap(jni::JNIEnv&, const PremultipliedImage&);
- static jni::Object<Bitmap> Copy(jni::JNIEnv&, jni::Object<Bitmap>);
+ static PremultipliedImage GetImage(jni::JNIEnv&, const jni::Object<Bitmap>&);
+ static jni::Local<jni::Object<Bitmap>> CreateBitmap(jni::JNIEnv&, const PremultipliedImage&);
+ static jni::Local<jni::Object<Bitmap>> Copy(jni::JNIEnv&, const jni::Object<Bitmap>&);
};
} // namespace android
diff --git a/platform/android/src/bitmap_factory.cpp b/platform/android/src/bitmap_factory.cpp
index 79cdc913a0..170bd52ea5 100644
--- a/platform/android/src/bitmap_factory.cpp
+++ b/platform/android/src/bitmap_factory.cpp
@@ -7,11 +7,11 @@ void BitmapFactory::registerNative(jni::JNIEnv& env) {
jni::Class<BitmapFactory>::Singleton(env);
}
-jni::Object<Bitmap> BitmapFactory::DecodeByteArray(jni::JNIEnv& env,
- jni::Array<jni::jbyte> data,
- jni::jint offset,
- jni::jint length) {
- static auto _class = jni::Class<BitmapFactory>::Singleton(env);
+jni::Local<jni::Object<Bitmap>> BitmapFactory::DecodeByteArray(jni::JNIEnv& env,
+ jni::Array<jni::jbyte>& data,
+ jni::jint offset,
+ jni::jint length) {
+ static auto& _class = jni::Class<BitmapFactory>::Singleton(env);
// Images are loaded with ARGB_8888 config, and premultiplied by default, which is exactly
// what we want, so we're not providing a BitmapFactory.Options object.
diff --git a/platform/android/src/bitmap_factory.hpp b/platform/android/src/bitmap_factory.hpp
index 6e019d017c..f73b7a2906 100644
--- a/platform/android/src/bitmap_factory.hpp
+++ b/platform/android/src/bitmap_factory.hpp
@@ -12,8 +12,8 @@ public:
static constexpr auto Name() { return "android/graphics/BitmapFactory"; };
static void registerNative(jni::JNIEnv&);
- static jni::Object<Bitmap>
- DecodeByteArray(jni::JNIEnv&, jni::Array<jni::jbyte> data, jni::jint offset, jni::jint length);
+ static jni::Local<jni::Object<Bitmap>>
+ DecodeByteArray(jni::JNIEnv&, jni::Array<jni::jbyte>& data, jni::jint offset, jni::jint length);
};
} // namespace android
diff --git a/platform/android/src/connectivity_listener.cpp b/platform/android/src/connectivity_listener.cpp
index 3fcc580aab..9c13f1f749 100644
--- a/platform/android/src/connectivity_listener.cpp
+++ b/platform/android/src/connectivity_listener.cpp
@@ -21,7 +21,7 @@ namespace android {
void ConnectivityListener::registerNative(jni::JNIEnv& env) {
// Lookup the class
- static auto javaClass = jni::Class<ConnectivityListener>::Singleton(env);
+ static auto& javaClass = jni::Class<ConnectivityListener>::Singleton(env);
#define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
diff --git a/platform/android/src/conversion/collection.cpp b/platform/android/src/conversion/collection.cpp
index 3195458aa6..954a161baf 100644
--- a/platform/android/src/conversion/collection.cpp
+++ b/platform/android/src/conversion/collection.cpp
@@ -5,23 +5,23 @@ namespace mbgl {
namespace android {
namespace conversion {
-std::vector<std::string> toVector(JNIEnv& env, jni::Array<jni::String> array) {
+std::vector<std::string> toVector(JNIEnv& env, const jni::Array<jni::String>& array) {
std::size_t len = array.Length(env);
std::vector<std::string> vector;
vector.reserve(len);
for (std::size_t i = 0; i < len; i++) {
- vector.push_back(*convert<std::string>(env, *jni::SeizeLocal(env, array.Get(env, i))));
+ vector.push_back(jni::Make<std::string>(env, array.Get(env, i)));
}
return vector;
}
-jni::Array<jni::String> toArray(JNIEnv& env, const std::vector<std::string>& vector) {
+jni::Local<jni::Array<jni::String>> toArray(JNIEnv& env, const std::vector<std::string>& vector) {
auto result = jni::Array<jni::String>::New(env, vector.size());
for (std::size_t i = 0; i < vector.size(); i++) {
- result.Set(env, i, *jni::SeizeLocal(env, jni::Make<jni::String>(env, vector.at(i))));
+ result.Set(env, i, jni::Make<jni::String>(env, vector.at(i)));
}
return result;
diff --git a/platform/android/src/conversion/collection.hpp b/platform/android/src/conversion/collection.hpp
index c6b08370ee..322ebb62e0 100644
--- a/platform/android/src/conversion/collection.hpp
+++ b/platform/android/src/conversion/collection.hpp
@@ -10,8 +10,8 @@ namespace mbgl {
namespace android {
namespace conversion {
-std::vector<std::string> toVector(JNIEnv& env, jni::Array<jni::String> array);
-jni::Array<jni::String> toArray(JNIEnv& env, const std::vector<std::string>&);
+std::vector<std::string> toVector(JNIEnv& env, const jni::Array<jni::String>& array);
+jni::Local<jni::Array<jni::String>> toArray(JNIEnv& env, const std::vector<std::string>&);
}
}
diff --git a/platform/android/src/conversion/constant.cpp b/platform/android/src/conversion/constant.cpp
index 16e8b32943..804d5fd146 100644
--- a/platform/android/src/conversion/constant.cpp
+++ b/platform/android/src/conversion/constant.cpp
@@ -1,4 +1,5 @@
#include "constant.hpp"
+#include "collection.hpp"
#include <sstream>
@@ -6,63 +7,46 @@ namespace mbgl {
namespace android {
namespace conversion {
-Result<jni::jobject*> Converter<jni::jobject*, bool>::operator()(jni::JNIEnv& env, const bool& value) const {
- static jni::jclass* javaClass = jni::NewGlobalRef(env, &jni::FindClass(env, "java/lang/Boolean")).release();
- static jni::jmethodID* constructor = &jni::GetMethodID(env, *javaClass, "<init>", "(Z)V");
- return {&jni::NewObject(env, *javaClass, *constructor, (jboolean) value)};
+Result<jni::Local<jni::Object<>>> Converter<jni::Local<jni::Object<>>, bool>::operator()(jni::JNIEnv& env, const bool& value) const {
+ return jni::Box(env, value ? jni::jni_true : jni::jni_false);
}
-Result<jni::jobject*> Converter<jni::jobject*, float>::operator()(jni::JNIEnv& env, const float& value) const {
- static jni::jclass* javaClass = jni::NewGlobalRef(env, &jni::FindClass(env, "java/lang/Float")).release();
- static jni::jmethodID* constructor = &jni::GetMethodID(env, *javaClass, "<init>", "(F)V");
- return {&jni::NewObject(env, *javaClass, *constructor, (jfloat) value)};
+Result<jni::Local<jni::Object<>>> Converter<jni::Local<jni::Object<>>, float>::operator()(jni::JNIEnv& env, const float& value) const {
+ return jni::Box(env, value);
}
-Result<jni::jobject*> Converter<jni::jobject*, double>::operator()(jni::JNIEnv& env, const double& value) const {
- static jni::jclass* javaClass = jni::NewGlobalRef(env, &jni::FindClass(env, "java/lang/Double")).release();
- static jni::jmethodID* constructor = &jni::GetMethodID(env, *javaClass, "<init>", "(D)V");
- return {&jni::NewObject(env, *javaClass, *constructor, (jfloat) value)};
+Result<jni::Local<jni::Object<>>> Converter<jni::Local<jni::Object<>>, double>::operator()(jni::JNIEnv& env, const double& value) const {
+ return jni::Box(env, value);
}
-Result<jni::jobject*> Converter<jni::jobject*, std::string>::operator()(jni::JNIEnv& env, const std::string& value) const {
- return {jni::Make<jni::String>(env, value).Get()};
+Result<jni::Local<jni::Object<>>> Converter<jni::Local<jni::Object<>>, std::string>::operator()(jni::JNIEnv& env, const std::string& value) const {
+ return jni::Make<jni::String>(env, value);
}
-Result<jni::jobject*> Converter<jni::jobject*, Color>::operator()(jni::JNIEnv& env, const Color& value) const {
+Result<jni::Local<jni::Object<>>> Converter<jni::Local<jni::Object<>>, Color>::operator()(jni::JNIEnv& env, const Color& value) const {
std::stringstream sstream;
sstream << "rgba(" << value.r << ", " << value.g << ", " << value.b << ", " << value.a << ")";
- std::string result = sstream.str();
- return convert<jni::jobject*, std::string>(env, result);
+ return jni::Make<jni::String>(env, sstream.str());
}
-Result<jni::jobject*> Converter<jni::jobject*, std::vector<std::string>>::operator()(jni::JNIEnv& env, const std::vector<std::string>& value) const {
- static jni::jclass* stringCass = jni::NewGlobalRef(env, &jni::FindClass(env, "java/lang/String")).release();
- jni::jarray<jni::jobject>& jarray = jni::NewObjectArray(env, value.size(), *stringCass);
+Result<jni::Local<jni::Object<>>> Converter<jni::Local<jni::Object<>>, std::vector<std::string>>::operator()(jni::JNIEnv& env, const std::vector<std::string>& value) const {
+ auto result = jni::Array<jni::String>::New(env, value.size());
- for(size_t i = 0; i < value.size(); i = i + 1) {
- Result<jni::jobject*> converted = convert<jni::jobject*, std::string>(env, value.at(i));
- jni::SetObjectArrayElement(env, jarray, i, *converted);
+ for (std::size_t i = 0; i < value.size(); i++) {
+ result.Set(env, i, jni::Make<jni::String>(env, value.at(i)));
}
- return &jarray;
+ return result;
}
-Result<jni::jobject*> Converter<jni::jobject*, std::vector<float>>::operator()(jni::JNIEnv& env, const std::vector<float>& value) const {
- static jni::jclass* floatClass = jni::NewGlobalRef(env, &jni::FindClass(env, "java/lang/Float")).release();
- jni::jarray<jni::jobject>& jarray = jni::NewObjectArray(env, value.size(), *floatClass);
+Result<jni::Local<jni::Object<>>> Converter<jni::Local<jni::Object<>>, std::vector<float>>::operator()(jni::JNIEnv& env, const std::vector<float>& value) const {
+ auto result = jni::Array<jni::Float>::New(env, value.size());
- for(size_t i = 0; i < value.size(); i = i + 1) {
- Result<jni::jobject*> converted = convert<jni::jobject*, float>(env, value.at(i));
- jni::SetObjectArrayElement(env, jarray, i, *converted);
+ for (std::size_t i = 0; i < value.size(); i++) {
+ result.Set(env, i, jni::Box(env, value.at(i)));
}
- return &jarray;
-}
-
-// Java -> C++
-
-Result<std::string> Converter<std::string, jni::String>::operator()(jni::JNIEnv& env, const jni::String& value) const {
- return { jni::Make<std::string>(env, value) };
+ return result;
}
} // namespace conversion
diff --git a/platform/android/src/conversion/constant.hpp b/platform/android/src/conversion/constant.hpp
index 0e665cf56a..c6dafe1174 100644
--- a/platform/android/src/conversion/constant.hpp
+++ b/platform/android/src/conversion/constant.hpp
@@ -16,18 +16,18 @@ namespace android {
namespace conversion {
template <>
-struct Converter<jni::jobject*, bool> {
- Result<jni::jobject*> operator()(jni::JNIEnv& env, const bool& value) const;
+struct Converter<jni::Local<jni::Object<>>, bool> {
+ Result<jni::Local<jni::Object<>>> operator()(jni::JNIEnv& env, const bool& value) const;
};
template <>
-struct Converter<jni::jobject*, float> {
- Result<jni::jobject*> operator()(jni::JNIEnv& env, const float& value) const;
+struct Converter<jni::Local<jni::Object<>>, float> {
+ Result<jni::Local<jni::Object<>>> operator()(jni::JNIEnv& env, const float& value) const;
};
template <>
-struct Converter<jni::jobject*, double> {
- Result<jni::jobject*> operator()(jni::JNIEnv& env, const double& value) const;
+struct Converter<jni::Local<jni::Object<>>, double> {
+ Result<jni::Local<jni::Object<>>> operator()(jni::JNIEnv& env, const double& value) const;
};
/**
@@ -35,61 +35,52 @@ struct Converter<jni::jobject*, double> {
* TODO: use BigDecimal for > 64 / unsigned?
*/
template<typename T>
-struct Converter<jni::jobject*, T, typename std::enable_if<std::is_integral<T>::value>::type> {
- Result<jni::jobject*> 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, "<init>", "(J)V");
- return {&jni::NewObject(env, *javaClass, *constructor, (jlong) value)};
+struct Converter<jni::Local<jni::Object<>>, T, typename std::enable_if<std::is_integral<T>::value>::type> {
+ Result<jni::Local<jni::Object<>>> operator()(jni::JNIEnv& env, const T& value) const {
+ return jni::Box(env, jni::jlong(value));
}
};
// TODO: convert integral types to primitive jni types
template <>
-struct Converter<jni::jobject*, std::string> {
- Result<jni::jobject*> operator()(jni::JNIEnv& env, const std::string& value) const;
+struct Converter<jni::Local<jni::Object<>>, std::string> {
+ Result<jni::Local<jni::Object<>>> operator()(jni::JNIEnv& env, const std::string& value) const;
};
template <>
-struct Converter<jni::jobject*, Color> {
- Result<jni::jobject*> operator()(jni::JNIEnv& env, const Color& value) const;
+struct Converter<jni::Local<jni::Object<>>, Color> {
+ Result<jni::Local<jni::Object<>>> operator()(jni::JNIEnv& env, const Color& value) const;
};
template <std::size_t N>
-struct Converter<jni::jobject*, std::array<float, N>> {
- Result<jni::jobject*> operator()(jni::JNIEnv& env, const std::array<float, N>& value) const {
+struct Converter<jni::Local<jni::Object<>>, std::array<float, N>> {
+ Result<jni::Local<jni::Object<>>> operator()(jni::JNIEnv& env, const std::array<float, N>& value) const {
std::vector<float> v;
for (const float& id : value) {
v.push_back(id);
}
- return convert<jni::jobject*, std::vector<float>>(env, v);
+ return convert<jni::Local<jni::Object<>>, std::vector<float>>(env, v);
}
};
template <>
-struct Converter<jni::jobject*, std::vector<std::string>> {
- Result<jni::jobject*> operator()(jni::JNIEnv& env, const std::vector<std::string>& value) const;
+struct Converter<jni::Local<jni::Object<>>, std::vector<std::string>> {
+ Result<jni::Local<jni::Object<>>> operator()(jni::JNIEnv& env, const std::vector<std::string>& value) const;
};
template <>
-struct Converter<jni::jobject*, std::vector<float>> {
- Result<jni::jobject*> operator()(jni::JNIEnv& env, const std::vector<float>& value) const;
+struct Converter<jni::Local<jni::Object<>>, std::vector<float>> {
+ Result<jni::Local<jni::Object<>>> operator()(jni::JNIEnv& env, const std::vector<float>& value) const;
};
template <class T>
-struct Converter<jni::jobject*, T, typename std::enable_if_t<std::is_enum<T>::value>> {
- Result<jni::jobject*> operator()(jni::JNIEnv& env, const T& value) const {
- return convert<jni::jobject*, std::string>(env, Enum<T>::toString(value));
+struct Converter<jni::Local<jni::Object<>>, T, typename std::enable_if_t<std::is_enum<T>::value>> {
+ Result<jni::Local<jni::Object<>>> operator()(jni::JNIEnv& env, const T& value) const {
+ return convert<jni::Local<jni::Object<>>, std::string>(env, Enum<T>::toString(value));
}
};
-// Java -> C++
-
-template <>
-struct Converter<std::string, jni::String> {
- Result<std::string> operator()(jni::JNIEnv& env, const jni::String& value) const;
-};
-
} // namespace conversion
-} // namespace style
+} // namespace android
} // namespace mbgl
diff --git a/platform/android/src/file_source.cpp b/platform/android/src/file_source.cpp
index 32c304b909..d9b8e12dc4 100644
--- a/platform/android/src/file_source.cpp
+++ b/platform/android/src/file_source.cpp
@@ -1,4 +1,5 @@
#include "file_source.hpp"
+#include "attach_env.hpp"
#include <mbgl/actor/actor.hpp>
#include <mbgl/actor/scheduler.hpp>
@@ -6,7 +7,6 @@
#include <mbgl/util/logging.hpp>
#include "asset_manager_file_source.hpp"
-#include "jni/generic_global_ref_deleter.hpp"
namespace mbgl {
namespace android {
@@ -14,9 +14,9 @@ namespace android {
// FileSource //
FileSource::FileSource(jni::JNIEnv& _env,
- jni::String accessToken,
- jni::String _cachePath,
- jni::Object<AssetManager> assetManager) {
+ const jni::String& accessToken,
+ const jni::String& _cachePath,
+ const jni::Object<AssetManager>& assetManager) {
// Create a core default file source
fileSource = std::make_unique<mbgl::DefaultFileSource>(
jni::Make<std::string>(_env, _cachePath) + "/mbgl-offline.db",
@@ -31,30 +31,31 @@ FileSource::FileSource(jni::JNIEnv& _env,
FileSource::~FileSource() {
}
-jni::String FileSource::getAccessToken(jni::JNIEnv& env) {
+jni::Local<jni::String> FileSource::getAccessToken(jni::JNIEnv& env) {
return jni::Make<jni::String>(env, fileSource->getAccessToken());
}
-void FileSource::setAccessToken(jni::JNIEnv& env, jni::String token) {
+void FileSource::setAccessToken(jni::JNIEnv& env, const jni::String& token) {
fileSource->setAccessToken(jni::Make<std::string>(env, token));
}
-void FileSource::setAPIBaseUrl(jni::JNIEnv& env, jni::String url) {
+void FileSource::setAPIBaseUrl(jni::JNIEnv& env, const jni::String& url) {
fileSource->setAPIBaseURL(jni::Make<std::string>(env, url));
}
-void FileSource::setResourceTransform(jni::JNIEnv& env, jni::Object<FileSource::ResourceTransformCallback> transformCallback) {
+void FileSource::setResourceTransform(jni::JNIEnv& env, const jni::Object<FileSource::ResourceTransformCallback>& transformCallback) {
if (transformCallback) {
+ auto global = jni::NewGlobal<jni::EnvAttachingDeleter>(env, transformCallback);
resourceTransform = std::make_unique<Actor<ResourceTransform>>(*Scheduler::GetCurrent(),
// Capture the ResourceTransformCallback object as a managed global into
// the lambda. It is released automatically when we're setting a new ResourceTransform in
// a subsequent call.
// Note: we're converting it to shared_ptr because this lambda is converted to a std::function,
// which requires copyability of its captured variables.
- [callback = std::shared_ptr<jni::jobject>(transformCallback.NewGlobalRef(env).release().Get(), GenericGlobalRefDeleter())]
+ [callback = std::make_shared<decltype(global)>(std::move(global))]
(mbgl::Resource::Kind kind, const std::string&& url_) {
android::UniqueEnv _env = android::AttachEnv();
- return FileSource::ResourceTransformCallback::onURL(*_env, jni::Object<FileSource::ResourceTransformCallback>(*callback), int(kind), url_);
+ return FileSource::ResourceTransformCallback::onURL(*_env, *callback, int(kind), url_);
});
fileSource->setResourceTransform(resourceTransform->self());
} else {
@@ -92,13 +93,13 @@ jni::jboolean FileSource::isResumed(jni::JNIEnv&) {
return (jboolean) false;
}
-FileSource* FileSource::getNativePeer(jni::JNIEnv& env, jni::Object<FileSource> jFileSource) {
- static auto javaClass = jni::Class<FileSource>::Singleton(env);
+FileSource* FileSource::getNativePeer(jni::JNIEnv& env, const jni::Object<FileSource>& jFileSource) {
+ static auto& javaClass = jni::Class<FileSource>::Singleton(env);
static auto field = javaClass.GetField<jlong>(env, "nativePtr");
return reinterpret_cast<FileSource *>(jFileSource.Get(env, field));
}
-mbgl::DefaultFileSource& FileSource::getDefaultFileSource(jni::JNIEnv& env, jni::Object<FileSource> jFileSource) {
+mbgl::DefaultFileSource& FileSource::getDefaultFileSource(jni::JNIEnv& env, const jni::Object<FileSource>& jFileSource) {
FileSource* fileSource = FileSource::getNativePeer(env, jFileSource);
assert(fileSource != nullptr);
return *fileSource->fileSource;
@@ -110,14 +111,14 @@ void FileSource::registerNative(jni::JNIEnv& env) {
// https://developer.android.com/training/articles/perf-jni#faq_FindClass
jni::Class<ResourceTransformCallback>::Singleton(env);
- static auto javaClass = jni::Class<FileSource>::Singleton(env);
+ static auto& javaClass = jni::Class<FileSource>::Singleton(env);
#define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
// Register the peer
jni::RegisterNativePeer<FileSource>(
env, javaClass, "nativePtr",
- std::make_unique<FileSource, JNIEnv&, jni::String, jni::String, jni::Object<AssetManager>>,
+ jni::MakePeer<FileSource, const jni::String&, const jni::String&, const jni::Object<AssetManager>&>,
"initialize",
"finalize",
METHOD(&FileSource::getAccessToken, "getAccessToken"),
@@ -133,13 +134,13 @@ void FileSource::registerNative(jni::JNIEnv& env) {
// FileSource::ResourceTransformCallback //
-std::string FileSource::ResourceTransformCallback::onURL(jni::JNIEnv& env, jni::Object<FileSource::ResourceTransformCallback> callback, int kind, std::string url_) {
- static auto javaClass = jni::Class<FileSource::ResourceTransformCallback>::Singleton(env);
+std::string FileSource::ResourceTransformCallback::onURL(jni::JNIEnv& env, const jni::Object<FileSource::ResourceTransformCallback>& callback, int kind, std::string url_) {
+ static auto& javaClass = jni::Class<FileSource::ResourceTransformCallback>::Singleton(env);
static auto method = javaClass.GetMethod<jni::String (jni::jint, jni::String)>(env, "onURL");
return jni::Make<std::string>(env,
- *jni::SeizeLocal(env, callback.Call(env, method, kind,
- *jni::SeizeLocal(env, jni::Make<jni::String>(env, url_)))));
+ callback.Call(env, method, kind,
+ jni::Make<jni::String>(env, url_)));
}
} // namespace android
diff --git a/platform/android/src/file_source.hpp b/platform/android/src/file_source.hpp
index f1b11c754c..572ac647b7 100644
--- a/platform/android/src/file_source.hpp
+++ b/platform/android/src/file_source.hpp
@@ -24,20 +24,20 @@ public:
struct ResourceTransformCallback {
static constexpr auto Name() { return "com/mapbox/mapboxsdk/storage/FileSource$ResourceTransformCallback"; }
- static std::string onURL(jni::JNIEnv&, jni::Object<FileSource::ResourceTransformCallback>, int, std::string);
+ static std::string onURL(jni::JNIEnv&, const jni::Object<FileSource::ResourceTransformCallback>&, int, std::string);
};
- FileSource(jni::JNIEnv&, jni::String, jni::String, jni::Object<AssetManager>);
+ FileSource(jni::JNIEnv&, const jni::String&, const jni::String&, const jni::Object<AssetManager>&);
~FileSource();
- jni::String getAccessToken(jni::JNIEnv&);
+ jni::Local<jni::String> getAccessToken(jni::JNIEnv&);
- void setAccessToken(jni::JNIEnv&, jni::String);
+ void setAccessToken(jni::JNIEnv&, const jni::String&);
- void setAPIBaseUrl(jni::JNIEnv&, jni::String);
+ void setAPIBaseUrl(jni::JNIEnv&, const jni::String&);
- void setResourceTransform(jni::JNIEnv&, jni::Object<FileSource::ResourceTransformCallback>);
+ void setResourceTransform(jni::JNIEnv&, const jni::Object<FileSource::ResourceTransformCallback>&);
void resume(jni::JNIEnv&);
@@ -45,9 +45,9 @@ public:
jni::jboolean isResumed(jni::JNIEnv&);
- static FileSource* getNativePeer(jni::JNIEnv&, jni::Object<FileSource>);
+ static FileSource* getNativePeer(jni::JNIEnv&, const jni::Object<FileSource>&);
- static mbgl::DefaultFileSource& getDefaultFileSource(jni::JNIEnv&, jni::Object<FileSource>);
+ static mbgl::DefaultFileSource& getDefaultFileSource(jni::JNIEnv&, const jni::Object<FileSource>&);
static void registerNative(jni::JNIEnv&);
diff --git a/platform/android/src/geojson/feature.cpp b/platform/android/src/geojson/feature.cpp
index 809ac42ef7..e79c238864 100644
--- a/platform/android/src/geojson/feature.cpp
+++ b/platform/android/src/geojson/feature.cpp
@@ -8,18 +8,18 @@ namespace geojson {
using namespace gson;
-mbgl::Feature Feature::convert(jni::JNIEnv& env, jni::Object<Feature> jFeature) {
- static auto javaClass = jni::Class<Feature>::Singleton(env);
+mbgl::Feature Feature::convert(jni::JNIEnv& env, const jni::Object<Feature>& jFeature) {
+ static auto& javaClass = jni::Class<Feature>::Singleton(env);
static auto id = javaClass.GetMethod<jni::String ()>(env, "id");
static auto geometry = javaClass.GetMethod<jni::Object<Geometry> ()>(env, "geometry");
static auto properties = javaClass.GetMethod<jni::Object<gson::JsonObject> ()>(env, "properties");
- auto jId = jni::SeizeLocal(env, jFeature.Call(env, id));
+ auto jId = jFeature.Call(env, id);
return mbgl::Feature {
- Geometry::convert(env, *jni::SeizeLocal(env, jFeature.Call(env, geometry))),
- JsonObject::convert(env, *jni::SeizeLocal(env, jFeature.Call(env, properties))),
- jId ? std::experimental::optional<mapbox::geometry::identifier>(jni::Make<std::string>(env, *jId))
+ Geometry::convert(env, jFeature.Call(env, geometry)),
+ JsonObject::convert(env, jFeature.Call(env, properties)),
+ jId ? std::experimental::optional<mapbox::geometry::identifier>(jni::Make<std::string>(env, jId))
: std::experimental::nullopt
};
}
@@ -43,21 +43,21 @@ public:
}
};
-jni::Object<Feature> convertFeature(jni::JNIEnv& env, const mbgl::Feature& value) {
- static auto javaClass = jni::Class<Feature>::Singleton(env);
+jni::Local<jni::Object<Feature>> convertFeature(jni::JNIEnv& env, const mbgl::Feature& value) {
+ static auto& javaClass = jni::Class<Feature>::Singleton(env);
static auto method = javaClass.GetStaticMethod<jni::Object<Feature> (jni::Object<Geometry>, jni::Object<JsonObject>, jni::String)>(env, "fromGeometry");
return javaClass.Call(env, method,
- *jni::SeizeLocal(env, Geometry::New(env, value.geometry)),
- *jni::SeizeLocal(env, JsonObject::New(env, value.properties)),
- *jni::SeizeLocal(env, jni::Make<jni::String>(env, value.id ? value.id.value().match(FeatureIdVisitor()) : "")));
+ Geometry::New(env, value.geometry),
+ JsonObject::New(env, value.properties),
+ jni::Make<jni::String>(env, value.id ? value.id.value().match(FeatureIdVisitor()) : ""));
}
-jni::Array<jni::Object<Feature>> Feature::convert(jni::JNIEnv& env, const std::vector<mbgl::Feature>& value) {
+jni::Local<jni::Array<jni::Object<Feature>>> Feature::convert(jni::JNIEnv& env, const std::vector<mbgl::Feature>& value) {
auto features = jni::Array<jni::Object<Feature>>::New(env, value.size());
for (size_t i = 0; i < value.size(); i = i + 1) {
- features.Set(env, i, *jni::SeizeLocal(env, convertFeature(env, value.at(i))));
+ features.Set(env, i, convertFeature(env, value.at(i)));
}
return features;
diff --git a/platform/android/src/geojson/feature.hpp b/platform/android/src/geojson/feature.hpp
index fba4815e0c..fdf5d977ba 100644
--- a/platform/android/src/geojson/feature.hpp
+++ b/platform/android/src/geojson/feature.hpp
@@ -8,12 +8,12 @@ namespace mbgl {
namespace android {
namespace geojson {
-class Feature : public jni::ObjectTag {
+class Feature {
public:
static constexpr auto Name() { return "com/mapbox/geojson/Feature"; };
- static mbgl::Feature convert(jni::JNIEnv&, jni::Object<Feature>);
- static jni::Array<jni::Object<Feature>> convert(jni::JNIEnv&, const std::vector<mbgl::Feature>&);
+ static mbgl::Feature convert(jni::JNIEnv&, const jni::Object<Feature>&);
+ static jni::Local<jni::Array<jni::Object<Feature>>> convert(jni::JNIEnv&, const std::vector<mbgl::Feature>&);
static void registerNative(jni::JNIEnv&);
};
diff --git a/platform/android/src/geojson/feature_collection.cpp b/platform/android/src/geojson/feature_collection.cpp
index c2825e037b..f90d5226b7 100644
--- a/platform/android/src/geojson/feature_collection.cpp
+++ b/platform/android/src/geojson/feature_collection.cpp
@@ -6,24 +6,24 @@ namespace mbgl {
namespace android {
namespace geojson {
-mbgl::FeatureCollection FeatureCollection::convert(jni::JNIEnv& env, jni::Object<FeatureCollection> jCollection) {
+mbgl::FeatureCollection FeatureCollection::convert(jni::JNIEnv& env, const jni::Object<FeatureCollection>& jCollection) {
auto collection = mbgl::FeatureCollection();
if (jCollection) {
- auto jFeatureList = jni::SeizeLocal(env, FeatureCollection::features(env, jCollection));
- auto jFeatures = jni::SeizeLocal(env, java::util::List::toArray<Feature>(env, *jFeatureList));
- auto size = size_t(jFeatures->Length(env));
+ auto jFeatureList = FeatureCollection::features(env, jCollection);
+ auto jFeatures = java::util::List::toArray<Feature>(env, jFeatureList);
+ auto size = size_t(jFeatures.Length(env));
collection.reserve(size);
for (size_t i = 0; i < size; i++) {
- collection.push_back(Feature::convert(env, *jni::SeizeLocal(env, jFeatures->Get(env, i))));
+ collection.push_back(Feature::convert(env, jFeatures.Get(env, i)));
}
}
return collection;
}
-jni::Object<java::util::List> FeatureCollection::features(jni::JNIEnv& env, jni::Object<FeatureCollection> jCollection) {
- static auto javaClass = jni::Class<FeatureCollection>::Singleton(env);
+jni::Local<jni::Object<java::util::List>> FeatureCollection::features(jni::JNIEnv& env, const jni::Object<FeatureCollection>& jCollection) {
+ static auto& javaClass = jni::Class<FeatureCollection>::Singleton(env);
static auto method = javaClass.GetMethod<jni::Object<java::util::List> ()>(env, "features");
return jCollection.Call(env, method);
}
diff --git a/platform/android/src/geojson/feature_collection.hpp b/platform/android/src/geojson/feature_collection.hpp
index 1b45cca5de..66e92eacad 100644
--- a/platform/android/src/geojson/feature_collection.hpp
+++ b/platform/android/src/geojson/feature_collection.hpp
@@ -3,7 +3,6 @@
#include "../java/util.hpp"
#include <mbgl/util/geojson.hpp>
-#include <mbgl/util/noncopyable.hpp>
#include <jni/jni.hpp>
@@ -11,13 +10,13 @@ namespace mbgl {
namespace android {
namespace geojson {
-class FeatureCollection : private mbgl::util::noncopyable {
+class FeatureCollection {
public:
static constexpr auto Name() { return "com/mapbox/geojson/FeatureCollection"; };
- static mbgl::FeatureCollection convert(jni::JNIEnv&, jni::Object<FeatureCollection>);
+ static mbgl::FeatureCollection convert(jni::JNIEnv&, const jni::Object<FeatureCollection>&);
- static jni::Object<java::util::List> features(jni::JNIEnv&, jni::Object<FeatureCollection>);
+ static jni::Local<jni::Object<java::util::List>> features(jni::JNIEnv&, const jni::Object<FeatureCollection>&);
static void registerNative(jni::JNIEnv&);
};
diff --git a/platform/android/src/geojson/geometry.cpp b/platform/android/src/geojson/geometry.cpp
index 4262b4ee69..2356af780a 100644
--- a/platform/android/src/geojson/geometry.cpp
+++ b/platform/android/src/geojson/geometry.cpp
@@ -22,65 +22,65 @@ public:
jni::JNIEnv& env;
- jni::Object<Geometry> operator()(const mbgl::Point<double> &geometry) const {
+ jni::Local<jni::Object<Geometry>> operator()(const mbgl::Point<double> &geometry) const {
return Point::New(env, geometry);
}
- jni::Object<Geometry> operator()(const mbgl::LineString<double> &geometry) const {
+ jni::Local<jni::Object<Geometry>> operator()(const mbgl::LineString<double> &geometry) const {
return LineString::New(env, geometry);
}
- jni::Object<Geometry> operator()(const mbgl::MultiLineString<double> &geometry) const {
+ jni::Local<jni::Object<Geometry>> operator()(const mbgl::MultiLineString<double> &geometry) const {
return MultiLineString::New(env, geometry);
}
- jni::Object<Geometry> operator()(const mbgl::MultiPoint<double> &geometry) const {
+ jni::Local<jni::Object<Geometry>> operator()(const mbgl::MultiPoint<double> &geometry) const {
return MultiPoint::New(env, geometry);
}
- jni::Object<Geometry> operator()(const mbgl::Polygon<double> &geometry) const {
+ jni::Local<jni::Object<Geometry>> operator()(const mbgl::Polygon<double> &geometry) const {
return Polygon::New(env, geometry);
}
- jni::Object<Geometry> operator()(const mbgl::MultiPolygon<double> &geometry) const {
+ jni::Local<jni::Object<Geometry>> operator()(const mbgl::MultiPolygon<double> &geometry) const {
return MultiPolygon::New(env, geometry);
}
- jni::Object<Geometry> operator()(const mapbox::geometry::geometry_collection<double> &geometry) const {
+ jni::Local<jni::Object<Geometry>> operator()(const mapbox::geometry::geometry_collection<double> &geometry) const {
return GeometryCollection::New(env, geometry);
}
};
-jni::Object<Geometry> Geometry::New(jni::JNIEnv& env, mbgl::Geometry<double> geometry) {
+jni::Local<jni::Object<Geometry>> Geometry::New(jni::JNIEnv& env, mbgl::Geometry<double> geometry) {
GeometryEvaluator evaluator { env } ;
return mbgl::Geometry<double>::visit(geometry, evaluator);
}
-mbgl::Geometry<double> Geometry::convert(jni::JNIEnv &env, jni::Object<Geometry> jGeometry) {
+mbgl::Geometry<double> Geometry::convert(jni::JNIEnv &env, const jni::Object<Geometry>& jGeometry) {
auto type = Geometry::getType(env, jGeometry);
if (type == Point::Type()) {
- return { Point::convert(env, jni::Object<Point>(jGeometry.Get())) };
+ return { Point::convert(env, jni::Cast(env, jni::Class<Point>::Singleton(env), jGeometry)) };
} else if (type == MultiPoint::Type()) {
- return { MultiPoint::convert(env, jni::Object<MultiPoint>(jGeometry.Get())) };
+ return { MultiPoint::convert(env, jni::Cast(env, jni::Class<MultiPoint>::Singleton(env), jGeometry)) };
} else if (type == LineString::Type()) {
- return { LineString::convert(env, jni::Object<LineString>(jGeometry.Get())) };
+ return { LineString::convert(env, jni::Cast(env, jni::Class<LineString>::Singleton(env), jGeometry)) };
} else if (type == MultiLineString::Type()) {
- return { MultiLineString::convert(env, jni::Object<MultiLineString>(jGeometry.Get())) };
+ return { MultiLineString::convert(env, jni::Cast(env, jni::Class<MultiLineString>::Singleton(env), jGeometry)) };
} else if (type == Polygon::Type()) {
- return { Polygon::convert(env, jni::Object<Polygon>(jGeometry.Get())) };
+ return { Polygon::convert(env, jni::Cast(env, jni::Class<Polygon>::Singleton(env), jGeometry)) };
} else if (type == MultiPolygon::Type()) {
- return { MultiPolygon::convert(env, jni::Object<MultiPolygon>(jGeometry.Get())) };
+ return { MultiPolygon::convert(env, jni::Cast(env, jni::Class<MultiPolygon>::Singleton(env), jGeometry)) };
} else if (type == GeometryCollection::Type()) {
- return { GeometryCollection::convert(env, jni::Object<GeometryCollection>(jGeometry.Get())) };
+ return { GeometryCollection::convert(env, jni::Cast(env, jni::Class<GeometryCollection>::Singleton(env), jGeometry)) };
}
throw std::runtime_error(std::string {"Unsupported GeoJSON type: " } + type);
}
-std::string Geometry::getType(jni::JNIEnv &env, jni::Object<Geometry> jGeometry) {
- static auto javaClass = jni::Class<Geometry>::Singleton(env);
+std::string Geometry::getType(jni::JNIEnv &env, const jni::Object<Geometry>& jGeometry) {
+ static auto& javaClass = jni::Class<Geometry>::Singleton(env);
static auto method = javaClass.GetMethod<jni::String ()>(env, "type");
- return jni::Make<std::string>(env, *jni::SeizeLocal(env, jGeometry.Call(env, method)));
+ return jni::Make<std::string>(env, jGeometry.Call(env, method));
}
void Geometry::registerNative(jni::JNIEnv &env) {
diff --git a/platform/android/src/geojson/geometry.hpp b/platform/android/src/geojson/geometry.hpp
index 836c3bd5a0..4bf55c858b 100644
--- a/platform/android/src/geojson/geometry.hpp
+++ b/platform/android/src/geojson/geometry.hpp
@@ -14,11 +14,11 @@ class Geometry {
public:
static constexpr auto Name() { return "com/mapbox/geojson/Geometry"; };
- static jni::Object<Geometry> New(jni::JNIEnv&, mbgl::Geometry<double>);
+ static jni::Local<jni::Object<Geometry>> New(jni::JNIEnv&, mbgl::Geometry<double>);
- static mbgl::Geometry<double> convert(jni::JNIEnv&, jni::Object<Geometry>);
+ static mbgl::Geometry<double> convert(jni::JNIEnv&, const jni::Object<Geometry>&);
- static std::string getType(jni::JNIEnv&, jni::Object<Geometry>);
+ static std::string getType(jni::JNIEnv&, const jni::Object<Geometry>&);
static void registerNative(jni::JNIEnv&);
};
diff --git a/platform/android/src/geojson/geometry_collection.cpp b/platform/android/src/geojson/geometry_collection.cpp
index ad0af71214..cca909126d 100644
--- a/platform/android/src/geojson/geometry_collection.cpp
+++ b/platform/android/src/geojson/geometry_collection.cpp
@@ -5,36 +5,34 @@ namespace mbgl {
namespace android {
namespace geojson {
-jni::Object<GeometryCollection> GeometryCollection::New(jni::JNIEnv& env, const mapbox::geometry::geometry_collection<double>& collection) {
+jni::Local<jni::Object<GeometryCollection>> GeometryCollection::New(jni::JNIEnv& env, const mapbox::geometry::geometry_collection<double>& collection) {
// Create an array of geometries
- auto jarray = jni::SeizeLocal(env, jni::Array<jni::Object<Geometry>>::New(env, collection.size()));
+ auto jarray = jni::Array<jni::Object<Geometry>>::New(env, collection.size());
for (size_t i = 0; i < collection.size(); i++) {
- jarray->Set(env, i, *jni::SeizeLocal(env, Geometry::New(env, collection.at(i))));
+ jarray.Set(env, i, Geometry::New(env, collection.at(i)));
}
// create the GeometryCollection
- static auto javaClass = jni::Class<GeometryCollection>::Singleton(env);
+ static auto& javaClass = jni::Class<GeometryCollection>::Singleton(env);
static auto method = javaClass.GetStaticMethod<jni::Object<GeometryCollection> (jni::Object<java::util::List>)>(env, "fromGeometries");
- return javaClass.Call(env, method, *jni::SeizeLocal(env, java::util::Arrays::asList(env, *jarray)));
+ return javaClass.Call(env, method, java::util::Arrays::asList(env, jarray));
}
-mapbox::geometry::geometry_collection<double> GeometryCollection::convert(jni::JNIEnv &env, jni::Object<GeometryCollection> jCollection) {
+mapbox::geometry::geometry_collection<double> GeometryCollection::convert(jni::JNIEnv &env, const jni::Object<GeometryCollection>& jCollection) {
// Get geometries
- static auto javaClass = jni::Class<GeometryCollection>::Singleton(env);
+ static auto& javaClass = jni::Class<GeometryCollection>::Singleton(env);
static auto getGeometries = javaClass.GetMethod<jni::Object<java::util::List> ()>(env, "geometries");
// Turn into array
- auto jarray = jni::SeizeLocal(env,
- java::util::List::toArray<Geometry>(env,
- *jni::SeizeLocal(env, jCollection.Call(env, getGeometries))));
+ auto jarray = java::util::List::toArray<Geometry>(env, jCollection.Call(env, getGeometries));
// Convert each geometry
mapbox::geometry::geometry_collection<double> collection{};
- auto size = jarray->Length(env);
+ auto size = jarray.Length(env);
for (jni::jsize i = 0; i < size; i++) {
- collection.push_back(Geometry::convert(env, *jni::SeizeLocal(env, jarray->Get(env, i))));
+ collection.push_back(Geometry::convert(env, jarray.Get(env, i)));
}
return collection;
diff --git a/platform/android/src/geojson/geometry_collection.hpp b/platform/android/src/geojson/geometry_collection.hpp
index a301d86933..9f02ac848d 100644
--- a/platform/android/src/geojson/geometry_collection.hpp
+++ b/platform/android/src/geojson/geometry_collection.hpp
@@ -8,15 +8,15 @@ namespace mbgl {
namespace android {
namespace geojson {
-class GeometryCollection : public Geometry {
+class GeometryCollection {
public:
+ using SuperTag = Geometry;
static constexpr auto Name() { return "com/mapbox/geojson/GeometryCollection"; };
-
static constexpr auto Type() { return "GeometryCollection"; };
- static jni::Object<GeometryCollection> New(jni::JNIEnv&, const mapbox::geometry::geometry_collection<double>&);
+ static jni::Local<jni::Object<GeometryCollection>> New(jni::JNIEnv&, const mapbox::geometry::geometry_collection<double>&);
- static mapbox::geometry::geometry_collection<double> convert(jni::JNIEnv&, jni::Object<GeometryCollection>);
+ static mapbox::geometry::geometry_collection<double> convert(jni::JNIEnv&, const jni::Object<GeometryCollection>&);
static void registerNative(jni::JNIEnv&);
};
diff --git a/platform/android/src/geojson/line_string.cpp b/platform/android/src/geojson/line_string.cpp
index 5a18a02bb7..ae1345c958 100644
--- a/platform/android/src/geojson/line_string.cpp
+++ b/platform/android/src/geojson/line_string.cpp
@@ -7,42 +7,41 @@ namespace mbgl {
namespace android {
namespace geojson {
-jni::Object<LineString> LineString::New(jni::JNIEnv& env, const mbgl::LineString<double>& lineString) {
- static auto javaClass = jni::Class<LineString>::Singleton(env);
+jni::Local<jni::Object<LineString>> LineString::New(jni::JNIEnv& env, const mbgl::LineString<double>& lineString) {
+ static auto& javaClass = jni::Class<LineString>::Singleton(env);
static auto method = javaClass.GetStaticMethod<jni::Object<LineString>(jni::Object<java::util::List>)>(env, "fromLngLats");
- return javaClass.Call(env, method,
- *jni::SeizeLocal(env, asPointsList(env, lineString)));
+ return javaClass.Call(env, method, asPointsList(env, lineString));
}
-mapbox::geojson::line_string LineString::convert(jni::JNIEnv &env, jni::Object<LineString> jLineString) {
+mapbox::geojson::line_string LineString::convert(jni::JNIEnv &env, const jni::Object<LineString>& jLineString) {
mapbox::geojson::line_string lineString;
if (jLineString) {
- lineString = LineString::convert(env, *jni::SeizeLocal(env, LineString::coordinates(env, jLineString)));
+ lineString = LineString::convert(env, LineString::coordinates(env, jLineString));
}
return lineString;
}
-mapbox::geojson::line_string LineString::convert(jni::JNIEnv &env, jni::Object<java::util::List/*<Point>*/> jPointList) {
+mapbox::geojson::line_string LineString::convert(jni::JNIEnv &env, const jni::Object<java::util::List/*<Point>*/>& jPointList) {
mapbox::geojson::line_string lineString;
if (jPointList) {
- auto jPointArray = jni::SeizeLocal(env, java::util::List::toArray<Point>(env, jPointList));
- auto size = jPointArray->Length(env);
+ auto jPointArray = java::util::List::toArray<Point>(env, jPointList);
+ auto size = jPointArray.Length(env);
lineString.reserve(size);
for (std::size_t i = 0; i < size; i++) {
- lineString.push_back(Point::convert(env, *jni::SeizeLocal(env, jPointArray->Get(env, i))));
+ lineString.push_back(Point::convert(env, jPointArray.Get(env, i)));
}
}
return lineString;
}
-jni::Object<java::util::List> LineString::coordinates(jni::JNIEnv &env, jni::Object<LineString> jLineString) {
- static auto javaClass = jni::Class<LineString>::Singleton(env);
+jni::Local<jni::Object<java::util::List>> LineString::coordinates(jni::JNIEnv &env, const jni::Object<LineString>& jLineString) {
+ static auto& javaClass = jni::Class<LineString>::Singleton(env);
static auto method = javaClass.GetMethod<jni::Object<java::util::List> ()>(env, "coordinates");
return jLineString.Call(env, method);
}
diff --git a/platform/android/src/geojson/line_string.hpp b/platform/android/src/geojson/line_string.hpp
index 4df9349185..906d809fa8 100644
--- a/platform/android/src/geojson/line_string.hpp
+++ b/platform/android/src/geojson/line_string.hpp
@@ -14,19 +14,19 @@ namespace android {
namespace geojson {
-class LineString : public Geometry {
+class LineString {
public:
+ using SuperTag = Geometry;
static constexpr auto Name() { return "com/mapbox/geojson/LineString"; };
-
static constexpr auto Type() { return "LineString"; };
- static jni::Object<LineString> New(jni::JNIEnv&, const mbgl::LineString<double>&);
+ static jni::Local<jni::Object<LineString>> New(jni::JNIEnv&, const mbgl::LineString<double>&);
- static mapbox::geojson::line_string convert(jni::JNIEnv&, jni::Object<LineString>);
+ static mapbox::geojson::line_string convert(jni::JNIEnv&, const jni::Object<LineString>&);
- static mapbox::geojson::line_string convert(jni::JNIEnv&, jni::Object<java::util::List/*<Point>*/>);
+ static mapbox::geojson::line_string convert(jni::JNIEnv&, const jni::Object<java::util::List/*<Point>*/>&);
- static jni::Object<java::util::List> coordinates(jni::JNIEnv&, jni::Object<LineString>);
+ static jni::Local<jni::Object<java::util::List>> coordinates(jni::JNIEnv&, const jni::Object<LineString>&);
static void registerNative(jni::JNIEnv&);
};
diff --git a/platform/android/src/geojson/multi_line_string.cpp b/platform/android/src/geojson/multi_line_string.cpp
index 0a0974062c..1aaf53c01f 100644
--- a/platform/android/src/geojson/multi_line_string.cpp
+++ b/platform/android/src/geojson/multi_line_string.cpp
@@ -7,44 +7,42 @@ namespace mbgl {
namespace android {
namespace geojson {
-jni::Object<MultiLineString> MultiLineString::New(jni::JNIEnv& env, const mbgl::MultiLineString<double>& multiLineString) {
- static auto javaClass = jni::Class<MultiLineString>::Singleton(env);
+jni::Local<jni::Object<MultiLineString>> MultiLineString::New(jni::JNIEnv& env, const mbgl::MultiLineString<double>& multiLineString) {
+ static auto& javaClass = jni::Class<MultiLineString>::Singleton(env);
static auto method = javaClass.GetStaticMethod<jni::Object<MultiLineString> (jni::Object<java::util::List>)>(env, "fromLngLats");
- return javaClass.Call(env, method,
- *jni::SeizeLocal(env, asPointsListsList(env, multiLineString)));
+ return javaClass.Call(env, method, asPointsListsList(env, multiLineString));
}
-mapbox::geojson::multi_line_string MultiLineString::convert(jni::JNIEnv &env, jni::Object<MultiLineString> jMultiLineString) {
+mapbox::geojson::multi_line_string MultiLineString::convert(jni::JNIEnv &env, const jni::Object<MultiLineString>& jMultiLineString) {
mapbox::geojson::multi_line_string multiLineString;
if (jMultiLineString) {
- multiLineString = MultiLineString::convert(env,
- *jni::SeizeLocal(env, MultiLineString::coordinates(env, jMultiLineString)));
+ multiLineString = MultiLineString::convert(env, MultiLineString::coordinates(env, jMultiLineString));
}
return multiLineString;
}
-mapbox::geojson::multi_line_string MultiLineString::convert(jni::JNIEnv &env, jni::Object<java::util::List/*<java::util::List<Point>>*/> jPointListsList) {
+mapbox::geojson::multi_line_string MultiLineString::convert(jni::JNIEnv &env, const jni::Object<java::util::List/*<java::util::List<Point>>*/>& jPointListsList) {
mapbox::geojson::multi_line_string multiLineString;
if (jPointListsList) {
- auto jPositionListsArray = jni::SeizeLocal(env, java::util::List::toArray<java::util::List>(env, jPointListsList));
+ auto jPositionListsArray = java::util::List::toArray<java::util::List>(env, jPointListsList);
- auto size = jPositionListsArray->Length(env);
+ auto size = jPositionListsArray.Length(env);
multiLineString.reserve(size);
for (std::size_t i = 0; i < size; i++) {
- multiLineString.push_back(LineString::convert(env, *jni::SeizeLocal(env, jPositionListsArray->Get(env, i))));
+ multiLineString.push_back(LineString::convert(env, jPositionListsArray.Get(env, i)));
}
}
return multiLineString;
}
-jni::Object<java::util::List> MultiLineString::coordinates(jni::JNIEnv &env, jni::Object<MultiLineString> jLineString) {
- static auto javaClass = jni::Class<MultiLineString>::Singleton(env);
+jni::Local<jni::Object<java::util::List>> MultiLineString::coordinates(jni::JNIEnv &env, const jni::Object<MultiLineString>& jLineString) {
+ static auto& javaClass = jni::Class<MultiLineString>::Singleton(env);
static auto method = javaClass.GetMethod<jni::Object<java::util::List> ()>(env, "coordinates");
return jLineString.Call(env, method);
}
diff --git a/platform/android/src/geojson/multi_line_string.hpp b/platform/android/src/geojson/multi_line_string.hpp
index c66aadaf03..65ce43bd1f 100644
--- a/platform/android/src/geojson/multi_line_string.hpp
+++ b/platform/android/src/geojson/multi_line_string.hpp
@@ -12,19 +12,19 @@ namespace mbgl {
namespace android {
namespace geojson {
-class MultiLineString : public Geometry {
+class MultiLineString {
public:
+ using SuperTag = Geometry;
static constexpr auto Name() { return "com/mapbox/geojson/MultiLineString"; };
-
static constexpr auto Type() { return "MultiLineString"; };
- static jni::Object<MultiLineString> New(jni::JNIEnv&, const mbgl::MultiLineString<double>&);
+ static jni::Local<jni::Object<MultiLineString>> New(jni::JNIEnv&, const mbgl::MultiLineString<double>&);
- static mapbox::geojson::multi_line_string convert(jni::JNIEnv&, jni::Object<MultiLineString>);
+ static mapbox::geojson::multi_line_string convert(jni::JNIEnv&, const jni::Object<MultiLineString>&);
- static mapbox::geojson::multi_line_string convert(jni::JNIEnv&, jni::Object<java::util::List/*<java::util::List<Point>>*/>);
+ static mapbox::geojson::multi_line_string convert(jni::JNIEnv&, const jni::Object<java::util::List/*<java::util::List<Point>>*/>&);
- static jni::Object<java::util::List> coordinates(jni::JNIEnv&, jni::Object<MultiLineString>);
+ static jni::Local<jni::Object<java::util::List>> coordinates(jni::JNIEnv&, const jni::Object<MultiLineString>&);
static void registerNative(jni::JNIEnv&);
};
diff --git a/platform/android/src/geojson/multi_point.cpp b/platform/android/src/geojson/multi_point.cpp
index 5f51058f38..d530ef721f 100644
--- a/platform/android/src/geojson/multi_point.cpp
+++ b/platform/android/src/geojson/multi_point.cpp
@@ -8,26 +8,26 @@ namespace mbgl {
namespace android {
namespace geojson {
-jni::Object<MultiPoint> MultiPoint::New(JNIEnv& env, const mbgl::MultiPoint<double>& multiPoint) {
- static auto javaClass = jni::Class<MultiPoint>::Singleton(env);
+jni::Local<jni::Object<MultiPoint>> MultiPoint::New(JNIEnv& env, const mbgl::MultiPoint<double>& multiPoint) {
+ static auto& javaClass = jni::Class<MultiPoint>::Singleton(env);
static auto method = javaClass.GetStaticMethod<jni::Object<MultiPoint>(jni::Object<java::util::List>)>(env, "fromLngLats");
- return javaClass.Call(env, method, *jni::SeizeLocal(env, asPointsList(env, multiPoint)));
+ return javaClass.Call(env, method, asPointsList(env, multiPoint));
}
-mapbox::geojson::multi_point MultiPoint::convert(jni::JNIEnv &env, jni::Object<MultiPoint> jMultiPoint) {
+mapbox::geojson::multi_point MultiPoint::convert(jni::JNIEnv& env, const jni::Object<MultiPoint>& jMultiPoint) {
mapbox::geojson::multi_point multiPoint;
if (jMultiPoint) {
multiPoint = convertExplicit<mapbox::geojson::multi_point>(
- LineString::convert(env, *jni::SeizeLocal(env, MultiPoint::coordinates(env, jMultiPoint))));
+ LineString::convert(env, MultiPoint::coordinates(env, jMultiPoint)));
}
return multiPoint;
}
-jni::Object<java::util::List> MultiPoint::coordinates(jni::JNIEnv &env, jni::Object<MultiPoint> jMultiPoint) {
- static auto javaClass = jni::Class<MultiPoint>::Singleton(env);
+jni::Local<jni::Object<java::util::List>> MultiPoint::coordinates(jni::JNIEnv& env, const jni::Object<MultiPoint>& jMultiPoint) {
+ static auto& javaClass = jni::Class<MultiPoint>::Singleton(env);
static auto method = javaClass.GetMethod<jni::Object<java::util::List> ()>(env, "coordinates");
return jMultiPoint.Call(env, method);
}
diff --git a/platform/android/src/geojson/multi_point.hpp b/platform/android/src/geojson/multi_point.hpp
index 0df16bfd6a..a3ca49b731 100644
--- a/platform/android/src/geojson/multi_point.hpp
+++ b/platform/android/src/geojson/multi_point.hpp
@@ -13,17 +13,17 @@ namespace mbgl {
namespace android {
namespace geojson {
-class MultiPoint : public Geometry {
+class MultiPoint {
public:
+ using SuperTag = Geometry;
static constexpr auto Name() { return "com/mapbox/geojson/MultiPoint"; };
-
static constexpr auto Type() { return "MultiPoint"; };
- static jni::Object<MultiPoint> New(jni::JNIEnv&, const mbgl::MultiPoint<double>&);
+ static jni::Local<jni::Object<MultiPoint>> New(jni::JNIEnv&, const mbgl::MultiPoint<double>&);
- static mapbox::geojson::multi_point convert(jni::JNIEnv&, jni::Object<MultiPoint>);
+ static mapbox::geojson::multi_point convert(jni::JNIEnv&, const jni::Object<MultiPoint>&);
- static jni::Object<java::util::List> coordinates(jni::JNIEnv&, jni::Object<MultiPoint>);
+ static jni::Local<jni::Object<java::util::List>> coordinates(jni::JNIEnv&, const jni::Object<MultiPoint>&);
static void registerNative(jni::JNIEnv&);
};
diff --git a/platform/android/src/geojson/multi_polygon.cpp b/platform/android/src/geojson/multi_polygon.cpp
index 109ac714c3..3c5c3ec338 100644
--- a/platform/android/src/geojson/multi_polygon.cpp
+++ b/platform/android/src/geojson/multi_polygon.cpp
@@ -7,41 +7,39 @@ namespace mbgl {
namespace android {
namespace geojson {
-jni::Object<MultiPolygon> MultiPolygon::New(JNIEnv& env, const mbgl::MultiPolygon<double>& multiPolygon) {
- static auto javaClass = jni::Class<MultiPolygon>::Singleton(env);
+jni::Local<jni::Object<MultiPolygon>> MultiPolygon::New(JNIEnv& env, const mbgl::MultiPolygon<double>& multiPolygon) {
+ static auto& javaClass = jni::Class<MultiPolygon>::Singleton(env);
static auto method = javaClass.GetStaticMethod<jni::Object<MultiPolygon> (jni::Object<java::util::List>)>(env, "fromLngLats");
- auto jarray = jni::SeizeLocal(env,
- jni::Array<jni::Object<java::util::List>>::New(env, multiPolygon.size()));
+ auto jarray = jni::Array<jni::Object<java::util::List>>::New(env, multiPolygon.size());
for (size_t i = 0; i < multiPolygon.size(); i++) {
- jarray->Set(env, i, *jni::SeizeLocal(env, asPointsListsList(env, multiPolygon.at(i))));
+ jarray.Set(env, i, asPointsListsList(env, multiPolygon.at(i)));
}
- return javaClass.Call(env, method,
- *jni::SeizeLocal(env, java::util::Arrays::asList(env, *jarray)));
+ return javaClass.Call(env, method, java::util::Arrays::asList(env, jarray));
}
-mapbox::geojson::multi_polygon MultiPolygon::convert(jni::JNIEnv &env, jni::Object<MultiPolygon> jMultiPolygon) {
+mapbox::geojson::multi_polygon MultiPolygon::convert(jni::JNIEnv& env, const jni::Object<MultiPolygon>& jMultiPolygon) {
mapbox::geojson::multi_polygon multiPolygon;
if (jMultiPolygon) {
- auto jPointListsListList = jni::SeizeLocal(env, MultiPolygon::coordinates(env, jMultiPolygon));
- auto jPointListsListArray = jni::SeizeLocal(env, java::util::List::toArray<java::util::List>(env, *jPointListsListList));
+ auto jPointListsListList = MultiPolygon::coordinates(env, jMultiPolygon);
+ auto jPointListsListArray = java::util::List::toArray<java::util::List>(env, jPointListsListList);
- auto size = jPointListsListArray->Length(env);
+ auto size = jPointListsListArray.Length(env);
multiPolygon.reserve(size);
for (size_t i = 0; i < size; i++) {
- multiPolygon.push_back(Polygon::convert(env, *jni::SeizeLocal(env, jPointListsListArray->Get(env, i))));
+ multiPolygon.push_back(Polygon::convert(env, jPointListsListArray.Get(env, i)));
}
}
return multiPolygon;
}
-jni::Object<java::util::List> MultiPolygon::coordinates(jni::JNIEnv &env, jni::Object<MultiPolygon> jPolygon) {
- static auto javaClass = jni::Class<MultiPolygon>::Singleton(env);
+jni::Local<jni::Object<java::util::List>> MultiPolygon::coordinates(jni::JNIEnv& env, const jni::Object<MultiPolygon>& jPolygon) {
+ static auto& javaClass = jni::Class<MultiPolygon>::Singleton(env);
static auto method = javaClass.GetMethod<jni::Object<java::util::List> ()>(env, "coordinates");
return jPolygon.Call(env, method);
}
diff --git a/platform/android/src/geojson/multi_polygon.hpp b/platform/android/src/geojson/multi_polygon.hpp
index 3477e989ea..fd7b08016d 100644
--- a/platform/android/src/geojson/multi_polygon.hpp
+++ b/platform/android/src/geojson/multi_polygon.hpp
@@ -12,17 +12,17 @@ namespace mbgl {
namespace android {
namespace geojson {
-class MultiPolygon : public Geometry {
+class MultiPolygon {
public:
+ using SuperTag = Geometry;
static constexpr auto Name() { return "com/mapbox/geojson/MultiPolygon"; };
-
static constexpr auto Type() { return "MultiPolygon"; };
- static jni::Object<MultiPolygon> New(jni::JNIEnv&, const mbgl::MultiPolygon<double>&);
+ static jni::Local<jni::Object<MultiPolygon>> New(jni::JNIEnv&, const mbgl::MultiPolygon<double>&);
- static mapbox::geojson::multi_polygon convert(jni::JNIEnv&, jni::Object<MultiPolygon>);
+ static mapbox::geojson::multi_polygon convert(jni::JNIEnv&, const jni::Object<MultiPolygon>&);
- static jni::Object<java::util::List> coordinates(jni::JNIEnv&, jni::Object<MultiPolygon>);
+ static jni::Local<jni::Object<java::util::List>> coordinates(jni::JNIEnv&, const jni::Object<MultiPolygon>&);
static void registerNative(jni::JNIEnv&);
};
diff --git a/platform/android/src/geojson/point.cpp b/platform/android/src/geojson/point.cpp
index 7fcc183dc1..2000447c0f 100644
--- a/platform/android/src/geojson/point.cpp
+++ b/platform/android/src/geojson/point.cpp
@@ -4,14 +4,14 @@ namespace mbgl {
namespace android {
namespace geojson {
-jni::Object<Point> Point::New(jni::JNIEnv& env, const mbgl::Point<double>& point) {
- static auto javaClass = jni::Class<Point>::Singleton(env);
+jni::Local<jni::Object<Point>> Point::New(jni::JNIEnv& env, const mbgl::Point<double>& point) {
+ static auto& javaClass = jni::Class<Point>::Singleton(env);
static auto method = javaClass.GetStaticMethod<jni::Object<Point> (jni::jdouble, jni::jdouble)>(env, "fromLngLat");
return javaClass.Call(env, method, point.x, point.y);
}
-mbgl::Point<double> Point::convert(jni::JNIEnv &env, jni::Object<Point> jPoint) {
- static auto javaClass = jni::Class<Point>::Singleton(env);
+mbgl::Point<double> Point::convert(jni::JNIEnv &env, const jni::Object<Point>& jPoint) {
+ static auto& javaClass = jni::Class<Point>::Singleton(env);
static auto longitude = javaClass.GetMethod<jni::jdouble ()>(env, "longitude");
static auto latitude = javaClass.GetMethod<jni::jdouble ()>(env, "latitude");
diff --git a/platform/android/src/geojson/point.hpp b/platform/android/src/geojson/point.hpp
index d5cc7780f3..b5d71ecae1 100644
--- a/platform/android/src/geojson/point.hpp
+++ b/platform/android/src/geojson/point.hpp
@@ -10,13 +10,14 @@ namespace mbgl {
namespace android {
namespace geojson {
-class Point : public Geometry {
+class Point {
public:
+ using SuperTag = Geometry;
static constexpr auto Name() { return "com/mapbox/geojson/Point"; };
static constexpr auto Type() { return "Point"; };
- static jni::Object<Point> New(jni::JNIEnv&, const mbgl::Point<double>&);
- static mbgl::Point<double> convert(jni::JNIEnv&, jni::Object<Point>);
+ static jni::Local<jni::Object<Point>> New(jni::JNIEnv&, const mbgl::Point<double>&);
+ static mbgl::Point<double> convert(jni::JNIEnv&, const jni::Object<Point>&);
static void registerNative(jni::JNIEnv&);
};
diff --git a/platform/android/src/geojson/polygon.cpp b/platform/android/src/geojson/polygon.cpp
index add843e294..4437d134a8 100644
--- a/platform/android/src/geojson/polygon.cpp
+++ b/platform/android/src/geojson/polygon.cpp
@@ -8,24 +8,24 @@ namespace mbgl {
namespace android {
namespace geojson {
-jni::Object<Polygon> Polygon::New(jni::JNIEnv& env, const mbgl::Polygon<double>& polygon) {
- static auto javaClass = jni::Class<Polygon>::Singleton(env);
+jni::Local<jni::Object<Polygon>> Polygon::New(jni::JNIEnv& env, const mbgl::Polygon<double>& polygon) {
+ static auto& javaClass = jni::Class<Polygon>::Singleton(env);
static auto method = javaClass.GetStaticMethod<jni::Object<Polygon> (jni::Object<java::util::List>)>(env, "fromLngLats");
- return javaClass.Call(env, method, *jni::SeizeLocal(env, asPointsListsList(env, polygon)));
+ return javaClass.Call(env, method, asPointsListsList(env, polygon));
}
-mapbox::geojson::polygon Polygon::convert(jni::JNIEnv &env, jni::Object<Polygon> jPolygon) {
+mapbox::geojson::polygon Polygon::convert(jni::JNIEnv &env, const jni::Object<Polygon>& jPolygon) {
mapbox::geojson::polygon polygon;
if (jPolygon) {
- polygon = Polygon::convert(env, *jni::SeizeLocal(env, Polygon::coordinates(env, jPolygon)));
+ polygon = Polygon::convert(env, Polygon::coordinates(env, jPolygon));
}
return polygon;
}
-mapbox::geojson::polygon Polygon::convert(jni::JNIEnv &env, jni::Object<java::util::List/*<java::util::List<Point>>*/> jPointListsList) {
+mapbox::geojson::polygon Polygon::convert(jni::JNIEnv &env, const jni::Object<java::util::List/*<java::util::List<Point>>*/>& jPointListsList) {
mapbox::geojson::polygon polygon;
if (jPointListsList) {
@@ -40,8 +40,8 @@ mapbox::geojson::polygon Polygon::convert(jni::JNIEnv &env, jni::Object<java::ut
}
-jni::Object<java::util::List> Polygon::coordinates(jni::JNIEnv &env, jni::Object<Polygon> jPolygon) {
- static auto javaClass = jni::Class<Polygon>::Singleton(env);
+jni::Local<jni::Object<java::util::List>> Polygon::coordinates(jni::JNIEnv &env, const jni::Object<Polygon>& jPolygon) {
+ static auto& javaClass = jni::Class<Polygon>::Singleton(env);
static auto method = javaClass.GetMethod<jni::Object<java::util::List> ()>(env, "coordinates");
return jPolygon.Call(env, method);
}
diff --git a/platform/android/src/geojson/polygon.hpp b/platform/android/src/geojson/polygon.hpp
index adfa60df4d..8e1761feda 100644
--- a/platform/android/src/geojson/polygon.hpp
+++ b/platform/android/src/geojson/polygon.hpp
@@ -13,19 +13,19 @@ namespace mbgl {
namespace android {
namespace geojson {
-class Polygon : public Geometry {
+class Polygon {
public:
+ using SuperTag = Geometry;
static constexpr auto Name() { return "com/mapbox/geojson/Polygon"; };
-
static constexpr auto Type() { return "Polygon"; };
- static jni::Object<Polygon> New(jni::JNIEnv&, const mbgl::Polygon<double>&);
+ static jni::Local<jni::Object<Polygon>> New(jni::JNIEnv&, const mbgl::Polygon<double>&);
- static mapbox::geojson::polygon convert(jni::JNIEnv &, jni::Object<Polygon>);
+ static mapbox::geojson::polygon convert(jni::JNIEnv &, const jni::Object<Polygon>&);
- static mapbox::geojson::polygon convert(jni::JNIEnv&, jni::Object<java::util::List/*<java::util::List<Point>>*/>);
+ static mapbox::geojson::polygon convert(jni::JNIEnv&, const jni::Object<java::util::List/*<java::util::List<Point>>*/>&);
- static jni::Object<java::util::List> coordinates(jni::JNIEnv&, jni::Object<Polygon>);
+ static jni::Local<jni::Object<java::util::List>> coordinates(jni::JNIEnv&, const jni::Object<Polygon>&);
static void registerNative(jni::JNIEnv &);
};
diff --git a/platform/android/src/geojson/util.hpp b/platform/android/src/geojson/util.hpp
index e889931c56..59154516fa 100644
--- a/platform/android/src/geojson/util.hpp
+++ b/platform/android/src/geojson/util.hpp
@@ -23,28 +23,28 @@ To convertExplicit(From&& src) {
* Geometry -> List<Point>
*/
template <class T>
-static jni::Object<java::util::List> asPointsList(jni::JNIEnv& env, const T& pointsList) {
- auto jarray = jni::SeizeLocal(env, jni::Array<jni::Object<Point>>::New(env, pointsList.size()));
+static jni::Local<jni::Object<java::util::List>> asPointsList(jni::JNIEnv& env, const T& pointsList) {
+ auto jarray = jni::Array<jni::Object<Point>>::New(env, pointsList.size());
for (jni::jsize i = 0; i < pointsList.size(); i++) {
- jarray->Set(env, i, *jni::SeizeLocal(env, Point::New(env, pointsList.at(i))));
+ jarray.Set(env, i, Point::New(env, pointsList.at(i)));
}
- return java::util::Arrays::asList(env, *jarray);
+ return java::util::Arrays::asList(env, jarray);
}
/**
* Geometry -> List<List<Point>>
*/
template <class SHAPE>
-static jni::Object<java::util::List> asPointsListsList(JNIEnv& env, SHAPE value) {
- auto jarray = jni::SeizeLocal(env, jni::Array<jni::Object<java::util::List>>::New(env, value.size()));
+static jni::Local<jni::Object<java::util::List>> asPointsListsList(JNIEnv& env, const SHAPE& value) {
+ auto jarray = jni::Array<jni::Object<java::util::List>>::New(env, value.size());
for (size_t i = 0; i < value.size(); i++) {
- jarray->Set(env, i, *jni::SeizeLocal(env, asPointsList(env, value[i])));
+ jarray.Set(env, i, asPointsList(env, value[i]));
}
- return java::util::Arrays::asList(env, *jarray);
+ return java::util::Arrays::asList(env, jarray);
}
} // namespace geojson
diff --git a/platform/android/src/geometry/lat_lng.cpp b/platform/android/src/geometry/lat_lng.cpp
index 135755d67e..5d8313cb2a 100644
--- a/platform/android/src/geometry/lat_lng.cpp
+++ b/platform/android/src/geometry/lat_lng.cpp
@@ -3,20 +3,20 @@
namespace mbgl {
namespace android {
-jni::Object<LatLng> LatLng::New(jni::JNIEnv& env, const mbgl::LatLng& latLng) {
- static auto javaClass = jni::Class<LatLng>::Singleton(env);
+jni::Local<jni::Object<LatLng>> LatLng::New(jni::JNIEnv& env, const mbgl::LatLng& latLng) {
+ static auto& javaClass = jni::Class<LatLng>::Singleton(env);
static auto constructor = javaClass.GetConstructor<double, double>(env);
return javaClass.New(env, constructor, latLng.latitude(), latLng.longitude());
}
-mbgl::Point<double> LatLng::getGeometry(jni::JNIEnv& env, jni::Object<LatLng> latLng) {
- static auto javaClass = jni::Class<LatLng>::Singleton(env);
+mbgl::Point<double> LatLng::getGeometry(jni::JNIEnv& env, const jni::Object<LatLng>& latLng) {
+ static auto& javaClass = jni::Class<LatLng>::Singleton(env);
static auto latitudeField = javaClass.GetField<jni::jdouble>(env, "latitude");
static auto longitudeField = javaClass.GetField<jni::jdouble>(env, "longitude");
return mbgl::Point<double>(latLng.Get(env, longitudeField), latLng.Get(env, latitudeField));
}
-mbgl::LatLng LatLng::getLatLng(jni::JNIEnv& env, jni::Object<LatLng> latLng) {
+mbgl::LatLng LatLng::getLatLng(jni::JNIEnv& env, const jni::Object<LatLng>& latLng) {
auto point = LatLng::getGeometry(env, latLng);
return mbgl::LatLng(point.y, point.x);
}
diff --git a/platform/android/src/geometry/lat_lng.hpp b/platform/android/src/geometry/lat_lng.hpp
index 4431f1c739..30b7db1ef3 100644
--- a/platform/android/src/geometry/lat_lng.hpp
+++ b/platform/android/src/geometry/lat_lng.hpp
@@ -14,11 +14,11 @@ public:
static constexpr auto Name() { return "com/mapbox/mapboxsdk/geometry/LatLng"; };
- static jni::Object<LatLng> New(jni::JNIEnv&, const mbgl::LatLng&);
+ static jni::Local<jni::Object<LatLng>> New(jni::JNIEnv&, const mbgl::LatLng&);
- static mbgl::Point<double> getGeometry(jni::JNIEnv&, jni::Object<LatLng>);
+ static mbgl::Point<double> getGeometry(jni::JNIEnv&, const jni::Object<LatLng>&);
- static mbgl::LatLng getLatLng(jni::JNIEnv&, jni::Object<LatLng>);
+ static mbgl::LatLng getLatLng(jni::JNIEnv&, const jni::Object<LatLng>&);
static void registerNative(jni::JNIEnv&);
diff --git a/platform/android/src/geometry/lat_lng_bounds.cpp b/platform/android/src/geometry/lat_lng_bounds.cpp
index 583120cb68..d76ff5b365 100644
--- a/platform/android/src/geometry/lat_lng_bounds.cpp
+++ b/platform/android/src/geometry/lat_lng_bounds.cpp
@@ -3,14 +3,14 @@
namespace mbgl {
namespace android {
-jni::Object<LatLngBounds> LatLngBounds::New(jni::JNIEnv& env, mbgl::LatLngBounds bounds) {
- static auto javaClass = jni::Class<LatLngBounds>::Singleton(env);
+jni::Local<jni::Object<LatLngBounds>> LatLngBounds::New(jni::JNIEnv& env, mbgl::LatLngBounds bounds) {
+ static auto& javaClass = jni::Class<LatLngBounds>::Singleton(env);
static auto constructor = javaClass.GetConstructor<double, double, double, double>(env);
return javaClass.New(env, constructor, bounds.north(), bounds.east(), bounds.south(), bounds.west());
}
-mbgl::LatLngBounds LatLngBounds::getLatLngBounds(jni::JNIEnv& env, jni::Object<LatLngBounds> bounds) {
- static auto javaClass = jni::Class<LatLngBounds>::Singleton(env);
+mbgl::LatLngBounds LatLngBounds::getLatLngBounds(jni::JNIEnv& env, const jni::Object<LatLngBounds>& bounds) {
+ static auto& javaClass = jni::Class<LatLngBounds>::Singleton(env);
static auto swLatField = javaClass.GetField<jni::jdouble>(env, "latitudeSouth");
static auto swLonField = javaClass.GetField<jni::jdouble>(env, "longitudeWest");
static auto neLatField = javaClass.GetField<jni::jdouble>(env, "latitudeNorth");
diff --git a/platform/android/src/geometry/lat_lng_bounds.hpp b/platform/android/src/geometry/lat_lng_bounds.hpp
index 751e0babda..d51026711d 100644
--- a/platform/android/src/geometry/lat_lng_bounds.hpp
+++ b/platform/android/src/geometry/lat_lng_bounds.hpp
@@ -14,9 +14,9 @@ public:
static constexpr auto Name() { return "com/mapbox/mapboxsdk/geometry/LatLngBounds"; };
- static jni::Object<LatLngBounds> New(jni::JNIEnv&, mbgl::LatLngBounds);
+ static jni::Local<jni::Object<LatLngBounds>> New(jni::JNIEnv&, mbgl::LatLngBounds);
- static mbgl::LatLngBounds getLatLngBounds(jni::JNIEnv&, jni::Object<LatLngBounds>);
+ static mbgl::LatLngBounds getLatLngBounds(jni::JNIEnv&, const jni::Object<LatLngBounds>&);
static void registerNative(jni::JNIEnv&);
};
diff --git a/platform/android/src/geometry/lat_lng_quad.cpp b/platform/android/src/geometry/lat_lng_quad.cpp
index 5530a22903..1a1e49048b 100644
--- a/platform/android/src/geometry/lat_lng_quad.cpp
+++ b/platform/android/src/geometry/lat_lng_quad.cpp
@@ -4,8 +4,8 @@
namespace mbgl {
namespace android {
-jni::Object<LatLngQuad> LatLngQuad::New(jni::JNIEnv& env, std::array<mbgl::LatLng, 4> coordinates) {
- static auto javaClass = jni::Class<LatLngQuad>::Singleton(env);
+jni::Local<jni::Object<LatLngQuad>> LatLngQuad::New(jni::JNIEnv& env, std::array<mbgl::LatLng, 4> coordinates) {
+ static auto& javaClass = jni::Class<LatLngQuad>::Singleton(env);
static auto quadConstructor = javaClass.GetConstructor<jni::Object<LatLng>, jni::Object<LatLng>, jni::Object<LatLng>, jni::Object<LatLng>>(env);
return javaClass.New(env, quadConstructor,
LatLng::New(env, coordinates[0]),
@@ -14,8 +14,8 @@ jni::Object<LatLngQuad> LatLngQuad::New(jni::JNIEnv& env, std::array<mbgl::LatLn
LatLng::New(env, coordinates[3]));
}
-std::array<mbgl::LatLng, 4> LatLngQuad::getLatLngArray(jni::JNIEnv& env, jni::Object<LatLngQuad> quad) {
- static auto javaClass = jni::Class<LatLngQuad>::Singleton(env);
+std::array<mbgl::LatLng, 4> LatLngQuad::getLatLngArray(jni::JNIEnv& env, const jni::Object<LatLngQuad>& quad) {
+ static auto& javaClass = jni::Class<LatLngQuad>::Singleton(env);
static auto topLeftField = javaClass.GetField <jni::Object<LatLng>>(env, "topLeft");
static auto topRightField = javaClass.GetField <jni::Object<LatLng>>(env, "topRight");
static auto bottomRightField = javaClass.GetField <jni::Object<LatLng>>(env, "bottomRight");
diff --git a/platform/android/src/geometry/lat_lng_quad.hpp b/platform/android/src/geometry/lat_lng_quad.hpp
index ca1430ffbc..f6560b57ba 100644
--- a/platform/android/src/geometry/lat_lng_quad.hpp
+++ b/platform/android/src/geometry/lat_lng_quad.hpp
@@ -15,9 +15,9 @@ public:
static constexpr auto Name() { return "com/mapbox/mapboxsdk/geometry/LatLngQuad"; };
- static jni::Object<LatLngQuad> New(jni::JNIEnv&, std::array<mbgl::LatLng, 4>);
+ static jni::Local<jni::Object<LatLngQuad>> New(jni::JNIEnv&, std::array<mbgl::LatLng, 4>);
- static std::array<mbgl::LatLng, 4> getLatLngArray(jni::JNIEnv&, jni::Object<LatLngQuad>);
+ static std::array<mbgl::LatLng, 4> getLatLngArray(jni::JNIEnv&, const jni::Object<LatLngQuad>&);
static void registerNative(jni::JNIEnv&);
};
diff --git a/platform/android/src/geometry/projected_meters.cpp b/platform/android/src/geometry/projected_meters.cpp
index 4dfd7b57b2..e079de0062 100644
--- a/platform/android/src/geometry/projected_meters.cpp
+++ b/platform/android/src/geometry/projected_meters.cpp
@@ -3,8 +3,8 @@
namespace mbgl {
namespace android {
-jni::Object<ProjectedMeters> ProjectedMeters::New(jni::JNIEnv& env, double northing, double easting) {
- static auto javaClass = jni::Class<ProjectedMeters>::Singleton(env);
+jni::Local<jni::Object<ProjectedMeters>> ProjectedMeters::New(jni::JNIEnv& env, double northing, double easting) {
+ static auto& javaClass = jni::Class<ProjectedMeters>::Singleton(env);
static auto constructor = javaClass.GetConstructor<double, double>(env);
return javaClass.New(env, constructor, northing, easting);
}
diff --git a/platform/android/src/geometry/projected_meters.hpp b/platform/android/src/geometry/projected_meters.hpp
index 5279e6bef2..baad1efc81 100644
--- a/platform/android/src/geometry/projected_meters.hpp
+++ b/platform/android/src/geometry/projected_meters.hpp
@@ -12,7 +12,7 @@ class ProjectedMeters : private mbgl::util::noncopyable {
public:
static constexpr auto Name() { return "com/mapbox/mapboxsdk/geometry/ProjectedMeters"; };
- static jni::Object<ProjectedMeters> New(jni::JNIEnv&, double, double);
+ static jni::Local<jni::Object<ProjectedMeters>> New(jni::JNIEnv&, double, double);
static void registerNative(jni::JNIEnv&);
};
diff --git a/platform/android/src/graphics/pointf.cpp b/platform/android/src/graphics/pointf.cpp
index eceb65b07a..2fc762d6e9 100644
--- a/platform/android/src/graphics/pointf.cpp
+++ b/platform/android/src/graphics/pointf.cpp
@@ -4,14 +4,14 @@
namespace mbgl {
namespace android {
-jni::Object<PointF> PointF::New(jni::JNIEnv& env, float x, float y) {
- static auto javaClass = jni::Class<PointF>::Singleton(env);
+jni::Local<jni::Object<PointF>> PointF::New(jni::JNIEnv& env, float x, float y) {
+ static auto& javaClass = jni::Class<PointF>::Singleton(env);
static auto constructor = javaClass.GetConstructor<float, float>(env);
return javaClass.New(env, constructor, x, y);
}
-mbgl::ScreenCoordinate PointF::getScreenCoordinate(jni::JNIEnv& env, jni::Object<PointF> point) {
- static auto javaClass = jni::Class<PointF>::Singleton(env);
+mbgl::ScreenCoordinate PointF::getScreenCoordinate(jni::JNIEnv& env, const jni::Object<PointF>& point) {
+ static auto& javaClass = jni::Class<PointF>::Singleton(env);
static auto xField = javaClass.GetField<jni::jfloat>(env, "x");
static auto yField = javaClass.GetField<jni::jfloat>(env, "y");
return mbgl::ScreenCoordinate{point.Get(env, xField), point.Get(env, yField)};
diff --git a/platform/android/src/graphics/pointf.hpp b/platform/android/src/graphics/pointf.hpp
index 27bd49138f..899468b8e3 100644
--- a/platform/android/src/graphics/pointf.hpp
+++ b/platform/android/src/graphics/pointf.hpp
@@ -12,9 +12,9 @@ public:
static constexpr auto Name() { return "android/graphics/PointF"; };
- static jni::Object<PointF> New(jni::JNIEnv&, float, float);
+ static jni::Local<jni::Object<PointF>> New(jni::JNIEnv&, float, float);
- static mbgl::ScreenCoordinate getScreenCoordinate(jni::JNIEnv&, jni::Object<PointF>);
+ static mbgl::ScreenCoordinate getScreenCoordinate(jni::JNIEnv&, const jni::Object<PointF>&);
static void registerNative(jni::JNIEnv&);
};
diff --git a/platform/android/src/graphics/rectf.cpp b/platform/android/src/graphics/rectf.cpp
index 9f05728b4c..8f418da037 100644
--- a/platform/android/src/graphics/rectf.cpp
+++ b/platform/android/src/graphics/rectf.cpp
@@ -3,26 +3,26 @@
namespace mbgl {
namespace android {
-float RectF::getLeft(jni::JNIEnv& env, jni::Object<RectF> rectf) {
- static auto javaClass = jni::Class<RectF>::Singleton(env);
+float RectF::getLeft(jni::JNIEnv& env, const jni::Object<RectF>& rectf) {
+ static auto& javaClass = jni::Class<RectF>::Singleton(env);
static auto field = javaClass.GetField<float>(env, "left");
return rectf.Get(env, field);
}
-float RectF::getTop(jni::JNIEnv& env, jni::Object<RectF> rectf) {
- static auto javaClass = jni::Class<RectF>::Singleton(env);
+float RectF::getTop(jni::JNIEnv& env, const jni::Object<RectF>& rectf) {
+ static auto& javaClass = jni::Class<RectF>::Singleton(env);
static auto field = javaClass.GetField<float>(env, "top");
return rectf.Get(env, field);
}
-float RectF::getRight(jni::JNIEnv& env, jni::Object<RectF> rectf) {
- static auto javaClass = jni::Class<RectF>::Singleton(env);
+float RectF::getRight(jni::JNIEnv& env, const jni::Object<RectF>& rectf) {
+ static auto& javaClass = jni::Class<RectF>::Singleton(env);
static auto field = javaClass.GetField<float>(env, "right");
return rectf.Get(env, field);
}
-float RectF::getBottom(jni::JNIEnv& env, jni::Object<RectF> rectf) {
- static auto javaClass = jni::Class<RectF>::Singleton(env);
+float RectF::getBottom(jni::JNIEnv& env, const jni::Object<RectF>& rectf) {
+ static auto& javaClass = jni::Class<RectF>::Singleton(env);
static auto field = javaClass.GetField<float>(env, "bottom");
return rectf.Get(env, field);
}
diff --git a/platform/android/src/graphics/rectf.hpp b/platform/android/src/graphics/rectf.hpp
index db836e78ba..ba611f2262 100644
--- a/platform/android/src/graphics/rectf.hpp
+++ b/platform/android/src/graphics/rectf.hpp
@@ -12,13 +12,13 @@ public:
static constexpr auto Name() { return "android/graphics/RectF"; };
- static float getLeft(jni::JNIEnv&, jni::Object<RectF>);
+ static float getLeft(jni::JNIEnv&, const jni::Object<RectF>&);
- static float getTop(jni::JNIEnv&, jni::Object<RectF>);
+ static float getTop(jni::JNIEnv&, const jni::Object<RectF>&);
- static float getRight(jni::JNIEnv&, jni::Object<RectF>);
+ static float getRight(jni::JNIEnv&, const jni::Object<RectF>&);
- static float getBottom(jni::JNIEnv&, jni::Object<RectF>);
+ static float getBottom(jni::JNIEnv&, const jni::Object<RectF>&);
static void registerNative(jni::JNIEnv&);
};
diff --git a/platform/android/src/gson/json_array.cpp b/platform/android/src/gson/json_array.cpp
index b5fb85e5d9..8ffa658b76 100644
--- a/platform/android/src/gson/json_array.cpp
+++ b/platform/android/src/gson/json_array.cpp
@@ -5,25 +5,25 @@ namespace mbgl {
namespace android {
namespace gson {
-jni::Object<JsonArray> JsonArray::New(jni::JNIEnv& env, const std::vector<mbgl::Value>& values){
- static auto javaClass = jni::Class<JsonArray>::Singleton(env);
+jni::Local<jni::Object<JsonArray>> JsonArray::New(jni::JNIEnv& env, const std::vector<mbgl::Value>& values){
+ static auto& javaClass = jni::Class<JsonArray>::Singleton(env);
static auto constructor = javaClass.GetConstructor(env);
static auto addMethod = javaClass.GetMethod<void (jni::Object<JsonElement>)>(env, "add");
auto jsonArray = javaClass.New(env, constructor);
for (const auto &v : values) {
- jsonArray.Call(env, addMethod, *jni::SeizeLocal(env, JsonElement::New(env, v)));
+ jsonArray.Call(env, addMethod, JsonElement::New(env, v));
}
return jsonArray;
}
-std::vector<mbgl::Value> JsonArray::convert(jni::JNIEnv& env, const jni::Object<JsonArray> jsonArray) {
+std::vector<mbgl::Value> JsonArray::convert(jni::JNIEnv& env, const jni::Object<JsonArray>& jsonArray) {
std::vector<mbgl::Value> values;
if (jsonArray) {
- static auto javaClass = jni::Class<JsonArray>::Singleton(env);
+ static auto& javaClass = jni::Class<JsonArray>::Singleton(env);
static auto getMethod = javaClass.GetMethod<jni::Object<JsonElement> (jni::jint)>(env, "get");
static auto sizeMethod = javaClass.GetMethod<jni::jint ()>(env, "size");
@@ -31,9 +31,9 @@ std::vector<mbgl::Value> JsonArray::convert(jni::JNIEnv& env, const jni::Object<
values.reserve(uint(size));
for (int i = 0; i < size; i++) {
- auto entry = jni::SeizeLocal(env, jsonArray.Call(env, getMethod, i));
- if (*entry) {
- values.push_back(JsonElement::convert(env, *entry));
+ auto entry = jsonArray.Call(env, getMethod, i);
+ if (entry) {
+ values.push_back(JsonElement::convert(env, entry));
}
}
}
diff --git a/platform/android/src/gson/json_array.hpp b/platform/android/src/gson/json_array.hpp
index b41596819f..24d5d3d291 100644
--- a/platform/android/src/gson/json_array.hpp
+++ b/platform/android/src/gson/json_array.hpp
@@ -8,12 +8,13 @@ namespace mbgl {
namespace android {
namespace gson {
-class JsonArray : public JsonElement {
+class JsonArray {
public:
+ using SuperTag = JsonElement;
static constexpr auto Name() { return "com/google/gson/JsonArray"; };
- static jni::Object<JsonArray> New(jni::JNIEnv&, const std::vector<mbgl::Value>&);
- static std::vector<mbgl::Value> convert(JNIEnv&, jni::Object<JsonArray>);
+ static jni::Local<jni::Object<JsonArray>> New(jni::JNIEnv&, const std::vector<mbgl::Value>&);
+ static std::vector<mbgl::Value> convert(JNIEnv&, const jni::Object<JsonArray>&);
static void registerNative(jni::JNIEnv&);
};
diff --git a/platform/android/src/gson/json_element.cpp b/platform/android/src/gson/json_element.cpp
index 28cb368386..7c9a34c03c 100644
--- a/platform/android/src/gson/json_element.cpp
+++ b/platform/android/src/gson/json_element.cpp
@@ -7,35 +7,30 @@ namespace mbgl {
namespace android {
namespace gson {
-jni::Object<JsonElement> JsonElement::New(jni::JNIEnv& env, const mbgl::Value& value) {
- static auto primitive = jni::Class<JsonPrimitive>::Singleton(env);
+jni::Local<jni::Object<JsonElement>> JsonElement::New(jni::JNIEnv& env, const mbgl::Value& value) {
+ static auto& primitive = jni::Class<JsonPrimitive>::Singleton(env);
static auto stringConstructor = primitive.GetConstructor<jni::String>(env);
static auto numberConstructor = primitive.GetConstructor<jni::Number>(env);
static auto booleanConstructor = primitive.GetConstructor<jni::Boolean>(env);
return value.match(
[&] (const mbgl::NullValue&) {
- return jni::Object<JsonElement>();
+ return jni::Local<jni::Object<JsonElement>>();
},
[&] (const std::string& value) {
- return primitive.New(env, stringConstructor,
- *jni::SeizeLocal(env, jni::Make<jni::String>(env, value)));
+ return primitive.New(env, stringConstructor, jni::Make<jni::String>(env, value));
},
[&] (const double value) {
- return primitive.New(env, numberConstructor,
- *jni::SeizeLocal(env, jni::Number(jni::Box(env, value))));
+ return primitive.New(env, numberConstructor, jni::Box(env, value));
},
[&] (const int64_t value) {
- return primitive.New(env, numberConstructor,
- *jni::SeizeLocal(env, jni::Number(jni::Box(env, value))));
+ return primitive.New(env, numberConstructor, jni::Box(env, value));
},
[&] (const uint64_t value) {
- return primitive.New(env, numberConstructor,
- *jni::SeizeLocal(env, jni::Number(jni::Box(env, int64_t(value))))); // TODO: should use BigInteger
+ return primitive.New(env, numberConstructor, jni::Box(env, int64_t(value))); // TODO: should use BigInteger
},
[&] (const bool value) {
- return primitive.New(env, booleanConstructor,
- *jni::SeizeLocal(env, jni::Box(env, value ? jni::jni_true : jni::jni_false)));
+ return primitive.New(env, booleanConstructor, jni::Box(env, value ? jni::jni_true : jni::jni_false));
},
[&] (const std::vector<mbgl::Value>& values) {
return JsonArray::New(env, values);
@@ -46,17 +41,17 @@ jni::Object<JsonElement> JsonElement::New(jni::JNIEnv& env, const mbgl::Value& v
);
}
-mbgl::Value JsonElement::convert(jni::JNIEnv &env, jni::Object<JsonElement> jsonElement) {
+mbgl::Value JsonElement::convert(jni::JNIEnv &env, const jni::Object<JsonElement>& jsonElement) {
if (!jsonElement) {
return mbgl::NullValue();
}
- static auto elementClass = jni::Class<JsonElement>::Singleton(env);
+ static auto& elementClass = jni::Class<JsonElement>::Singleton(env);
static auto isJsonObject = elementClass.GetMethod<jni::jboolean ()>(env, "isJsonObject");
static auto isJsonArray = elementClass.GetMethod<jni::jboolean ()>(env, "isJsonArray");
static auto isJsonPrimitive = elementClass.GetMethod<jni::jboolean ()>(env, "isJsonPrimitive");
- static auto primitiveClass = jni::Class<JsonPrimitive>::Singleton(env);
+ static auto& primitiveClass = jni::Class<JsonPrimitive>::Singleton(env);
static auto isBoolean = primitiveClass.GetMethod<jni::jboolean ()>(env, "isBoolean");
static auto isString = primitiveClass.GetMethod<jni::jboolean ()>(env, "isString");
static auto isNumber = primitiveClass.GetMethod<jni::jboolean ()>(env, "isNumber");
@@ -71,7 +66,7 @@ mbgl::Value JsonElement::convert(jni::JNIEnv &env, jni::Object<JsonElement> json
} else if (primitive.Call(env, isNumber)) {
return primitive.Call(env, getAsDouble); // TODO: how to differentiate types here?
} else if (primitive.Call(env, isString)) {
- return jni::Make<std::string>(env, *jni::SeizeLocal(env, primitive.Call(env, getAsString)));
+ return jni::Make<std::string>(env, primitive.Call(env, getAsString));
} else {
return mbgl::NullValue();
}
diff --git a/platform/android/src/gson/json_element.hpp b/platform/android/src/gson/json_element.hpp
index 384459dc41..e3b8a0268d 100644
--- a/platform/android/src/gson/json_element.hpp
+++ b/platform/android/src/gson/json_element.hpp
@@ -8,12 +8,13 @@ namespace mbgl {
namespace android {
namespace gson {
-class JsonElement : public jni::ObjectTag {
+class JsonElement {
public:
+ using SuperTag = jni::ObjectTag;
static constexpr auto Name() { return "com/google/gson/JsonElement"; };
- static jni::Object<JsonElement> New(jni::JNIEnv&, const mbgl::Value&);
- static mbgl::Value convert(JNIEnv&, jni::Object<JsonElement>);
+ static jni::Local<jni::Object<JsonElement>> New(jni::JNIEnv&, const mbgl::Value&);
+ static mbgl::Value convert(JNIEnv&, const jni::Object<JsonElement>&);
static void registerNative(jni::JNIEnv&);
};
diff --git a/platform/android/src/gson/json_object.cpp b/platform/android/src/gson/json_object.cpp
index 5dcb07642f..10d244ee48 100644
--- a/platform/android/src/gson/json_object.cpp
+++ b/platform/android/src/gson/json_object.cpp
@@ -9,48 +9,46 @@ namespace android {
namespace gson {
-jni::Object<JsonObject> JsonObject::New(jni::JNIEnv& env, const mbgl::PropertyMap& values) {
- static auto javaClass = jni::Class<JsonObject>::Singleton(env);
+jni::Local<jni::Object<JsonObject>> JsonObject::New(jni::JNIEnv& env, const mbgl::PropertyMap& values) {
+ static auto& javaClass = jni::Class<JsonObject>::Singleton(env);
static auto constructor = javaClass.GetConstructor(env);
static auto addMethod = javaClass.GetMethod<void (jni::String, jni::Object<JsonElement>)>(env, "add");
- jni::Object<JsonObject> jsonObject = javaClass.New(env, constructor);
+ auto jsonObject = javaClass.New(env, constructor);
for (auto &item : values) {
jsonObject.Call(env, addMethod,
- *jni::SeizeLocal(env, jni::Make<jni::String>(env, item.first)),
- *jni::SeizeLocal(env, JsonElement::New(env, item.second)));
+ jni::Make<jni::String>(env, item.first),
+ JsonElement::New(env, item.second));
}
return jsonObject;
}
template <typename F> // void (jni::String, jni::Object<gson::JsonElement>)
-static void iterateEntrySet(jni::JNIEnv& env, jni::Object<JsonObject> jsonObject, F callback) {
+static void iterateEntrySet(jni::JNIEnv& env, const jni::Object<JsonObject>& jsonObject, F callback) {
// Get Set<Map.Entry<String, JsonElement>>
- static auto javaClass = jni::Class<JsonObject>::Singleton(env);
+ static auto& javaClass = jni::Class<JsonObject>::Singleton(env);
static auto method = javaClass.GetMethod<jni::Object<java::util::Set> ()>(env, "entrySet");
- auto entryArray =
- jni::SeizeLocal(env, java::util::Set::toArray<java::util::Map::Entry>(env,
- *jni::SeizeLocal(env, jsonObject.Call(env, method))));
+ auto entryArray = java::util::Set::toArray<java::util::Map::Entry>(env, jsonObject.Call(env, method));
- size_t size = entryArray->Length(env);
+ size_t size = entryArray.Length(env);
for (size_t i = 0; i < size; i++) {
- auto entry = jni::SeizeLocal(env, entryArray->Get(env, i));
+ auto entry = entryArray.Get(env, i);
if (entry) {
callback(
- *jni::SeizeLocal(env, java::util::Map::Entry::getKey<jni::StringTag>(env, *entry)),
- *jni::SeizeLocal(env, java::util::Map::Entry::getValue<gson::JsonElement>(env, *entry)));
+ java::util::Map::Entry::getKey<jni::StringTag>(env, entry),
+ java::util::Map::Entry::getValue<gson::JsonElement>(env, entry));
}
}
}
-mbgl::PropertyMap JsonObject::convert(jni::JNIEnv &env, jni::Object<JsonObject> jsonObject) {
+mbgl::PropertyMap JsonObject::convert(jni::JNIEnv& env, const jni::Object<JsonObject>& jsonObject) {
mbgl::PropertyMap map;
if (jsonObject) {
- iterateEntrySet(env, jsonObject, [&map, &env](jni::String jId, jni::Object<gson::JsonElement> jsonElement) {
+ iterateEntrySet(env, jsonObject, [&map, &env](const jni::String& jId, const jni::Object<gson::JsonElement>& jsonElement) {
map[jni::Make<std::string>(env, jId)] = JsonElement::convert(env, jsonElement);
});
}
diff --git a/platform/android/src/gson/json_object.hpp b/platform/android/src/gson/json_object.hpp
index 256161f0d9..b8916f8ae1 100644
--- a/platform/android/src/gson/json_object.hpp
+++ b/platform/android/src/gson/json_object.hpp
@@ -8,12 +8,13 @@ namespace mbgl {
namespace android {
namespace gson {
-class JsonObject : public JsonElement {
+class JsonObject {
public:
+ using SuperTag = JsonElement;
static constexpr auto Name() { return "com/google/gson/JsonObject"; };
- static jni::Object<JsonObject> New(jni::JNIEnv&, const mbgl::PropertyMap&);
- static mbgl::PropertyMap convert(JNIEnv&, jni::Object<JsonObject>);
+ static jni::Local<jni::Object<JsonObject>> New(jni::JNIEnv&, const mbgl::PropertyMap&);
+ static mbgl::PropertyMap convert(JNIEnv&, const jni::Object<JsonObject>&);
static void registerNative(jni::JNIEnv&);
};
diff --git a/platform/android/src/gson/json_primitive.hpp b/platform/android/src/gson/json_primitive.hpp
index fb3eefc855..36f138d902 100644
--- a/platform/android/src/gson/json_primitive.hpp
+++ b/platform/android/src/gson/json_primitive.hpp
@@ -8,8 +8,9 @@ namespace mbgl {
namespace android {
namespace gson {
-class JsonPrimitive : public JsonElement {
+class JsonPrimitive {
public:
+ using SuperTag = JsonElement;
static constexpr auto Name() { return "com/google/gson/JsonPrimitive"; };
static void registerNative(jni::JNIEnv&);
diff --git a/platform/android/src/http_file_source.cpp b/platform/android/src/http_file_source.cpp
index 6b359aab8c..e1b3493f0f 100644
--- a/platform/android/src/http_file_source.cpp
+++ b/platform/android/src/http_file_source.cpp
@@ -25,12 +25,12 @@ public:
HTTPRequest(jni::JNIEnv&, const Resource&, FileSource::Callback);
~HTTPRequest();
- void onFailure(jni::JNIEnv&, int type, jni::String message);
+ void onFailure(jni::JNIEnv&, int type, const jni::String& message);
void onResponse(jni::JNIEnv&, int code,
- jni::String etag, jni::String modified,
- jni::String cacheControl, jni::String expires,
- jni::String retryAfter, jni::String xRateLimitReset,
- jni::Array<jni::jbyte> body);
+ const jni::String& etag, const jni::String& modified,
+ const jni::String& cacheControl, const jni::String& expires,
+ const jni::String& retryAfter, const jni::String& xRateLimitReset,
+ const jni::Array<jni::jbyte>& body);
jni::Global<jni::Object<HTTPRequest>> javaRequest;
@@ -54,7 +54,7 @@ private:
namespace android {
void RegisterNativeHTTPRequest(jni::JNIEnv& env) {
- static auto javaClass = jni::Class<HTTPRequest>::Singleton(env);
+ static auto& javaClass = jni::Class<HTTPRequest>::Singleton(env);
#define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
@@ -79,31 +79,32 @@ HTTPRequest::HTTPRequest(jni::JNIEnv& env, const Resource& resource_, FileSource
jni::UniqueLocalFrame frame = jni::PushLocalFrame(env, 10);
- static auto javaClass = jni::Class<HTTPRequest>::Singleton(env);
+ static auto& javaClass = jni::Class<HTTPRequest>::Singleton(env);
static auto constructor =
javaClass.GetConstructor<jni::jlong, jni::String, jni::String, jni::String>(env);
- javaRequest = javaClass.New(env, constructor,
- reinterpret_cast<jlong>(this),
- jni::Make<jni::String>(env, resource.url),
- jni::Make<jni::String>(env, etagStr),
- jni::Make<jni::String>(env, modifiedStr)).NewGlobalRef(env);
+ javaRequest = jni::NewGlobal(env,
+ javaClass.New(env, constructor,
+ reinterpret_cast<jlong>(this),
+ jni::Make<jni::String>(env, resource.url),
+ jni::Make<jni::String>(env, etagStr),
+ jni::Make<jni::String>(env, modifiedStr)));
}
HTTPRequest::~HTTPRequest() {
android::UniqueEnv env = android::AttachEnv();
- static auto javaClass = jni::Class<HTTPRequest>::Singleton(*env);
+ static auto& javaClass = jni::Class<HTTPRequest>::Singleton(*env);
static auto cancel = javaClass.GetMethod<void ()>(*env, "cancel");
- javaRequest->Call(*env, cancel);
+ javaRequest.Call(*env, cancel);
}
void HTTPRequest::onResponse(jni::JNIEnv& env, int code,
- jni::String etag, jni::String modified,
- jni::String cacheControl, jni::String expires,
- jni::String jRetryAfter, jni::String jXRateLimitReset,
- jni::Array<jni::jbyte> body) {
+ const jni::String& etag, const jni::String& modified,
+ const jni::String& cacheControl, const jni::String& expires,
+ const jni::String& jRetryAfter, const jni::String& jXRateLimitReset,
+ const jni::Array<jni::jbyte>& body) {
using Error = Response::Error;
@@ -158,7 +159,7 @@ void HTTPRequest::onResponse(jni::JNIEnv& env, int code,
async.send();
}
-void HTTPRequest::onFailure(jni::JNIEnv& env, int type, jni::String message) {
+void HTTPRequest::onFailure(jni::JNIEnv& env, int type, const jni::String& message) {
std::string messageStr = jni::Make<std::string>(env, message);
using Error = Response::Error;
diff --git a/platform/android/src/image.cpp b/platform/android/src/image.cpp
index a85e9aeaa2..31515ff16f 100644
--- a/platform/android/src/image.cpp
+++ b/platform/android/src/image.cpp
@@ -11,12 +11,11 @@ namespace mbgl {
PremultipliedImage decodeImage(const std::string& string) {
auto env{ android::AttachEnv() };
- auto array = jni::SeizeLocal(*env, jni::Array<jni::jbyte>::New(*env, string.size()));
- jni::SetArrayRegion(*env, **array, 0, string.size(),
+ auto array = jni::Array<jni::jbyte>::New(*env, string.size());
+ jni::SetArrayRegion(*env, *array, 0, string.size(),
reinterpret_cast<const signed char*>(string.data()));
- return android::Bitmap::GetImage(*env,
- *jni::SeizeLocal(*env, android::BitmapFactory::DecodeByteArray(*env, *array, 0, string.size())));
+ return android::Bitmap::GetImage(*env, android::BitmapFactory::DecodeByteArray(*env, array, 0, string.size()));
}
} // namespace mbgl
diff --git a/platform/android/src/java/util.hpp b/platform/android/src/java/util.hpp
index 808f14be15..9b0c01459e 100644
--- a/platform/android/src/java/util.hpp
+++ b/platform/android/src/java/util.hpp
@@ -14,10 +14,11 @@ public:
static constexpr auto Name() { return "java/util/List"; };
template<class T>
- static jni::Array<jni::Object<T>> toArray(jni::JNIEnv& env, jni::Object<List> list) {
- static auto javaClass = jni::Class<List>::Singleton(env);
+ static jni::Local<jni::Array<jni::Object<T>>> toArray(jni::JNIEnv& env, const jni::Object<List>& list) {
+ static auto& javaClass = jni::Class<List>::Singleton(env);
static auto toArray = javaClass.GetMethod<jni::Array<jni::Object<>> ()>(env, "toArray");
- return (jni::Array<jni::Object<T>>) list.Call(env, toArray);
+
+ return jni::Local<jni::Array<jni::Object<T>>>(env, list.Call(env, toArray).release());
};
};
@@ -26,10 +27,12 @@ public:
static constexpr auto Name() { return "java/util/Arrays"; };
template <class T>
- static jni::Object<List> asList(jni::JNIEnv& env, jni::Array<jni::Object<T>> array) {
- static auto javaClass = jni::Class<Arrays>::Singleton(env);
+ static jni::Local<jni::Object<List>> asList(jni::JNIEnv& env, const jni::Array<jni::Object<T>>& array) {
+ static auto& javaClass = jni::Class<Arrays>::Singleton(env);
static auto asList = javaClass.GetStaticMethod<jni::Object<List>(jni::Array<jni::Object<>>)>(env, "asList");
- return javaClass.Call(env, asList, (jni::Array<jni::Object<>>) array);
+
+ auto typeErasedArray = jni::Local<jni::Array<jni::Object<>>>(env, jni::NewLocal(env, array).release());
+ return javaClass.Call(env, asList, typeErasedArray);
}
};
@@ -38,10 +41,11 @@ public:
static constexpr auto Name() { return "java/util/Set"; };
template<class T>
- static jni::Array<jni::Object<T>> toArray(jni::JNIEnv& env, jni::Object<Set> list) {
- static auto javaClass = jni::Class<Set>::Singleton(env);
+ static jni::Local<jni::Array<jni::Object<T>>> toArray(jni::JNIEnv& env, const jni::Object<Set>& list) {
+ static auto& javaClass = jni::Class<Set>::Singleton(env);
static auto toArray = javaClass.GetMethod<jni::Array<jni::Object<>> ()>(env, "toArray");
- return (jni::Array<jni::Object<T>>) list.Call(env, toArray);
+
+ return jni::Local<jni::Array<jni::Object<T>>>(env, list.Call(env, toArray).release());
};
};
@@ -54,15 +58,15 @@ public:
static constexpr auto Name() { return "java/util/Map$Entry"; };
template <class T>
- static jni::Object<T> getKey(jni::JNIEnv& env, jni::Object<Entry> entry) {
- static auto javaClass = jni::Class<Map::Entry>::Singleton(env);
+ static jni::Local<jni::Object<T>> getKey(jni::JNIEnv& env, const jni::Object<Entry>& entry) {
+ static auto& javaClass = jni::Class<Map::Entry>::Singleton(env);
static auto method = javaClass.GetMethod<jni::Object<> ()>(env, "getKey");
return jni::Cast(env, jni::Class<T>::Singleton(env), entry.Call(env, method));
}
template <class T>
- static jni::Object<T> getValue(jni::JNIEnv& env, jni::Object<Entry> entry) {
- static auto javaClass = jni::Class<Map::Entry>::Singleton(env);
+ static jni::Local<jni::Object<T>> getValue(jni::JNIEnv& env, const jni::Object<Entry>& entry) {
+ static auto& javaClass = jni::Class<Map::Entry>::Singleton(env);
static auto method = javaClass.GetMethod<jni::Object<> ()>(env, "getValue");
return jni::Cast(env, jni::Class<T>::Singleton(env), entry.Call(env, method));
}
diff --git a/platform/android/src/jni/generic_global_ref_deleter.hpp b/platform/android/src/jni/generic_global_ref_deleter.hpp
deleted file mode 100644
index b865ee9f8b..0000000000
--- a/platform/android/src/jni/generic_global_ref_deleter.hpp
+++ /dev/null
@@ -1,45 +0,0 @@
-#pragma once
-
-#include <jni/jni.hpp>
-
-#include "../attach_env.hpp"
-
-namespace mbgl {
-namespace android {
-
-// A deleter that doesn't retain an JNIEnv handle but instead tries to attach the JVM. This means
-// it can be used on any thread to delete a global ref.
-struct GenericGlobalRefDeleter {
- void operator()(jni::jobject* p) const {
- if (p) {
- AttachEnv()->DeleteGlobalRef(jni::Unwrap(p));
- }
- }
-};
-
-struct GenericWeakGlobalRefDeleter {
- void operator()(jni::jobject* p) const {
- if (p) {
- AttachEnv()->DeleteWeakGlobalRef(jni::Unwrap(p));
- }
- }
-};
-
-template < class T >
-using GenericGlobal = jni::UniquePointerlike< T, GenericGlobalRefDeleter >;
-
-template < class T >
-using GenericWeak = jni::UniquePointerlike< T, GenericWeakGlobalRefDeleter >;
-
-template < class T >
-GenericGlobal<T> SeizeGenericGlobal(T&& t) {
- return GenericGlobal<T>(std::move(t), GenericGlobalRefDeleter());
-};
-
-template < class T >
-GenericWeak<T> SeizeGenericWeak(T&& t) {
- return GenericWeak<T>(std::move(t), GenericWeakGlobalRefDeleter());
-};
-
-} // namespace android
-} // namespace mbgl
diff --git a/platform/android/src/logger.cpp b/platform/android/src/logger.cpp
index ddc4d84525..f5d78cc83c 100644
--- a/platform/android/src/logger.cpp
+++ b/platform/android/src/logger.cpp
@@ -9,24 +9,24 @@ void Logger::registerNative(jni::JNIEnv& env) {
}
void Logger::log(jni::JNIEnv& env, EventSeverity severity, const std::string &msg) {
- static auto _class = jni::Class<Logger>::Singleton(env);
+ static auto& _class = jni::Class<Logger>::Singleton(env);
- auto tag = jni::SeizeLocal(env, jni::Make<jni::String>(env, "Mbgl"));
- auto message = jni::SeizeLocal(env, jni::Make<jni::String>(env, msg));
+ auto tag = jni::Make<jni::String>(env, "Mbgl");
+ auto message = jni::Make<jni::String>(env, msg);
using Signature = void(jni::String, jni::String);
if (severity == EventSeverity::Debug) {
auto static debug = _class.GetStaticMethod<Signature>(env, "d");
- _class.Call(env, debug, *tag, *message);
+ _class.Call(env, debug, tag, message);
} else if (severity == EventSeverity::Info) {
auto static info = _class.GetStaticMethod<Signature>(env, "i");
- _class.Call(env, info, *tag, *message);
+ _class.Call(env, info, tag, message);
} else if(severity == EventSeverity::Warning) {
auto static warning = _class.GetStaticMethod<Signature>(env, "w");
- _class.Call(env, warning, *tag, *message);
+ _class.Call(env, warning, tag, message);
} else {
auto static error = _class.GetStaticMethod<Signature>(env, "e");
- _class.Call(env, error, *tag, *message);
+ _class.Call(env, error, tag, message);
}
}
diff --git a/platform/android/src/map/camera_position.cpp b/platform/android/src/map/camera_position.cpp
index 5700341d65..3caf4ea2f3 100644
--- a/platform/android/src/map/camera_position.cpp
+++ b/platform/android/src/map/camera_position.cpp
@@ -4,8 +4,8 @@
namespace mbgl {
namespace android {
-jni::Object<CameraPosition> CameraPosition::New(jni::JNIEnv &env, mbgl::CameraOptions options) {
- static auto javaClass = jni::Class<CameraPosition>::Singleton(env);
+jni::Local<jni::Object<CameraPosition>> CameraPosition::New(jni::JNIEnv &env, mbgl::CameraOptions options) {
+ static auto& javaClass = jni::Class<CameraPosition>::Singleton(env);
static auto constructor = javaClass.GetConstructor<jni::Object<LatLng>, double, double, double>(env);
// wrap LatLng values coming from core
@@ -28,14 +28,14 @@ jni::Object<CameraPosition> CameraPosition::New(jni::JNIEnv &env, mbgl::CameraOp
return javaClass.New(env, constructor, LatLng::New(env, center), options.zoom.value_or(0), tilt_degrees, bearing_degrees);
}
-mbgl::CameraOptions CameraPosition::getCameraOptions(jni::JNIEnv& env, jni::Object<CameraPosition> position) {
- static auto javaClass = jni::Class<CameraPosition>::Singleton(env);
+mbgl::CameraOptions CameraPosition::getCameraOptions(jni::JNIEnv& env, const jni::Object<CameraPosition>& position) {
+ static auto& javaClass = jni::Class<CameraPosition>::Singleton(env);
static auto bearing = javaClass.GetField<jni::jdouble>(env, "bearing");
static auto target = javaClass.GetField<jni::Object<LatLng>>(env, "target");
static auto tilt = javaClass.GetField<jni::jdouble>(env, "tilt");
static auto zoom = javaClass.GetField<jni::jdouble>(env, "zoom");
- auto center = LatLng::getLatLng(env, *jni::SeizeLocal(env, position.Get(env, target)));
+ auto center = LatLng::getLatLng(env, position.Get(env, target));
return mbgl::CameraOptions {
center,
diff --git a/platform/android/src/map/camera_position.hpp b/platform/android/src/map/camera_position.hpp
index d577811915..7579f9fed1 100644
--- a/platform/android/src/map/camera_position.hpp
+++ b/platform/android/src/map/camera_position.hpp
@@ -12,9 +12,9 @@ class CameraPosition : private mbgl::util::noncopyable {
public:
static constexpr auto Name() { return "com/mapbox/mapboxsdk/camera/CameraPosition"; };
- static jni::Object<CameraPosition> New(jni::JNIEnv&, mbgl::CameraOptions);
+ static jni::Local<jni::Object<CameraPosition>> New(jni::JNIEnv&, mbgl::CameraOptions);
- static mbgl::CameraOptions getCameraOptions(jni::JNIEnv&, jni::Object<CameraPosition>);
+ static mbgl::CameraOptions getCameraOptions(jni::JNIEnv&, const jni::Object<CameraPosition>&);
static void registerNative(jni::JNIEnv&);
};
diff --git a/platform/android/src/map/image.cpp b/platform/android/src/map/image.cpp
index ee3c7012a7..a91cc938ed 100644
--- a/platform/android/src/map/image.cpp
+++ b/platform/android/src/map/image.cpp
@@ -5,8 +5,8 @@
namespace mbgl {
namespace android {
-mbgl::style::Image Image::getImage(jni::JNIEnv& env, jni::Object<Image> image) {
- static auto javaClass = jni::Class<Image>::Singleton(env);
+mbgl::style::Image Image::getImage(jni::JNIEnv& env, const jni::Object<Image>& image) {
+ static auto& javaClass = jni::Class<Image>::Singleton(env);
static auto widthField = javaClass.GetField<jni::jint>(env, "width");
static auto heightField = javaClass.GetField<jni::jint>(env, "height");
static auto pixelRatioField = javaClass.GetField<jni::jfloat>(env, "pixelRatio");
@@ -17,19 +17,19 @@ mbgl::style::Image Image::getImage(jni::JNIEnv& env, jni::Object<Image> image) {
auto height = image.Get(env, heightField);
auto width = image.Get(env, widthField);
auto pixelRatio = image.Get(env, pixelRatioField);
- auto pixels = jni::SeizeLocal(env, image.Get(env, bufferField));
- auto name = jni::Make<std::string>(env, *jni::SeizeLocal(env, image.Get(env, nameField)));
+ auto pixels = image.Get(env, bufferField);
+ auto name = jni::Make<std::string>(env, image.Get(env, nameField));
auto sdf = (bool) image.Get(env, sdfField);
- jni::NullCheck(env, pixels->Get());
- std::size_t size = pixels->Length(env);
+ jni::NullCheck(env, pixels.get());
+ std::size_t size = pixels.Length(env);
mbgl::PremultipliedImage premultipliedImage({ static_cast<uint32_t>(width), static_cast<uint32_t>(height) });
if (premultipliedImage.bytes() != uint32_t(size)) {
throw mbgl::util::SpriteImageException("Sprite image pixel count mismatch");
}
- jni::GetArrayRegion(env, **pixels, 0, size, reinterpret_cast<jbyte*>(premultipliedImage.data.get()));
+ jni::GetArrayRegion(env, *pixels, 0, size, reinterpret_cast<jbyte*>(premultipliedImage.data.get()));
return mbgl::style::Image {name, std::move(premultipliedImage), pixelRatio, sdf};
}
diff --git a/platform/android/src/map/image.hpp b/platform/android/src/map/image.hpp
index 17ed4cbef8..7549bc646a 100644
--- a/platform/android/src/map/image.hpp
+++ b/platform/android/src/map/image.hpp
@@ -12,7 +12,7 @@ class Image : private mbgl::util::noncopyable {
public:
static constexpr auto Name() { return "com/mapbox/mapboxsdk/maps/Image"; };
- static mbgl::style::Image getImage(jni::JNIEnv&, jni::Object<Image>);
+ static mbgl::style::Image getImage(jni::JNIEnv&, const jni::Object<Image>&);
static void registerNative(jni::JNIEnv&);
};
diff --git a/platform/android/src/map_renderer.cpp b/platform/android/src/map_renderer.cpp
index 1f8c82ac05..13790c4544 100644
--- a/platform/android/src/map_renderer.cpp
+++ b/platform/android/src/map_renderer.cpp
@@ -14,15 +14,17 @@
namespace mbgl {
namespace android {
-MapRenderer::MapRenderer(jni::JNIEnv& _env, jni::Object<MapRenderer> obj,
- jni::Object<FileSource> _fileSource, jni::jfloat pixelRatio_,
- jni::String programCacheDir_,
- jni::String localIdeographFontFamily_)
- : javaPeer(SeizeGenericWeak(obj.NewWeakGlobalRef(_env).release()))
+MapRenderer::MapRenderer(jni::JNIEnv& _env,
+ const jni::Object<MapRenderer>& obj,
+ const jni::Object<FileSource>& _fileSource,
+ jni::jfloat pixelRatio_,
+ const jni::String& programCacheDir_,
+ const jni::String& localIdeographFontFamily_)
+ : javaPeer(_env, obj)
, pixelRatio(pixelRatio_)
, fileSource(FileSource::getDefaultFileSource(_env, _fileSource))
, programCacheDir(jni::Make<std::string>(_env, programCacheDir_))
- , localIdeographFontFamily(localIdeographFontFamily_ == nullptr ? optional<std::string>{} : jni::Make<std::string>(_env, localIdeographFontFamily_ ))
+ , localIdeographFontFamily(localIdeographFontFamily_ ? jni::Make<std::string>(_env, localIdeographFontFamily_) : optional<std::string>{})
, threadPool(sharedThreadPool())
, mailbox(std::make_shared<Mailbox>(*this)) {
}
@@ -53,10 +55,10 @@ void MapRenderer::schedule(std::weak_ptr<Mailbox> scheduled) {
auto peer = runnable->peer();
// Queue the event on the Java Peer
- static auto javaClass = jni::Class<MapRenderer>::Singleton(*_env);
+ static auto& javaClass = jni::Class<MapRenderer>::Singleton(*_env);
static auto queueEvent = javaClass.GetMethod<void(
jni::Object<MapRendererRunnable>)>(*_env, "queueEvent");
- javaPeer->Call(*_env, queueEvent, *peer);
+ javaPeer.get(*_env).Call(*_env, queueEvent, peer);
// Release the c++ peer as it will be destroyed on GC of the Java Peer
runnable.release();
@@ -64,9 +66,9 @@ void MapRenderer::schedule(std::weak_ptr<Mailbox> scheduled) {
void MapRenderer::requestRender() {
android::UniqueEnv _env = android::AttachEnv();
- static auto javaClass = jni::Class<MapRenderer>::Singleton(*_env);
+ static auto& javaClass = jni::Class<MapRenderer>::Singleton(*_env);
static auto onInvalidate = javaClass.GetMethod<void()>(*_env, "requestRender");
- javaPeer->Call(*_env, onInvalidate);
+ javaPeer.get(*_env).Call(*_env, onInvalidate);
}
void MapRenderer::update(std::shared_ptr<UpdateParameters> params) {
@@ -184,13 +186,13 @@ void MapRenderer::onSurfaceChanged(JNIEnv&, jint width, jint height) {
void MapRenderer::registerNative(jni::JNIEnv& env) {
// Lookup the class
- static auto javaClass = jni::Class<MapRenderer>::Singleton(env);
+ static auto& javaClass = jni::Class<MapRenderer>::Singleton(env);
#define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
// Register the peer
jni::RegisterNativePeer<MapRenderer>(env, javaClass, "nativePtr",
- std::make_unique<MapRenderer, JNIEnv&, jni::Object<MapRenderer>, jni::Object<FileSource>, jni::jfloat, jni::String, jni::String>,
+ jni::MakePeer<MapRenderer, const jni::Object<MapRenderer>&, const jni::Object<FileSource>&, jni::jfloat, const jni::String&, const jni::String&>,
"nativeInitialize", "finalize",
METHOD(&MapRenderer::render, "nativeRender"),
METHOD(&MapRenderer::onSurfaceCreated,
@@ -199,8 +201,8 @@ void MapRenderer::registerNative(jni::JNIEnv& env) {
"nativeOnSurfaceChanged"));
}
-MapRenderer& MapRenderer::getNativePeer(JNIEnv& env, jni::Object<MapRenderer> jObject) {
- static auto javaClass = jni::Class<MapRenderer>::Singleton(env);
+MapRenderer& MapRenderer::getNativePeer(JNIEnv& env, const jni::Object<MapRenderer>& jObject) {
+ static auto& javaClass = jni::Class<MapRenderer>::Singleton(env);
static auto field = javaClass.GetField<jlong>(env, "nativePtr");
MapRenderer* mapRenderer = reinterpret_cast<MapRenderer*>(jObject.Get(env, field));
assert(mapRenderer != nullptr);
diff --git a/platform/android/src/map_renderer.hpp b/platform/android/src/map_renderer.hpp
index 6fcf2fee71..d60447e0ec 100644
--- a/platform/android/src/map_renderer.hpp
+++ b/platform/android/src/map_renderer.hpp
@@ -9,8 +9,6 @@
#include <jni/jni.hpp>
#include <mbgl/storage/default_file_source.hpp>
-#include "jni/generic_global_ref_deleter.hpp"
-
namespace mbgl {
template <class>
@@ -40,14 +38,14 @@ public:
static void registerNative(jni::JNIEnv&);
- static MapRenderer& getNativePeer(JNIEnv&, jni::Object<MapRenderer>);
+ static MapRenderer& getNativePeer(JNIEnv&, const jni::Object<MapRenderer>&);
MapRenderer(jni::JNIEnv& _env,
- jni::Object<MapRenderer>,
- jni::Object<FileSource>,
+ const jni::Object<MapRenderer>&,
+ const jni::Object<FileSource>&,
jni::jfloat pixelRatio,
- jni::String programCacheDir,
- jni::String localIdeographFontFamily);
+ const jni::String& programCacheDir,
+ const jni::String& localIdeographFontFamily);
~MapRenderer() override;
@@ -97,7 +95,7 @@ private:
void onSurfaceChanged(JNIEnv&, jint width, jint height);
private:
- GenericWeak<jni::Object<MapRenderer>> javaPeer;
+ jni::WeakReference<jni::Object<MapRenderer>, jni::EnvAttachingDeleter> javaPeer;
float pixelRatio;
DefaultFileSource& fileSource;
diff --git a/platform/android/src/map_renderer_runnable.cpp b/platform/android/src/map_renderer_runnable.cpp
index 1bfccebd2d..77c3aa301d 100644
--- a/platform/android/src/map_renderer_runnable.cpp
+++ b/platform/android/src/map_renderer_runnable.cpp
@@ -12,10 +12,10 @@ MapRendererRunnable::MapRendererRunnable(jni::JNIEnv& env, std::weak_ptr<Mailbox
// Not using a weak reference here as this might oerflow
// the weak reference table on some devices
jni::UniqueLocalFrame frame = jni::PushLocalFrame(env, 5);
- static auto javaClass = jni::Class<MapRendererRunnable>::Singleton(env);
+ static auto& javaClass = jni::Class<MapRendererRunnable>::Singleton(env);
static auto constructor = javaClass.GetConstructor<jlong>(env);
auto instance = javaClass.New(env, constructor, reinterpret_cast<jlong>(this));
- javaPeer = instance.NewGlobalRef(env);
+ javaPeer = jni::NewGlobal(env, instance);
}
MapRendererRunnable::~MapRendererRunnable() = default;
@@ -32,7 +32,7 @@ jni::Global<jni::Object<MapRendererRunnable>> MapRendererRunnable::peer() {
void MapRendererRunnable::registerNative(jni::JNIEnv& env) {
// Lookup the class
- static auto javaClass = jni::Class<MapRendererRunnable>::Singleton(env);
+ static auto& javaClass = jni::Class<MapRendererRunnable>::Singleton(env);
#define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
diff --git a/platform/android/src/native_map_view.cpp b/platform/android/src/native_map_view.cpp
index d396e00b47..25605e09e4 100755
--- a/platform/android/src/native_map_view.cpp
+++ b/platform/android/src/native_map_view.cpp
@@ -57,11 +57,11 @@ namespace mbgl {
namespace android {
NativeMapView::NativeMapView(jni::JNIEnv& _env,
- jni::Object<NativeMapView> _obj,
- jni::Object<FileSource> jFileSource,
- jni::Object<MapRenderer> jMapRenderer,
+ const jni::Object<NativeMapView>& _obj,
+ const jni::Object<FileSource>& jFileSource,
+ const jni::Object<MapRenderer>& jMapRenderer,
jni::jfloat _pixelRatio)
- : javaPeer(_obj.NewWeakGlobalRef(_env))
+ : javaPeer(_env, _obj)
, mapRenderer(MapRenderer::getNativePeer(_env, jMapRenderer))
, pixelRatio(_pixelRatio)
, threadPool(sharedThreadPool()) {
@@ -103,9 +103,9 @@ void NativeMapView::notifyMapChange(mbgl::MapChange change) {
assert(vm != nullptr);
android::UniqueEnv _env = android::AttachEnv();
- static auto javaClass = jni::Class<NativeMapView>::Singleton(*_env);
+ static auto& javaClass = jni::Class<NativeMapView>::Singleton(*_env);
static auto onMapChanged = javaClass.GetMethod<void (int)>(*_env, "onMapChanged");
- javaPeer->Call(*_env, onMapChanged, (int) change);
+ javaPeer.get(*_env).Call(*_env, onMapChanged, (int) change);
}
void NativeMapView::onCameraWillChange(MapObserver::CameraChangeMode mode) {
@@ -180,23 +180,23 @@ void NativeMapView::resizeView(jni::JNIEnv&, int w, int h) {
map->setSize({ static_cast<uint32_t>(width), static_cast<uint32_t>(height) });
}
-jni::String NativeMapView::getStyleUrl(jni::JNIEnv& env) {
+jni::Local<jni::String> NativeMapView::getStyleUrl(jni::JNIEnv& env) {
return jni::Make<jni::String>(env, map->getStyle().getURL());
}
-void NativeMapView::setStyleUrl(jni::JNIEnv& env, jni::String url) {
+void NativeMapView::setStyleUrl(jni::JNIEnv& env, const jni::String& url) {
map->getStyle().loadURL(jni::Make<std::string>(env, url));
}
-jni::String NativeMapView::getStyleJson(jni::JNIEnv& env) {
+jni::Local<jni::String> NativeMapView::getStyleJson(jni::JNIEnv& env) {
return jni::Make<jni::String>(env, map->getStyle().getJSON());
}
-void NativeMapView::setStyleJson(jni::JNIEnv& env, jni::String json) {
+void NativeMapView::setStyleJson(jni::JNIEnv& env, const jni::String& json) {
map->getStyle().loadJSON(jni::Make<std::string>(env, json));
}
-void NativeMapView::setLatLngBounds(jni::JNIEnv& env, jni::Object<mbgl::android::LatLngBounds> jBounds) {
+void NativeMapView::setLatLngBounds(jni::JNIEnv& env, const jni::Object<mbgl::android::LatLngBounds>& jBounds) {
if (jBounds) {
map->setLatLngBounds(mbgl::android::LatLngBounds::getLatLngBounds(env, jBounds));
} else {
@@ -281,7 +281,7 @@ void NativeMapView::flyTo(jni::JNIEnv&, jni::jdouble angle, jni::jdouble latitud
map->flyTo(cameraOptions, animationOptions);
}
-jni::Object<LatLng> NativeMapView::getLatLng(JNIEnv& env) {
+jni::Local<jni::Object<LatLng>> NativeMapView::getLatLng(JNIEnv& env) {
return LatLng::New(env, map->getLatLng(insets));
}
@@ -289,12 +289,12 @@ void NativeMapView::setLatLng(jni::JNIEnv&, jni::jdouble latitude, jni::jdouble
map->setLatLng(mbgl::LatLng(latitude, longitude), insets, mbgl::AnimationOptions{mbgl::Milliseconds(duration)});
}
-jni::Object<CameraPosition> NativeMapView::getCameraForLatLngBounds(jni::JNIEnv& env, jni::Object<LatLngBounds> jBounds, double top, double left, double bottom, double right, double bearing, double tilt) {
+jni::Local<jni::Object<CameraPosition>> NativeMapView::getCameraForLatLngBounds(jni::JNIEnv& env, const jni::Object<LatLngBounds>& jBounds, double top, double left, double bottom, double right, double bearing, double tilt) {
mbgl::EdgeInsets padding = {top, left, bottom, right};
return CameraPosition::New(env, map->cameraForLatLngBounds(mbgl::android::LatLngBounds::getLatLngBounds(env, jBounds), padding, bearing, tilt));
}
-jni::Object<CameraPosition> NativeMapView::getCameraForGeometry(jni::JNIEnv& env, jni::Object<geojson::Geometry> jGeometry, double top, double left, double bottom, double right, double bearing, double tilt) {
+jni::Local<jni::Object<CameraPosition>> NativeMapView::getCameraForGeometry(jni::JNIEnv& env, const jni::Object<geojson::Geometry>& jGeometry, double top, double left, double bottom, double right, double bearing, double tilt) {
auto geometry = geojson::Geometry::convert(env, jGeometry);
mbgl::EdgeInsets padding = {top, left, bottom, right};
return CameraPosition::New(env, map->cameraForGeometry(geometry, padding, bearing, tilt));
@@ -369,7 +369,7 @@ void NativeMapView::resetNorth(jni::JNIEnv&) {
map->resetNorth();
}
-void NativeMapView::setVisibleCoordinateBounds(JNIEnv& env, jni::Array<jni::Object<LatLng>> coordinates, jni::Object<RectF> padding, jdouble direction, jni::jlong duration) {
+void NativeMapView::setVisibleCoordinateBounds(JNIEnv& env, const jni::Array<jni::Object<LatLng>>& coordinates, const jni::Object<RectF>& padding, jdouble direction, jni::jlong duration) {
NullCheck(env, &coordinates);
std::size_t count = coordinates.Length(env);
@@ -377,7 +377,7 @@ void NativeMapView::setVisibleCoordinateBounds(JNIEnv& env, jni::Array<jni::Obje
latLngs.reserve(count);
for (std::size_t i = 0; i < count; i++) {
- latLngs.push_back(LatLng::getLatLng(env, *jni::SeizeLocal(env, coordinates.Get(env, i))));
+ latLngs.push_back(LatLng::getLatLng(env, coordinates.Get(env, i)));
}
mbgl::EdgeInsets mbglInsets = { RectF::getTop(env, padding), RectF::getLeft(env, padding), RectF::getBottom(env, padding), RectF::getRight(env, padding) };
@@ -408,17 +408,17 @@ void NativeMapView::scheduleSnapshot(jni::JNIEnv&) {
auto bitmap = Bitmap::CreateBitmap(*_env, std::move(image));
// invoke Mapview#OnSnapshotReady
- static auto javaClass = jni::Class<NativeMapView>::Singleton(*_env);
+ static auto& javaClass = jni::Class<NativeMapView>::Singleton(*_env);
static auto onSnapshotReady = javaClass.GetMethod<void (jni::Object<Bitmap>)>(*_env, "onSnapshotReady");
- javaPeer->Call(*_env, onSnapshotReady, bitmap);
+ javaPeer.get(*_env).Call(*_env, onSnapshotReady, bitmap);
});
}
-jni::Object<CameraPosition> NativeMapView::getCameraPosition(jni::JNIEnv& env) {
+jni::Local<jni::Object<CameraPosition>> NativeMapView::getCameraPosition(jni::JNIEnv& env) {
return CameraPosition::New(env, map->getCameraOptions(insets));
}
-void NativeMapView::updateMarker(jni::JNIEnv& env, jni::jlong markerId, jni::jdouble lat, jni::jdouble lon, jni::String jid) {
+void NativeMapView::updateMarker(jni::JNIEnv& env, jni::jlong markerId, jni::jdouble lat, jni::jdouble lon, const jni::String& jid) {
if (markerId == -1) {
return;
}
@@ -428,7 +428,7 @@ void NativeMapView::updateMarker(jni::JNIEnv& env, jni::jlong markerId, jni::jdo
map->updateAnnotation(markerId, mbgl::SymbolAnnotation { mbgl::Point<double>(lon, lat), iconId });
}
-jni::Array<jni::jlong> NativeMapView::addMarkers(jni::JNIEnv& env, jni::Array<jni::Object<Marker>> jmarkers) {
+jni::Local<jni::Array<jni::jlong>> NativeMapView::addMarkers(jni::JNIEnv& env, const jni::Array<jni::Object<Marker>>& jmarkers) {
jni::NullCheck(env, &jmarkers);
std::size_t len = jmarkers.Length(env);
@@ -436,10 +436,10 @@ jni::Array<jni::jlong> NativeMapView::addMarkers(jni::JNIEnv& env, jni::Array<jn
ids.reserve(len);
for (std::size_t i = 0; i < len; i++) {
- auto marker = jni::SeizeLocal(env, jmarkers.Get(env, i));
+ auto marker = jmarkers.Get(env, i);
ids.push_back(map->addAnnotation(mbgl::SymbolAnnotation {
- Marker::getPosition(env, *marker),
- Marker::getIconId(env, *marker)
+ Marker::getPosition(env, marker),
+ Marker::getIconId(env, marker)
}));
}
@@ -477,25 +477,25 @@ jni::jdouble NativeMapView::getMetersPerPixelAtLatitude(JNIEnv&, jni::jdouble la
return mbgl::Projection::getMetersPerPixelAtLatitude(lat, zoom);
}
-jni::Object<ProjectedMeters> NativeMapView::projectedMetersForLatLng(JNIEnv& env, jni::jdouble latitude, jni::jdouble longitude) {
+jni::Local<jni::Object<ProjectedMeters>> NativeMapView::projectedMetersForLatLng(JNIEnv& env, jni::jdouble latitude, jni::jdouble longitude) {
mbgl::ProjectedMeters projectedMeters = mbgl::Projection::projectedMetersForLatLng(mbgl::LatLng(latitude, longitude));
return ProjectedMeters::New(env, projectedMeters.northing(), projectedMeters.easting());
}
-jni::Object<LatLng> NativeMapView::latLngForProjectedMeters(JNIEnv& env, jdouble northing, jdouble easting) {
+jni::Local<jni::Object<LatLng>> NativeMapView::latLngForProjectedMeters(JNIEnv& env, jdouble northing, jdouble easting) {
return LatLng::New(env, mbgl::Projection::latLngForProjectedMeters(mbgl::ProjectedMeters(northing, easting)));
}
-jni::Object<PointF> NativeMapView::pixelForLatLng(JNIEnv& env, jdouble latitude, jdouble longitude) {
+jni::Local<jni::Object<PointF>> NativeMapView::pixelForLatLng(JNIEnv& env, jdouble latitude, jdouble longitude) {
mbgl::ScreenCoordinate pixel = map->pixelForLatLng(mbgl::LatLng(latitude, longitude));
return PointF::New(env, static_cast<float>(pixel.x), static_cast<float>(pixel.y));
}
-jni::Object<LatLng> NativeMapView::latLngForPixel(JNIEnv& env, jfloat x, jfloat y) {
+jni::Local<jni::Object<LatLng>> NativeMapView::latLngForPixel(JNIEnv& env, jfloat x, jfloat y) {
return LatLng::New(env, map->latLngForPixel(mbgl::ScreenCoordinate(x, y)));
}
-jni::Array<jlong> NativeMapView::addPolylines(JNIEnv& env, jni::Array<jni::Object<Polyline>> polylines) {
+jni::Local<jni::Array<jlong>> NativeMapView::addPolylines(JNIEnv& env, const jni::Array<jni::Object<Polyline>>& polylines) {
NullCheck(env, &polylines);
std::size_t len = polylines.Length(env);
@@ -503,7 +503,7 @@ jni::Array<jlong> NativeMapView::addPolylines(JNIEnv& env, jni::Array<jni::Objec
ids.reserve(len);
for (std::size_t i = 0; i < len; i++) {
- mbgl::LineAnnotation annotation = Polyline::toAnnotation(env, *jni::SeizeLocal(env, polylines.Get(env, i)));
+ mbgl::LineAnnotation annotation = Polyline::toAnnotation(env, polylines.Get(env, i));
ids.push_back(map->addAnnotation(annotation));
}
@@ -514,7 +514,7 @@ jni::Array<jlong> NativeMapView::addPolylines(JNIEnv& env, jni::Array<jni::Objec
}
-jni::Array<jlong> NativeMapView::addPolygons(JNIEnv& env, jni::Array<jni::Object<Polygon>> polygons) {
+jni::Local<jni::Array<jlong>> NativeMapView::addPolygons(JNIEnv& env, const jni::Array<jni::Object<Polygon>>& polygons) {
NullCheck(env, &polygons);
std::size_t len = polygons.Length(env);
@@ -522,7 +522,7 @@ jni::Array<jlong> NativeMapView::addPolygons(JNIEnv& env, jni::Array<jni::Object
ids.reserve(len);
for (std::size_t i = 0; i < len; i++) {
- mbgl::FillAnnotation annotation = Polygon::toAnnotation(env, *jni::SeizeLocal(env, polygons.Get(env, i)));
+ mbgl::FillAnnotation annotation = Polygon::toAnnotation(env, polygons.Get(env, i));
ids.push_back(map->addAnnotation(annotation));
}
@@ -533,18 +533,18 @@ jni::Array<jlong> NativeMapView::addPolygons(JNIEnv& env, jni::Array<jni::Object
}
//TODO: Move to Polyline class and make native peer
-void NativeMapView::updatePolyline(JNIEnv& env, jlong polylineId, jni::Object<Polyline> polyline) {
+void NativeMapView::updatePolyline(JNIEnv& env, jlong polylineId, const jni::Object<Polyline>& polyline) {
mbgl::LineAnnotation annotation = Polyline::toAnnotation(env, polyline);
map->updateAnnotation(polylineId, annotation);
}
//TODO: Move to Polygon class and make native peer
-void NativeMapView::updatePolygon(JNIEnv& env, jlong polygonId, jni::Object<Polygon> polygon) {
+void NativeMapView::updatePolygon(JNIEnv& env, jlong polygonId, const jni::Object<Polygon>& polygon) {
mbgl::FillAnnotation annotation = Polygon::toAnnotation(env, polygon);
map->updateAnnotation(polygonId, annotation);
}
-void NativeMapView::removeAnnotations(JNIEnv& env, jni::Array<jlong> ids) {
+void NativeMapView::removeAnnotations(JNIEnv& env, const jni::Array<jlong>& ids) {
NullCheck(env, &ids);
std::size_t len = ids.Length(env);
auto elements = jni::GetArrayElements(env, *ids);
@@ -558,7 +558,7 @@ void NativeMapView::removeAnnotations(JNIEnv& env, jni::Array<jlong> ids) {
}
}
-void NativeMapView::addAnnotationIcon(JNIEnv& env, jni::String symbol, jint w, jint h, jfloat scale, jni::Array<jbyte> jpixels) {
+void NativeMapView::addAnnotationIcon(JNIEnv& env, const jni::String& symbol, jint w, jint h, jfloat scale, const jni::Array<jbyte>& jpixels) {
const std::string symbolName = jni::Make<std::string>(env, symbol);
NullCheck(env, &jpixels);
@@ -574,12 +574,12 @@ void NativeMapView::addAnnotationIcon(JNIEnv& env, jni::String symbol, jint w, j
symbolName, std::move(premultipliedImage), float(scale)));
}
-void NativeMapView::removeAnnotationIcon(JNIEnv& env, jni::String symbol) {
+void NativeMapView::removeAnnotationIcon(JNIEnv& env, const jni::String& symbol) {
const std::string symbolName = jni::Make<std::string>(env, symbol);
map->removeAnnotationImage(symbolName);
}
-jdouble NativeMapView::getTopOffsetPixelsForAnnotationSymbol(JNIEnv& env, jni::String symbolName) {
+jdouble NativeMapView::getTopOffsetPixelsForAnnotationSymbol(JNIEnv& env, const jni::String& symbolName) {
return map->getTopOffsetPixelsForAnnotationImage(jni::Make<std::string>(env, symbolName));
}
@@ -605,7 +605,7 @@ void NativeMapView::setTransitionDelay(JNIEnv&, jlong delay) {
map->getStyle().setTransitionOptions(transitionOptions);
}
-jni::Array<jlong> NativeMapView::queryPointAnnotations(JNIEnv& env, jni::Object<RectF> rect) {
+jni::Local<jni::Array<jlong>> NativeMapView::queryPointAnnotations(JNIEnv& env, const jni::Object<RectF>& rect) {
using namespace mbgl::style;
using namespace mbgl::style::conversion;
@@ -626,7 +626,7 @@ jni::Array<jlong> NativeMapView::queryPointAnnotations(JNIEnv& env, jni::Object<
return result;
}
-jni::Array<jlong> NativeMapView::queryShapeAnnotations(JNIEnv &env, jni::Object<RectF> rect) {
+jni::Local<jni::Array<jlong>> NativeMapView::queryShapeAnnotations(JNIEnv& env, const jni::Object<RectF>& rect) {
using namespace mbgl::style;
using namespace mbgl::style::conversion;
@@ -646,31 +646,31 @@ jni::Array<jlong> NativeMapView::queryShapeAnnotations(JNIEnv &env, jni::Object<
return result;
}
-jni::Array<jni::Object<geojson::Feature>> NativeMapView::queryRenderedFeaturesForPoint(JNIEnv& env, jni::jfloat x, jni::jfloat y,
- jni::Array<jni::String> layerIds,
- jni::Array<jni::Object<>> jfilter) {
+jni::Local<jni::Array<jni::Object<geojson::Feature>>> NativeMapView::queryRenderedFeaturesForPoint(JNIEnv& env, jni::jfloat x, jni::jfloat y,
+ const jni::Array<jni::String>& layerIds,
+ const jni::Array<jni::Object<>>& jfilter) {
using namespace mbgl::android::conversion;
using namespace mbgl::android::geojson;
mbgl::optional<std::vector<std::string>> layers;
- if (layerIds != nullptr && layerIds.Length(env) > 0) {
+ if (layerIds && layerIds.Length(env) > 0) {
layers = android::conversion::toVector(env, layerIds);
}
mapbox::geometry::point<double> point = {x, y};
return Feature::convert(
env,
- rendererFrontend->queryRenderedFeatures(point, { layers, toFilter(env, jni::SeizeLocal(env, std::move(jfilter))) }));
+ rendererFrontend->queryRenderedFeatures(point, { layers, toFilter(env, jfilter) }));
}
-jni::Array<jni::Object<geojson::Feature>> NativeMapView::queryRenderedFeaturesForBox(JNIEnv& env, jni::jfloat left, jni::jfloat top,
- jni::jfloat right, jni::jfloat bottom, jni::Array<jni::String> layerIds,
- jni::Array<jni::Object<>> jfilter) {
+jni::Local<jni::Array<jni::Object<geojson::Feature>>> NativeMapView::queryRenderedFeaturesForBox(JNIEnv& env, jni::jfloat left, jni::jfloat top,
+ jni::jfloat right, jni::jfloat bottom, const jni::Array<jni::String>& layerIds,
+ const jni::Array<jni::Object<>>& jfilter) {
using namespace mbgl::android::conversion;
using namespace mbgl::android::geojson;
mbgl::optional<std::vector<std::string>> layers;
- if (layerIds != nullptr && layerIds.Length(env) > 0) {
+ if (layerIds && layerIds.Length(env) > 0) {
layers = toVector(env, layerIds);
}
mapbox::geometry::box<double> box = {
@@ -680,48 +680,48 @@ jni::Array<jni::Object<geojson::Feature>> NativeMapView::queryRenderedFeaturesFo
return Feature::convert(
env,
- rendererFrontend->queryRenderedFeatures(box, { layers, toFilter(env, jni::SeizeLocal(env, std::move(jfilter))) }));
+ rendererFrontend->queryRenderedFeatures(box, { layers, toFilter(env, jfilter) }));
}
-jni::Object<Light> NativeMapView::getLight(JNIEnv& env) {
+jni::Local<jni::Object<Light>> NativeMapView::getLight(JNIEnv& env) {
mbgl::style::Light* light = map->getStyle().getLight();
if (light) {
- return jni::Object<Light>(Light::createJavaLightPeer(env, *map, *light));
+ return Light::createJavaLightPeer(env, *map, *light);
} else {
- return jni::Object<Light>();
+ return jni::Local<jni::Object<Light>>();
}
}
-jni::Array<jni::Object<Layer>> NativeMapView::getLayers(JNIEnv& env) {
+jni::Local<jni::Array<jni::Object<Layer>>> NativeMapView::getLayers(JNIEnv& env) {
// Get the core layers
std::vector<style::Layer*> layers = map->getStyle().getLayers();
// Convert
- jni::Array<jni::Object<Layer>> jLayers = jni::Array<jni::Object<Layer>>::New(env, layers.size());
+ auto jLayers = jni::Array<jni::Object<Layer>>::New(env, layers.size());
int index = 0;
for (auto layer : layers) {
- jLayers.Set(env, index, *jni::SeizeLocal(env, jni::Object<Layer>(createJavaLayerPeer(env, *map, *layer))));
+ jLayers.Set(env, index, createJavaLayerPeer(env, *map, *layer));
index++;
}
return jLayers;
}
-jni::Object<Layer> NativeMapView::getLayer(JNIEnv& env, jni::String layerId) {
+jni::Local<jni::Object<Layer>> NativeMapView::getLayer(JNIEnv& env, const jni::String& layerId) {
// Find the layer
mbgl::style::Layer* coreLayer = map->getStyle().getLayer(jni::Make<std::string>(env, layerId));
if (!coreLayer) {
mbgl::Log::Debug(mbgl::Event::JNI, "No layer found");
- return jni::Object<Layer>();
+ return jni::Local<jni::Object<Layer>>();
}
// Create and return the layer's native peer
- return jni::Object<Layer>(createJavaLayerPeer(env, *map, *coreLayer));
+ return createJavaLayerPeer(env, *map, *coreLayer);
}
-void NativeMapView::addLayer(JNIEnv& env, jlong nativeLayerPtr, jni::String before) {
+void NativeMapView::addLayer(JNIEnv& env, jlong nativeLayerPtr, const jni::String& before) {
assert(nativeLayerPtr != 0);
Layer *layer = reinterpret_cast<Layer *>(nativeLayerPtr);
@@ -732,7 +732,7 @@ void NativeMapView::addLayer(JNIEnv& env, jlong nativeLayerPtr, jni::String befo
}
}
-void NativeMapView::addLayerAbove(JNIEnv& env, jlong nativeLayerPtr, jni::String above) {
+void NativeMapView::addLayerAbove(JNIEnv& env, jlong nativeLayerPtr, const jni::String& above) {
assert(nativeLayerPtr != 0);
Layer *layer = reinterpret_cast<Layer *>(nativeLayerPtr);
@@ -795,33 +795,33 @@ void NativeMapView::addLayerAt(JNIEnv& env, jlong nativeLayerPtr, jni::jint inde
/**
* Remove by layer id.
*/
-jni::Object<Layer> NativeMapView::removeLayerById(JNIEnv& env, jni::String id) {
+jni::Local<jni::Object<Layer>> NativeMapView::removeLayerById(JNIEnv& env, const jni::String& id) {
std::unique_ptr<mbgl::style::Layer> coreLayer = map->getStyle().removeLayer(jni::Make<std::string>(env, id));
if (coreLayer) {
- return jni::Object<Layer>(createJavaLayerPeer(env, *map, std::move(coreLayer)));
+ return createJavaLayerPeer(env, *map, std::move(coreLayer));
} else {
- return jni::Object<Layer>();
+ return jni::Local<jni::Object<Layer>>();
}
}
/**
* Remove layer at index.
*/
-jni::Object<Layer> NativeMapView::removeLayerAt(JNIEnv& env, jni::jint index) {
+jni::Local<jni::Object<Layer>> NativeMapView::removeLayerAt(JNIEnv& env, jni::jint index) {
auto layers = map->getStyle().getLayers();
// Check index
int numLayers = layers.size() - 1;
if (index > numLayers || index < 0) {
Log::Warning(Event::JNI, "Index out of range: %i", index);
- return jni::Object<Layer>();
+ return jni::Local<jni::Object<Layer>>();
}
std::unique_ptr<mbgl::style::Layer> coreLayer = map->getStyle().removeLayer(layers.at(index)->getID());
if (coreLayer) {
- return jni::Object<Layer>(createJavaLayerPeer(env, *map, std::move(coreLayer)));
+ return createJavaLayerPeer(env, *map, std::move(coreLayer));
} else {
- return jni::Object<Layer>();
+ return jni::Local<jni::Object<Layer>>();
}
}
@@ -838,12 +838,12 @@ void NativeMapView::removeLayer(JNIEnv&, jlong layerPtr) {
}
}
-jni::Array<jni::Object<Source>> NativeMapView::getSources(JNIEnv& env) {
+jni::Local<jni::Array<jni::Object<Source>>> NativeMapView::getSources(JNIEnv& env) {
// Get the core sources
std::vector<style::Source*> sources = map->getStyle().getSources();
// Convert
- jni::Array<jni::Object<Source>> jSources = jni::Array<jni::Object<Source>>::New(env, sources.size());
+ auto jSources = jni::Array<jni::Object<Source>>::New(env, sources.size());
int index = 0;
for (auto source : sources) {
jSources.Set(env, index, Source::peerForCoreSource(env, *source, *rendererFrontend));
@@ -853,19 +853,19 @@ jni::Array<jni::Object<Source>> NativeMapView::getSources(JNIEnv& env) {
return jSources;
}
-jni::Object<Source> NativeMapView::getSource(JNIEnv& env, jni::String sourceId) {
+jni::Local<jni::Object<Source>> NativeMapView::getSource(JNIEnv& env, const jni::String& sourceId) {
// Find the source
mbgl::style::Source* coreSource = map->getStyle().getSource(jni::Make<std::string>(env, sourceId));
if (!coreSource) {
mbgl::Log::Debug(mbgl::Event::JNI, "No source found");
- return jni::Object<Source>();
+ return jni::Local<jni::Object<Source>>();
}
// Create and return the source's native peer
- return Source::peerForCoreSource(env, *coreSource, *rendererFrontend);
+ return jni::NewLocal(env, Source::peerForCoreSource(env, *coreSource, *rendererFrontend));
}
-void NativeMapView::addSource(JNIEnv& env, jni::Object<Source> obj, jlong sourcePtr) {
+void NativeMapView::addSource(JNIEnv& env, const jni::Object<Source>& obj, jlong sourcePtr) {
assert(sourcePtr != 0);
Source *source = reinterpret_cast<Source *>(sourcePtr);
@@ -876,7 +876,7 @@ void NativeMapView::addSource(JNIEnv& env, jni::Object<Source> obj, jlong source
}
}
-void NativeMapView::removeSource(JNIEnv& env, jni::Object<Source> obj, jlong sourcePtr) {
+void NativeMapView::removeSource(JNIEnv& env, const jni::Object<Source>& obj, jlong sourcePtr) {
assert(sourcePtr != 0);
mbgl::android::Source *source = reinterpret_cast<mbgl::android::Source *>(sourcePtr);
@@ -885,7 +885,7 @@ void NativeMapView::removeSource(JNIEnv& env, jni::Object<Source> obj, jlong sou
}
}
-void NativeMapView::addImage(JNIEnv& env, jni::String name, jni::Object<Bitmap> bitmap, jni::jfloat scale, jni::jboolean sdf) {
+void NativeMapView::addImage(JNIEnv& env, const jni::String& name, const jni::Object<Bitmap>& bitmap, jni::jfloat scale, jni::jboolean sdf) {
jni::NullCheck(env, &bitmap);
mbgl::PremultipliedImage premultipliedImage = Bitmap::GetImage(env, bitmap);
@@ -897,26 +897,26 @@ void NativeMapView::addImage(JNIEnv& env, jni::String name, jni::Object<Bitmap>
);
}
-void NativeMapView::addImages(JNIEnv& env, jni::Array<jni::Object<mbgl::android::Image>> jimages) {
+void NativeMapView::addImages(JNIEnv& env, const jni::Array<jni::Object<mbgl::android::Image>>& jimages) {
jni::NullCheck(env, &jimages);
std::size_t len = jimages.Length(env);
for (std::size_t i = 0; i < len; i++) {
- auto image = mbgl::android::Image::getImage(env, *jni::SeizeLocal(env, jimages.Get(env, i)));
+ auto image = mbgl::android::Image::getImage(env, jimages.Get(env, i));
map->getStyle().addImage(std::make_unique<mbgl::style::Image>(image));
}
}
-void NativeMapView::removeImage(JNIEnv& env, jni::String name) {
+void NativeMapView::removeImage(JNIEnv& env, const jni::String& name) {
map->getStyle().removeImage(jni::Make<std::string>(env, name));
}
-jni::Object<Bitmap> NativeMapView::getImage(JNIEnv& env, jni::String name) {
+jni::Local<jni::Object<Bitmap>> NativeMapView::getImage(JNIEnv& env, const jni::String& name) {
const mbgl::style::Image *image = map->getStyle().getImage(jni::Make<std::string>(env, name));
if (image) {
return Bitmap::CreateBitmap(env, image->getImage());
} else {
- return jni::Object<Bitmap>();
+ return jni::Local<jni::Object<Bitmap>>();
}
}
@@ -936,13 +936,13 @@ mbgl::Map& NativeMapView::getMap() {
void NativeMapView::registerNative(jni::JNIEnv& env) {
// Lookup the class
- static auto javaClass = jni::Class<NativeMapView>::Singleton(env);
+ static auto& javaClass = jni::Class<NativeMapView>::Singleton(env);
#define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
// Register the peer
jni::RegisterNativePeer<NativeMapView>(env, javaClass, "nativePtr",
- std::make_unique<NativeMapView, JNIEnv&, jni::Object<NativeMapView>, jni::Object<FileSource>, jni::Object<MapRenderer>, jni::jfloat>,
+ jni::MakePeer<NativeMapView, const jni::Object<NativeMapView>&, const jni::Object<FileSource>&, const jni::Object<MapRenderer>&, jni::jfloat>,
"nativeInitialize",
"nativeDestroy",
METHOD(&NativeMapView::resizeView, "nativeResizeView"),
diff --git a/platform/android/src/native_map_view.hpp b/platform/android/src/native_map_view.hpp
index d398b39bf7..969833a25b 100755
--- a/platform/android/src/native_map_view.hpp
+++ b/platform/android/src/native_map_view.hpp
@@ -48,9 +48,9 @@ public:
static void registerNative(jni::JNIEnv&);
NativeMapView(jni::JNIEnv&,
- jni::Object<NativeMapView>,
- jni::Object<FileSource>,
- jni::Object<MapRenderer>,
+ const jni::Object<NativeMapView>&,
+ const jni::Object<FileSource>&,
+ const jni::Object<MapRenderer>&,
jni::jfloat pixelRatio);
virtual ~NativeMapView();
@@ -76,15 +76,15 @@ public:
void resizeView(jni::JNIEnv&, int, int);
- jni::String getStyleUrl(jni::JNIEnv&);
+ jni::Local<jni::String> getStyleUrl(jni::JNIEnv&);
- void setStyleUrl(jni::JNIEnv&, jni::String);
+ void setStyleUrl(jni::JNIEnv&, const jni::String&);
- jni::String getStyleJson(jni::JNIEnv&);
+ jni::Local<jni::String> getStyleJson(jni::JNIEnv&);
- void setStyleJson(jni::JNIEnv&, jni::String);
+ void setStyleJson(jni::JNIEnv&, const jni::String&);
- void setLatLngBounds(jni::JNIEnv&, jni::Object<mbgl::android::LatLngBounds>);
+ void setLatLngBounds(jni::JNIEnv&, const jni::Object<mbgl::android::LatLngBounds>&);
void cancelTransitions(jni::JNIEnv&);
@@ -98,13 +98,13 @@ public:
void flyTo(jni::JNIEnv&, jni::jdouble, jni::jdouble, jni::jdouble, jni::jlong, jni::jdouble, jni::jdouble);
- jni::Object<LatLng> getLatLng(JNIEnv&);
+ jni::Local<jni::Object<LatLng>> getLatLng(JNIEnv&);
void setLatLng(jni::JNIEnv&, jni::jdouble, jni::jdouble, jni::jlong);
- jni::Object<CameraPosition> getCameraForLatLngBounds(jni::JNIEnv&, jni::Object<mbgl::android::LatLngBounds>, double top, double left, double bottom, double right, double bearing, double tilt);
+ jni::Local<jni::Object<CameraPosition>> getCameraForLatLngBounds(jni::JNIEnv&, const jni::Object<mbgl::android::LatLngBounds>&, double top, double left, double bottom, double right, double bearing, double tilt);
- jni::Object<CameraPosition> getCameraForGeometry(jni::JNIEnv&, jni::Object<geojson::Geometry>, double top, double left, double bottom, double right, double bearing, double tilt);
+ jni::Local<jni::Object<CameraPosition>> getCameraForGeometry(jni::JNIEnv&, const jni::Object<geojson::Geometry>&, double top, double left, double bottom, double right, double bearing, double tilt);
void setReachability(jni::JNIEnv&, jni::jboolean);
@@ -138,17 +138,17 @@ public:
void resetNorth(jni::JNIEnv&);
- void setVisibleCoordinateBounds(JNIEnv&, jni::Array<jni::Object<LatLng>>, jni::Object<RectF>, jni::jdouble, jni::jlong);
+ void setVisibleCoordinateBounds(JNIEnv&, const jni::Array<jni::Object<LatLng>>&, const jni::Object<RectF>&, jni::jdouble, jni::jlong);
void setContentPadding(JNIEnv&, double, double, double, double);
void scheduleSnapshot(jni::JNIEnv&);
- jni::Object<CameraPosition> getCameraPosition(jni::JNIEnv&);
+ jni::Local<jni::Object<CameraPosition>> getCameraPosition(jni::JNIEnv&);
- void updateMarker(jni::JNIEnv&, jni::jlong, jni::jdouble, jni::jdouble, jni::String);
+ void updateMarker(jni::JNIEnv&, jni::jlong, jni::jdouble, jni::jdouble, const jni::String&);
- jni::Array<jni::jlong> addMarkers(jni::JNIEnv&, jni::Array<jni::Object<Marker>>);
+ jni::Local<jni::Array<jni::jlong>> addMarkers(jni::JNIEnv&, const jni::Array<jni::Object<Marker>>&);
void onLowMemory(JNIEnv& env);
@@ -162,29 +162,29 @@ public:
jni::jdouble getMetersPerPixelAtLatitude(JNIEnv&, jni::jdouble, jni::jdouble);
- jni::Object<ProjectedMeters> projectedMetersForLatLng(JNIEnv&, jni::jdouble, jni::jdouble);
+ jni::Local<jni::Object<ProjectedMeters>> projectedMetersForLatLng(JNIEnv&, jni::jdouble, jni::jdouble);
- jni::Object<PointF> pixelForLatLng(JNIEnv&, jdouble, jdouble);
+ jni::Local<jni::Object<PointF>> pixelForLatLng(JNIEnv&, jdouble, jdouble);
- jni::Object<LatLng> latLngForProjectedMeters(JNIEnv&, jdouble, jdouble);
+ jni::Local<jni::Object<LatLng>> latLngForProjectedMeters(JNIEnv&, jdouble, jdouble);
- jni::Object<LatLng> latLngForPixel(JNIEnv&, jfloat, jfloat);
+ jni::Local<jni::Object<LatLng>> latLngForPixel(JNIEnv&, jfloat, jfloat);
- jni::Array<jlong> addPolylines(JNIEnv&, jni::Array<jni::Object<Polyline>>);
+ jni::Local<jni::Array<jlong>> addPolylines(JNIEnv&, const jni::Array<jni::Object<Polyline>>&);
- jni::Array<jlong> addPolygons(JNIEnv&, jni::Array<jni::Object<Polygon>>);
+ jni::Local<jni::Array<jlong>> addPolygons(JNIEnv&, const jni::Array<jni::Object<Polygon>>&);
- void updatePolyline(JNIEnv&, jlong, jni::Object<Polyline>);
+ void updatePolyline(JNIEnv&, jlong, const jni::Object<Polyline>&);
- void updatePolygon(JNIEnv&, jlong, jni::Object<Polygon>);
+ void updatePolygon(JNIEnv&, jlong, const jni::Object<Polygon>&);
- void removeAnnotations(JNIEnv&, jni::Array<jlong>);
+ void removeAnnotations(JNIEnv&, const jni::Array<jlong>&);
- void addAnnotationIcon(JNIEnv&, jni::String, jint, jint, jfloat, jni::Array<jbyte>);
+ void addAnnotationIcon(JNIEnv&, const jni::String&, jint, jint, jfloat, const jni::Array<jbyte>&);
- void removeAnnotationIcon(JNIEnv&, jni::String);
+ void removeAnnotationIcon(JNIEnv&, const jni::String&);
- jni::jdouble getTopOffsetPixelsForAnnotationSymbol(JNIEnv&, jni::String);
+ jni::jdouble getTopOffsetPixelsForAnnotationSymbol(JNIEnv&, const jni::String&);
jni::jlong getTransitionDuration(JNIEnv&);
@@ -194,53 +194,53 @@ public:
void setTransitionDelay(JNIEnv&, jni::jlong);
- jni::Array<jlong> queryPointAnnotations(JNIEnv&, jni::Object<RectF>);
+ jni::Local<jni::Array<jlong>> queryPointAnnotations(JNIEnv&, const jni::Object<RectF>&);
- jni::Array<jlong> queryShapeAnnotations(JNIEnv&, jni::Object<RectF>);
+ jni::Local<jni::Array<jlong>> queryShapeAnnotations(JNIEnv&, const jni::Object<RectF>&);
- jni::Array<jni::Object<geojson::Feature>> queryRenderedFeaturesForPoint(JNIEnv&, jni::jfloat, jni::jfloat,
- jni::Array<jni::String>,
- jni::Array<jni::Object<>> jfilter);
+ jni::Local<jni::Array<jni::Object<geojson::Feature>>> queryRenderedFeaturesForPoint(JNIEnv&, jni::jfloat, jni::jfloat,
+ const jni::Array<jni::String>&,
+ const jni::Array<jni::Object<>>& jfilter);
- jni::Array<jni::Object<geojson::Feature>> queryRenderedFeaturesForBox(JNIEnv&, jni::jfloat, jni::jfloat, jni::jfloat,
- jni::jfloat, jni::Array<jni::String>,
- jni::Array<jni::Object<>> jfilter);
+ jni::Local<jni::Array<jni::Object<geojson::Feature>>> queryRenderedFeaturesForBox(JNIEnv&, jni::jfloat, jni::jfloat, jni::jfloat,
+ jni::jfloat, const jni::Array<jni::String>&,
+ const jni::Array<jni::Object<>>& jfilter);
- jni::Object<Light> getLight(JNIEnv&);
+ jni::Local<jni::Object<Light>> getLight(JNIEnv&);
- jni::Array<jni::Object<Layer>> getLayers(JNIEnv&);
+ jni::Local<jni::Array<jni::Object<Layer>>> getLayers(JNIEnv&);
- jni::Object<Layer> getLayer(JNIEnv&, jni::String);
+ jni::Local<jni::Object<Layer>> getLayer(JNIEnv&, const jni::String&);
- void addLayer(JNIEnv&, jlong, jni::String);
+ void addLayer(JNIEnv&, jlong, const jni::String&);
- void addLayerAbove(JNIEnv&, jlong, jni::String);
+ void addLayerAbove(JNIEnv&, jlong, const jni::String&);
void addLayerAt(JNIEnv&, jni::jlong, jni::jint);
- jni::Object<Layer> removeLayerById(JNIEnv&, jni::String);
+ jni::Local<jni::Object<Layer>> removeLayerById(JNIEnv&, const jni::String&);
- jni::Object<Layer> removeLayerAt(JNIEnv&, jni::jint);
+ jni::Local<jni::Object<Layer>> removeLayerAt(JNIEnv&, jni::jint);
void removeLayer(JNIEnv&, jlong);
- jni::Array<jni::Object<Source>> getSources(JNIEnv&);
+ jni::Local<jni::Array<jni::Object<Source>>> getSources(JNIEnv&);
- jni::Object<Source> getSource(JNIEnv&, jni::String);
+ jni::Local<jni::Object<Source>> getSource(JNIEnv&, const jni::String&);
- void addSource(JNIEnv&, jni::Object<Source>, jlong nativePtr);
+ void addSource(JNIEnv&, const jni::Object<Source>&, jlong nativePtr);
- jni::Object<Source> removeSourceById(JNIEnv&, jni::String);
+ jni::Local<jni::Object<Source>> removeSourceById(JNIEnv&, const jni::String&);
- void removeSource(JNIEnv&, jni::Object<Source>, jlong nativePtr);
+ void removeSource(JNIEnv&, const jni::Object<Source>&, jlong nativePtr);
- void addImage(JNIEnv&, jni::String, jni::Object<Bitmap> bitmap, jni::jfloat, jni::jboolean);
+ void addImage(JNIEnv&, const jni::String&, const jni::Object<Bitmap>& bitmap, jni::jfloat, jni::jboolean);
- void addImages(JNIEnv&, jni::Array<jni::Object<mbgl::android::Image>>);
+ void addImages(JNIEnv&, const jni::Array<jni::Object<mbgl::android::Image>>&);
- void removeImage(JNIEnv&, jni::String);
+ void removeImage(JNIEnv&, const jni::String&);
- jni::Object<Bitmap> getImage(JNIEnv&, jni::String);
+ jni::Local<jni::Object<Bitmap>> getImage(JNIEnv&, const jni::String&);
void setPrefetchesTiles(JNIEnv&, jni::jboolean);
@@ -252,7 +252,7 @@ private:
std::unique_ptr<AndroidRendererFrontend> rendererFrontend;
JavaVM *vm = nullptr;
- jni::Weak<jni::Object<NativeMapView>> javaPeer;
+ jni::WeakReference<jni::Object<NativeMapView>> javaPeer;
MapRenderer& mapRenderer;
diff --git a/platform/android/src/offline/offline_manager.cpp b/platform/android/src/offline/offline_manager.cpp
index 263f7b9d8b..b27af8bdae 100644
--- a/platform/android/src/offline/offline_manager.cpp
+++ b/platform/android/src/offline/offline_manager.cpp
@@ -3,14 +3,13 @@
#include <mbgl/util/string.hpp>
#include "../attach_env.hpp"
-#include "../jni/generic_global_ref_deleter.hpp"
namespace mbgl {
namespace android {
// OfflineManager //
-OfflineManager::OfflineManager(jni::JNIEnv& env, jni::Object<FileSource> jFileSource)
+OfflineManager::OfflineManager(jni::JNIEnv& env, const jni::Object<FileSource>& jFileSource)
: fileSource(mbgl::android::FileSource::getDefaultFileSource(env, jFileSource)) {
}
@@ -20,12 +19,14 @@ void OfflineManager::setOfflineMapboxTileCountLimit(jni::JNIEnv&, jni::jlong lim
fileSource.setOfflineMapboxTileCountLimit(limit);
}
-void OfflineManager::listOfflineRegions(jni::JNIEnv& env_, jni::Object<FileSource> jFileSource_, jni::Object<ListOfflineRegionsCallback> callback_) {
- // list regions
+void OfflineManager::listOfflineRegions(jni::JNIEnv& env_, const jni::Object<FileSource>& jFileSource_, const jni::Object<ListOfflineRegionsCallback>& callback_) {
+ auto globalCallback = jni::NewGlobal<jni::EnvAttachingDeleter>(env_, callback_);
+ auto globalFilesource = jni::NewGlobal<jni::EnvAttachingDeleter>(env_, jFileSource_);
+
fileSource.listOfflineRegions([
//Keep a shared ptr to a global reference of the callback and file source so they are not GC'd in the meanwhile
- callback = std::shared_ptr<jni::jobject>(callback_.NewGlobalRef(env_).release().Get(), GenericGlobalRefDeleter()),
- jFileSource = std::shared_ptr<jni::jobject>(jFileSource_.NewGlobalRef(env_).release().Get(), GenericGlobalRefDeleter())
+ callback = std::make_shared<decltype(globalCallback)>(std::move(globalCallback)),
+ jFileSource = std::make_shared<decltype(globalFilesource)>(std::move(globalFilesource))
](mbgl::expected<mbgl::OfflineRegions, std::exception_ptr> regions) mutable {
// Reattach, the callback comes from a different thread
@@ -33,20 +34,19 @@ void OfflineManager::listOfflineRegions(jni::JNIEnv& env_, jni::Object<FileSourc
if (regions) {
OfflineManager::ListOfflineRegionsCallback::onList(
- *env, jni::Object<FileSource>(*jFileSource),
- jni::Object<ListOfflineRegionsCallback>(*callback), std::move(*regions));
+ *env, *jFileSource, *callback, std::move(*regions));
} else {
OfflineManager::ListOfflineRegionsCallback::onError(
- *env, jni::Object<ListOfflineRegionsCallback>(*callback), regions.error());
+ *env, *callback, regions.error());
}
});
}
void OfflineManager::createOfflineRegion(jni::JNIEnv& env_,
- jni::Object<FileSource> jFileSource_,
- jni::Object<OfflineRegionDefinition> definition_,
- jni::Array<jni::jbyte> metadata_,
- jni::Object<CreateOfflineRegionCallback> callback_) {
+ const jni::Object<FileSource>& jFileSource_,
+ const jni::Object<OfflineRegionDefinition>& definition_,
+ const jni::Array<jni::jbyte>& metadata_,
+ const jni::Object<CreateOfflineRegionCallback>& callback_) {
// Convert
auto definition = OfflineRegionDefinition::getDefinition(env_, definition_);
@@ -55,11 +55,14 @@ void OfflineManager::createOfflineRegion(jni::JNIEnv& env_,
metadata = OfflineRegion::metadata(env_, metadata_);
}
+ auto globalCallback = jni::NewGlobal<jni::EnvAttachingDeleter>(env_, callback_);
+ auto globalFilesource = jni::NewGlobal<jni::EnvAttachingDeleter>(env_, jFileSource_);
+
// Create region
fileSource.createOfflineRegion(definition, metadata, [
//Keep a shared ptr to a global reference of the callback and file source so they are not GC'd in the meanwhile
- callback = std::shared_ptr<jni::jobject>(callback_.NewGlobalRef(env_).release().Get(), GenericGlobalRefDeleter()),
- jFileSource = std::shared_ptr<jni::jobject>(jFileSource_.NewGlobalRef(env_).release().Get(), GenericGlobalRefDeleter())
+ callback = std::make_shared<decltype(globalCallback)>(std::move(globalCallback)),
+ jFileSource = std::make_shared<decltype(globalFilesource)>(std::move(globalFilesource))
](mbgl::expected<mbgl::OfflineRegion, std::exception_ptr> region) mutable {
// Reattach, the callback comes from a different thread
@@ -67,12 +70,11 @@ void OfflineManager::createOfflineRegion(jni::JNIEnv& env_,
if (region) {
OfflineManager::CreateOfflineRegionCallback::onCreate(
- *env,
- jni::Object<FileSource>(*jFileSource),
- jni::Object<CreateOfflineRegionCallback>(*callback), std::move(*region)
+ *env, *jFileSource, *callback, std::move(*region)
);
} else {
- OfflineManager::CreateOfflineRegionCallback::onError(*env, jni::Object<CreateOfflineRegionCallback>(*callback), region.error());
+ OfflineManager::CreateOfflineRegionCallback::onError(
+ *env, *callback, region.error());
}
});
}
@@ -81,12 +83,12 @@ void OfflineManager::registerNative(jni::JNIEnv& env) {
jni::Class<ListOfflineRegionsCallback>::Singleton(env);
jni::Class<CreateOfflineRegionCallback>::Singleton(env);
- static auto javaClass = jni::Class<OfflineManager>::Singleton(env);
+ static auto& javaClass = jni::Class<OfflineManager>::Singleton(env);
#define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
jni::RegisterNativePeer<OfflineManager>( env, javaClass, "nativePtr",
- std::make_unique<OfflineManager, JNIEnv&, jni::Object<FileSource>>,
+ jni::MakePeer<OfflineManager, const jni::Object<FileSource>&>,
"initialize",
"finalize",
METHOD(&OfflineManager::setOfflineMapboxTileCountLimit, "setOfflineMapboxTileCountLimit"),
@@ -97,53 +99,50 @@ void OfflineManager::registerNative(jni::JNIEnv& env) {
// OfflineManager::ListOfflineRegionsCallback //
void OfflineManager::ListOfflineRegionsCallback::onError(jni::JNIEnv& env,
- jni::Object<OfflineManager::ListOfflineRegionsCallback> callback,
+ const jni::Object<OfflineManager::ListOfflineRegionsCallback>& callback,
std::exception_ptr error) {
- static auto javaClass = jni::Class<OfflineManager::ListOfflineRegionsCallback>::Singleton(env);
+ static auto& javaClass = jni::Class<OfflineManager::ListOfflineRegionsCallback>::Singleton(env);
static auto method = javaClass.GetMethod<void (jni::String)>(env, "onError");
- callback.Call(env, method,
- *jni::SeizeLocal(env, jni::Make<jni::String>(env, mbgl::util::toString(error))));
+ callback.Call(env, method, jni::Make<jni::String>(env, mbgl::util::toString(error)));
}
void OfflineManager::ListOfflineRegionsCallback::onList(jni::JNIEnv& env,
- jni::Object<FileSource> jFileSource,
- jni::Object<OfflineManager::ListOfflineRegionsCallback> callback,
+ const jni::Object<FileSource>& jFileSource,
+ const jni::Object<OfflineManager::ListOfflineRegionsCallback>& callback,
mbgl::optional<std::vector<mbgl::OfflineRegion>> regions) {
- static auto javaClass = jni::Class<OfflineManager::ListOfflineRegionsCallback>::Singleton(env);
+ static auto& javaClass = jni::Class<OfflineManager::ListOfflineRegionsCallback>::Singleton(env);
static auto method = javaClass.GetMethod<void (jni::Array<jni::Object<OfflineRegion>>)>(env, "onList");
std::size_t index = 0;
- auto jregions = jni::SeizeLocal(env, jni::Array<jni::Object<OfflineRegion>>::New(env, regions->size()));
+ auto jregions = jni::Array<jni::Object<OfflineRegion>>::New(env, regions->size());
for (auto& region : *regions) {
- jregions->Set(env, index, *jni::SeizeLocal(env, OfflineRegion::New(env, jFileSource, std::move(region))));
+ jregions.Set(env, index, OfflineRegion::New(env, jFileSource, std::move(region)));
index++;
}
- callback.Call(env, method, *jregions);
+ callback.Call(env, method, jregions);
}
// OfflineManager::CreateOfflineRegionCallback //
void OfflineManager::CreateOfflineRegionCallback::onError(jni::JNIEnv& env,
- jni::Object<OfflineManager::CreateOfflineRegionCallback> callback,
+ const jni::Object<OfflineManager::CreateOfflineRegionCallback>& callback,
std::exception_ptr error) {
- static auto javaClass = jni::Class<OfflineManager::CreateOfflineRegionCallback>::Singleton(env);
+ static auto& javaClass = jni::Class<OfflineManager::CreateOfflineRegionCallback>::Singleton(env);
static auto method = javaClass.GetMethod<void (jni::String)>(env, "onError");
- callback.Call(env, method,
- *jni::SeizeLocal(env, jni::Make<jni::String>(env, mbgl::util::toString(error))));
+ callback.Call(env, method, jni::Make<jni::String>(env, mbgl::util::toString(error)));
}
void OfflineManager::CreateOfflineRegionCallback::onCreate(jni::JNIEnv& env,
- jni::Object<FileSource> jFileSource,
- jni::Object<OfflineManager::CreateOfflineRegionCallback> callback,
+ const jni::Object<FileSource>& jFileSource,
+ const jni::Object<OfflineManager::CreateOfflineRegionCallback>& callback,
mbgl::optional<mbgl::OfflineRegion> region) {
- static auto javaClass = jni::Class<OfflineManager::CreateOfflineRegionCallback>::Singleton(env);
+ static auto& javaClass = jni::Class<OfflineManager::CreateOfflineRegionCallback>::Singleton(env);
static auto method = javaClass.GetMethod<void (jni::Object<OfflineRegion>)>(env, "onCreate");
- callback.Call(env, method,
- *jni::SeizeLocal(env, OfflineRegion::New(env, jFileSource, std::move(*region))));
+ callback.Call(env, method, OfflineRegion::New(env, jFileSource, std::move(*region)));
}
} // namespace android
diff --git a/platform/android/src/offline/offline_manager.hpp b/platform/android/src/offline/offline_manager.hpp
index 43f5045c71..21ca5ca9c1 100644
--- a/platform/android/src/offline/offline_manager.hpp
+++ b/platform/android/src/offline/offline_manager.hpp
@@ -20,11 +20,11 @@ public:
public:
static constexpr auto Name() { return "com/mapbox/mapboxsdk/offline/OfflineManager$ListOfflineRegionsCallback";}
- static void onError(jni::JNIEnv&, jni::Object<OfflineManager::ListOfflineRegionsCallback>, std::exception_ptr);
+ static void onError(jni::JNIEnv&, const jni::Object<OfflineManager::ListOfflineRegionsCallback>&, std::exception_ptr);
static void onList(jni::JNIEnv&,
- jni::Object<FileSource>,
- jni::Object<OfflineManager::ListOfflineRegionsCallback>,
+ const jni::Object<FileSource>&,
+ const jni::Object<OfflineManager::ListOfflineRegionsCallback>&,
mbgl::optional<std::vector<mbgl::OfflineRegion>>);
};
@@ -32,11 +32,11 @@ public:
public:
static constexpr auto Name() { return "com/mapbox/mapboxsdk/offline/OfflineManager$CreateOfflineRegionCallback"; }
- static void onError(jni::JNIEnv&, jni::Object<OfflineManager::CreateOfflineRegionCallback>, std::exception_ptr);
+ static void onError(jni::JNIEnv&, const jni::Object<OfflineManager::CreateOfflineRegionCallback>&, std::exception_ptr);
static void onCreate(jni::JNIEnv&,
- jni::Object<FileSource>,
- jni::Object<OfflineManager::CreateOfflineRegionCallback>,
+ const jni::Object<FileSource>&,
+ const jni::Object<OfflineManager::CreateOfflineRegionCallback>&,
mbgl::optional<mbgl::OfflineRegion>);
};
@@ -44,18 +44,18 @@ public:
static void registerNative(jni::JNIEnv&);
- OfflineManager(jni::JNIEnv&, jni::Object<FileSource>);
+ OfflineManager(jni::JNIEnv&, const jni::Object<FileSource>&);
~OfflineManager();
void setOfflineMapboxTileCountLimit(jni::JNIEnv&, jni::jlong limit);
- void listOfflineRegions(jni::JNIEnv&, jni::Object<FileSource>, jni::Object<ListOfflineRegionsCallback> callback);
+ void listOfflineRegions(jni::JNIEnv&, const jni::Object<FileSource>&, const jni::Object<ListOfflineRegionsCallback>& callback);
void createOfflineRegion(jni::JNIEnv&,
- jni::Object<FileSource> jFileSource_,
- jni::Object<OfflineRegionDefinition> definition,
- jni::Array<jni::jbyte> metadata,
- jni::Object<OfflineManager::CreateOfflineRegionCallback> callback);
+ const jni::Object<FileSource>& jFileSource_,
+ const jni::Object<OfflineRegionDefinition>& definition,
+ const jni::Array<jni::jbyte>& metadata,
+ const jni::Object<OfflineManager::CreateOfflineRegionCallback>& callback);
private:
mbgl::DefaultFileSource& fileSource;
diff --git a/platform/android/src/offline/offline_region.cpp b/platform/android/src/offline/offline_region.cpp
index 949377e221..1cd73a7c76 100644
--- a/platform/android/src/offline/offline_region.cpp
+++ b/platform/android/src/offline/offline_region.cpp
@@ -7,71 +7,62 @@
#include "offline_region_error.hpp"
#include "offline_region_status.hpp"
#include "../attach_env.hpp"
-#include "../jni/generic_global_ref_deleter.hpp"
namespace mbgl {
namespace android {
// OfflineRegion //
-OfflineRegion::OfflineRegion(jni::JNIEnv& env, jni::jlong offlineRegionPtr, jni::Object<FileSource> jFileSource)
+OfflineRegion::OfflineRegion(jni::JNIEnv& env, jni::jlong offlineRegionPtr, const jni::Object<FileSource>& jFileSource)
: region(reinterpret_cast<mbgl::OfflineRegion *>(offlineRegionPtr)),
fileSource(mbgl::android::FileSource::getDefaultFileSource(env, jFileSource)) {}
OfflineRegion::~OfflineRegion() {}
-void OfflineRegion::setOfflineRegionObserver(jni::JNIEnv& env_, jni::Object<OfflineRegion::OfflineRegionObserver> callback) {
+void OfflineRegion::setOfflineRegionObserver(jni::JNIEnv& env_, const jni::Object<OfflineRegion::OfflineRegionObserver>& callback) {
// Define the observer
class Observer : public mbgl::OfflineRegionObserver {
public:
- Observer(jni::Global<jni::Object<OfflineRegion::OfflineRegionObserver>>&& callback_)
- //TODO add a generic deleter for jni::Object
- : callback(callback_.release().Get()) {
- }
-
- ~Observer() override {
- android::UniqueEnv env = android::AttachEnv();
- env->DeleteGlobalRef(Unwrap(*callback));
+ Observer(jni::Global<jni::Object<OfflineRegion::OfflineRegionObserver>, jni::EnvAttachingDeleter> callback_)
+ : callback(std::move(callback_)) {
}
void statusChanged(mbgl::OfflineRegionStatus status) override {
// Reattach, the callback comes from a different thread
android::UniqueEnv env = android::AttachEnv();
- static auto javaClass = jni::Class<OfflineRegion::OfflineRegionObserver>::Singleton(*env);
+ static auto& javaClass = jni::Class<OfflineRegion::OfflineRegionObserver>::Singleton(*env);
static auto method = javaClass.GetMethod<void (jni::Object<OfflineRegionStatus>)>(*env, "onStatusChanged");
- callback.Call(*env, method,
- *jni::SeizeLocal(*env, OfflineRegionStatus::New(*env, status)));
+ callback.Call(*env, method, OfflineRegionStatus::New(*env, status));
}
void responseError(mbgl::Response::Error error) override {
// Reattach, the callback comes from a different thread
android::UniqueEnv env = android::AttachEnv();
- static auto javaClass = jni::Class<OfflineRegion::OfflineRegionObserver>::Singleton(*env);
+ static auto& javaClass = jni::Class<OfflineRegion::OfflineRegionObserver>::Singleton(*env);
static auto method = javaClass.GetMethod<void (jni::Object<mbgl::android::OfflineRegionError>)>(*env, "onError");
- callback.Call(*env, method,
- *jni::SeizeLocal(*env, OfflineRegionError::New(*env, error)));
+ callback.Call(*env, method, OfflineRegionError::New(*env, error));
}
void mapboxTileCountLimitExceeded(uint64_t limit) override {
// Reattach, the callback comes from a different thread
android::UniqueEnv env = android::AttachEnv();
- static auto javaClass = jni::Class<OfflineRegion::OfflineRegionObserver>::Singleton(*env);
+ static auto& javaClass = jni::Class<OfflineRegion::OfflineRegionObserver>::Singleton(*env);
static auto method = javaClass.GetMethod<void (jni::jlong)>(*env, "mapboxTileCountLimitExceeded");
callback.Call(*env, method, jlong(limit));
}
- jni::Object<OfflineRegion::OfflineRegionObserver> callback;
+ jni::Global<jni::Object<OfflineRegion::OfflineRegionObserver>, jni::EnvAttachingDeleter> callback;
};
// Set the observer
- fileSource.setOfflineRegionObserver(*region, std::make_unique<Observer>(callback.NewGlobalRef(env_)));
+ fileSource.setOfflineRegionObserver(*region, std::make_unique<Observer>(jni::NewGlobal<jni::EnvAttachingDeleter>(env_, callback)));
}
void OfflineRegion::setOfflineRegionDownloadState(jni::JNIEnv&, jni::jint jState) {
@@ -92,85 +83,84 @@ void OfflineRegion::setOfflineRegionDownloadState(jni::JNIEnv&, jni::jint jState
fileSource.setOfflineRegionDownloadState(*region, state);
}
-void OfflineRegion::getOfflineRegionStatus(jni::JNIEnv& env_, jni::Object<OfflineRegionStatusCallback> callback_) {
+void OfflineRegion::getOfflineRegionStatus(jni::JNIEnv& env_, const jni::Object<OfflineRegionStatusCallback>& callback_) {
+ auto globalCallback = jni::NewGlobal<jni::EnvAttachingDeleter>(env_, callback_);
fileSource.getOfflineRegionStatus(*region, [
//Ensure the object is not gc'd in the meanwhile
- callback = std::shared_ptr<jni::jobject>(callback_.NewGlobalRef(env_).release().Get(), GenericGlobalRefDeleter())
+ callback = std::make_shared<decltype(globalCallback)>(std::move(globalCallback))
](mbgl::expected<mbgl::OfflineRegionStatus, std::exception_ptr> status) mutable {
// Reattach, the callback comes from a different thread
android::UniqueEnv env = android::AttachEnv();
if (status) {
- OfflineRegionStatusCallback::onStatus(*env, jni::Object<OfflineRegionStatusCallback>(*callback), std::move(*status));
+ OfflineRegionStatusCallback::onStatus(*env, *callback, std::move(*status));
} else {
- OfflineRegionStatusCallback::onError(*env, jni::Object<OfflineRegionStatusCallback>(*callback), status.error());
+ OfflineRegionStatusCallback::onError(*env, *callback, status.error());
}
});
}
-void OfflineRegion::deleteOfflineRegion(jni::JNIEnv& env_, jni::Object<OfflineRegionDeleteCallback> callback_) {
- // Delete
+void OfflineRegion::deleteOfflineRegion(jni::JNIEnv& env_, const jni::Object<OfflineRegionDeleteCallback>& callback_) {
+ auto globalCallback = jni::NewGlobal<jni::EnvAttachingDeleter>(env_, callback_);
+
fileSource.deleteOfflineRegion(std::move(*region), [
//Ensure the object is not gc'd in the meanwhile
- callback = std::shared_ptr<jni::jobject>(callback_.NewGlobalRef(env_).release().Get(), GenericGlobalRefDeleter())
+ callback = std::make_shared<decltype(globalCallback)>(std::move(globalCallback))
](std::exception_ptr error) mutable {
// Reattach, the callback comes from a different thread
android::UniqueEnv env = android::AttachEnv();
if (error) {
- OfflineRegionDeleteCallback::onError(*env, jni::Object<OfflineRegionDeleteCallback>(*callback), error);
+ OfflineRegionDeleteCallback::onError(*env, *callback, error);
} else {
- OfflineRegionDeleteCallback::onDelete(*env, jni::Object<OfflineRegionDeleteCallback>(*callback));
+ OfflineRegionDeleteCallback::onDelete(*env, *callback);
}
});
}
-void OfflineRegion::updateOfflineRegionMetadata(jni::JNIEnv& env_, jni::Array<jni::jbyte> jMetadata, jni::Object<OfflineRegionUpdateMetadataCallback> callback_) {
-
- // Convert
+void OfflineRegion::updateOfflineRegionMetadata(jni::JNIEnv& env_, const jni::Array<jni::jbyte>& jMetadata, const jni::Object<OfflineRegionUpdateMetadataCallback>& callback_) {
auto metadata = OfflineRegion::metadata(env_, jMetadata);
+ auto globalCallback = jni::NewGlobal<jni::EnvAttachingDeleter>(env_, callback_);
fileSource.updateOfflineMetadata(region->getID(), metadata, [
//Ensure the object is not gc'd in the meanwhile
- callback = std::shared_ptr<jni::jobject>(callback_.NewGlobalRef(env_).release().Get(), GenericGlobalRefDeleter())
+ callback = std::make_shared<decltype(globalCallback)>(std::move(globalCallback))
](mbgl::expected<mbgl::OfflineRegionMetadata, std::exception_ptr> data) mutable {
// Reattach, the callback comes from a different thread
android::UniqueEnv env = android::AttachEnv();
if (data) {
- OfflineRegionUpdateMetadataCallback::onUpdate(*env, jni::Object<OfflineRegionUpdateMetadataCallback>(*callback), std::move(*data));
+ OfflineRegionUpdateMetadataCallback::onUpdate(*env, *callback, std::move(*data));
} else {
- OfflineRegionUpdateMetadataCallback::onError(*env, jni::Object<OfflineRegionUpdateMetadataCallback>(*callback), data.error());
+ OfflineRegionUpdateMetadataCallback::onError(*env, *callback, data.error());
}
});
}
-jni::Object<OfflineRegion> OfflineRegion::New(jni::JNIEnv& env, jni::Object<FileSource> jFileSource, mbgl::OfflineRegion region) {
+jni::Local<jni::Object<OfflineRegion>> OfflineRegion::New(jni::JNIEnv& env, const jni::Object<FileSource>& jFileSource, mbgl::OfflineRegion region) {
// Definition
- auto definition = jni::SeizeLocal(env, region.getDefinition().match(
+ auto definition = region.getDefinition().match(
[&](const mbgl::OfflineTilePyramidRegionDefinition def) {
- return jni::Object<OfflineRegionDefinition>(
- *OfflineTilePyramidRegionDefinition::New(env, def));
+ return OfflineTilePyramidRegionDefinition::New(env, def);
}, [&](const mbgl::OfflineGeometryRegionDefinition def) {
- return jni::Object<OfflineRegionDefinition>(
- *OfflineGeometryRegionDefinition::New(env, def));
- }));
+ return OfflineGeometryRegionDefinition::New(env, def);
+ });
// Create region java object
- static auto javaClass = jni::Class<OfflineRegion>::Singleton(env);
+ static auto& javaClass = jni::Class<OfflineRegion>::Singleton(env);
static auto constructor = javaClass.GetConstructor<jni::jlong, jni::Object<FileSource>, jni::jlong, jni::Object<OfflineRegionDefinition>, jni::Array<jni::jbyte>>(env);
return javaClass.New(env, constructor,
reinterpret_cast<jni::jlong>(new mbgl::OfflineRegion(std::move(region))), //Copy a region to the heap
jFileSource,
jni::jlong(region.getID()),
- *definition,
- *jni::SeizeLocal(env, OfflineRegion::metadata(env, region.getMetadata())));
+ definition,
+ OfflineRegion::metadata(env, region.getMetadata()));
}
-jni::Array<jni::jbyte> OfflineRegion::metadata(jni::JNIEnv& env, mbgl::OfflineRegionMetadata metadata_) {
+jni::Local<jni::Array<jni::jbyte>> OfflineRegion::metadata(jni::JNIEnv& env, mbgl::OfflineRegionMetadata metadata_) {
std::vector<jni::jbyte> convertedMetadata(metadata_.begin(), metadata_.end());
std::size_t length = static_cast<std::size_t>(convertedMetadata.size());
auto metadata = jni::Array<jni::jbyte>::New(env, length);
@@ -178,7 +168,7 @@ jni::Array<jni::jbyte> OfflineRegion::metadata(jni::JNIEnv& env, mbgl::OfflineRe
return metadata;
}
-mbgl::OfflineRegionMetadata OfflineRegion::metadata(jni::JNIEnv& env, jni::Array<jni::jbyte> metadata_) {
+mbgl::OfflineRegionMetadata OfflineRegion::metadata(jni::JNIEnv& env, const jni::Array<jni::jbyte>& metadata_) {
std::size_t length = metadata_.Length(env);
auto metadata_tmp = std::vector<jni::jbyte>();
metadata_tmp.resize(length);
@@ -193,12 +183,12 @@ void OfflineRegion::registerNative(jni::JNIEnv& env) {
jni::Class<OfflineRegionDeleteCallback>::Singleton(env);
jni::Class<OfflineRegionUpdateMetadataCallback>::Singleton(env);
- static auto javaClass = jni::Class<OfflineRegion>::Singleton(env);
+ static auto& javaClass = jni::Class<OfflineRegion>::Singleton(env);
#define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
jni::RegisterNativePeer<OfflineRegion>( env, javaClass, "nativePtr",
- std::make_unique<OfflineRegion, JNIEnv&, jni::jlong, jni::Object<FileSource>>,
+ jni::MakePeer<OfflineRegion, jni::jlong, const jni::Object<FileSource>&>,
"initialize",
"finalize",
METHOD(&OfflineRegion::setOfflineRegionObserver, "setOfflineRegionObserver"),
@@ -214,40 +204,37 @@ void OfflineRegion::registerNative(jni::JNIEnv& env) {
// OfflineRegionStatusCallback //
void OfflineRegion::OfflineRegionStatusCallback::onError(jni::JNIEnv& env,
- jni::Object<OfflineRegion::OfflineRegionStatusCallback> callback,
+ const jni::Object<OfflineRegion::OfflineRegionStatusCallback>& callback,
std::exception_ptr error) {
- static auto javaClass = jni::Class<OfflineRegion::OfflineRegionStatusCallback>::Singleton(env);
+ static auto& javaClass = jni::Class<OfflineRegion::OfflineRegionStatusCallback>::Singleton(env);
static auto method = javaClass.GetMethod<void (jni::String)>(env, "onError");
- callback.Call(env, method,
- *jni::SeizeLocal(env, jni::Make<jni::String>(env, mbgl::util::toString(error))));
+ callback.Call(env, method, jni::Make<jni::String>(env, mbgl::util::toString(error)));
}
void OfflineRegion::OfflineRegionStatusCallback::onStatus(jni::JNIEnv& env,
- jni::Object<OfflineRegion::OfflineRegionStatusCallback> callback,
+ const jni::Object<OfflineRegion::OfflineRegionStatusCallback>& callback,
mbgl::optional<mbgl::OfflineRegionStatus> status) {
- static auto javaClass = jni::Class<OfflineRegion::OfflineRegionStatusCallback>::Singleton(env);
+ static auto& javaClass = jni::Class<OfflineRegion::OfflineRegionStatusCallback>::Singleton(env);
static auto method = javaClass.GetMethod<void (jni::Object<OfflineRegionStatus>)>(env, "onStatus");
- callback.Call(env, method,
- *jni::SeizeLocal(env, OfflineRegionStatus::New(env, std::move(*status))));
+ callback.Call(env, method, OfflineRegionStatus::New(env, std::move(*status)));
}
// OfflineRegionDeleteCallback //
void OfflineRegion::OfflineRegionDeleteCallback::onError(jni::JNIEnv& env,
- jni::Object<OfflineRegion::OfflineRegionDeleteCallback> callback,
+ const jni::Object<OfflineRegion::OfflineRegionDeleteCallback>& callback,
std::exception_ptr error) {
- static auto javaClass = jni::Class<OfflineRegion::OfflineRegionDeleteCallback>::Singleton(env);
+ static auto& javaClass = jni::Class<OfflineRegion::OfflineRegionDeleteCallback>::Singleton(env);
static auto method = javaClass.GetMethod<void (jni::String)>(env, "onError");
- callback.Call(env, method,
- *jni::SeizeLocal(env, jni::Make<jni::String>(env, mbgl::util::toString(error))));
+ callback.Call(env, method, jni::Make<jni::String>(env, mbgl::util::toString(error)));
}
-void OfflineRegion::OfflineRegionDeleteCallback::onDelete(jni::JNIEnv& env, jni::Object<OfflineRegion::OfflineRegionDeleteCallback> callback) {
+void OfflineRegion::OfflineRegionDeleteCallback::onDelete(jni::JNIEnv& env, const jni::Object<OfflineRegion::OfflineRegionDeleteCallback>& callback) {
// Trigger callback
- static auto javaClass = jni::Class<OfflineRegion::OfflineRegionDeleteCallback>::Singleton(env);
+ static auto& javaClass = jni::Class<OfflineRegion::OfflineRegionDeleteCallback>::Singleton(env);
static auto method = javaClass.GetMethod<void ()>(env, "onDelete");
callback.Call(env, method);
@@ -256,23 +243,21 @@ void OfflineRegion::OfflineRegionDeleteCallback::onDelete(jni::JNIEnv& env, jni:
// OfflineRegionUpdateMetadataCallback //
void OfflineRegion::OfflineRegionUpdateMetadataCallback::onError(jni::JNIEnv& env,
- jni::Object<OfflineRegion::OfflineRegionUpdateMetadataCallback> callback,
+ const jni::Object<OfflineRegion::OfflineRegionUpdateMetadataCallback>& callback,
std::exception_ptr error) {
- static auto javaClass = jni::Class<OfflineRegion::OfflineRegionUpdateMetadataCallback>::Singleton(env);
+ static auto& javaClass = jni::Class<OfflineRegion::OfflineRegionUpdateMetadataCallback>::Singleton(env);
static auto method = javaClass.GetMethod<void (jni::String)>(env, "onError");
- callback.Call(env, method,
- *jni::SeizeLocal(env, jni::Make<jni::String>(env, mbgl::util::toString(error))));
+ callback.Call(env, method, jni::Make<jni::String>(env, mbgl::util::toString(error)));
}
void OfflineRegion::OfflineRegionUpdateMetadataCallback::onUpdate(jni::JNIEnv& env,
- jni::Object<OfflineRegion::OfflineRegionUpdateMetadataCallback> callback,
+ const jni::Object<OfflineRegion::OfflineRegionUpdateMetadataCallback>& callback,
mbgl::optional<mbgl::OfflineRegionMetadata> metadata) {
- static auto javaClass = jni::Class<OfflineRegion::OfflineRegionUpdateMetadataCallback>::Singleton(env);
+ static auto& javaClass = jni::Class<OfflineRegion::OfflineRegionUpdateMetadataCallback>::Singleton(env);
static auto method = javaClass.GetMethod<void (jni::Array<jni::jbyte>)>(env, "onUpdate");
- callback.Call(env, method,
- *jni::SeizeLocal(env, OfflineRegion::metadata(env, std::move(*metadata))));
+ callback.Call(env, method, OfflineRegion::metadata(env, std::move(*metadata)));
}
} // namespace android
diff --git a/platform/android/src/offline/offline_region.hpp b/platform/android/src/offline/offline_region.hpp
index 11aecb82a9..49fa0c8ff8 100644
--- a/platform/android/src/offline/offline_region.hpp
+++ b/platform/android/src/offline/offline_region.hpp
@@ -21,10 +21,10 @@ public:
public:
static constexpr auto Name() { return "com/mapbox/mapboxsdk/offline/OfflineRegion$OfflineRegionStatusCallback"; };
- static void onError(jni::JNIEnv&, jni::Object<OfflineRegionStatusCallback>, std::exception_ptr);
+ static void onError(jni::JNIEnv&, const jni::Object<OfflineRegionStatusCallback>&, std::exception_ptr);
static void onStatus(jni::JNIEnv&,
- jni::Object<OfflineRegionStatusCallback>,
+ const jni::Object<OfflineRegionStatusCallback>&,
mbgl::optional<mbgl::OfflineRegionStatus>);
};
@@ -32,43 +32,43 @@ public:
public:
static constexpr auto Name() { return "com/mapbox/mapboxsdk/offline/OfflineRegion$OfflineRegionDeleteCallback"; };
- static void onError(jni::JNIEnv&, jni::Object<OfflineRegionDeleteCallback>, std::exception_ptr);
+ static void onError(jni::JNIEnv&, const jni::Object<OfflineRegionDeleteCallback>&, std::exception_ptr);
- static void onDelete(jni::JNIEnv&, jni::Object<OfflineRegionDeleteCallback>);
+ static void onDelete(jni::JNIEnv&, const jni::Object<OfflineRegionDeleteCallback>&);
};
class OfflineRegionUpdateMetadataCallback {
public:
static constexpr auto Name() { return "com/mapbox/mapboxsdk/offline/OfflineRegion$OfflineRegionUpdateMetadataCallback"; };
- static void onError(jni::JNIEnv&, jni::Object<OfflineRegionUpdateMetadataCallback>, std::exception_ptr);
+ static void onError(jni::JNIEnv&, const jni::Object<OfflineRegionUpdateMetadataCallback>&, std::exception_ptr);
static void onUpdate(jni::JNIEnv&,
- jni::Object<OfflineRegionUpdateMetadataCallback>,
+ const jni::Object<OfflineRegionUpdateMetadataCallback>&,
mbgl::optional<mbgl::OfflineRegionMetadata>);
};
static constexpr auto Name() { return "com/mapbox/mapboxsdk/offline/OfflineRegion"; };
- OfflineRegion(jni::JNIEnv&, jni::jlong, jni::Object<FileSource>);
+ OfflineRegion(jni::JNIEnv&, jni::jlong, const jni::Object<FileSource>&);
~OfflineRegion();
- void setOfflineRegionObserver(jni::JNIEnv&, jni::Object<OfflineRegion::OfflineRegionObserver>);
+ void setOfflineRegionObserver(jni::JNIEnv&, const jni::Object<OfflineRegion::OfflineRegionObserver>&);
void setOfflineRegionDownloadState(jni::JNIEnv&, jni::jint);
- void getOfflineRegionStatus(jni::JNIEnv&, jni::Object<OfflineRegion::OfflineRegionStatusCallback>);
+ void getOfflineRegionStatus(jni::JNIEnv&, const jni::Object<OfflineRegion::OfflineRegionStatusCallback>&);
- void deleteOfflineRegion(jni::JNIEnv&, jni::Object<OfflineRegionDeleteCallback>);
+ void deleteOfflineRegion(jni::JNIEnv&, const jni::Object<OfflineRegionDeleteCallback>&);
- void updateOfflineRegionMetadata(jni::JNIEnv&, jni::Array<jni::jbyte>, jni::Object<OfflineRegionUpdateMetadataCallback>);
+ void updateOfflineRegionMetadata(jni::JNIEnv&, const jni::Array<jni::jbyte>&, const jni::Object<OfflineRegionUpdateMetadataCallback>&);
- static jni::Object<OfflineRegion> New(jni::JNIEnv&, jni::Object<FileSource>, mbgl::OfflineRegion);
+ static jni::Local<jni::Object<OfflineRegion>> New(jni::JNIEnv&, const jni::Object<FileSource>&, mbgl::OfflineRegion);
- static jni::Array<jni::jbyte> metadata(jni::JNIEnv&, mbgl::OfflineRegionMetadata);
+ static jni::Local<jni::Array<jni::jbyte>> metadata(jni::JNIEnv&, mbgl::OfflineRegionMetadata);
- static mbgl::OfflineRegionMetadata metadata(jni::JNIEnv&, jni::Array<jni::jbyte>);
+ static mbgl::OfflineRegionMetadata metadata(jni::JNIEnv&, const jni::Array<jni::jbyte>&);
static void registerNative(jni::JNIEnv&);
diff --git a/platform/android/src/offline/offline_region_definition.cpp b/platform/android/src/offline/offline_region_definition.cpp
index 2a69181f5b..23e5b7466b 100644
--- a/platform/android/src/offline/offline_region_definition.cpp
+++ b/platform/android/src/offline/offline_region_definition.cpp
@@ -15,11 +15,11 @@ void OfflineRegionDefinition::registerNative(jni::JNIEnv& env) {
}
mbgl::OfflineRegionDefinition OfflineRegionDefinition::getDefinition(JNIEnv& env,
- jni::Object<OfflineRegionDefinition> jDefinition) {
+ const jni::Object<OfflineRegionDefinition>& jDefinition) {
if (jDefinition.IsInstanceOf(env, jni::Class<OfflineTilePyramidRegionDefinition>::Singleton(env))) {
- return OfflineTilePyramidRegionDefinition::getDefinition(env, jni::Object<OfflineTilePyramidRegionDefinition>(*jDefinition));
+ return OfflineTilePyramidRegionDefinition::getDefinition(env, jni::Cast(env, jni::Class<OfflineTilePyramidRegionDefinition>::Singleton(env), jDefinition));
} else if (jDefinition.IsInstanceOf(env, jni::Class<OfflineGeometryRegionDefinition>::Singleton(env))) {
- return OfflineGeometryRegionDefinition::getDefinition(env, jni::Object<OfflineGeometryRegionDefinition>(*jDefinition));
+ return OfflineGeometryRegionDefinition::getDefinition(env, jni::Cast(env, jni::Class<OfflineGeometryRegionDefinition>::Singleton(env), jDefinition));
}
throw std::runtime_error("Unknown offline region definition java class");
@@ -27,21 +27,21 @@ mbgl::OfflineRegionDefinition OfflineRegionDefinition::getDefinition(JNIEnv& env
// OfflineTilePyramidRegionDefinition //
-jni::Object<OfflineTilePyramidRegionDefinition> OfflineTilePyramidRegionDefinition::New(jni::JNIEnv& env, const mbgl::OfflineTilePyramidRegionDefinition& definition) {
- static auto javaClass = jni::Class<OfflineTilePyramidRegionDefinition>::Singleton(env);
+jni::Local<jni::Object<OfflineRegionDefinition>> OfflineTilePyramidRegionDefinition::New(jni::JNIEnv& env, const mbgl::OfflineTilePyramidRegionDefinition& definition) {
+ static auto& javaClass = jni::Class<OfflineTilePyramidRegionDefinition>::Singleton(env);
static auto constructor = javaClass.GetConstructor<jni::String, jni::Object<LatLngBounds>, jni::jdouble, jni::jdouble, jni::jfloat>(env);
return javaClass.New(env, constructor,
- *jni::SeizeLocal(env, jni::Make<jni::String>(env, definition.styleURL)),
- *jni::SeizeLocal(env, LatLngBounds::New(env, definition.bounds)),
+ jni::Make<jni::String>(env, definition.styleURL),
+ LatLngBounds::New(env, definition.bounds),
definition.minZoom,
definition.maxZoom,
definition.pixelRatio);
}
-mbgl::OfflineTilePyramidRegionDefinition OfflineTilePyramidRegionDefinition::getDefinition(jni::JNIEnv& env, jni::Object<OfflineTilePyramidRegionDefinition> jDefinition) {
+mbgl::OfflineTilePyramidRegionDefinition OfflineTilePyramidRegionDefinition::getDefinition(jni::JNIEnv& env, const jni::Object<OfflineTilePyramidRegionDefinition>& jDefinition) {
// Field references
- static auto javaClass = jni::Class<OfflineTilePyramidRegionDefinition>::Singleton(env);
+ static auto& javaClass = jni::Class<OfflineTilePyramidRegionDefinition>::Singleton(env);
static auto styleURLF = javaClass.GetField<jni::String>(env, "styleURL");
static auto boundsF = javaClass.GetField<jni::Object<LatLngBounds>>(env, "bounds");
static auto minZoomF = javaClass.GetField<jni::jdouble>(env, "minZoom");
@@ -49,8 +49,8 @@ mbgl::OfflineTilePyramidRegionDefinition OfflineTilePyramidRegionDefinition::get
static auto pixelRatioF = javaClass.GetField<jni::jfloat>(env, "pixelRatio");
return mbgl::OfflineTilePyramidRegionDefinition(
- jni::Make<std::string>(env, *jni::SeizeLocal(env, jDefinition.Get(env, styleURLF))),
- LatLngBounds::getLatLngBounds(env, *jni::SeizeLocal(env, jDefinition.Get(env, boundsF))),
+ jni::Make<std::string>(env, jDefinition.Get(env, styleURLF)),
+ LatLngBounds::getLatLngBounds(env, jDefinition.Get(env, boundsF)),
jDefinition.Get(env, minZoomF),
jDefinition.Get(env, maxZoomF),
jDefinition.Get(env, pixelRatioF)
@@ -63,21 +63,21 @@ void OfflineTilePyramidRegionDefinition::registerNative(jni::JNIEnv& env) {
// OfflineGeometryRegionDefinition //
-jni::Object<OfflineGeometryRegionDefinition> OfflineGeometryRegionDefinition::New(jni::JNIEnv& env, const mbgl::OfflineGeometryRegionDefinition& definition) {
- static auto javaClass = jni::Class<OfflineGeometryRegionDefinition>::Singleton(env);
+jni::Local<jni::Object<OfflineRegionDefinition>> OfflineGeometryRegionDefinition::New(jni::JNIEnv& env, const mbgl::OfflineGeometryRegionDefinition& definition) {
+ static auto& javaClass = jni::Class<OfflineGeometryRegionDefinition>::Singleton(env);
static auto constructor = javaClass.GetConstructor<jni::String, jni::Object<geojson::Geometry>, jni::jdouble, jni::jdouble, jni::jfloat>(env);
return javaClass.New(env, constructor,
- *jni::SeizeLocal(env, jni::Make<jni::String>(env, definition.styleURL)),
- *jni::SeizeLocal(env, geojson::Geometry::New(env, definition.geometry)),
+ jni::Make<jni::String>(env, definition.styleURL),
+ geojson::Geometry::New(env, definition.geometry),
definition.minZoom,
definition.maxZoom,
definition.pixelRatio);
}
-mbgl::OfflineGeometryRegionDefinition OfflineGeometryRegionDefinition::getDefinition(jni::JNIEnv& env, jni::Object<OfflineGeometryRegionDefinition> jDefinition) {
+mbgl::OfflineGeometryRegionDefinition OfflineGeometryRegionDefinition::getDefinition(jni::JNIEnv& env, const jni::Object<OfflineGeometryRegionDefinition>& jDefinition) {
// Field references
- static auto javaClass = jni::Class<OfflineGeometryRegionDefinition>::Singleton(env);
+ static auto& javaClass = jni::Class<OfflineGeometryRegionDefinition>::Singleton(env);
static auto styleURLF = javaClass.GetField<jni::String>(env, "styleURL");
static auto geometryF = javaClass.GetField<jni::Object<geojson::Geometry>>(env, "geometry");
static auto minZoomF = javaClass.GetField<jni::jdouble>(env, "minZoom");
@@ -85,8 +85,8 @@ mbgl::OfflineGeometryRegionDefinition OfflineGeometryRegionDefinition::getDefini
static auto pixelRatioF = javaClass.GetField<jni::jfloat>(env, "pixelRatio");
return mbgl::OfflineGeometryRegionDefinition(
- jni::Make<std::string>(env, *jni::SeizeLocal(env, jDefinition.Get(env, styleURLF))),
- geojson::Geometry::convert(env, *jni::SeizeLocal(env, jDefinition.Get(env, geometryF))),
+ jni::Make<std::string>(env, jDefinition.Get(env, styleURLF)),
+ geojson::Geometry::convert(env, jDefinition.Get(env, geometryF)),
jDefinition.Get(env, minZoomF),
jDefinition.Get(env, maxZoomF),
jDefinition.Get(env, pixelRatioF)
diff --git a/platform/android/src/offline/offline_region_definition.hpp b/platform/android/src/offline/offline_region_definition.hpp
index 853cc833bf..827fac0a80 100644
--- a/platform/android/src/offline/offline_region_definition.hpp
+++ b/platform/android/src/offline/offline_region_definition.hpp
@@ -12,27 +12,29 @@ public:
static void registerNative(jni::JNIEnv&);
- static mbgl::OfflineRegionDefinition getDefinition(JNIEnv& env, jni::Object<OfflineRegionDefinition> jDefinition);
+ static mbgl::OfflineRegionDefinition getDefinition(JNIEnv& env, const jni::Object<OfflineRegionDefinition>& jDefinition);
};
-class OfflineTilePyramidRegionDefinition: public OfflineRegionDefinition {
+class OfflineTilePyramidRegionDefinition {
public:
+ using SuperTag = OfflineRegionDefinition;
static constexpr auto Name() { return "com/mapbox/mapboxsdk/offline/OfflineTilePyramidRegionDefinition"; };
- static jni::Object<OfflineTilePyramidRegionDefinition> New(jni::JNIEnv&, const mbgl::OfflineTilePyramidRegionDefinition&);
+ static jni::Local<jni::Object<OfflineRegionDefinition>> New(jni::JNIEnv&, const mbgl::OfflineTilePyramidRegionDefinition&);
- static mbgl::OfflineTilePyramidRegionDefinition getDefinition(jni::JNIEnv&, jni::Object<OfflineTilePyramidRegionDefinition>);
+ static mbgl::OfflineTilePyramidRegionDefinition getDefinition(jni::JNIEnv&, const jni::Object<OfflineTilePyramidRegionDefinition>&);
static void registerNative(jni::JNIEnv&);
};
-class OfflineGeometryRegionDefinition: public OfflineRegionDefinition {
+class OfflineGeometryRegionDefinition {
public:
+ using SuperTag = OfflineRegionDefinition;
static constexpr auto Name() { return "com/mapbox/mapboxsdk/offline/OfflineGeometryRegionDefinition"; };
- static jni::Object<OfflineGeometryRegionDefinition> New(jni::JNIEnv&, const mbgl::OfflineGeometryRegionDefinition&);
+ static jni::Local<jni::Object<OfflineRegionDefinition>> New(jni::JNIEnv&, const mbgl::OfflineGeometryRegionDefinition&);
- static mbgl::OfflineGeometryRegionDefinition getDefinition(jni::JNIEnv&, jni::Object<OfflineGeometryRegionDefinition>);
+ static mbgl::OfflineGeometryRegionDefinition getDefinition(jni::JNIEnv&, const jni::Object<OfflineGeometryRegionDefinition>&);
static void registerNative(jni::JNIEnv&);
};
diff --git a/platform/android/src/offline/offline_region_error.cpp b/platform/android/src/offline/offline_region_error.cpp
index 02432757d4..199bbafa6b 100644
--- a/platform/android/src/offline/offline_region_error.cpp
+++ b/platform/android/src/offline/offline_region_error.cpp
@@ -3,7 +3,7 @@
namespace mbgl {
namespace android {
-jni::Object<OfflineRegionError> OfflineRegionError::New(jni::JNIEnv& env, mbgl::Response::Error error) {
+jni::Local<jni::Object<OfflineRegionError>> OfflineRegionError::New(jni::JNIEnv& env, mbgl::Response::Error error) {
// Handle the value of reason independently of the underlying int value
std::string reason;
@@ -28,12 +28,12 @@ jni::Object<OfflineRegionError> OfflineRegionError::New(jni::JNIEnv& env, mbgl::
break;
}
- static auto javaClass = jni::Class<OfflineRegionError>::Singleton(env);
+ static auto& javaClass = jni::Class<OfflineRegionError>::Singleton(env);
static auto constructor = javaClass.GetConstructor<jni::String, jni::String>(env);
return javaClass.New(env, constructor,
- *jni::SeizeLocal(env, jni::Make<jni::String>(env, reason)),
- *jni::SeizeLocal(env, jni::Make<jni::String>(env, error.message)));
+ jni::Make<jni::String>(env, reason),
+ jni::Make<jni::String>(env, error.message));
}
void OfflineRegionError::registerNative(jni::JNIEnv& env) {
diff --git a/platform/android/src/offline/offline_region_error.hpp b/platform/android/src/offline/offline_region_error.hpp
index c51f08a745..151e05ab19 100644
--- a/platform/android/src/offline/offline_region_error.hpp
+++ b/platform/android/src/offline/offline_region_error.hpp
@@ -10,7 +10,7 @@ class OfflineRegionError {
public:
static constexpr auto Name() { return "com/mapbox/mapboxsdk/offline/OfflineRegionError"; };
- static jni::Object<OfflineRegionError> New(jni::JNIEnv&, mbgl::Response::Error);
+ static jni::Local<jni::Object<OfflineRegionError>> New(jni::JNIEnv&, mbgl::Response::Error);
static void registerNative(jni::JNIEnv&);
};
diff --git a/platform/android/src/offline/offline_region_status.cpp b/platform/android/src/offline/offline_region_status.cpp
index 0a415bdb5f..5dd9f20a7f 100644
--- a/platform/android/src/offline/offline_region_status.cpp
+++ b/platform/android/src/offline/offline_region_status.cpp
@@ -3,7 +3,7 @@
namespace mbgl {
namespace android {
-jni::Object<OfflineRegionStatus> OfflineRegionStatus::New(jni::JNIEnv& env, mbgl::OfflineRegionStatus status) {
+jni::Local<jni::Object<OfflineRegionStatus>> OfflineRegionStatus::New(jni::JNIEnv& env, mbgl::OfflineRegionStatus status) {
// Convert to jint
jint downloadState;
@@ -17,7 +17,7 @@ jni::Object<OfflineRegionStatus> OfflineRegionStatus::New(jni::JNIEnv& env, mbgl
}
// Create java object
- static auto javaClass = jni::Class<OfflineRegionStatus>::Singleton(env);
+ static auto& javaClass = jni::Class<OfflineRegionStatus>::Singleton(env);
static auto constructor = javaClass.GetConstructor<jint, jlong, jlong, jlong, jlong, jlong, jboolean>(env);
return javaClass.New(env, constructor,
downloadState,
diff --git a/platform/android/src/offline/offline_region_status.hpp b/platform/android/src/offline/offline_region_status.hpp
index 9f638e1093..9ef48ec357 100644
--- a/platform/android/src/offline/offline_region_status.hpp
+++ b/platform/android/src/offline/offline_region_status.hpp
@@ -10,7 +10,7 @@ class OfflineRegionStatus {
public:
static constexpr auto Name() { return "com/mapbox/mapboxsdk/offline/OfflineRegionStatus"; };
- static jni::Object<OfflineRegionStatus> New(jni::JNIEnv&, mbgl::OfflineRegionStatus status);
+ static jni::Local<jni::Object<OfflineRegionStatus>> New(jni::JNIEnv&, mbgl::OfflineRegionStatus status);
static void registerNative(jni::JNIEnv&);
};
diff --git a/platform/android/src/snapshotter/map_snapshot.cpp b/platform/android/src/snapshotter/map_snapshot.cpp
index d626ae68b7..1650f72dc7 100644
--- a/platform/android/src/snapshotter/map_snapshot.cpp
+++ b/platform/android/src/snapshotter/map_snapshot.cpp
@@ -16,18 +16,18 @@ MapSnapshot::MapSnapshot(float pixelRatio_, MapSnapshot::PointForFn pointForFn_,
MapSnapshot::~MapSnapshot() = default;
-jni::Object<PointF> MapSnapshot::pixelForLatLng(jni::JNIEnv& env, jni::Object<LatLng> jLatLng) {
+jni::Local<jni::Object<PointF>> MapSnapshot::pixelForLatLng(jni::JNIEnv& env, jni::Object<LatLng>& jLatLng) {
ScreenCoordinate point = pointForFn(LatLng::getLatLng(env, jLatLng));
return PointF::New(env, point.x * pixelRatio, point.y * pixelRatio);
}
-jni::Object<LatLng> MapSnapshot::latLngForPixel(jni::JNIEnv& env, jni::Object<PointF>jPoint) {
+jni::Local<jni::Object<LatLng>> MapSnapshot::latLngForPixel(jni::JNIEnv& env, jni::Object<PointF>& jPoint) {
return LatLng::New(env, latLngForFn(PointF::getScreenCoordinate(env, jPoint)));
}
// Static methods //
-jni::Object<MapSnapshot> MapSnapshot::New(JNIEnv& env,
+jni::Local<jni::Object<MapSnapshot>> MapSnapshot::New(JNIEnv& env,
PremultipliedImage&& image,
float pixelRatio,
std::vector<std::string> attributions,
@@ -38,7 +38,7 @@ jni::Object<MapSnapshot> MapSnapshot::New(JNIEnv& env,
auto bitmap = Bitmap::CreateBitmap(env, std::move(image));
// Create the Mapsnapshot peers
- static auto javaClass = jni::Class<MapSnapshot>::Singleton(env);
+ static auto& javaClass = jni::Class<MapSnapshot>::Singleton(env);
static auto constructor = javaClass.GetConstructor<jni::jlong, jni::Object<Bitmap>, jni::Array<jni::String>, jni::jboolean>(env);
auto nativePeer = std::make_unique<MapSnapshot>(pixelRatio, pointForFn, latLngForFn);
return javaClass.New(env, constructor, reinterpret_cast<jlong>(nativePeer.release()), bitmap, conversion::toArray(env, attributions), (jni::jboolean) showLogo);
@@ -46,7 +46,7 @@ jni::Object<MapSnapshot> MapSnapshot::New(JNIEnv& env,
void MapSnapshot::registerNative(jni::JNIEnv& env) {
// Lookup the class
- static auto javaClass = jni::Class<MapSnapshot>::Singleton(env);
+ static auto& javaClass = jni::Class<MapSnapshot>::Singleton(env);
#define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
diff --git a/platform/android/src/snapshotter/map_snapshot.hpp b/platform/android/src/snapshotter/map_snapshot.hpp
index 3cd293b621..6b82d02835 100644
--- a/platform/android/src/snapshotter/map_snapshot.hpp
+++ b/platform/android/src/snapshotter/map_snapshot.hpp
@@ -23,7 +23,7 @@ public:
static void registerNative(jni::JNIEnv&);
- static jni::Object<MapSnapshot> New(JNIEnv& env,
+ static jni::Local<jni::Object<MapSnapshot>> New(JNIEnv& env,
PremultipliedImage&& image,
float pixelRatio,
std::vector<std::string> attributions,
@@ -35,8 +35,8 @@ public:
MapSnapshot(float pixelRatio, PointForFn, LatLngForFn);
~MapSnapshot();
- jni::Object<PointF> pixelForLatLng(jni::JNIEnv&, jni::Object<LatLng>);
- jni::Object<LatLng> latLngForPixel(jni::JNIEnv&, jni::Object<PointF>);
+ jni::Local<jni::Object<PointF>> pixelForLatLng(jni::JNIEnv&, jni::Object<LatLng>&);
+ jni::Local<jni::Object<LatLng>> latLngForPixel(jni::JNIEnv&, jni::Object<PointF>&);
private:
float pixelRatio;
diff --git a/platform/android/src/snapshotter/map_snapshotter.cpp b/platform/android/src/snapshotter/map_snapshotter.cpp
index 4df0749aa0..e2e01f4e38 100644
--- a/platform/android/src/snapshotter/map_snapshotter.cpp
+++ b/platform/android/src/snapshotter/map_snapshotter.cpp
@@ -14,18 +14,18 @@ namespace mbgl {
namespace android {
MapSnapshotter::MapSnapshotter(jni::JNIEnv& _env,
- jni::Object<MapSnapshotter> _obj,
- jni::Object<FileSource> _jFileSource,
+ const jni::Object<MapSnapshotter>& _obj,
+ const jni::Object<FileSource>& _jFileSource,
jni::jfloat _pixelRatio,
jni::jint width,
jni::jint height,
- jni::String styleURL,
- jni::String styleJSON,
- jni::Object<LatLngBounds> region,
- jni::Object<CameraPosition> position,
+ const jni::String& styleURL,
+ const jni::String& styleJSON,
+ const jni::Object<LatLngBounds>& region,
+ const jni::Object<CameraPosition>& position,
jni::jboolean _showLogo,
- jni::String _programCacheDir)
- : javaPeer(SeizeGenericWeak(_obj.NewWeakGlobalRef(_env).release()))
+ const jni::String& _programCacheDir)
+ : javaPeer(_env, _obj)
, pixelRatio(_pixelRatio)
, threadPool(sharedThreadPool()) {
@@ -80,20 +80,19 @@ void MapSnapshotter::start(JNIEnv& env) {
[this](std::exception_ptr err, PremultipliedImage image, std::vector<std::string> attributions, mbgl::MapSnapshotter::PointForFn pointForFn, mbgl::MapSnapshotter::LatLngForFn latLngForFn) {
MBGL_VERIFY_THREAD(tid);
android::UniqueEnv _env = android::AttachEnv();
- static auto javaClass = jni::Class<MapSnapshotter>::Singleton(*_env);
+ static auto& javaClass = jni::Class<MapSnapshotter>::Singleton(*_env);
if (err) {
// error handler callback
static auto onSnapshotFailed = javaClass.GetMethod<void (jni::String)>(*_env, "onSnapshotFailed");
- javaPeer->Call(*_env, onSnapshotFailed,
- *jni::SeizeLocal(*_env, jni::Make<jni::String>(*_env, util::toString(err))));
+ javaPeer.get(*_env).Call(*_env, onSnapshotFailed, jni::Make<jni::String>(*_env, util::toString(err)));
} else {
// Create the wrapper
auto mapSnapshot = android::MapSnapshot::New(*_env, std::move(image), pixelRatio, attributions, showLogo, pointForFn, latLngForFn);
// invoke callback
static auto onSnapshotReady = javaClass.GetMethod<void (jni::Object<MapSnapshot>)>(*_env, "onSnapshotReady");
- javaPeer->Call(*_env, onSnapshotReady, mapSnapshot);
+ javaPeer.get(*_env).Call(*_env, onSnapshotReady, mapSnapshot);
}
deactivateFilesource(*_env);
@@ -108,11 +107,11 @@ void MapSnapshotter::cancel(JNIEnv& env) {
deactivateFilesource(env);
}
-void MapSnapshotter::setStyleUrl(JNIEnv& env, jni::String styleURL) {
+void MapSnapshotter::setStyleUrl(JNIEnv& env, const jni::String& styleURL) {
snapshotter->setStyleURL(jni::Make<std::string>(env, styleURL));
}
-void MapSnapshotter::setStyleJson(JNIEnv& env, jni::String styleJSON) {
+void MapSnapshotter::setStyleJson(JNIEnv& env, const jni::String& styleJSON) {
snapshotter->setStyleJSON(jni::Make<std::string>(env, styleJSON));
}
@@ -121,12 +120,12 @@ void MapSnapshotter::setSize(JNIEnv&, jni::jint width, jni::jint height) {
snapshotter->setSize(size);
}
-void MapSnapshotter::setCameraPosition(JNIEnv& env, jni::Object<CameraPosition> position) {
+void MapSnapshotter::setCameraPosition(JNIEnv& env, const jni::Object<CameraPosition>& position) {
auto options = CameraPosition::getCameraOptions(env, position);
snapshotter->setCameraOptions(options);
}
-void MapSnapshotter::setRegion(JNIEnv& env, jni::Object<LatLngBounds> region) {
+void MapSnapshotter::setRegion(JNIEnv& env, const jni::Object<LatLngBounds>& region) {
snapshotter->setRegion(LatLngBounds::getLatLngBounds(env, region));
}
@@ -151,13 +150,13 @@ void MapSnapshotter::deactivateFilesource(JNIEnv& env) {
void MapSnapshotter::registerNative(jni::JNIEnv& env) {
// Lookup the class
- static auto javaClass = jni::Class<MapSnapshotter>::Singleton(env);
+ static auto& javaClass = jni::Class<MapSnapshotter>::Singleton(env);
#define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
// Register the peer
jni::RegisterNativePeer<MapSnapshotter>(env, javaClass, "nativePtr",
- std::make_unique<MapSnapshotter, JNIEnv&, jni::Object<MapSnapshotter>, jni::Object<FileSource>, jni::jfloat, jni::jint, jni::jint, jni::String, jni::String, jni::Object<LatLngBounds>, jni::Object<CameraPosition>, jni::jboolean, jni::String>,
+ jni::MakePeer<MapSnapshotter, const jni::Object<MapSnapshotter>&, const jni::Object<FileSource>&, jni::jfloat, jni::jint, jni::jint, const jni::String&, const jni::String&, const jni::Object<LatLngBounds>&, const jni::Object<CameraPosition>&, jni::jboolean, const jni::String&>,
"nativeInitialize",
"finalize",
METHOD(&MapSnapshotter::setStyleUrl, "setStyleUrl"),
diff --git a/platform/android/src/snapshotter/map_snapshotter.hpp b/platform/android/src/snapshotter/map_snapshotter.hpp
index 05a27256aa..e20acf4f1f 100644
--- a/platform/android/src/snapshotter/map_snapshotter.hpp
+++ b/platform/android/src/snapshotter/map_snapshotter.hpp
@@ -9,7 +9,6 @@
#include "../map/camera_position.hpp"
#include <jni/jni.hpp>
-#include "../jni/generic_global_ref_deleter.hpp"
#include <memory>
@@ -26,29 +25,29 @@ public:
static void registerNative(jni::JNIEnv&);
MapSnapshotter(jni::JNIEnv&,
- jni::Object<MapSnapshotter>,
- jni::Object<FileSource>,
+ const jni::Object<MapSnapshotter>&,
+ const jni::Object<FileSource>&,
jni::jfloat pixelRatio,
jni::jint width,
jni::jint height,
- jni::String styleURL,
- jni::String styleJSON,
- jni::Object<LatLngBounds> region,
- jni::Object<CameraPosition> position,
+ const jni::String& styleURL,
+ const jni::String& styleJSON,
+ const jni::Object<LatLngBounds>& region,
+ const jni::Object<CameraPosition>& position,
jni::jboolean showLogo,
- jni::String programCacheDir);
+ const jni::String& programCacheDir);
~MapSnapshotter();
- void setStyleUrl(JNIEnv&, jni::String styleURL);
+ void setStyleUrl(JNIEnv&, const jni::String& styleURL);
- void setStyleJson(JNIEnv&, jni::String styleJSON);
+ void setStyleJson(JNIEnv&, const jni::String& styleJSON);
void setSize(JNIEnv&, jni::jint width, jni::jint height);
- void setCameraPosition(JNIEnv&, jni::Object<CameraPosition> position);
+ void setCameraPosition(JNIEnv&, const jni::Object<CameraPosition>& position);
- void setRegion(JNIEnv&, jni::Object<LatLngBounds> region);
+ void setRegion(JNIEnv&, const jni::Object<LatLngBounds>& region);
void start(JNIEnv&);
@@ -58,7 +57,7 @@ private:
MBGL_STORE_THREAD(tid);
JavaVM *vm = nullptr;
- GenericWeak<jni::Object<MapSnapshotter>> javaPeer;
+ jni::WeakReference<jni::Object<MapSnapshotter>, jni::EnvAttachingDeleter> javaPeer;
float pixelRatio;
bool showLogo;
diff --git a/platform/android/src/style/conversion/filter.cpp b/platform/android/src/style/conversion/filter.cpp
index 44b5a71aa3..d15e2747ac 100644
--- a/platform/android/src/style/conversion/filter.cpp
+++ b/platform/android/src/style/conversion/filter.cpp
@@ -8,11 +8,11 @@ namespace mbgl {
namespace android {
namespace conversion {
-optional<mbgl::style::Filter> toFilter(jni::JNIEnv& env, jni::Local<jni::Array<jni::Object<>>> jfilter) {
+optional<mbgl::style::Filter> toFilter(jni::JNIEnv& env, const jni::Array<jni::Object<>>& jfilter) {
mbgl::optional<mbgl::style::Filter> filter;
if (jfilter) {
mbgl::style::conversion::Error error;
- auto converted = mbgl::style::conversion::convert<mbgl::style::Filter>(Value(env, std::move(jfilter)), error);
+ auto converted = mbgl::style::conversion::convert<mbgl::style::Filter>(Value(env, jfilter), error);
if (!converted) {
mbgl::Log::Error(mbgl::Event::JNI, "Error converting filter: " + error.message);
}
diff --git a/platform/android/src/style/conversion/filter.hpp b/platform/android/src/style/conversion/filter.hpp
index f638a853a1..920d336a1a 100644
--- a/platform/android/src/style/conversion/filter.hpp
+++ b/platform/android/src/style/conversion/filter.hpp
@@ -9,7 +9,7 @@ namespace mbgl {
namespace android {
namespace conversion {
-optional<mbgl::style::Filter> toFilter(jni::JNIEnv&, jni::Local<jni::Array<jni::Object<>>>);
+optional<mbgl::style::Filter> toFilter(jni::JNIEnv&, const jni::Array<jni::Object<>>&);
} // namespace conversion
} // namespace android
diff --git a/platform/android/src/style/conversion/position.cpp b/platform/android/src/style/conversion/position.cpp
index 9b3925914e..e3c334afd2 100644
--- a/platform/android/src/style/conversion/position.cpp
+++ b/platform/android/src/style/conversion/position.cpp
@@ -4,7 +4,7 @@ namespace mbgl {
namespace android {
namespace conversion {
-Result<jni::Object<Position>> Converter<jni::Object<Position>, mbgl::style::Position>::operator()(jni::JNIEnv &env, const mbgl::style::Position &value) const {
+Result<jni::Local<jni::Object<Position>>> Converter<jni::Local<jni::Object<Position>>, mbgl::style::Position>::operator()(jni::JNIEnv &env, const mbgl::style::Position &value) const {
std::array<float, 3> cartPosition = value.getSpherical();
return Position::fromPosition(env, cartPosition[0], cartPosition[1], cartPosition[2]);
}
diff --git a/platform/android/src/style/conversion/position.hpp b/platform/android/src/style/conversion/position.hpp
index 2ef4bf4395..90409d527d 100644
--- a/platform/android/src/style/conversion/position.hpp
+++ b/platform/android/src/style/conversion/position.hpp
@@ -11,8 +11,8 @@ namespace android {
namespace conversion {
template <>
-struct Converter<jni::Object<Position>, mbgl::style::Position> {
- Result<jni::Object<Position>> operator()(jni::JNIEnv &env, const mbgl::style::Position &value) const;
+struct Converter<jni::Local<jni::Object<Position>>, mbgl::style::Position> {
+ Result<jni::Local<jni::Object<Position>>> operator()(jni::JNIEnv &env, const mbgl::style::Position &value) const;
};
template <>
diff --git a/platform/android/src/style/conversion/property_expression.hpp b/platform/android/src/style/conversion/property_expression.hpp
index 08429960cb..4e26b11f96 100644
--- a/platform/android/src/style/conversion/property_expression.hpp
+++ b/platform/android/src/style/conversion/property_expression.hpp
@@ -12,8 +12,8 @@ namespace android {
namespace conversion {
template <class T>
-struct Converter<jni::Object<android::gson::JsonElement>, mbgl::style::PropertyExpression<T>> {
- Result<jni::Object<android::gson::JsonElement>> operator()(jni::JNIEnv& env, const mbgl::style::PropertyExpression<T>& value) const {
+struct Converter<jni::Local<jni::Object<android::gson::JsonElement>>, mbgl::style::PropertyExpression<T>> {
+ Result<jni::Local<jni::Object<android::gson::JsonElement>>> operator()(jni::JNIEnv& env, const mbgl::style::PropertyExpression<T>& value) const {
return gson::JsonElement::New(env, value.getExpression().serialize());
}
};
diff --git a/platform/android/src/style/conversion/property_value.hpp b/platform/android/src/style/conversion/property_value.hpp
index 8150285c85..317705a286 100644
--- a/platform/android/src/style/conversion/property_value.hpp
+++ b/platform/android/src/style/conversion/property_value.hpp
@@ -19,16 +19,16 @@ class PropertyValueEvaluator {
public:
PropertyValueEvaluator(jni::JNIEnv& _env) : env(_env) {}
- jni::jobject* operator()(const mbgl::style::Undefined) const {
- return nullptr;
+ jni::Local<jni::Object<>> operator()(const mbgl::style::Undefined) const {
+ return jni::Local<jni::Object<>>(env, nullptr);
}
- jni::jobject* operator()(const T& value) const {
- return *convert<jni::jobject*>(env, value);
+ jni::Local<jni::Object<>> operator()(const T& value) const {
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, value));
}
- jni::jobject* operator()(const mbgl::style::PropertyExpression<T>& value) const {
- return *convert<jni::Object<android::gson::JsonElement>>(env, value);
+ jni::Local<jni::Object<>> operator()(const mbgl::style::PropertyExpression<T>& value) const {
+ return std::move(*convert<jni::Local<jni::Object<android::gson::JsonElement>>>(env, value));
}
private:
@@ -39,8 +39,8 @@ private:
* Convert core property values to java
*/
template <class T>
-struct Converter<jni::jobject*, mbgl::style::PropertyValue<T>> {
- Result<jni::jobject*> operator()(jni::JNIEnv& env, const mbgl::style::PropertyValue<T>& value) const {
+struct Converter<jni::Local<jni::Object<>>, mbgl::style::PropertyValue<T>> {
+ Result<jni::Local<jni::Object<>>> operator()(jni::JNIEnv& env, const mbgl::style::PropertyValue<T>& value) const {
PropertyValueEvaluator<T> evaluator(env);
return value.evaluate(evaluator);
}
@@ -50,10 +50,10 @@ struct Converter<jni::jobject*, mbgl::style::PropertyValue<T>> {
* Convert core heat map color property value to java
*/
template <>
-struct Converter<jni::jobject*, mbgl::style::ColorRampPropertyValue> {
- Result<jni::jobject*> operator()(jni::JNIEnv& env, const mbgl::style::ColorRampPropertyValue& value) const {
+struct Converter<jni::Local<jni::Object<>>, mbgl::style::ColorRampPropertyValue> {
+ Result<jni::Local<jni::Object<>>> operator()(jni::JNIEnv& env, const mbgl::style::ColorRampPropertyValue& value) const {
PropertyValueEvaluator<mbgl::style::ColorRampPropertyValue> evaluator(env);
- return *convert<jni::jobject*>(env, value.evaluate(evaluator));
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, value.evaluate(evaluator)));
}
};
diff --git a/platform/android/src/style/conversion/transition_options.cpp b/platform/android/src/style/conversion/transition_options.cpp
index 313333ad17..66ddc74145 100644
--- a/platform/android/src/style/conversion/transition_options.cpp
+++ b/platform/android/src/style/conversion/transition_options.cpp
@@ -4,7 +4,7 @@ namespace mbgl {
namespace android {
namespace conversion {
-Result<jni::Object<TransitionOptions>> Converter<jni::Object<TransitionOptions>, mbgl::style::TransitionOptions>::operator()(jni::JNIEnv& env, const mbgl::style::TransitionOptions& value) const {
+Result<jni::Local<jni::Object<TransitionOptions>>> Converter<jni::Local<jni::Object<TransitionOptions>>, mbgl::style::TransitionOptions>::operator()(jni::JNIEnv& env, const mbgl::style::TransitionOptions& value) const {
return TransitionOptions::fromTransitionOptions(env,
std::chrono::duration_cast<std::chrono::milliseconds>(value.duration.value_or(mbgl::Duration::zero())).count(),
std::chrono::duration_cast<std::chrono::milliseconds>(value.delay.value_or(mbgl::Duration::zero())).count()
diff --git a/platform/android/src/style/conversion/transition_options.hpp b/platform/android/src/style/conversion/transition_options.hpp
index 6630456d37..06c042922e 100644
--- a/platform/android/src/style/conversion/transition_options.hpp
+++ b/platform/android/src/style/conversion/transition_options.hpp
@@ -12,8 +12,8 @@ namespace android {
namespace conversion {
template<>
-struct Converter<jni::Object<TransitionOptions>, mbgl::style::TransitionOptions> {
- Result<jni::Object<TransitionOptions>> operator()(jni::JNIEnv&, const mbgl::style::TransitionOptions&) const;
+struct Converter<jni::Local<jni::Object<TransitionOptions>>, mbgl::style::TransitionOptions> {
+ Result<jni::Local<jni::Object<TransitionOptions>>> operator()(jni::JNIEnv&, const mbgl::style::TransitionOptions&) const;
};
}
diff --git a/platform/android/src/style/layers/background_layer.cpp b/platform/android/src/style/layers/background_layer.cpp
index 00c348b232..c806e8471f 100644
--- a/platform/android/src/style/layers/background_layer.cpp
+++ b/platform/android/src/style/layers/background_layer.cpp
@@ -13,7 +13,7 @@ namespace android {
/**
* Creates an owning peer object (for layers not attached to the map) from the JVM side
*/
- BackgroundLayer::BackgroundLayer(jni::JNIEnv& env, jni::String layerId)
+ BackgroundLayer::BackgroundLayer(jni::JNIEnv& env, jni::String& layerId)
: Layer(env, std::make_unique<mbgl::style::BackgroundLayer>(jni::Make<std::string>(env, layerId))) {
}
@@ -35,16 +35,15 @@ namespace android {
// Property getters
- jni::Object<jni::ObjectTag> BackgroundLayer::getBackgroundColor(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> BackgroundLayer::getBackgroundColor(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::BackgroundLayer>()->BackgroundLayer::getBackgroundColor());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::BackgroundLayer>()->BackgroundLayer::getBackgroundColor()));
}
- jni::Object<TransitionOptions> BackgroundLayer::getBackgroundColorTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> BackgroundLayer::getBackgroundColorTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::BackgroundLayer>()->BackgroundLayer::getBackgroundColorTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void BackgroundLayer::setBackgroundColorTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -54,16 +53,15 @@ namespace android {
layer.as<mbgl::style::BackgroundLayer>()->BackgroundLayer::setBackgroundColorTransition(options);
}
- jni::Object<jni::ObjectTag> BackgroundLayer::getBackgroundPattern(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> BackgroundLayer::getBackgroundPattern(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::BackgroundLayer>()->BackgroundLayer::getBackgroundPattern());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::BackgroundLayer>()->BackgroundLayer::getBackgroundPattern()));
}
- jni::Object<TransitionOptions> BackgroundLayer::getBackgroundPatternTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> BackgroundLayer::getBackgroundPatternTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::BackgroundLayer>()->BackgroundLayer::getBackgroundPatternTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void BackgroundLayer::setBackgroundPatternTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -73,16 +71,15 @@ namespace android {
layer.as<mbgl::style::BackgroundLayer>()->BackgroundLayer::setBackgroundPatternTransition(options);
}
- jni::Object<jni::ObjectTag> BackgroundLayer::getBackgroundOpacity(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> BackgroundLayer::getBackgroundOpacity(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::BackgroundLayer>()->BackgroundLayer::getBackgroundOpacity());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::BackgroundLayer>()->BackgroundLayer::getBackgroundOpacity()));
}
- jni::Object<TransitionOptions> BackgroundLayer::getBackgroundOpacityTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> BackgroundLayer::getBackgroundOpacityTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::BackgroundLayer>()->BackgroundLayer::getBackgroundOpacityTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void BackgroundLayer::setBackgroundOpacityTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -93,22 +90,22 @@ namespace android {
}
- jni::jobject* BackgroundLayer::createJavaPeer(jni::JNIEnv& env) {
- static auto javaClass = jni::Class<BackgroundLayer>::Singleton(env);
+ jni::Local<jni::Object<Layer>> BackgroundLayer::createJavaPeer(jni::JNIEnv& env) {
+ static auto& javaClass = jni::Class<BackgroundLayer>::Singleton(env);
static auto constructor = javaClass.GetConstructor<jni::jlong>(env);
return javaClass.New(env, constructor, reinterpret_cast<jni::jlong>(this));
}
void BackgroundLayer::registerNative(jni::JNIEnv& env) {
// Lookup the class
- static auto javaClass = jni::Class<BackgroundLayer>::Singleton(env);
+ static auto& javaClass = jni::Class<BackgroundLayer>::Singleton(env);
#define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
// Register the peer
jni::RegisterNativePeer<BackgroundLayer>(
env, javaClass, "nativePtr",
- std::make_unique<BackgroundLayer, JNIEnv&, jni::String>,
+ jni::MakePeer<BackgroundLayer, jni::String&>,
"initialize",
"finalize",
METHOD(&BackgroundLayer::getBackgroundColorTransition, "nativeGetBackgroundColorTransition"),
diff --git a/platform/android/src/style/layers/background_layer.hpp b/platform/android/src/style/layers/background_layer.hpp
index 3b7f03ddb6..78cd5659fd 100644
--- a/platform/android/src/style/layers/background_layer.hpp
+++ b/platform/android/src/style/layers/background_layer.hpp
@@ -12,12 +12,12 @@ namespace android {
class BackgroundLayer : public Layer {
public:
-
+ using SuperTag = Layer;
static constexpr auto Name() { return "com/mapbox/mapboxsdk/style/layers/BackgroundLayer"; };
static void registerNative(jni::JNIEnv&);
- BackgroundLayer(jni::JNIEnv&, jni::String);
+ BackgroundLayer(jni::JNIEnv&, jni::String&);
BackgroundLayer(mbgl::Map&, mbgl::style::BackgroundLayer&);
@@ -27,18 +27,18 @@ public:
// Properties
- jni::Object<jni::ObjectTag> getBackgroundColor(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getBackgroundColor(jni::JNIEnv&);
void setBackgroundColorTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getBackgroundColorTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getBackgroundColorTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getBackgroundPattern(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getBackgroundPattern(jni::JNIEnv&);
void setBackgroundPatternTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getBackgroundPatternTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getBackgroundPatternTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getBackgroundOpacity(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getBackgroundOpacity(jni::JNIEnv&);
void setBackgroundOpacityTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getBackgroundOpacityTransition(jni::JNIEnv&);
- jni::jobject* createJavaPeer(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getBackgroundOpacityTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<Layer>> createJavaPeer(jni::JNIEnv&);
}; // class BackgroundLayer
diff --git a/platform/android/src/style/layers/circle_layer.cpp b/platform/android/src/style/layers/circle_layer.cpp
index 47a492dd43..9ec48d7b18 100644
--- a/platform/android/src/style/layers/circle_layer.cpp
+++ b/platform/android/src/style/layers/circle_layer.cpp
@@ -13,7 +13,7 @@ namespace android {
/**
* Creates an owning peer object (for layers not attached to the map) from the JVM side
*/
- CircleLayer::CircleLayer(jni::JNIEnv& env, jni::String layerId, jni::String sourceId)
+ CircleLayer::CircleLayer(jni::JNIEnv& env, jni::String& layerId, jni::String& sourceId)
: Layer(env, std::make_unique<mbgl::style::CircleLayer>(jni::Make<std::string>(env, layerId), jni::Make<std::string>(env, sourceId))) {
}
@@ -35,16 +35,15 @@ namespace android {
// Property getters
- jni::Object<jni::ObjectTag> CircleLayer::getCircleRadius(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> CircleLayer::getCircleRadius(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::CircleLayer>()->CircleLayer::getCircleRadius());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::CircleLayer>()->CircleLayer::getCircleRadius()));
}
- jni::Object<TransitionOptions> CircleLayer::getCircleRadiusTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> CircleLayer::getCircleRadiusTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::CircleLayer>()->CircleLayer::getCircleRadiusTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void CircleLayer::setCircleRadiusTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -54,16 +53,15 @@ namespace android {
layer.as<mbgl::style::CircleLayer>()->CircleLayer::setCircleRadiusTransition(options);
}
- jni::Object<jni::ObjectTag> CircleLayer::getCircleColor(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> CircleLayer::getCircleColor(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::CircleLayer>()->CircleLayer::getCircleColor());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::CircleLayer>()->CircleLayer::getCircleColor()));
}
- jni::Object<TransitionOptions> CircleLayer::getCircleColorTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> CircleLayer::getCircleColorTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::CircleLayer>()->CircleLayer::getCircleColorTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void CircleLayer::setCircleColorTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -73,16 +71,15 @@ namespace android {
layer.as<mbgl::style::CircleLayer>()->CircleLayer::setCircleColorTransition(options);
}
- jni::Object<jni::ObjectTag> CircleLayer::getCircleBlur(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> CircleLayer::getCircleBlur(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::CircleLayer>()->CircleLayer::getCircleBlur());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::CircleLayer>()->CircleLayer::getCircleBlur()));
}
- jni::Object<TransitionOptions> CircleLayer::getCircleBlurTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> CircleLayer::getCircleBlurTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::CircleLayer>()->CircleLayer::getCircleBlurTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void CircleLayer::setCircleBlurTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -92,16 +89,15 @@ namespace android {
layer.as<mbgl::style::CircleLayer>()->CircleLayer::setCircleBlurTransition(options);
}
- jni::Object<jni::ObjectTag> CircleLayer::getCircleOpacity(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> CircleLayer::getCircleOpacity(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::CircleLayer>()->CircleLayer::getCircleOpacity());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::CircleLayer>()->CircleLayer::getCircleOpacity()));
}
- jni::Object<TransitionOptions> CircleLayer::getCircleOpacityTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> CircleLayer::getCircleOpacityTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::CircleLayer>()->CircleLayer::getCircleOpacityTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void CircleLayer::setCircleOpacityTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -111,16 +107,15 @@ namespace android {
layer.as<mbgl::style::CircleLayer>()->CircleLayer::setCircleOpacityTransition(options);
}
- jni::Object<jni::ObjectTag> CircleLayer::getCircleTranslate(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> CircleLayer::getCircleTranslate(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::CircleLayer>()->CircleLayer::getCircleTranslate());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::CircleLayer>()->CircleLayer::getCircleTranslate()));
}
- jni::Object<TransitionOptions> CircleLayer::getCircleTranslateTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> CircleLayer::getCircleTranslateTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::CircleLayer>()->CircleLayer::getCircleTranslateTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void CircleLayer::setCircleTranslateTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -130,34 +125,30 @@ namespace android {
layer.as<mbgl::style::CircleLayer>()->CircleLayer::setCircleTranslateTransition(options);
}
- jni::Object<jni::ObjectTag> CircleLayer::getCircleTranslateAnchor(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> CircleLayer::getCircleTranslateAnchor(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::CircleLayer>()->CircleLayer::getCircleTranslateAnchor());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::CircleLayer>()->CircleLayer::getCircleTranslateAnchor()));
}
- jni::Object<jni::ObjectTag> CircleLayer::getCirclePitchScale(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> CircleLayer::getCirclePitchScale(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::CircleLayer>()->CircleLayer::getCirclePitchScale());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::CircleLayer>()->CircleLayer::getCirclePitchScale()));
}
- jni::Object<jni::ObjectTag> CircleLayer::getCirclePitchAlignment(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> CircleLayer::getCirclePitchAlignment(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::CircleLayer>()->CircleLayer::getCirclePitchAlignment());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::CircleLayer>()->CircleLayer::getCirclePitchAlignment()));
}
- jni::Object<jni::ObjectTag> CircleLayer::getCircleStrokeWidth(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> CircleLayer::getCircleStrokeWidth(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::CircleLayer>()->CircleLayer::getCircleStrokeWidth());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::CircleLayer>()->CircleLayer::getCircleStrokeWidth()));
}
- jni::Object<TransitionOptions> CircleLayer::getCircleStrokeWidthTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> CircleLayer::getCircleStrokeWidthTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::CircleLayer>()->CircleLayer::getCircleStrokeWidthTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void CircleLayer::setCircleStrokeWidthTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -167,16 +158,15 @@ namespace android {
layer.as<mbgl::style::CircleLayer>()->CircleLayer::setCircleStrokeWidthTransition(options);
}
- jni::Object<jni::ObjectTag> CircleLayer::getCircleStrokeColor(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> CircleLayer::getCircleStrokeColor(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::CircleLayer>()->CircleLayer::getCircleStrokeColor());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::CircleLayer>()->CircleLayer::getCircleStrokeColor()));
}
- jni::Object<TransitionOptions> CircleLayer::getCircleStrokeColorTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> CircleLayer::getCircleStrokeColorTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::CircleLayer>()->CircleLayer::getCircleStrokeColorTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void CircleLayer::setCircleStrokeColorTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -186,16 +176,15 @@ namespace android {
layer.as<mbgl::style::CircleLayer>()->CircleLayer::setCircleStrokeColorTransition(options);
}
- jni::Object<jni::ObjectTag> CircleLayer::getCircleStrokeOpacity(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> CircleLayer::getCircleStrokeOpacity(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::CircleLayer>()->CircleLayer::getCircleStrokeOpacity());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::CircleLayer>()->CircleLayer::getCircleStrokeOpacity()));
}
- jni::Object<TransitionOptions> CircleLayer::getCircleStrokeOpacityTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> CircleLayer::getCircleStrokeOpacityTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::CircleLayer>()->CircleLayer::getCircleStrokeOpacityTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void CircleLayer::setCircleStrokeOpacityTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -206,22 +195,22 @@ namespace android {
}
- jni::jobject* CircleLayer::createJavaPeer(jni::JNIEnv& env) {
- static auto javaClass = jni::Class<CircleLayer>::Singleton(env);
+ jni::Local<jni::Object<Layer>> CircleLayer::createJavaPeer(jni::JNIEnv& env) {
+ static auto& javaClass = jni::Class<CircleLayer>::Singleton(env);
static auto constructor = javaClass.GetConstructor<jni::jlong>(env);
return javaClass.New(env, constructor, reinterpret_cast<jni::jlong>(this));
}
void CircleLayer::registerNative(jni::JNIEnv& env) {
// Lookup the class
- static auto javaClass = jni::Class<CircleLayer>::Singleton(env);
+ static auto& javaClass = jni::Class<CircleLayer>::Singleton(env);
#define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
// Register the peer
jni::RegisterNativePeer<CircleLayer>(
env, javaClass, "nativePtr",
- std::make_unique<CircleLayer, JNIEnv&, jni::String, jni::String>,
+ jni::MakePeer<CircleLayer, jni::String&, jni::String&>,
"initialize",
"finalize",
METHOD(&CircleLayer::getCircleRadiusTransition, "nativeGetCircleRadiusTransition"),
diff --git a/platform/android/src/style/layers/circle_layer.hpp b/platform/android/src/style/layers/circle_layer.hpp
index 03063b1fc1..0ff34094e1 100644
--- a/platform/android/src/style/layers/circle_layer.hpp
+++ b/platform/android/src/style/layers/circle_layer.hpp
@@ -12,12 +12,12 @@ namespace android {
class CircleLayer : public Layer {
public:
-
+ using SuperTag = Layer;
static constexpr auto Name() { return "com/mapbox/mapboxsdk/style/layers/CircleLayer"; };
static void registerNative(jni::JNIEnv&);
- CircleLayer(jni::JNIEnv&, jni::String, jni::String);
+ CircleLayer(jni::JNIEnv&, jni::String&, jni::String&);
CircleLayer(mbgl::Map&, mbgl::style::CircleLayer&);
@@ -27,44 +27,44 @@ public:
// Properties
- jni::Object<jni::ObjectTag> getCircleRadius(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getCircleRadius(jni::JNIEnv&);
void setCircleRadiusTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getCircleRadiusTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getCircleRadiusTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getCircleColor(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getCircleColor(jni::JNIEnv&);
void setCircleColorTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getCircleColorTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getCircleColorTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getCircleBlur(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getCircleBlur(jni::JNIEnv&);
void setCircleBlurTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getCircleBlurTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getCircleBlurTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getCircleOpacity(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getCircleOpacity(jni::JNIEnv&);
void setCircleOpacityTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getCircleOpacityTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getCircleOpacityTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getCircleTranslate(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getCircleTranslate(jni::JNIEnv&);
void setCircleTranslateTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getCircleTranslateTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getCircleTranslateTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getCircleTranslateAnchor(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getCircleTranslateAnchor(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getCirclePitchScale(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getCirclePitchScale(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getCirclePitchAlignment(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getCirclePitchAlignment(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getCircleStrokeWidth(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getCircleStrokeWidth(jni::JNIEnv&);
void setCircleStrokeWidthTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getCircleStrokeWidthTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getCircleStrokeWidthTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getCircleStrokeColor(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getCircleStrokeColor(jni::JNIEnv&);
void setCircleStrokeColorTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getCircleStrokeColorTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getCircleStrokeColorTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getCircleStrokeOpacity(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getCircleStrokeOpacity(jni::JNIEnv&);
void setCircleStrokeOpacityTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getCircleStrokeOpacityTransition(jni::JNIEnv&);
- jni::jobject* createJavaPeer(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getCircleStrokeOpacityTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<Layer>> createJavaPeer(jni::JNIEnv&);
}; // class CircleLayer
diff --git a/platform/android/src/style/layers/custom_layer.cpp b/platform/android/src/style/layers/custom_layer.cpp
index c0dcc24f06..f6f3bb249c 100644
--- a/platform/android/src/style/layers/custom_layer.cpp
+++ b/platform/android/src/style/layers/custom_layer.cpp
@@ -7,7 +7,7 @@
namespace mbgl {
namespace android {
- CustomLayer::CustomLayer(jni::JNIEnv& env, jni::String layerId, jni::jlong host)
+ CustomLayer::CustomLayer(jni::JNIEnv& env, const jni::String& layerId, jni::jlong host)
: Layer(env, std::make_unique<mbgl::style::CustomLayer>(
jni::Make<std::string>(env, layerId),
std::unique_ptr<mbgl::style::CustomLayerHost>(reinterpret_cast<mbgl::style::CustomLayerHost*>(host)))
@@ -33,22 +33,22 @@ namespace android {
}
}
- jni::jobject* CustomLayer::createJavaPeer(jni::JNIEnv& env) {
- static auto javaClass = jni::Class<CustomLayer>::Singleton(env);
+ jni::Local<jni::Object<Layer>> CustomLayer::createJavaPeer(jni::JNIEnv& env) {
+ static auto& javaClass = jni::Class<CustomLayer>::Singleton(env);
static auto constructor = javaClass.GetConstructor<jni::jlong>(env);
return javaClass.New(env, constructor, reinterpret_cast<jni::jlong>(this));
}
void CustomLayer::registerNative(jni::JNIEnv& env) {
// Lookup the class
- static auto javaClass = jni::Class<CustomLayer>::Singleton(env);
+ static auto& javaClass = jni::Class<CustomLayer>::Singleton(env);
#define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
// Register the peer
jni::RegisterNativePeer<CustomLayer>(
env, javaClass, "nativePtr",
- std::make_unique<CustomLayer, JNIEnv&, jni::String, jni::jlong>,
+ jni::MakePeer<CustomLayer, const jni::String&, jni::jlong>,
"initialize",
"finalize",
METHOD(&CustomLayer::update, "nativeUpdate"));
diff --git a/platform/android/src/style/layers/custom_layer.hpp b/platform/android/src/style/layers/custom_layer.hpp
index 75e1957717..950fcef9c1 100644
--- a/platform/android/src/style/layers/custom_layer.hpp
+++ b/platform/android/src/style/layers/custom_layer.hpp
@@ -9,18 +9,19 @@ namespace android {
class CustomLayer : public Layer {
public:
+ using SuperTag = Layer;
static constexpr auto Name() { return "com/mapbox/mapboxsdk/style/layers/CustomLayer"; };
static void registerNative(jni::JNIEnv&);
- CustomLayer(jni::JNIEnv&, jni::String, jni::jlong);
+ CustomLayer(jni::JNIEnv&, const jni::String&, jni::jlong);
CustomLayer(mbgl::Map&, mbgl::style::CustomLayer&);
CustomLayer(mbgl::Map&, std::unique_ptr<mbgl::style::CustomLayer>);
~CustomLayer();
void update(jni::JNIEnv&);
- jni::jobject* createJavaPeer(jni::JNIEnv&);
+ jni::Local<jni::Object<Layer>> createJavaPeer(jni::JNIEnv&);
}; // class CustomLayer
diff --git a/platform/android/src/style/layers/fill_extrusion_layer.cpp b/platform/android/src/style/layers/fill_extrusion_layer.cpp
index 6c6a0bef5a..cf53e774a5 100644
--- a/platform/android/src/style/layers/fill_extrusion_layer.cpp
+++ b/platform/android/src/style/layers/fill_extrusion_layer.cpp
@@ -13,7 +13,7 @@ namespace android {
/**
* Creates an owning peer object (for layers not attached to the map) from the JVM side
*/
- FillExtrusionLayer::FillExtrusionLayer(jni::JNIEnv& env, jni::String layerId, jni::String sourceId)
+ FillExtrusionLayer::FillExtrusionLayer(jni::JNIEnv& env, jni::String& layerId, jni::String& sourceId)
: Layer(env, std::make_unique<mbgl::style::FillExtrusionLayer>(jni::Make<std::string>(env, layerId), jni::Make<std::string>(env, sourceId))) {
}
@@ -35,16 +35,15 @@ namespace android {
// Property getters
- jni::Object<jni::ObjectTag> FillExtrusionLayer::getFillExtrusionOpacity(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> FillExtrusionLayer::getFillExtrusionOpacity(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::FillExtrusionLayer>()->FillExtrusionLayer::getFillExtrusionOpacity());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::FillExtrusionLayer>()->FillExtrusionLayer::getFillExtrusionOpacity()));
}
- jni::Object<TransitionOptions> FillExtrusionLayer::getFillExtrusionOpacityTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> FillExtrusionLayer::getFillExtrusionOpacityTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::FillExtrusionLayer>()->FillExtrusionLayer::getFillExtrusionOpacityTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void FillExtrusionLayer::setFillExtrusionOpacityTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -54,16 +53,15 @@ namespace android {
layer.as<mbgl::style::FillExtrusionLayer>()->FillExtrusionLayer::setFillExtrusionOpacityTransition(options);
}
- jni::Object<jni::ObjectTag> FillExtrusionLayer::getFillExtrusionColor(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> FillExtrusionLayer::getFillExtrusionColor(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::FillExtrusionLayer>()->FillExtrusionLayer::getFillExtrusionColor());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::FillExtrusionLayer>()->FillExtrusionLayer::getFillExtrusionColor()));
}
- jni::Object<TransitionOptions> FillExtrusionLayer::getFillExtrusionColorTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> FillExtrusionLayer::getFillExtrusionColorTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::FillExtrusionLayer>()->FillExtrusionLayer::getFillExtrusionColorTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void FillExtrusionLayer::setFillExtrusionColorTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -73,16 +71,15 @@ namespace android {
layer.as<mbgl::style::FillExtrusionLayer>()->FillExtrusionLayer::setFillExtrusionColorTransition(options);
}
- jni::Object<jni::ObjectTag> FillExtrusionLayer::getFillExtrusionTranslate(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> FillExtrusionLayer::getFillExtrusionTranslate(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::FillExtrusionLayer>()->FillExtrusionLayer::getFillExtrusionTranslate());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::FillExtrusionLayer>()->FillExtrusionLayer::getFillExtrusionTranslate()));
}
- jni::Object<TransitionOptions> FillExtrusionLayer::getFillExtrusionTranslateTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> FillExtrusionLayer::getFillExtrusionTranslateTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::FillExtrusionLayer>()->FillExtrusionLayer::getFillExtrusionTranslateTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void FillExtrusionLayer::setFillExtrusionTranslateTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -92,22 +89,20 @@ namespace android {
layer.as<mbgl::style::FillExtrusionLayer>()->FillExtrusionLayer::setFillExtrusionTranslateTransition(options);
}
- jni::Object<jni::ObjectTag> FillExtrusionLayer::getFillExtrusionTranslateAnchor(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> FillExtrusionLayer::getFillExtrusionTranslateAnchor(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::FillExtrusionLayer>()->FillExtrusionLayer::getFillExtrusionTranslateAnchor());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::FillExtrusionLayer>()->FillExtrusionLayer::getFillExtrusionTranslateAnchor()));
}
- jni::Object<jni::ObjectTag> FillExtrusionLayer::getFillExtrusionPattern(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> FillExtrusionLayer::getFillExtrusionPattern(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::FillExtrusionLayer>()->FillExtrusionLayer::getFillExtrusionPattern());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::FillExtrusionLayer>()->FillExtrusionLayer::getFillExtrusionPattern()));
}
- jni::Object<TransitionOptions> FillExtrusionLayer::getFillExtrusionPatternTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> FillExtrusionLayer::getFillExtrusionPatternTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::FillExtrusionLayer>()->FillExtrusionLayer::getFillExtrusionPatternTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void FillExtrusionLayer::setFillExtrusionPatternTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -117,16 +112,15 @@ namespace android {
layer.as<mbgl::style::FillExtrusionLayer>()->FillExtrusionLayer::setFillExtrusionPatternTransition(options);
}
- jni::Object<jni::ObjectTag> FillExtrusionLayer::getFillExtrusionHeight(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> FillExtrusionLayer::getFillExtrusionHeight(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::FillExtrusionLayer>()->FillExtrusionLayer::getFillExtrusionHeight());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::FillExtrusionLayer>()->FillExtrusionLayer::getFillExtrusionHeight()));
}
- jni::Object<TransitionOptions> FillExtrusionLayer::getFillExtrusionHeightTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> FillExtrusionLayer::getFillExtrusionHeightTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::FillExtrusionLayer>()->FillExtrusionLayer::getFillExtrusionHeightTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void FillExtrusionLayer::setFillExtrusionHeightTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -136,16 +130,15 @@ namespace android {
layer.as<mbgl::style::FillExtrusionLayer>()->FillExtrusionLayer::setFillExtrusionHeightTransition(options);
}
- jni::Object<jni::ObjectTag> FillExtrusionLayer::getFillExtrusionBase(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> FillExtrusionLayer::getFillExtrusionBase(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::FillExtrusionLayer>()->FillExtrusionLayer::getFillExtrusionBase());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::FillExtrusionLayer>()->FillExtrusionLayer::getFillExtrusionBase()));
}
- jni::Object<TransitionOptions> FillExtrusionLayer::getFillExtrusionBaseTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> FillExtrusionLayer::getFillExtrusionBaseTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::FillExtrusionLayer>()->FillExtrusionLayer::getFillExtrusionBaseTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void FillExtrusionLayer::setFillExtrusionBaseTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -156,22 +149,22 @@ namespace android {
}
- jni::jobject* FillExtrusionLayer::createJavaPeer(jni::JNIEnv& env) {
- static auto javaClass = jni::Class<FillExtrusionLayer>::Singleton(env);
+ jni::Local<jni::Object<Layer>> FillExtrusionLayer::createJavaPeer(jni::JNIEnv& env) {
+ static auto& javaClass = jni::Class<FillExtrusionLayer>::Singleton(env);
static auto constructor = javaClass.GetConstructor<jni::jlong>(env);
return javaClass.New(env, constructor, reinterpret_cast<jni::jlong>(this));
}
void FillExtrusionLayer::registerNative(jni::JNIEnv& env) {
// Lookup the class
- static auto javaClass = jni::Class<FillExtrusionLayer>::Singleton(env);
+ static auto& javaClass = jni::Class<FillExtrusionLayer>::Singleton(env);
#define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
// Register the peer
jni::RegisterNativePeer<FillExtrusionLayer>(
env, javaClass, "nativePtr",
- std::make_unique<FillExtrusionLayer, JNIEnv&, jni::String, jni::String>,
+ jni::MakePeer<FillExtrusionLayer, jni::String&, jni::String&>,
"initialize",
"finalize",
METHOD(&FillExtrusionLayer::getFillExtrusionOpacityTransition, "nativeGetFillExtrusionOpacityTransition"),
diff --git a/platform/android/src/style/layers/fill_extrusion_layer.hpp b/platform/android/src/style/layers/fill_extrusion_layer.hpp
index 233c3cc334..abc30b5845 100644
--- a/platform/android/src/style/layers/fill_extrusion_layer.hpp
+++ b/platform/android/src/style/layers/fill_extrusion_layer.hpp
@@ -12,12 +12,12 @@ namespace android {
class FillExtrusionLayer : public Layer {
public:
-
+ using SuperTag = Layer;
static constexpr auto Name() { return "com/mapbox/mapboxsdk/style/layers/FillExtrusionLayer"; };
static void registerNative(jni::JNIEnv&);
- FillExtrusionLayer(jni::JNIEnv&, jni::String, jni::String);
+ FillExtrusionLayer(jni::JNIEnv&, jni::String&, jni::String&);
FillExtrusionLayer(mbgl::Map&, mbgl::style::FillExtrusionLayer&);
@@ -27,32 +27,32 @@ public:
// Properties
- jni::Object<jni::ObjectTag> getFillExtrusionOpacity(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getFillExtrusionOpacity(jni::JNIEnv&);
void setFillExtrusionOpacityTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getFillExtrusionOpacityTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getFillExtrusionOpacityTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getFillExtrusionColor(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getFillExtrusionColor(jni::JNIEnv&);
void setFillExtrusionColorTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getFillExtrusionColorTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getFillExtrusionColorTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getFillExtrusionTranslate(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getFillExtrusionTranslate(jni::JNIEnv&);
void setFillExtrusionTranslateTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getFillExtrusionTranslateTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getFillExtrusionTranslateTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getFillExtrusionTranslateAnchor(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getFillExtrusionTranslateAnchor(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getFillExtrusionPattern(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getFillExtrusionPattern(jni::JNIEnv&);
void setFillExtrusionPatternTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getFillExtrusionPatternTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getFillExtrusionPatternTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getFillExtrusionHeight(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getFillExtrusionHeight(jni::JNIEnv&);
void setFillExtrusionHeightTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getFillExtrusionHeightTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getFillExtrusionHeightTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getFillExtrusionBase(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getFillExtrusionBase(jni::JNIEnv&);
void setFillExtrusionBaseTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getFillExtrusionBaseTransition(jni::JNIEnv&);
- jni::jobject* createJavaPeer(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getFillExtrusionBaseTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<Layer>> createJavaPeer(jni::JNIEnv&);
}; // class FillExtrusionLayer
diff --git a/platform/android/src/style/layers/fill_layer.cpp b/platform/android/src/style/layers/fill_layer.cpp
index 5182c546c8..555f8eb3cd 100644
--- a/platform/android/src/style/layers/fill_layer.cpp
+++ b/platform/android/src/style/layers/fill_layer.cpp
@@ -13,7 +13,7 @@ namespace android {
/**
* Creates an owning peer object (for layers not attached to the map) from the JVM side
*/
- FillLayer::FillLayer(jni::JNIEnv& env, jni::String layerId, jni::String sourceId)
+ FillLayer::FillLayer(jni::JNIEnv& env, jni::String& layerId, jni::String& sourceId)
: Layer(env, std::make_unique<mbgl::style::FillLayer>(jni::Make<std::string>(env, layerId), jni::Make<std::string>(env, sourceId))) {
}
@@ -35,22 +35,20 @@ namespace android {
// Property getters
- jni::Object<jni::ObjectTag> FillLayer::getFillAntialias(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> FillLayer::getFillAntialias(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::FillLayer>()->FillLayer::getFillAntialias());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::FillLayer>()->FillLayer::getFillAntialias()));
}
- jni::Object<jni::ObjectTag> FillLayer::getFillOpacity(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> FillLayer::getFillOpacity(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::FillLayer>()->FillLayer::getFillOpacity());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::FillLayer>()->FillLayer::getFillOpacity()));
}
- jni::Object<TransitionOptions> FillLayer::getFillOpacityTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> FillLayer::getFillOpacityTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::FillLayer>()->FillLayer::getFillOpacityTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void FillLayer::setFillOpacityTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -60,16 +58,15 @@ namespace android {
layer.as<mbgl::style::FillLayer>()->FillLayer::setFillOpacityTransition(options);
}
- jni::Object<jni::ObjectTag> FillLayer::getFillColor(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> FillLayer::getFillColor(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::FillLayer>()->FillLayer::getFillColor());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::FillLayer>()->FillLayer::getFillColor()));
}
- jni::Object<TransitionOptions> FillLayer::getFillColorTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> FillLayer::getFillColorTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::FillLayer>()->FillLayer::getFillColorTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void FillLayer::setFillColorTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -79,16 +76,15 @@ namespace android {
layer.as<mbgl::style::FillLayer>()->FillLayer::setFillColorTransition(options);
}
- jni::Object<jni::ObjectTag> FillLayer::getFillOutlineColor(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> FillLayer::getFillOutlineColor(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::FillLayer>()->FillLayer::getFillOutlineColor());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::FillLayer>()->FillLayer::getFillOutlineColor()));
}
- jni::Object<TransitionOptions> FillLayer::getFillOutlineColorTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> FillLayer::getFillOutlineColorTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::FillLayer>()->FillLayer::getFillOutlineColorTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void FillLayer::setFillOutlineColorTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -98,16 +94,15 @@ namespace android {
layer.as<mbgl::style::FillLayer>()->FillLayer::setFillOutlineColorTransition(options);
}
- jni::Object<jni::ObjectTag> FillLayer::getFillTranslate(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> FillLayer::getFillTranslate(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::FillLayer>()->FillLayer::getFillTranslate());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::FillLayer>()->FillLayer::getFillTranslate()));
}
- jni::Object<TransitionOptions> FillLayer::getFillTranslateTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> FillLayer::getFillTranslateTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::FillLayer>()->FillLayer::getFillTranslateTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void FillLayer::setFillTranslateTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -117,22 +112,20 @@ namespace android {
layer.as<mbgl::style::FillLayer>()->FillLayer::setFillTranslateTransition(options);
}
- jni::Object<jni::ObjectTag> FillLayer::getFillTranslateAnchor(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> FillLayer::getFillTranslateAnchor(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::FillLayer>()->FillLayer::getFillTranslateAnchor());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::FillLayer>()->FillLayer::getFillTranslateAnchor()));
}
- jni::Object<jni::ObjectTag> FillLayer::getFillPattern(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> FillLayer::getFillPattern(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::FillLayer>()->FillLayer::getFillPattern());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::FillLayer>()->FillLayer::getFillPattern()));
}
- jni::Object<TransitionOptions> FillLayer::getFillPatternTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> FillLayer::getFillPatternTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::FillLayer>()->FillLayer::getFillPatternTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void FillLayer::setFillPatternTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -143,22 +136,22 @@ namespace android {
}
- jni::jobject* FillLayer::createJavaPeer(jni::JNIEnv& env) {
- static auto javaClass = jni::Class<FillLayer>::Singleton(env);
+ jni::Local<jni::Object<Layer>> FillLayer::createJavaPeer(jni::JNIEnv& env) {
+ static auto& javaClass = jni::Class<FillLayer>::Singleton(env);
static auto constructor = javaClass.GetConstructor<jni::jlong>(env);
return javaClass.New(env, constructor, reinterpret_cast<jni::jlong>(this));
}
void FillLayer::registerNative(jni::JNIEnv& env) {
// Lookup the class
- static auto javaClass = jni::Class<FillLayer>::Singleton(env);
+ static auto& javaClass = jni::Class<FillLayer>::Singleton(env);
#define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
// Register the peer
jni::RegisterNativePeer<FillLayer>(
env, javaClass, "nativePtr",
- std::make_unique<FillLayer, JNIEnv&, jni::String, jni::String>,
+ jni::MakePeer<FillLayer, jni::String&, jni::String&>,
"initialize",
"finalize",
METHOD(&FillLayer::getFillAntialias, "nativeGetFillAntialias"),
diff --git a/platform/android/src/style/layers/fill_layer.hpp b/platform/android/src/style/layers/fill_layer.hpp
index db1fee1667..ea96320570 100644
--- a/platform/android/src/style/layers/fill_layer.hpp
+++ b/platform/android/src/style/layers/fill_layer.hpp
@@ -12,12 +12,12 @@ namespace android {
class FillLayer : public Layer {
public:
-
+ using SuperTag = Layer;
static constexpr auto Name() { return "com/mapbox/mapboxsdk/style/layers/FillLayer"; };
static void registerNative(jni::JNIEnv&);
- FillLayer(jni::JNIEnv&, jni::String, jni::String);
+ FillLayer(jni::JNIEnv&, jni::String&, jni::String&);
FillLayer(mbgl::Map&, mbgl::style::FillLayer&);
@@ -27,30 +27,30 @@ public:
// Properties
- jni::Object<jni::ObjectTag> getFillAntialias(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getFillAntialias(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getFillOpacity(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getFillOpacity(jni::JNIEnv&);
void setFillOpacityTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getFillOpacityTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getFillOpacityTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getFillColor(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getFillColor(jni::JNIEnv&);
void setFillColorTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getFillColorTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getFillColorTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getFillOutlineColor(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getFillOutlineColor(jni::JNIEnv&);
void setFillOutlineColorTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getFillOutlineColorTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getFillOutlineColorTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getFillTranslate(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getFillTranslate(jni::JNIEnv&);
void setFillTranslateTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getFillTranslateTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getFillTranslateTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getFillTranslateAnchor(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getFillTranslateAnchor(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getFillPattern(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getFillPattern(jni::JNIEnv&);
void setFillPatternTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getFillPatternTransition(jni::JNIEnv&);
- jni::jobject* createJavaPeer(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getFillPatternTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<Layer>> createJavaPeer(jni::JNIEnv&);
}; // class FillLayer
diff --git a/platform/android/src/style/layers/heatmap_layer.cpp b/platform/android/src/style/layers/heatmap_layer.cpp
index e83d92873f..b72b372929 100644
--- a/platform/android/src/style/layers/heatmap_layer.cpp
+++ b/platform/android/src/style/layers/heatmap_layer.cpp
@@ -13,7 +13,7 @@ namespace android {
/**
* Creates an owning peer object (for layers not attached to the map) from the JVM side
*/
- HeatmapLayer::HeatmapLayer(jni::JNIEnv& env, jni::String layerId, jni::String sourceId)
+ HeatmapLayer::HeatmapLayer(jni::JNIEnv& env, jni::String& layerId, jni::String& sourceId)
: Layer(env, std::make_unique<mbgl::style::HeatmapLayer>(jni::Make<std::string>(env, layerId), jni::Make<std::string>(env, sourceId))) {
}
@@ -35,16 +35,15 @@ namespace android {
// Property getters
- jni::Object<jni::ObjectTag> HeatmapLayer::getHeatmapRadius(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> HeatmapLayer::getHeatmapRadius(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::HeatmapLayer>()->HeatmapLayer::getHeatmapRadius());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::HeatmapLayer>()->HeatmapLayer::getHeatmapRadius()));
}
- jni::Object<TransitionOptions> HeatmapLayer::getHeatmapRadiusTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> HeatmapLayer::getHeatmapRadiusTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::HeatmapLayer>()->HeatmapLayer::getHeatmapRadiusTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void HeatmapLayer::setHeatmapRadiusTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -54,22 +53,20 @@ namespace android {
layer.as<mbgl::style::HeatmapLayer>()->HeatmapLayer::setHeatmapRadiusTransition(options);
}
- jni::Object<jni::ObjectTag> HeatmapLayer::getHeatmapWeight(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> HeatmapLayer::getHeatmapWeight(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::HeatmapLayer>()->HeatmapLayer::getHeatmapWeight());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::HeatmapLayer>()->HeatmapLayer::getHeatmapWeight()));
}
- jni::Object<jni::ObjectTag> HeatmapLayer::getHeatmapIntensity(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> HeatmapLayer::getHeatmapIntensity(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::HeatmapLayer>()->HeatmapLayer::getHeatmapIntensity());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::HeatmapLayer>()->HeatmapLayer::getHeatmapIntensity()));
}
- jni::Object<TransitionOptions> HeatmapLayer::getHeatmapIntensityTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> HeatmapLayer::getHeatmapIntensityTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::HeatmapLayer>()->HeatmapLayer::getHeatmapIntensityTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void HeatmapLayer::setHeatmapIntensityTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -79,26 +76,24 @@ namespace android {
layer.as<mbgl::style::HeatmapLayer>()->HeatmapLayer::setHeatmapIntensityTransition(options);
}
- 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));
}
- jni::Object<jni::ObjectTag> HeatmapLayer::getHeatmapOpacity(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> HeatmapLayer::getHeatmapOpacity(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::HeatmapLayer>()->HeatmapLayer::getHeatmapOpacity());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::HeatmapLayer>()->HeatmapLayer::getHeatmapOpacity()));
}
- jni::Object<TransitionOptions> HeatmapLayer::getHeatmapOpacityTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> HeatmapLayer::getHeatmapOpacityTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::HeatmapLayer>()->HeatmapLayer::getHeatmapOpacityTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void HeatmapLayer::setHeatmapOpacityTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -109,22 +104,22 @@ namespace android {
}
- jni::jobject* HeatmapLayer::createJavaPeer(jni::JNIEnv& env) {
- static auto javaClass = jni::Class<HeatmapLayer>::Singleton(env);
+ jni::Local<jni::Object<Layer>> HeatmapLayer::createJavaPeer(jni::JNIEnv& env) {
+ static auto& javaClass = jni::Class<HeatmapLayer>::Singleton(env);
static auto constructor = javaClass.GetConstructor<jni::jlong>(env);
return javaClass.New(env, constructor, reinterpret_cast<jni::jlong>(this));
}
void HeatmapLayer::registerNative(jni::JNIEnv& env) {
// Lookup the class
- static auto javaClass = jni::Class<HeatmapLayer>::Singleton(env);
+ static auto& javaClass = jni::Class<HeatmapLayer>::Singleton(env);
#define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
// Register the peer
jni::RegisterNativePeer<HeatmapLayer>(
env, javaClass, "nativePtr",
- std::make_unique<HeatmapLayer, JNIEnv&, jni::String, jni::String>,
+ jni::MakePeer<HeatmapLayer, jni::String&, jni::String&>,
"initialize",
"finalize",
METHOD(&HeatmapLayer::getHeatmapRadiusTransition, "nativeGetHeatmapRadiusTransition"),
diff --git a/platform/android/src/style/layers/heatmap_layer.hpp b/platform/android/src/style/layers/heatmap_layer.hpp
index 00ab27d854..2976e6c482 100644
--- a/platform/android/src/style/layers/heatmap_layer.hpp
+++ b/platform/android/src/style/layers/heatmap_layer.hpp
@@ -12,12 +12,12 @@ namespace android {
class HeatmapLayer : public Layer {
public:
-
+ using SuperTag = Layer;
static constexpr auto Name() { return "com/mapbox/mapboxsdk/style/layers/HeatmapLayer"; };
static void registerNative(jni::JNIEnv&);
- HeatmapLayer(jni::JNIEnv&, jni::String, jni::String);
+ HeatmapLayer(jni::JNIEnv&, jni::String&, jni::String&);
HeatmapLayer(mbgl::Map&, mbgl::style::HeatmapLayer&);
@@ -27,22 +27,22 @@ public:
// Properties
- jni::Object<jni::ObjectTag> getHeatmapRadius(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getHeatmapRadius(jni::JNIEnv&);
void setHeatmapRadiusTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getHeatmapRadiusTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getHeatmapRadiusTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getHeatmapWeight(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getHeatmapWeight(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getHeatmapIntensity(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getHeatmapIntensity(jni::JNIEnv&);
void setHeatmapIntensityTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getHeatmapIntensityTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getHeatmapIntensityTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getHeatmapColor(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getHeatmapColor(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getHeatmapOpacity(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getHeatmapOpacity(jni::JNIEnv&);
void setHeatmapOpacityTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getHeatmapOpacityTransition(jni::JNIEnv&);
- jni::jobject* createJavaPeer(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getHeatmapOpacityTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<Layer>> createJavaPeer(jni::JNIEnv&);
}; // class HeatmapLayer
diff --git a/platform/android/src/style/layers/hillshade_layer.cpp b/platform/android/src/style/layers/hillshade_layer.cpp
index b6409b3b3e..5cd6162575 100644
--- a/platform/android/src/style/layers/hillshade_layer.cpp
+++ b/platform/android/src/style/layers/hillshade_layer.cpp
@@ -13,7 +13,7 @@ namespace android {
/**
* Creates an owning peer object (for layers not attached to the map) from the JVM side
*/
- HillshadeLayer::HillshadeLayer(jni::JNIEnv& env, jni::String layerId, jni::String sourceId)
+ HillshadeLayer::HillshadeLayer(jni::JNIEnv& env, jni::String& layerId, jni::String& sourceId)
: Layer(env, std::make_unique<mbgl::style::HillshadeLayer>(jni::Make<std::string>(env, layerId), jni::Make<std::string>(env, sourceId))) {
}
@@ -35,28 +35,25 @@ namespace android {
// Property getters
- jni::Object<jni::ObjectTag> HillshadeLayer::getHillshadeIlluminationDirection(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> HillshadeLayer::getHillshadeIlluminationDirection(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::HillshadeLayer>()->HillshadeLayer::getHillshadeIlluminationDirection());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::HillshadeLayer>()->HillshadeLayer::getHillshadeIlluminationDirection()));
}
- jni::Object<jni::ObjectTag> HillshadeLayer::getHillshadeIlluminationAnchor(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> HillshadeLayer::getHillshadeIlluminationAnchor(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::HillshadeLayer>()->HillshadeLayer::getHillshadeIlluminationAnchor());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::HillshadeLayer>()->HillshadeLayer::getHillshadeIlluminationAnchor()));
}
- jni::Object<jni::ObjectTag> HillshadeLayer::getHillshadeExaggeration(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> HillshadeLayer::getHillshadeExaggeration(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::HillshadeLayer>()->HillshadeLayer::getHillshadeExaggeration());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::HillshadeLayer>()->HillshadeLayer::getHillshadeExaggeration()));
}
- jni::Object<TransitionOptions> HillshadeLayer::getHillshadeExaggerationTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> HillshadeLayer::getHillshadeExaggerationTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::HillshadeLayer>()->HillshadeLayer::getHillshadeExaggerationTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void HillshadeLayer::setHillshadeExaggerationTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -66,16 +63,15 @@ namespace android {
layer.as<mbgl::style::HillshadeLayer>()->HillshadeLayer::setHillshadeExaggerationTransition(options);
}
- jni::Object<jni::ObjectTag> HillshadeLayer::getHillshadeShadowColor(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> HillshadeLayer::getHillshadeShadowColor(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::HillshadeLayer>()->HillshadeLayer::getHillshadeShadowColor());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::HillshadeLayer>()->HillshadeLayer::getHillshadeShadowColor()));
}
- jni::Object<TransitionOptions> HillshadeLayer::getHillshadeShadowColorTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> HillshadeLayer::getHillshadeShadowColorTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::HillshadeLayer>()->HillshadeLayer::getHillshadeShadowColorTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void HillshadeLayer::setHillshadeShadowColorTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -85,16 +81,15 @@ namespace android {
layer.as<mbgl::style::HillshadeLayer>()->HillshadeLayer::setHillshadeShadowColorTransition(options);
}
- jni::Object<jni::ObjectTag> HillshadeLayer::getHillshadeHighlightColor(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> HillshadeLayer::getHillshadeHighlightColor(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::HillshadeLayer>()->HillshadeLayer::getHillshadeHighlightColor());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::HillshadeLayer>()->HillshadeLayer::getHillshadeHighlightColor()));
}
- jni::Object<TransitionOptions> HillshadeLayer::getHillshadeHighlightColorTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> HillshadeLayer::getHillshadeHighlightColorTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::HillshadeLayer>()->HillshadeLayer::getHillshadeHighlightColorTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void HillshadeLayer::setHillshadeHighlightColorTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -104,16 +99,15 @@ namespace android {
layer.as<mbgl::style::HillshadeLayer>()->HillshadeLayer::setHillshadeHighlightColorTransition(options);
}
- jni::Object<jni::ObjectTag> HillshadeLayer::getHillshadeAccentColor(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> HillshadeLayer::getHillshadeAccentColor(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::HillshadeLayer>()->HillshadeLayer::getHillshadeAccentColor());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::HillshadeLayer>()->HillshadeLayer::getHillshadeAccentColor()));
}
- jni::Object<TransitionOptions> HillshadeLayer::getHillshadeAccentColorTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> HillshadeLayer::getHillshadeAccentColorTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::HillshadeLayer>()->HillshadeLayer::getHillshadeAccentColorTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void HillshadeLayer::setHillshadeAccentColorTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -124,22 +118,22 @@ namespace android {
}
- jni::jobject* HillshadeLayer::createJavaPeer(jni::JNIEnv& env) {
- static auto javaClass = jni::Class<HillshadeLayer>::Singleton(env);
+ jni::Local<jni::Object<Layer>> HillshadeLayer::createJavaPeer(jni::JNIEnv& env) {
+ static auto& javaClass = jni::Class<HillshadeLayer>::Singleton(env);
static auto constructor = javaClass.GetConstructor<jni::jlong>(env);
return javaClass.New(env, constructor, reinterpret_cast<jni::jlong>(this));
}
void HillshadeLayer::registerNative(jni::JNIEnv& env) {
// Lookup the class
- static auto javaClass = jni::Class<HillshadeLayer>::Singleton(env);
+ static auto& javaClass = jni::Class<HillshadeLayer>::Singleton(env);
#define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
// Register the peer
jni::RegisterNativePeer<HillshadeLayer>(
env, javaClass, "nativePtr",
- std::make_unique<HillshadeLayer, JNIEnv&, jni::String, jni::String>,
+ jni::MakePeer<HillshadeLayer, jni::String&, jni::String&>,
"initialize",
"finalize",
METHOD(&HillshadeLayer::getHillshadeIlluminationDirection, "nativeGetHillshadeIlluminationDirection"),
diff --git a/platform/android/src/style/layers/hillshade_layer.hpp b/platform/android/src/style/layers/hillshade_layer.hpp
index f824698058..9ca0e33cfd 100644
--- a/platform/android/src/style/layers/hillshade_layer.hpp
+++ b/platform/android/src/style/layers/hillshade_layer.hpp
@@ -12,12 +12,12 @@ namespace android {
class HillshadeLayer : public Layer {
public:
-
+ using SuperTag = Layer;
static constexpr auto Name() { return "com/mapbox/mapboxsdk/style/layers/HillshadeLayer"; };
static void registerNative(jni::JNIEnv&);
- HillshadeLayer(jni::JNIEnv&, jni::String, jni::String);
+ HillshadeLayer(jni::JNIEnv&, jni::String&, jni::String&);
HillshadeLayer(mbgl::Map&, mbgl::style::HillshadeLayer&);
@@ -27,26 +27,26 @@ public:
// Properties
- jni::Object<jni::ObjectTag> getHillshadeIlluminationDirection(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getHillshadeIlluminationDirection(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getHillshadeIlluminationAnchor(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getHillshadeIlluminationAnchor(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getHillshadeExaggeration(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getHillshadeExaggeration(jni::JNIEnv&);
void setHillshadeExaggerationTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getHillshadeExaggerationTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getHillshadeExaggerationTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getHillshadeShadowColor(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getHillshadeShadowColor(jni::JNIEnv&);
void setHillshadeShadowColorTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getHillshadeShadowColorTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getHillshadeShadowColorTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getHillshadeHighlightColor(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getHillshadeHighlightColor(jni::JNIEnv&);
void setHillshadeHighlightColorTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getHillshadeHighlightColorTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getHillshadeHighlightColorTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getHillshadeAccentColor(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getHillshadeAccentColor(jni::JNIEnv&);
void setHillshadeAccentColorTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getHillshadeAccentColorTransition(jni::JNIEnv&);
- jni::jobject* createJavaPeer(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getHillshadeAccentColorTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<Layer>> createJavaPeer(jni::JNIEnv&);
}; // class HillshadeLayer
diff --git a/platform/android/src/style/layers/layer.cpp b/platform/android/src/style/layers/layer.cpp
index fe4fb9aeb6..5726873f40 100644
--- a/platform/android/src/style/layers/layer.cpp
+++ b/platform/android/src/style/layers/layer.cpp
@@ -83,7 +83,7 @@ namespace android {
return std::move(ownedLayer);
}
- jni::String Layer::getId(jni::JNIEnv& env) {
+ jni::Local<jni::String> Layer::getId(jni::JNIEnv& env) {
return jni::Make<jni::String>(env, layer.getID());
}
@@ -91,18 +91,18 @@ namespace android {
return layer;
}
- void Layer::setLayoutProperty(jni::JNIEnv& env, jni::String jname, jni::Object<> jvalue) {
+ void Layer::setLayoutProperty(jni::JNIEnv& env, const jni::String& jname, const jni::Object<>& jvalue) {
// Convert and set property
- optional<mbgl::style::conversion::Error> error = layer.setLayoutProperty(jni::Make<std::string>(env, jname), Value(env, jni::SeizeLocal(env, std::move(jvalue))));
+ optional<mbgl::style::conversion::Error> error = layer.setLayoutProperty(jni::Make<std::string>(env, jname), Value(env, jvalue));
if (error) {
mbgl::Log::Error(mbgl::Event::JNI, "Error setting property: " + jni::Make<std::string>(env, jname) + " " + error->message);
return;
}
}
- void Layer::setPaintProperty(jni::JNIEnv& env, jni::String jname, jni::Object<> jvalue) {
+ void Layer::setPaintProperty(jni::JNIEnv& env, const jni::String& jname, const jni::Object<>& jvalue) {
// Convert and set property
- optional<mbgl::style::conversion::Error> error = layer.setPaintProperty(jni::Make<std::string>(env, jname), Value(env, jni::SeizeLocal(env, std::move(jvalue))));
+ optional<mbgl::style::conversion::Error> error = layer.setPaintProperty(jni::Make<std::string>(env, jname), Value(env, jvalue));
if (error) {
mbgl::Log::Error(mbgl::Event::JNI, "Error setting property: " + jni::Make<std::string>(env, jname) + " " + error->message);
return;
@@ -123,12 +123,12 @@ namespace android {
}
};
- void Layer::setFilter(jni::JNIEnv& env, jni::Array<jni::Object<>> jfilter) {
+ void Layer::setFilter(jni::JNIEnv& env, const jni::Array<jni::Object<>>& jfilter) {
using namespace mbgl::style;
using namespace mbgl::style::conversion;
Error error;
- optional<Filter> converted = convert<Filter>(Value(env, jni::SeizeLocal(env, std::move(jfilter))), error);
+ optional<Filter> converted = convert<Filter>(Value(env, jfilter), error);
if (!converted) {
mbgl::Log::Error(mbgl::Event::JNI, "Error setting filter: " + error.message);
return;
@@ -154,7 +154,7 @@ namespace android {
}
};
- jni::Object<gson::JsonElement> Layer::getFilter(jni::JNIEnv& env) {
+ jni::Local<jni::Object<gson::JsonElement>> Layer::getFilter(jni::JNIEnv& env) {
using namespace mbgl::style;
using namespace mbgl::style::conversion;
@@ -163,7 +163,7 @@ namespace android {
mbgl::Value expressionValue = (*filter.expression)->serialize();
return gson::JsonElement::New(env, expressionValue);
} else {
- return jni::Object<gson::JsonElement>();
+ return jni::Local<jni::Object<gson::JsonElement>>(env, nullptr);
}
}
@@ -181,7 +181,7 @@ namespace android {
}
};
- void Layer::setSourceLayer(jni::JNIEnv& env, jni::String sourceLayer) {
+ void Layer::setSourceLayer(jni::JNIEnv& env, const jni::String& sourceLayer) {
layer.accept(SetSourceLayerEvaluator {jni::Make<std::string>(env, sourceLayer)});
}
@@ -202,7 +202,7 @@ namespace android {
}
};
- jni::String Layer::getSourceLayer(jni::JNIEnv& env) {
+ jni::Local<jni::String> Layer::getSourceLayer(jni::JNIEnv& env) {
return jni::Make<jni::String>(env, layer.accept(GetSourceLayerEvaluator()));
}
@@ -221,7 +221,7 @@ namespace android {
}
};
- jni::String Layer::getSourceId(jni::JNIEnv& env) {
+ jni::Local<jni::String> Layer::getSourceId(jni::JNIEnv& env) {
return jni::Make<jni::String>(env, layer.accept(GetSourceIdEvaluator()));
}
@@ -241,14 +241,14 @@ namespace android {
layer.setMaxZoom(zoom);
}
- jni::Object<jni::ObjectTag> Layer::getVisibility(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> Layer::getVisibility(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- return jni::Object<jni::ObjectTag>(*convert<jni::jobject*>(env, layer.getVisibility()));
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.getVisibility()));
}
void Layer::registerNative(jni::JNIEnv& env) {
// Lookup the class
- static auto javaClass = jni::Class<Layer>::Singleton(env);
+ static auto& javaClass = jni::Class<Layer>::Singleton(env);
#define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
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++) {%>
diff --git a/platform/android/src/style/layers/layer.hpp b/platform/android/src/style/layers/layer.hpp
index 8112dd18d6..cee1b5a64e 100644
--- a/platform/android/src/style/layers/layer.hpp
+++ b/platform/android/src/style/layers/layer.hpp
@@ -36,7 +36,7 @@ public:
virtual ~Layer();
- virtual jni::jobject* createJavaPeer(jni::JNIEnv&) = 0;
+ virtual jni::Local<jni::Object<Layer>> createJavaPeer(jni::JNIEnv&) = 0;
/**
* Set core layer (ie return ownership after remove)
@@ -45,15 +45,15 @@ public:
void addToMap(mbgl::Map&, mbgl::optional<std::string>);
- jni::String getId(jni::JNIEnv&);
+ jni::Local<jni::String> getId(jni::JNIEnv&);
- jni::String getSourceId(jni::JNIEnv&);
+ jni::Local<jni::String> getSourceId(jni::JNIEnv&);
style::Layer& get();
- void setLayoutProperty(jni::JNIEnv&, jni::String, jni::Object<> value);
+ void setLayoutProperty(jni::JNIEnv&, const jni::String&, const jni::Object<>& value);
- void setPaintProperty(jni::JNIEnv&, jni::String, jni::Object<> value);
+ void setPaintProperty(jni::JNIEnv&, const jni::String&, const jni::Object<>& value);
// Zoom
@@ -67,17 +67,17 @@ public:
/* common properties, but not shared by all */
- void setFilter(jni::JNIEnv&, jni::Array<jni::Object<>>);
+ void setFilter(jni::JNIEnv&, const jni::Array<jni::Object<>>&);
- jni::Object<gson::JsonElement> getFilter(jni::JNIEnv&);
+ jni::Local<jni::Object<gson::JsonElement>> getFilter(jni::JNIEnv&);
- void setSourceLayer(jni::JNIEnv&, jni::String);
+ void setSourceLayer(jni::JNIEnv&, const jni::String&);
- jni::String getSourceLayer(jni::JNIEnv&);
+ jni::Local<jni::String> getSourceLayer(jni::JNIEnv&);
// Property getters
- jni::Object<jni::ObjectTag> getVisibility(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getVisibility(jni::JNIEnv&);
protected:
// Release the owned view and return it
diff --git a/platform/android/src/style/layers/layer.hpp.ejs b/platform/android/src/style/layers/layer.hpp.ejs
index dd599d71df..5ceab0dcfa 100644
--- a/platform/android/src/style/layers/layer.hpp.ejs
+++ b/platform/android/src/style/layers/layer.hpp.ejs
@@ -16,15 +16,15 @@ namespace android {
class <%- camelize(type) %>Layer : public Layer {
public:
-
+ using SuperTag = Layer;
static constexpr auto Name() { return "com/mapbox/mapboxsdk/style/layers/<%- camelize(type) %>Layer"; };
static void registerNative(jni::JNIEnv&);
<% if (type === 'background') { -%>
- <%- camelize(type) %>Layer(jni::JNIEnv&, jni::String);
+ <%- camelize(type) %>Layer(jni::JNIEnv&, jni::String&);
<% } else { -%>
- <%- camelize(type) %>Layer(jni::JNIEnv&, jni::String, jni::String);
+ <%- camelize(type) %>Layer(jni::JNIEnv&, jni::String&, jni::String&);
<% } -%>
<%- camelize(type) %>Layer(mbgl::Map&, mbgl::style::<%- camelize(type) %>Layer&);
@@ -36,13 +36,13 @@ public:
// Properties
<% for (const property of properties) { -%>
- jni::Object<jni::ObjectTag> get<%- camelize(property.name) %>(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> get<%- camelize(property.name) %>(jni::JNIEnv&);
<% if (property.transition) { -%>
void set<%- camelize(property.name) %>Transition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> get<%- camelize(property.name) %>Transition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> get<%- camelize(property.name) %>Transition(jni::JNIEnv&);
<% } -%>
<% } -%>
- jni::jobject* createJavaPeer(jni::JNIEnv&);
+ jni::Local<jni::Object<Layer>> createJavaPeer(jni::JNIEnv&);
}; // class <%- camelize(type) %>Layer
diff --git a/platform/android/src/style/layers/layers.cpp b/platform/android/src/style/layers/layers.cpp
index 5df689b45d..232e92a7c7 100644
--- a/platform/android/src/style/layers/layers.cpp
+++ b/platform/android/src/style/layers/layers.cpp
@@ -77,16 +77,16 @@ static Layer* initializeLayerPeer(Map& map, std::unique_ptr<mbgl::style::Layer>
return layer ? layer : new UnknownLayer(map, std::move(coreLayer));
}
-jni::jobject* createJavaLayerPeer(jni::JNIEnv& env, Map& map, style::Layer& coreLayer) {
+jni::Local<jni::Object<Layer>> createJavaLayerPeer(jni::JNIEnv& env, Map& map, style::Layer& coreLayer) {
std::unique_ptr<Layer> peerLayer = std::unique_ptr<Layer>(initializeLayerPeer(map, coreLayer));
- jni::jobject* result = peerLayer->createJavaPeer(env);
+ jni::Local<jni::Object<Layer>> result = peerLayer->createJavaPeer(env);
peerLayer.release();
return result;
}
-jni::jobject* createJavaLayerPeer(jni::JNIEnv& env, mbgl::Map& map, std::unique_ptr<mbgl::style::Layer> coreLayer) {
+jni::Local<jni::Object<Layer>> createJavaLayerPeer(jni::JNIEnv& env, mbgl::Map& map, std::unique_ptr<mbgl::style::Layer> coreLayer) {
std::unique_ptr<Layer> peerLayer = std::unique_ptr<Layer>(initializeLayerPeer(map, std::move(coreLayer)));
- jni::jobject* result = peerLayer->createJavaPeer(env);
+ jni::Local<jni::Object<Layer>> result = peerLayer->createJavaPeer(env);
peerLayer.release();
return result;
}
diff --git a/platform/android/src/style/layers/layers.hpp b/platform/android/src/style/layers/layers.hpp
index 75863a324a..c9a6ba2e66 100644
--- a/platform/android/src/style/layers/layers.hpp
+++ b/platform/android/src/style/layers/layers.hpp
@@ -13,12 +13,12 @@ namespace android {
/**
* Create a non-owning peer
*/
-jni::jobject* createJavaLayerPeer(jni::JNIEnv&, mbgl::Map&, mbgl::style::Layer&);
+jni::Local<jni::Object<Layer>> createJavaLayerPeer(jni::JNIEnv&, mbgl::Map&, mbgl::style::Layer&);
/**
* Create an owning peer
*/
-jni::jobject* createJavaLayerPeer(jni::JNIEnv& env, mbgl::Map& map, std::unique_ptr<mbgl::style::Layer>);
+jni::Local<jni::Object<Layer>> createJavaLayerPeer(jni::JNIEnv& env, mbgl::Map& map, std::unique_ptr<mbgl::style::Layer>);
void registerNativeLayers(jni::JNIEnv&);
diff --git a/platform/android/src/style/layers/line_layer.cpp b/platform/android/src/style/layers/line_layer.cpp
index 2656bd9c09..376e4aafc0 100644
--- a/platform/android/src/style/layers/line_layer.cpp
+++ b/platform/android/src/style/layers/line_layer.cpp
@@ -13,7 +13,7 @@ namespace android {
/**
* Creates an owning peer object (for layers not attached to the map) from the JVM side
*/
- LineLayer::LineLayer(jni::JNIEnv& env, jni::String layerId, jni::String sourceId)
+ LineLayer::LineLayer(jni::JNIEnv& env, jni::String& layerId, jni::String& sourceId)
: Layer(env, std::make_unique<mbgl::style::LineLayer>(jni::Make<std::string>(env, layerId), jni::Make<std::string>(env, sourceId))) {
}
@@ -35,40 +35,35 @@ namespace android {
// Property getters
- jni::Object<jni::ObjectTag> LineLayer::getLineCap(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> LineLayer::getLineCap(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLineCap());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLineCap()));
}
- jni::Object<jni::ObjectTag> LineLayer::getLineJoin(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> LineLayer::getLineJoin(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLineJoin());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLineJoin()));
}
- jni::Object<jni::ObjectTag> LineLayer::getLineMiterLimit(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> LineLayer::getLineMiterLimit(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLineMiterLimit());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLineMiterLimit()));
}
- jni::Object<jni::ObjectTag> LineLayer::getLineRoundLimit(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> LineLayer::getLineRoundLimit(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLineRoundLimit());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLineRoundLimit()));
}
- jni::Object<jni::ObjectTag> LineLayer::getLineOpacity(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> LineLayer::getLineOpacity(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLineOpacity());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLineOpacity()));
}
- jni::Object<TransitionOptions> LineLayer::getLineOpacityTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> LineLayer::getLineOpacityTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::LineLayer>()->LineLayer::getLineOpacityTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void LineLayer::setLineOpacityTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -78,16 +73,15 @@ namespace android {
layer.as<mbgl::style::LineLayer>()->LineLayer::setLineOpacityTransition(options);
}
- jni::Object<jni::ObjectTag> LineLayer::getLineColor(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> LineLayer::getLineColor(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLineColor());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLineColor()));
}
- jni::Object<TransitionOptions> LineLayer::getLineColorTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> LineLayer::getLineColorTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::LineLayer>()->LineLayer::getLineColorTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void LineLayer::setLineColorTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -97,16 +91,15 @@ namespace android {
layer.as<mbgl::style::LineLayer>()->LineLayer::setLineColorTransition(options);
}
- jni::Object<jni::ObjectTag> LineLayer::getLineTranslate(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> LineLayer::getLineTranslate(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLineTranslate());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLineTranslate()));
}
- jni::Object<TransitionOptions> LineLayer::getLineTranslateTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> LineLayer::getLineTranslateTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::LineLayer>()->LineLayer::getLineTranslateTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void LineLayer::setLineTranslateTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -116,22 +109,20 @@ namespace android {
layer.as<mbgl::style::LineLayer>()->LineLayer::setLineTranslateTransition(options);
}
- jni::Object<jni::ObjectTag> LineLayer::getLineTranslateAnchor(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> LineLayer::getLineTranslateAnchor(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLineTranslateAnchor());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLineTranslateAnchor()));
}
- jni::Object<jni::ObjectTag> LineLayer::getLineWidth(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> LineLayer::getLineWidth(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLineWidth());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLineWidth()));
}
- jni::Object<TransitionOptions> LineLayer::getLineWidthTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> LineLayer::getLineWidthTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::LineLayer>()->LineLayer::getLineWidthTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void LineLayer::setLineWidthTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -141,16 +132,15 @@ namespace android {
layer.as<mbgl::style::LineLayer>()->LineLayer::setLineWidthTransition(options);
}
- jni::Object<jni::ObjectTag> LineLayer::getLineGapWidth(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> LineLayer::getLineGapWidth(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLineGapWidth());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLineGapWidth()));
}
- jni::Object<TransitionOptions> LineLayer::getLineGapWidthTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> LineLayer::getLineGapWidthTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::LineLayer>()->LineLayer::getLineGapWidthTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void LineLayer::setLineGapWidthTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -160,16 +150,15 @@ namespace android {
layer.as<mbgl::style::LineLayer>()->LineLayer::setLineGapWidthTransition(options);
}
- jni::Object<jni::ObjectTag> LineLayer::getLineOffset(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> LineLayer::getLineOffset(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLineOffset());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLineOffset()));
}
- jni::Object<TransitionOptions> LineLayer::getLineOffsetTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> LineLayer::getLineOffsetTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::LineLayer>()->LineLayer::getLineOffsetTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void LineLayer::setLineOffsetTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -179,16 +168,15 @@ namespace android {
layer.as<mbgl::style::LineLayer>()->LineLayer::setLineOffsetTransition(options);
}
- jni::Object<jni::ObjectTag> LineLayer::getLineBlur(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> LineLayer::getLineBlur(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLineBlur());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLineBlur()));
}
- jni::Object<TransitionOptions> LineLayer::getLineBlurTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> LineLayer::getLineBlurTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::LineLayer>()->LineLayer::getLineBlurTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void LineLayer::setLineBlurTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -198,16 +186,15 @@ namespace android {
layer.as<mbgl::style::LineLayer>()->LineLayer::setLineBlurTransition(options);
}
- jni::Object<jni::ObjectTag> LineLayer::getLineDasharray(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> LineLayer::getLineDasharray(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLineDasharray());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLineDasharray()));
}
- jni::Object<TransitionOptions> LineLayer::getLineDasharrayTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> LineLayer::getLineDasharrayTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::LineLayer>()->LineLayer::getLineDasharrayTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void LineLayer::setLineDasharrayTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -217,16 +204,15 @@ namespace android {
layer.as<mbgl::style::LineLayer>()->LineLayer::setLineDasharrayTransition(options);
}
- jni::Object<jni::ObjectTag> LineLayer::getLinePattern(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> LineLayer::getLinePattern(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLinePattern());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLinePattern()));
}
- jni::Object<TransitionOptions> LineLayer::getLinePatternTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> LineLayer::getLinePatternTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::LineLayer>()->LineLayer::getLinePatternTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void LineLayer::setLinePatternTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -236,29 +222,28 @@ namespace android {
layer.as<mbgl::style::LineLayer>()->LineLayer::setLinePatternTransition(options);
}
- jni::Object<jni::ObjectTag> LineLayer::getLineGradient(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> LineLayer::getLineGradient(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLineGradient());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLineGradient()));
}
- jni::jobject* LineLayer::createJavaPeer(jni::JNIEnv& env) {
- static auto javaClass = jni::Class<LineLayer>::Singleton(env);
+ jni::Local<jni::Object<Layer>> LineLayer::createJavaPeer(jni::JNIEnv& env) {
+ static auto& javaClass = jni::Class<LineLayer>::Singleton(env);
static auto constructor = javaClass.GetConstructor<jni::jlong>(env);
return javaClass.New(env, constructor, reinterpret_cast<jni::jlong>(this));
}
void LineLayer::registerNative(jni::JNIEnv& env) {
// Lookup the class
- static auto javaClass = jni::Class<LineLayer>::Singleton(env);
+ static auto& javaClass = jni::Class<LineLayer>::Singleton(env);
#define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
// Register the peer
jni::RegisterNativePeer<LineLayer>(
env, javaClass, "nativePtr",
- std::make_unique<LineLayer, JNIEnv&, jni::String, jni::String>,
+ jni::MakePeer<LineLayer, jni::String&, jni::String&>,
"initialize",
"finalize",
METHOD(&LineLayer::getLineCap, "nativeGetLineCap"),
diff --git a/platform/android/src/style/layers/line_layer.hpp b/platform/android/src/style/layers/line_layer.hpp
index 4d1e759c1b..01be481958 100644
--- a/platform/android/src/style/layers/line_layer.hpp
+++ b/platform/android/src/style/layers/line_layer.hpp
@@ -12,12 +12,12 @@ namespace android {
class LineLayer : public Layer {
public:
-
+ using SuperTag = Layer;
static constexpr auto Name() { return "com/mapbox/mapboxsdk/style/layers/LineLayer"; };
static void registerNative(jni::JNIEnv&);
- LineLayer(jni::JNIEnv&, jni::String, jni::String);
+ LineLayer(jni::JNIEnv&, jni::String&, jni::String&);
LineLayer(mbgl::Map&, mbgl::style::LineLayer&);
@@ -27,54 +27,54 @@ public:
// Properties
- jni::Object<jni::ObjectTag> getLineCap(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getLineCap(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getLineJoin(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getLineJoin(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getLineMiterLimit(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getLineMiterLimit(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getLineRoundLimit(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getLineRoundLimit(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getLineOpacity(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getLineOpacity(jni::JNIEnv&);
void setLineOpacityTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getLineOpacityTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getLineOpacityTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getLineColor(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getLineColor(jni::JNIEnv&);
void setLineColorTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getLineColorTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getLineColorTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getLineTranslate(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getLineTranslate(jni::JNIEnv&);
void setLineTranslateTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getLineTranslateTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getLineTranslateTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getLineTranslateAnchor(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getLineTranslateAnchor(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getLineWidth(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getLineWidth(jni::JNIEnv&);
void setLineWidthTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getLineWidthTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getLineWidthTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getLineGapWidth(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getLineGapWidth(jni::JNIEnv&);
void setLineGapWidthTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getLineGapWidthTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getLineGapWidthTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getLineOffset(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getLineOffset(jni::JNIEnv&);
void setLineOffsetTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getLineOffsetTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getLineOffsetTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getLineBlur(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getLineBlur(jni::JNIEnv&);
void setLineBlurTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getLineBlurTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getLineBlurTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getLineDasharray(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getLineDasharray(jni::JNIEnv&);
void setLineDasharrayTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getLineDasharrayTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getLineDasharrayTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getLinePattern(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getLinePattern(jni::JNIEnv&);
void setLinePatternTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getLinePatternTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getLinePatternTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getLineGradient(jni::JNIEnv&);
- jni::jobject* createJavaPeer(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getLineGradient(jni::JNIEnv&);
+ jni::Local<jni::Object<Layer>> createJavaPeer(jni::JNIEnv&);
}; // class LineLayer
diff --git a/platform/android/src/style/layers/raster_layer.cpp b/platform/android/src/style/layers/raster_layer.cpp
index c52891b662..5a3579bc37 100644
--- a/platform/android/src/style/layers/raster_layer.cpp
+++ b/platform/android/src/style/layers/raster_layer.cpp
@@ -13,7 +13,7 @@ namespace android {
/**
* Creates an owning peer object (for layers not attached to the map) from the JVM side
*/
- RasterLayer::RasterLayer(jni::JNIEnv& env, jni::String layerId, jni::String sourceId)
+ RasterLayer::RasterLayer(jni::JNIEnv& env, jni::String& layerId, jni::String& sourceId)
: Layer(env, std::make_unique<mbgl::style::RasterLayer>(jni::Make<std::string>(env, layerId), jni::Make<std::string>(env, sourceId))) {
}
@@ -35,16 +35,15 @@ namespace android {
// Property getters
- jni::Object<jni::ObjectTag> RasterLayer::getRasterOpacity(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> RasterLayer::getRasterOpacity(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::RasterLayer>()->RasterLayer::getRasterOpacity());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::RasterLayer>()->RasterLayer::getRasterOpacity()));
}
- jni::Object<TransitionOptions> RasterLayer::getRasterOpacityTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> RasterLayer::getRasterOpacityTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::RasterLayer>()->RasterLayer::getRasterOpacityTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void RasterLayer::setRasterOpacityTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -54,16 +53,15 @@ namespace android {
layer.as<mbgl::style::RasterLayer>()->RasterLayer::setRasterOpacityTransition(options);
}
- jni::Object<jni::ObjectTag> RasterLayer::getRasterHueRotate(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> RasterLayer::getRasterHueRotate(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::RasterLayer>()->RasterLayer::getRasterHueRotate());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::RasterLayer>()->RasterLayer::getRasterHueRotate()));
}
- jni::Object<TransitionOptions> RasterLayer::getRasterHueRotateTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> RasterLayer::getRasterHueRotateTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::RasterLayer>()->RasterLayer::getRasterHueRotateTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void RasterLayer::setRasterHueRotateTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -73,16 +71,15 @@ namespace android {
layer.as<mbgl::style::RasterLayer>()->RasterLayer::setRasterHueRotateTransition(options);
}
- jni::Object<jni::ObjectTag> RasterLayer::getRasterBrightnessMin(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> RasterLayer::getRasterBrightnessMin(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::RasterLayer>()->RasterLayer::getRasterBrightnessMin());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::RasterLayer>()->RasterLayer::getRasterBrightnessMin()));
}
- jni::Object<TransitionOptions> RasterLayer::getRasterBrightnessMinTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> RasterLayer::getRasterBrightnessMinTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::RasterLayer>()->RasterLayer::getRasterBrightnessMinTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void RasterLayer::setRasterBrightnessMinTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -92,16 +89,15 @@ namespace android {
layer.as<mbgl::style::RasterLayer>()->RasterLayer::setRasterBrightnessMinTransition(options);
}
- jni::Object<jni::ObjectTag> RasterLayer::getRasterBrightnessMax(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> RasterLayer::getRasterBrightnessMax(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::RasterLayer>()->RasterLayer::getRasterBrightnessMax());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::RasterLayer>()->RasterLayer::getRasterBrightnessMax()));
}
- jni::Object<TransitionOptions> RasterLayer::getRasterBrightnessMaxTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> RasterLayer::getRasterBrightnessMaxTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::RasterLayer>()->RasterLayer::getRasterBrightnessMaxTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void RasterLayer::setRasterBrightnessMaxTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -111,16 +107,15 @@ namespace android {
layer.as<mbgl::style::RasterLayer>()->RasterLayer::setRasterBrightnessMaxTransition(options);
}
- jni::Object<jni::ObjectTag> RasterLayer::getRasterSaturation(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> RasterLayer::getRasterSaturation(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::RasterLayer>()->RasterLayer::getRasterSaturation());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::RasterLayer>()->RasterLayer::getRasterSaturation()));
}
- jni::Object<TransitionOptions> RasterLayer::getRasterSaturationTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> RasterLayer::getRasterSaturationTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::RasterLayer>()->RasterLayer::getRasterSaturationTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void RasterLayer::setRasterSaturationTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -130,16 +125,15 @@ namespace android {
layer.as<mbgl::style::RasterLayer>()->RasterLayer::setRasterSaturationTransition(options);
}
- jni::Object<jni::ObjectTag> RasterLayer::getRasterContrast(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> RasterLayer::getRasterContrast(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::RasterLayer>()->RasterLayer::getRasterContrast());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::RasterLayer>()->RasterLayer::getRasterContrast()));
}
- jni::Object<TransitionOptions> RasterLayer::getRasterContrastTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> RasterLayer::getRasterContrastTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::RasterLayer>()->RasterLayer::getRasterContrastTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void RasterLayer::setRasterContrastTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -149,35 +143,33 @@ namespace android {
layer.as<mbgl::style::RasterLayer>()->RasterLayer::setRasterContrastTransition(options);
}
- jni::Object<jni::ObjectTag> RasterLayer::getRasterResampling(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> RasterLayer::getRasterResampling(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::RasterLayer>()->RasterLayer::getRasterResampling());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::RasterLayer>()->RasterLayer::getRasterResampling()));
}
- jni::Object<jni::ObjectTag> RasterLayer::getRasterFadeDuration(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> RasterLayer::getRasterFadeDuration(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::RasterLayer>()->RasterLayer::getRasterFadeDuration());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::RasterLayer>()->RasterLayer::getRasterFadeDuration()));
}
- jni::jobject* RasterLayer::createJavaPeer(jni::JNIEnv& env) {
- static auto javaClass = jni::Class<RasterLayer>::Singleton(env);
+ jni::Local<jni::Object<Layer>> RasterLayer::createJavaPeer(jni::JNIEnv& env) {
+ static auto& javaClass = jni::Class<RasterLayer>::Singleton(env);
static auto constructor = javaClass.GetConstructor<jni::jlong>(env);
return javaClass.New(env, constructor, reinterpret_cast<jni::jlong>(this));
}
void RasterLayer::registerNative(jni::JNIEnv& env) {
// Lookup the class
- static auto javaClass = jni::Class<RasterLayer>::Singleton(env);
+ static auto& javaClass = jni::Class<RasterLayer>::Singleton(env);
#define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
// Register the peer
jni::RegisterNativePeer<RasterLayer>(
env, javaClass, "nativePtr",
- std::make_unique<RasterLayer, JNIEnv&, jni::String, jni::String>,
+ jni::MakePeer<RasterLayer, jni::String&, jni::String&>,
"initialize",
"finalize",
METHOD(&RasterLayer::getRasterOpacityTransition, "nativeGetRasterOpacityTransition"),
diff --git a/platform/android/src/style/layers/raster_layer.hpp b/platform/android/src/style/layers/raster_layer.hpp
index 4e268c36e5..40cc47634e 100644
--- a/platform/android/src/style/layers/raster_layer.hpp
+++ b/platform/android/src/style/layers/raster_layer.hpp
@@ -12,12 +12,12 @@ namespace android {
class RasterLayer : public Layer {
public:
-
+ using SuperTag = Layer;
static constexpr auto Name() { return "com/mapbox/mapboxsdk/style/layers/RasterLayer"; };
static void registerNative(jni::JNIEnv&);
- RasterLayer(jni::JNIEnv&, jni::String, jni::String);
+ RasterLayer(jni::JNIEnv&, jni::String&, jni::String&);
RasterLayer(mbgl::Map&, mbgl::style::RasterLayer&);
@@ -27,34 +27,34 @@ public:
// Properties
- jni::Object<jni::ObjectTag> getRasterOpacity(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getRasterOpacity(jni::JNIEnv&);
void setRasterOpacityTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getRasterOpacityTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getRasterOpacityTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getRasterHueRotate(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getRasterHueRotate(jni::JNIEnv&);
void setRasterHueRotateTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getRasterHueRotateTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getRasterHueRotateTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getRasterBrightnessMin(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getRasterBrightnessMin(jni::JNIEnv&);
void setRasterBrightnessMinTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getRasterBrightnessMinTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getRasterBrightnessMinTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getRasterBrightnessMax(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getRasterBrightnessMax(jni::JNIEnv&);
void setRasterBrightnessMaxTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getRasterBrightnessMaxTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getRasterBrightnessMaxTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getRasterSaturation(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getRasterSaturation(jni::JNIEnv&);
void setRasterSaturationTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getRasterSaturationTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getRasterSaturationTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getRasterContrast(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getRasterContrast(jni::JNIEnv&);
void setRasterContrastTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getRasterContrastTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getRasterContrastTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getRasterResampling(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getRasterResampling(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getRasterFadeDuration(jni::JNIEnv&);
- jni::jobject* createJavaPeer(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getRasterFadeDuration(jni::JNIEnv&);
+ jni::Local<jni::Object<Layer>> createJavaPeer(jni::JNIEnv&);
}; // class RasterLayer
diff --git a/platform/android/src/style/layers/symbol_layer.cpp b/platform/android/src/style/layers/symbol_layer.cpp
index 953c73e221..a0f37c91d2 100644
--- a/platform/android/src/style/layers/symbol_layer.cpp
+++ b/platform/android/src/style/layers/symbol_layer.cpp
@@ -13,7 +13,7 @@ namespace android {
/**
* Creates an owning peer object (for layers not attached to the map) from the JVM side
*/
- SymbolLayer::SymbolLayer(jni::JNIEnv& env, jni::String layerId, jni::String sourceId)
+ SymbolLayer::SymbolLayer(jni::JNIEnv& env, jni::String& layerId, jni::String& sourceId)
: Layer(env, std::make_unique<mbgl::style::SymbolLayer>(jni::Make<std::string>(env, layerId), jni::Make<std::string>(env, sourceId))) {
}
@@ -35,232 +35,195 @@ namespace android {
// Property getters
- jni::Object<jni::ObjectTag> SymbolLayer::getSymbolPlacement(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getSymbolPlacement(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getSymbolPlacement());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getSymbolPlacement()));
}
- jni::Object<jni::ObjectTag> SymbolLayer::getSymbolSpacing(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getSymbolSpacing(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getSymbolSpacing());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getSymbolSpacing()));
}
- jni::Object<jni::ObjectTag> SymbolLayer::getSymbolAvoidEdges(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getSymbolAvoidEdges(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getSymbolAvoidEdges());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getSymbolAvoidEdges()));
}
- jni::Object<jni::ObjectTag> SymbolLayer::getIconAllowOverlap(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getIconAllowOverlap(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconAllowOverlap());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconAllowOverlap()));
}
- jni::Object<jni::ObjectTag> SymbolLayer::getIconIgnorePlacement(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getIconIgnorePlacement(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconIgnorePlacement());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconIgnorePlacement()));
}
- jni::Object<jni::ObjectTag> SymbolLayer::getIconOptional(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getIconOptional(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconOptional());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconOptional()));
}
- jni::Object<jni::ObjectTag> SymbolLayer::getIconRotationAlignment(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getIconRotationAlignment(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconRotationAlignment());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconRotationAlignment()));
}
- jni::Object<jni::ObjectTag> SymbolLayer::getIconSize(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getIconSize(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconSize());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconSize()));
}
- jni::Object<jni::ObjectTag> SymbolLayer::getIconTextFit(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getIconTextFit(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconTextFit());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconTextFit()));
}
- jni::Object<jni::ObjectTag> SymbolLayer::getIconTextFitPadding(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getIconTextFitPadding(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconTextFitPadding());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconTextFitPadding()));
}
- jni::Object<jni::ObjectTag> SymbolLayer::getIconImage(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getIconImage(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconImage());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconImage()));
}
- jni::Object<jni::ObjectTag> SymbolLayer::getIconRotate(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getIconRotate(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconRotate());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconRotate()));
}
- jni::Object<jni::ObjectTag> SymbolLayer::getIconPadding(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getIconPadding(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconPadding());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconPadding()));
}
- jni::Object<jni::ObjectTag> SymbolLayer::getIconKeepUpright(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getIconKeepUpright(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconKeepUpright());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconKeepUpright()));
}
- jni::Object<jni::ObjectTag> SymbolLayer::getIconOffset(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getIconOffset(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconOffset());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconOffset()));
}
- jni::Object<jni::ObjectTag> SymbolLayer::getIconAnchor(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getIconAnchor(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconAnchor());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconAnchor()));
}
- jni::Object<jni::ObjectTag> SymbolLayer::getIconPitchAlignment(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getIconPitchAlignment(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconPitchAlignment());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconPitchAlignment()));
}
- jni::Object<jni::ObjectTag> SymbolLayer::getTextPitchAlignment(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getTextPitchAlignment(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextPitchAlignment());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextPitchAlignment()));
}
- jni::Object<jni::ObjectTag> SymbolLayer::getTextRotationAlignment(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getTextRotationAlignment(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextRotationAlignment());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextRotationAlignment()));
}
- jni::Object<jni::ObjectTag> SymbolLayer::getTextField(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getTextField(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextField());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextField()));
}
- jni::Object<jni::ObjectTag> SymbolLayer::getTextFont(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getTextFont(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextFont());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextFont()));
}
- jni::Object<jni::ObjectTag> SymbolLayer::getTextSize(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getTextSize(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextSize());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextSize()));
}
- jni::Object<jni::ObjectTag> SymbolLayer::getTextMaxWidth(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getTextMaxWidth(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextMaxWidth());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextMaxWidth()));
}
- jni::Object<jni::ObjectTag> SymbolLayer::getTextLineHeight(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getTextLineHeight(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextLineHeight());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextLineHeight()));
}
- jni::Object<jni::ObjectTag> SymbolLayer::getTextLetterSpacing(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getTextLetterSpacing(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextLetterSpacing());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextLetterSpacing()));
}
- jni::Object<jni::ObjectTag> SymbolLayer::getTextJustify(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getTextJustify(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextJustify());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextJustify()));
}
- jni::Object<jni::ObjectTag> SymbolLayer::getTextAnchor(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getTextAnchor(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextAnchor());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextAnchor()));
}
- jni::Object<jni::ObjectTag> SymbolLayer::getTextMaxAngle(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getTextMaxAngle(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextMaxAngle());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextMaxAngle()));
}
- jni::Object<jni::ObjectTag> SymbolLayer::getTextRotate(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getTextRotate(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextRotate());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextRotate()));
}
- jni::Object<jni::ObjectTag> SymbolLayer::getTextPadding(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getTextPadding(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextPadding());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextPadding()));
}
- jni::Object<jni::ObjectTag> SymbolLayer::getTextKeepUpright(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getTextKeepUpright(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextKeepUpright());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextKeepUpright()));
}
- jni::Object<jni::ObjectTag> SymbolLayer::getTextTransform(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getTextTransform(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextTransform());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextTransform()));
}
- jni::Object<jni::ObjectTag> SymbolLayer::getTextOffset(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getTextOffset(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextOffset());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextOffset()));
}
- jni::Object<jni::ObjectTag> SymbolLayer::getTextAllowOverlap(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getTextAllowOverlap(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextAllowOverlap());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextAllowOverlap()));
}
- jni::Object<jni::ObjectTag> SymbolLayer::getTextIgnorePlacement(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getTextIgnorePlacement(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextIgnorePlacement());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextIgnorePlacement()));
}
- jni::Object<jni::ObjectTag> SymbolLayer::getTextOptional(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getTextOptional(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextOptional());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextOptional()));
}
- jni::Object<jni::ObjectTag> SymbolLayer::getIconOpacity(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getIconOpacity(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconOpacity());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconOpacity()));
}
- jni::Object<TransitionOptions> SymbolLayer::getIconOpacityTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> SymbolLayer::getIconOpacityTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconOpacityTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void SymbolLayer::setIconOpacityTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -270,16 +233,15 @@ namespace android {
layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::setIconOpacityTransition(options);
}
- jni::Object<jni::ObjectTag> SymbolLayer::getIconColor(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getIconColor(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconColor());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconColor()));
}
- jni::Object<TransitionOptions> SymbolLayer::getIconColorTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> SymbolLayer::getIconColorTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconColorTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void SymbolLayer::setIconColorTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -289,16 +251,15 @@ namespace android {
layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::setIconColorTransition(options);
}
- jni::Object<jni::ObjectTag> SymbolLayer::getIconHaloColor(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getIconHaloColor(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconHaloColor());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconHaloColor()));
}
- jni::Object<TransitionOptions> SymbolLayer::getIconHaloColorTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> SymbolLayer::getIconHaloColorTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconHaloColorTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void SymbolLayer::setIconHaloColorTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -308,16 +269,15 @@ namespace android {
layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::setIconHaloColorTransition(options);
}
- jni::Object<jni::ObjectTag> SymbolLayer::getIconHaloWidth(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getIconHaloWidth(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconHaloWidth());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconHaloWidth()));
}
- jni::Object<TransitionOptions> SymbolLayer::getIconHaloWidthTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> SymbolLayer::getIconHaloWidthTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconHaloWidthTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void SymbolLayer::setIconHaloWidthTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -327,16 +287,15 @@ namespace android {
layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::setIconHaloWidthTransition(options);
}
- jni::Object<jni::ObjectTag> SymbolLayer::getIconHaloBlur(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getIconHaloBlur(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconHaloBlur());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconHaloBlur()));
}
- jni::Object<TransitionOptions> SymbolLayer::getIconHaloBlurTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> SymbolLayer::getIconHaloBlurTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconHaloBlurTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void SymbolLayer::setIconHaloBlurTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -346,16 +305,15 @@ namespace android {
layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::setIconHaloBlurTransition(options);
}
- jni::Object<jni::ObjectTag> SymbolLayer::getIconTranslate(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getIconTranslate(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconTranslate());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconTranslate()));
}
- jni::Object<TransitionOptions> SymbolLayer::getIconTranslateTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> SymbolLayer::getIconTranslateTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconTranslateTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void SymbolLayer::setIconTranslateTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -365,22 +323,20 @@ namespace android {
layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::setIconTranslateTransition(options);
}
- jni::Object<jni::ObjectTag> SymbolLayer::getIconTranslateAnchor(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getIconTranslateAnchor(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconTranslateAnchor());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconTranslateAnchor()));
}
- jni::Object<jni::ObjectTag> SymbolLayer::getTextOpacity(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getTextOpacity(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextOpacity());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextOpacity()));
}
- jni::Object<TransitionOptions> SymbolLayer::getTextOpacityTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> SymbolLayer::getTextOpacityTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextOpacityTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void SymbolLayer::setTextOpacityTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -390,16 +346,15 @@ namespace android {
layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::setTextOpacityTransition(options);
}
- jni::Object<jni::ObjectTag> SymbolLayer::getTextColor(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getTextColor(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextColor());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextColor()));
}
- jni::Object<TransitionOptions> SymbolLayer::getTextColorTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> SymbolLayer::getTextColorTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextColorTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void SymbolLayer::setTextColorTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -409,16 +364,15 @@ namespace android {
layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::setTextColorTransition(options);
}
- jni::Object<jni::ObjectTag> SymbolLayer::getTextHaloColor(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getTextHaloColor(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextHaloColor());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextHaloColor()));
}
- jni::Object<TransitionOptions> SymbolLayer::getTextHaloColorTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> SymbolLayer::getTextHaloColorTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextHaloColorTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void SymbolLayer::setTextHaloColorTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -428,16 +382,15 @@ namespace android {
layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::setTextHaloColorTransition(options);
}
- jni::Object<jni::ObjectTag> SymbolLayer::getTextHaloWidth(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getTextHaloWidth(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextHaloWidth());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextHaloWidth()));
}
- jni::Object<TransitionOptions> SymbolLayer::getTextHaloWidthTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> SymbolLayer::getTextHaloWidthTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextHaloWidthTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void SymbolLayer::setTextHaloWidthTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -447,16 +400,15 @@ namespace android {
layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::setTextHaloWidthTransition(options);
}
- jni::Object<jni::ObjectTag> SymbolLayer::getTextHaloBlur(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getTextHaloBlur(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextHaloBlur());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextHaloBlur()));
}
- jni::Object<TransitionOptions> SymbolLayer::getTextHaloBlurTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> SymbolLayer::getTextHaloBlurTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextHaloBlurTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void SymbolLayer::setTextHaloBlurTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -466,16 +418,15 @@ namespace android {
layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::setTextHaloBlurTransition(options);
}
- jni::Object<jni::ObjectTag> SymbolLayer::getTextTranslate(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getTextTranslate(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextTranslate());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextTranslate()));
}
- jni::Object<TransitionOptions> SymbolLayer::getTextTranslateTransition(jni::JNIEnv& env) {
+ jni::Local<jni::Object<TransitionOptions>> SymbolLayer::getTextTranslateTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextTranslateTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void SymbolLayer::setTextTranslateTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -485,29 +436,28 @@ namespace android {
layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::setTextTranslateTransition(options);
}
- jni::Object<jni::ObjectTag> SymbolLayer::getTextTranslateAnchor(jni::JNIEnv& env) {
+ jni::Local<jni::Object<>> SymbolLayer::getTextTranslateAnchor(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
- Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextTranslateAnchor());
- return jni::Object<jni::ObjectTag>(*converted);
+ return std::move(*convert<jni::Local<jni::Object<>>>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextTranslateAnchor()));
}
- jni::jobject* SymbolLayer::createJavaPeer(jni::JNIEnv& env) {
- static auto javaClass = jni::Class<SymbolLayer>::Singleton(env);
+ jni::Local<jni::Object<Layer>> SymbolLayer::createJavaPeer(jni::JNIEnv& env) {
+ static auto& javaClass = jni::Class<SymbolLayer>::Singleton(env);
static auto constructor = javaClass.GetConstructor<jni::jlong>(env);
return javaClass.New(env, constructor, reinterpret_cast<jni::jlong>(this));
}
void SymbolLayer::registerNative(jni::JNIEnv& env) {
// Lookup the class
- static auto javaClass = jni::Class<SymbolLayer>::Singleton(env);
+ static auto& javaClass = jni::Class<SymbolLayer>::Singleton(env);
#define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
// Register the peer
jni::RegisterNativePeer<SymbolLayer>(
env, javaClass, "nativePtr",
- std::make_unique<SymbolLayer, JNIEnv&, jni::String, jni::String>,
+ jni::MakePeer<SymbolLayer, jni::String&, jni::String&>,
"initialize",
"finalize",
METHOD(&SymbolLayer::getSymbolPlacement, "nativeGetSymbolPlacement"),
diff --git a/platform/android/src/style/layers/symbol_layer.hpp b/platform/android/src/style/layers/symbol_layer.hpp
index 3835e01bf1..206a6546c3 100644
--- a/platform/android/src/style/layers/symbol_layer.hpp
+++ b/platform/android/src/style/layers/symbol_layer.hpp
@@ -12,12 +12,12 @@ namespace android {
class SymbolLayer : public Layer {
public:
-
+ using SuperTag = Layer;
static constexpr auto Name() { return "com/mapbox/mapboxsdk/style/layers/SymbolLayer"; };
static void registerNative(jni::JNIEnv&);
- SymbolLayer(jni::JNIEnv&, jni::String, jni::String);
+ SymbolLayer(jni::JNIEnv&, jni::String&, jni::String&);
SymbolLayer(mbgl::Map&, mbgl::style::SymbolLayer&);
@@ -27,130 +27,130 @@ public:
// Properties
- jni::Object<jni::ObjectTag> getSymbolPlacement(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getSymbolPlacement(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getSymbolSpacing(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getSymbolSpacing(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getSymbolAvoidEdges(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getSymbolAvoidEdges(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getIconAllowOverlap(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getIconAllowOverlap(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getIconIgnorePlacement(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getIconIgnorePlacement(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getIconOptional(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getIconOptional(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getIconRotationAlignment(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getIconRotationAlignment(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getIconSize(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getIconSize(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getIconTextFit(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getIconTextFit(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getIconTextFitPadding(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getIconTextFitPadding(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getIconImage(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getIconImage(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getIconRotate(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getIconRotate(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getIconPadding(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getIconPadding(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getIconKeepUpright(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getIconKeepUpright(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getIconOffset(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getIconOffset(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getIconAnchor(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getIconAnchor(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getIconPitchAlignment(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getIconPitchAlignment(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getTextPitchAlignment(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getTextPitchAlignment(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getTextRotationAlignment(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getTextRotationAlignment(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getTextField(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getTextField(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getTextFont(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getTextFont(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getTextSize(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getTextSize(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getTextMaxWidth(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getTextMaxWidth(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getTextLineHeight(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getTextLineHeight(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getTextLetterSpacing(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getTextLetterSpacing(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getTextJustify(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getTextJustify(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getTextAnchor(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getTextAnchor(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getTextMaxAngle(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getTextMaxAngle(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getTextRotate(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getTextRotate(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getTextPadding(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getTextPadding(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getTextKeepUpright(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getTextKeepUpright(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getTextTransform(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getTextTransform(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getTextOffset(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getTextOffset(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getTextAllowOverlap(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getTextAllowOverlap(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getTextIgnorePlacement(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getTextIgnorePlacement(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getTextOptional(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getTextOptional(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getIconOpacity(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getIconOpacity(jni::JNIEnv&);
void setIconOpacityTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getIconOpacityTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getIconOpacityTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getIconColor(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getIconColor(jni::JNIEnv&);
void setIconColorTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getIconColorTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getIconColorTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getIconHaloColor(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getIconHaloColor(jni::JNIEnv&);
void setIconHaloColorTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getIconHaloColorTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getIconHaloColorTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getIconHaloWidth(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getIconHaloWidth(jni::JNIEnv&);
void setIconHaloWidthTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getIconHaloWidthTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getIconHaloWidthTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getIconHaloBlur(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getIconHaloBlur(jni::JNIEnv&);
void setIconHaloBlurTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getIconHaloBlurTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getIconHaloBlurTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getIconTranslate(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getIconTranslate(jni::JNIEnv&);
void setIconTranslateTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getIconTranslateTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getIconTranslateTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getIconTranslateAnchor(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getIconTranslateAnchor(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getTextOpacity(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getTextOpacity(jni::JNIEnv&);
void setTextOpacityTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getTextOpacityTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getTextOpacityTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getTextColor(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getTextColor(jni::JNIEnv&);
void setTextColorTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getTextColorTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getTextColorTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getTextHaloColor(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getTextHaloColor(jni::JNIEnv&);
void setTextHaloColorTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getTextHaloColorTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getTextHaloColorTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getTextHaloWidth(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getTextHaloWidth(jni::JNIEnv&);
void setTextHaloWidthTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getTextHaloWidthTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getTextHaloWidthTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getTextHaloBlur(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getTextHaloBlur(jni::JNIEnv&);
void setTextHaloBlurTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getTextHaloBlurTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getTextHaloBlurTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getTextTranslate(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getTextTranslate(jni::JNIEnv&);
void setTextTranslateTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getTextTranslateTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getTextTranslateTransition(jni::JNIEnv&);
- jni::Object<jni::ObjectTag> getTextTranslateAnchor(jni::JNIEnv&);
- jni::jobject* createJavaPeer(jni::JNIEnv&);
+ jni::Local<jni::Object<jni::ObjectTag>> getTextTranslateAnchor(jni::JNIEnv&);
+ jni::Local<jni::Object<Layer>> createJavaPeer(jni::JNIEnv&);
}; // class SymbolLayer
diff --git a/platform/android/src/style/layers/unknown_layer.cpp b/platform/android/src/style/layers/unknown_layer.cpp
index 9f877e4896..5c770012bd 100644
--- a/platform/android/src/style/layers/unknown_layer.cpp
+++ b/platform/android/src/style/layers/unknown_layer.cpp
@@ -22,15 +22,15 @@ namespace android {
: Layer(map, std::move(coreLayer)) {
}
- jni::jobject* UnknownLayer::createJavaPeer(jni::JNIEnv& env) {
- static auto javaClass = jni::Class<UnknownLayer>::Singleton(env);
+ jni::Local<jni::Object<Layer>> UnknownLayer::createJavaPeer(jni::JNIEnv& env) {
+ static auto& javaClass = jni::Class<UnknownLayer>::Singleton(env);
static auto constructor = javaClass.GetConstructor<jni::jlong>(env);
return javaClass.New(env, constructor, reinterpret_cast<jni::jlong>(this));
}
void UnknownLayer::registerNative(jni::JNIEnv& env) {
// Lookup the class
- static auto javaClass = jni::Class<UnknownLayer>::Singleton(env);
+ static auto& javaClass = jni::Class<UnknownLayer>::Singleton(env);
#define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
diff --git a/platform/android/src/style/layers/unknown_layer.hpp b/platform/android/src/style/layers/unknown_layer.hpp
index 0610c843f1..692e2f5db4 100644
--- a/platform/android/src/style/layers/unknown_layer.hpp
+++ b/platform/android/src/style/layers/unknown_layer.hpp
@@ -9,7 +9,7 @@ namespace android {
class UnknownLayer : public Layer {
public:
-
+ using SuperTag = Layer;
static constexpr auto Name() { return "com/mapbox/mapboxsdk/style/layers/UnknownLayer"; };
static void registerNative(jni::JNIEnv&);
@@ -20,7 +20,7 @@ public:
~UnknownLayer() = default;
- jni::jobject* createJavaPeer(jni::JNIEnv&);
+ jni::Local<jni::Object<Layer>> createJavaPeer(jni::JNIEnv&);
}; // class UnknownLayer
diff --git a/platform/android/src/style/light.cpp b/platform/android/src/style/light.cpp
index 64afb89204..d8ed4d9d96 100644
--- a/platform/android/src/style/light.cpp
+++ b/platform/android/src/style/light.cpp
@@ -1,5 +1,3 @@
-// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
-
#include <mbgl/map/map.hpp>
#include "light.hpp"
#include "conversion/transition_options.hpp"
@@ -16,20 +14,20 @@ static Light* initializeLightPeer(mbgl::Map& map, mbgl::style::Light& coreLight)
return new Light(map, coreLight);
}
-jni::jobject* Light::createJavaLightPeer(jni::JNIEnv& env, Map& map, mbgl::style::Light& coreLight) {
+jni::Local<jni::Object<Light>> Light::createJavaLightPeer(jni::JNIEnv& env, Map& map, mbgl::style::Light& coreLight) {
std::unique_ptr<Light> peerLight = std::unique_ptr<Light>(initializeLightPeer(map, coreLight));
- jni::jobject* result = peerLight->createJavaPeer(env);
+ auto result = peerLight->createJavaPeer(env);
peerLight.release();
return result;
}
-jni::jobject* Light::createJavaPeer(jni::JNIEnv& env) {
- static auto javaClass = jni::Class<Light>::Singleton(env);
+jni::Local<jni::Object<Light>> Light::createJavaPeer(jni::JNIEnv& env) {
+ static auto& javaClass = jni::Class<Light>::Singleton(env);
static auto constructor = javaClass.GetConstructor<jni::jlong>(env);
return javaClass.New(env, constructor, reinterpret_cast<jni::jlong>(this));
}
-void Light::setAnchor(jni::JNIEnv& env, jni::String property) {
+void Light::setAnchor(jni::JNIEnv& env, const jni::String& property) {
std::string anchorStr = jni::Make<std::string>(env, property);
if (anchorStr.compare("map") == 0) {
light.setAnchor(LightAnchorType::Map);
@@ -38,7 +36,7 @@ void Light::setAnchor(jni::JNIEnv& env, jni::String property) {
}
}
-jni::String Light::getAnchor(jni::JNIEnv& env) {
+jni::Local<jni::String> Light::getAnchor(jni::JNIEnv& env) {
auto anchorType = light.getAnchor();
if (anchorType == LightAnchorType::Map) {
return jni::Make<jni::String>(env, "map");
@@ -47,22 +45,22 @@ jni::String Light::getAnchor(jni::JNIEnv& env) {
}
}
-void Light::setPosition(jni::JNIEnv& env, jni::Object<Position> jposition) {
+void Light::setPosition(jni::JNIEnv& env, const jni::Object<Position>& jposition) {
using namespace mbgl::android::conversion;
auto position = *convert<mbgl::style::Position>(env, jposition);
light.setPosition(position);
}
-jni::Object<Position> Light::getPosition(jni::JNIEnv& env) {
+jni::Local<jni::Object<Position>> Light::getPosition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::Position position = light.getPosition().asConstant();
- return *convert<jni::Object<Position>>(env, position);
+ return std::move(*convert<jni::Local<jni::Object<Position>>>(env, position));
}
-jni::Object<TransitionOptions> Light::getPositionTransition(jni::JNIEnv& env) {
+jni::Local<jni::Object<TransitionOptions>> Light::getPositionTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = light.getPositionTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void Light::setPositionTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -72,22 +70,22 @@ void Light::setPositionTransition(jni::JNIEnv&, jlong duration, jlong delay) {
light.setPositionTransition(options);
}
-void Light::setColor(jni::JNIEnv& env, jni::String property) {
+void Light::setColor(jni::JNIEnv& env, const jni::String& property) {
auto color = Color::parse(jni::Make<std::string>(env, property));
if (color) {
light.setColor(color.value());
}
}
-jni::String Light::getColor(jni::JNIEnv &env) {
+jni::Local<jni::String> Light::getColor(jni::JNIEnv &env) {
auto color = light.getColor().asConstant();
return jni::Make<jni::String>(env, color.stringify());
}
-jni::Object<TransitionOptions> Light::getColorTransition(jni::JNIEnv& env) {
+jni::Local<jni::Object<TransitionOptions>> Light::getColorTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = light.getColorTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void Light::setColorTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -105,10 +103,10 @@ jni::jfloat Light::getIntensity(jni::JNIEnv&) {
return light.getIntensity().asConstant();
}
-jni::Object<TransitionOptions> Light::getIntensityTransition(jni::JNIEnv& env) {
+jni::Local<jni::Object<TransitionOptions>> Light::getIntensityTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = light.getIntensityTransition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
+ return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void Light::setIntensityTransition(jni::JNIEnv&, jlong duration, jlong delay) {
@@ -120,7 +118,7 @@ void Light::setIntensityTransition(jni::JNIEnv&, jlong duration, jlong delay) {
void Light::registerNative(jni::JNIEnv& env) {
// Lookup the class
- static auto javaClass = jni::Class<Light>::Singleton(env);
+ static auto& javaClass = jni::Class<Light>::Singleton(env);
#define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
// Register the peer
diff --git a/platform/android/src/style/light.cpp.ejs b/platform/android/src/style/light.cpp.ejs
deleted file mode 100644
index f18dc57a4f..0000000000
--- a/platform/android/src/style/light.cpp.ejs
+++ /dev/null
@@ -1,122 +0,0 @@
-<%
- const properties = locals.properties;
--%>
-// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
-
-#include <mbgl/map/map.hpp>
-#include "light.hpp"
-#include "conversion/transition_options.hpp"
-#include "conversion/position.hpp"
-
-namespace mbgl {
-namespace android {
-
-Light::Light(mbgl::Map& coreMap, mbgl::style::Light& coreLight)
- : light(coreLight) , map(&coreMap) {
-}
-
-static Light* initializeLightPeer(mbgl::Map& map, mbgl::style::Light& coreLight) {
- return new Light(map, coreLight);
-}
-
-jni::jobject* Light::createJavaLightPeer(jni::JNIEnv& env, Map& map, mbgl::style::Light& coreLight) {
- std::unique_ptr<Light> peerLight = std::unique_ptr<Light>(initializeLightPeer(map, coreLight));
- jni::jobject* result = peerLight->createJavaPeer(env);
- peerLight.release();
- return result;
-}
-
-jni::jobject* Light::createJavaPeer(jni::JNIEnv& env) {
- static auto javaClass = jni::Class<Light>::Singleton(env);
- static auto constructor = javaClass.GetConstructor<jni::jlong>(env);
- return javaClass.New(env, constructor, reinterpret_cast<jni::jlong>(this));
-}
-
-<% for (const property of properties) { -%>
-<% if (property.name == "position") { -%>
-void Light::set<%- camelize(property.name) %>(jni::JNIEnv& env, jni::Object<<%- camelize(property.name) %>> j<%- property.name %>) {
- using namespace mbgl::android::conversion;
- auto position = *convert<mbgl::style::<%- camelize(property.name) %>>(env, jposition);
- light.set<%- camelize(property.name) %>(<%- property.name %>);
-}
-
-jni::Object<Position> Light::get<%- camelize(property.name) %>(jni::JNIEnv& env) {
- using namespace mbgl::android::conversion;
- mbgl::style::<%- camelize(property.name) %> <%- property.name %> = light.get<%- camelize(property.name) %>().asConstant();
- return *convert<jni::Object<<%- camelize(property.name) %>>>(env, <%- property.name %>);
-}
-<% } else { -%>
-<% if(property.name == "color") {-%>
-void Light::set<%- camelize(property.name) %>(jni::JNIEnv& env, jni::<%- propertyJNIType(property) %> property) {
- auto color = Color::parse(jni::Make<std::string>(env, property));
- if (color) {
- light.set<%- camelize(property.name) %>(color.value());
- }
-}
-
-jni::String Light::get<%- camelize(property.name) %>(jni::JNIEnv &env) {
- auto color = light.get<%- camelize(property.name) %>().asConstant();
- return jni::Make<jni::String>(env, color.stringify());
-}
-<% } else if(property.name == "anchor"){ -%>
-void Light::set<%- camelize(property.name) %>(jni::JNIEnv& env, jni::<%- propertyJNIType(property) %> property) {
- std::string anchorStr = jni::Make<std::string>(env, property);
- if (anchorStr.compare("map") == 0) {
- light.setAnchor(LightAnchorType::Map);
- } else if (anchorStr.compare("viewport") == 0) {
- light.setAnchor(LightAnchorType::Viewport);
- }
-}
-
-jni::String Light::getAnchor(jni::JNIEnv& env) {
- auto anchorType = light.getAnchor();
- if (anchorType == LightAnchorType::Map) {
- return jni::Make<jni::String>(env, "map");
- } else {
- return jni::Make<jni::String>(env, "viewport");
- }
-}
-<% } else { -%>
-void Light::set<%- camelize(property.name) %>(jni::JNIEnv&, jni::<%- propertyJNIType(property) %> property) {
- light.set<%- camelize(property.name) %>(property);
-}
-
-jni::<%- propertyJNIType(property) %> Light::get<%- camelize(property.name) %>(jni::JNIEnv&) {
- return light.get<%- camelize(property.name) %>().asConstant();
-}
-<% } -%>
-<% } -%>
-
-<% if (property.transition) { -%>
-jni::Object<TransitionOptions> Light::get<%- camelize(property.name) %>Transition(jni::JNIEnv& env) {
- using namespace mbgl::android::conversion;
- mbgl::style::TransitionOptions options = light.get<%- camelize(property.name) %>Transition();
- return *convert<jni::Object<TransitionOptions>>(env, options);
-}
-
-void Light::set<%- camelize(property.name) %>Transition(jni::JNIEnv&, jlong duration, jlong delay) {
- mbgl::style::TransitionOptions options;
- options.duration.emplace(mbgl::Milliseconds(duration));
- options.delay.emplace(mbgl::Milliseconds(delay));
- light.set<%- camelize(property.name) %>Transition(options);
-}
-
-<% } -%>
-<% } -%>
-void Light::registerNative(jni::JNIEnv& env) {
- // Lookup the class
- static auto javaClass = jni::Class<Light>::Singleton(env);
-
-#define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
- // Register the peer
- jni::RegisterNativePeer<Light>(env, javaClass, "nativePtr",<% for(var i = 0; i < properties.length; i++) {%>
-<% if (properties[i].transition) { -%>
- METHOD(&Light::get<%- camelize(properties[i].name) %>Transition, "nativeGet<%- camelize(properties[i].name) %>Transition"),
- METHOD(&Light::set<%- camelize(properties[i].name) %>Transition, "nativeSet<%- camelize(properties[i].name) %>Transition"),
-<% } -%>
- METHOD(&Light::get<%- camelize(properties[i].name) %>, "nativeGet<%- camelize(properties[i].name) %>"),
- METHOD(&Light::set<%- camelize(properties[i].name) %>, "nativeSet<%- camelize(properties[i].name) %>")<% if(i != (properties.length -1)) {-%>,<% } -%><% } -%>);
-}
-
-} // namespace android
-} // namespace mb
diff --git a/platform/android/src/style/light.hpp b/platform/android/src/style/light.hpp
index 2c314067be..97767c4f76 100644
--- a/platform/android/src/style/light.hpp
+++ b/platform/android/src/style/light.hpp
@@ -1,5 +1,3 @@
-// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
-
#pragma once
#include <mbgl/util/noncopyable.hpp>
@@ -21,29 +19,27 @@ public:
static constexpr auto Name() { return "com/mapbox/mapboxsdk/style/light/Light"; };
- static jni::Class<Light> javaClass;
-
static void registerNative(jni::JNIEnv&);
- static jni::jobject* createJavaLightPeer(jni::JNIEnv&, mbgl::Map&, mbgl::style::Light&);
+ static jni::Local<jni::Object<Light>> createJavaLightPeer(jni::JNIEnv&, mbgl::Map&, mbgl::style::Light&);
Light(mbgl::Map&, mbgl::style::Light&);
- void setAnchor(jni::JNIEnv&, jni::String);
- jni::String getAnchor(jni::JNIEnv&);
- void setPosition(jni::JNIEnv&, jni::Object<Position>);
- jni::Object<Position> getPosition(jni::JNIEnv&);
+ void setAnchor(jni::JNIEnv&, const jni::String&);
+ jni::Local<jni::String> getAnchor(jni::JNIEnv&);
+ void setPosition(jni::JNIEnv&, const jni::Object<Position>&);
+ jni::Local<jni::Object<Position>> getPosition(jni::JNIEnv&);
void setPositionTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getPositionTransition(jni::JNIEnv&);
- void setColor(jni::JNIEnv&, jni::String);
- jni::String getColor(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getPositionTransition(jni::JNIEnv&);
+ void setColor(jni::JNIEnv&, const jni::String&);
+ jni::Local<jni::String> getColor(jni::JNIEnv&);
void setColorTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getColorTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getColorTransition(jni::JNIEnv&);
void setIntensity(jni::JNIEnv&, jni::jfloat);
jni::jfloat getIntensity(jni::JNIEnv&);
void setIntensityTransition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> getIntensityTransition(jni::JNIEnv&);
- jni::jobject* createJavaPeer(jni::JNIEnv&);
+ jni::Local<jni::Object<TransitionOptions>> getIntensityTransition(jni::JNIEnv&);
+ jni::Local<jni::Object<Light>> createJavaPeer(jni::JNIEnv&);
protected:
diff --git a/platform/android/src/style/light.hpp.ejs b/platform/android/src/style/light.hpp.ejs
deleted file mode 100644
index 18f961b9e0..0000000000
--- a/platform/android/src/style/light.hpp.ejs
+++ /dev/null
@@ -1,59 +0,0 @@
-<%
- const properties = locals.properties;
--%>
-// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
-
-#pragma once
-
-#include <mbgl/util/noncopyable.hpp>
-
-#include <jni/jni.hpp>
-#include <mbgl/style/light.hpp>
-#include "transition_options.hpp"
-#include "position.hpp"
-#include <mbgl/style/types.hpp>
-#include <mbgl/style/property_value.hpp>
-
-namespace mbgl {
-namespace android {
-
-using namespace style;
-
-class Light : private mbgl::util::noncopyable {
-public:
-
- static constexpr auto Name() { return "com/mapbox/mapboxsdk/style/light/Light"; };
-
- static jni::Class<Light> javaClass;
-
- static void registerNative(jni::JNIEnv&);
-
- static jni::jobject* createJavaLightPeer(jni::JNIEnv&, mbgl::Map&, mbgl::style::Light&);
-
- Light(mbgl::Map&, mbgl::style::Light&);
-
-<% for (const property of properties) { -%>
-<% if (property.name=="position") {-%>
- void set<%- camelize(property.name) %>(jni::JNIEnv&, jni::Object<Position>);
- jni::Object<<%- camelize(property.name) %>> get<%- camelize(property.name) %>(jni::JNIEnv&);
-<% } else { -%>
- void set<%- camelize(property.name) %>(jni::JNIEnv&, jni::<%- propertyJNIType(property) %>);
- jni::<%- propertyJNIType(property) %> get<%- camelize(property.name) %>(jni::JNIEnv&);
-<% } -%>
-<% if (property.transition) { -%>
- void set<%- camelize(property.name) %>Transition(jni::JNIEnv&, jlong duration, jlong delay);
- jni::Object<TransitionOptions> get<%- camelize(property.name) %>Transition(jni::JNIEnv&);
-<% } -%>
-<% } -%>
- jni::jobject* createJavaPeer(jni::JNIEnv&);
-
-protected:
-
- // Raw reference to the light
- mbgl::style::Light& light;
-
- // Map is set when the light is retrieved
- mbgl::Map* map;
-};
-} // namespace android
-} // namespace mbgl \ No newline at end of file
diff --git a/platform/android/src/style/position.cpp b/platform/android/src/style/position.cpp
index c6918a2e9a..20a0c47dff 100644
--- a/platform/android/src/style/position.cpp
+++ b/platform/android/src/style/position.cpp
@@ -3,8 +3,8 @@
namespace mbgl {
namespace android {
-jni::Object<Position> Position::fromPosition(jni::JNIEnv& env, jfloat radialCoordinate, jfloat azimuthalAngle, jfloat polarAngle) {
- static auto javaClass = jni::Class<Position>::Singleton(env);
+jni::Local<jni::Object<Position>> Position::fromPosition(jni::JNIEnv& env, jfloat radialCoordinate, jfloat azimuthalAngle, jfloat polarAngle) {
+ static auto& javaClass = jni::Class<Position>::Singleton(env);
static auto method = javaClass.GetStaticMethod<jni::Object<Position> (jfloat, jfloat, jfloat)>(env, "fromPosition");
return javaClass.Call(env, method, radialCoordinate, azimuthalAngle, polarAngle);
}
@@ -13,20 +13,20 @@ void Position::registerNative(jni::JNIEnv& env) {
jni::Class<Position>::Singleton(env);
}
-float Position::getRadialCoordinate(jni::JNIEnv& env, jni::Object<Position> position){
- static auto javaClass = jni::Class<Position>::Singleton(env);
+float Position::getRadialCoordinate(jni::JNIEnv& env, const jni::Object<Position>& position) {
+ static auto& javaClass = jni::Class<Position>::Singleton(env);
static auto field = javaClass.GetField<jfloat>(env, "radialCoordinate");
return position.Get(env, field);
}
-float Position::getAzimuthalAngle(jni::JNIEnv& env, jni::Object<Position> position){
- static auto javaClass = jni::Class<Position>::Singleton(env);
+float Position::getAzimuthalAngle(jni::JNIEnv& env, const jni::Object<Position>& position) {
+ static auto& javaClass = jni::Class<Position>::Singleton(env);
static auto field = javaClass.GetField<jfloat>(env, "azimuthalAngle");
return position.Get(env, field);
}
-float Position::getPolarAngle(jni::JNIEnv& env, jni::Object<Position> position){
- static auto javaClass = jni::Class<Position>::Singleton(env);
+float Position::getPolarAngle(jni::JNIEnv& env, const jni::Object<Position>& position) {
+ static auto& javaClass = jni::Class<Position>::Singleton(env);
static auto field = javaClass.GetField<jfloat>(env, "polarAngle");
return position.Get(env, field);
}
diff --git a/platform/android/src/style/position.hpp b/platform/android/src/style/position.hpp
index 4f3738da9f..eb4f5ac674 100644
--- a/platform/android/src/style/position.hpp
+++ b/platform/android/src/style/position.hpp
@@ -11,13 +11,13 @@ class Position : private mbgl::util::noncopyable {
public:
static constexpr auto Name() { return "com/mapbox/mapboxsdk/style/light/Position"; };
- static jni::Object<Position> fromPosition(jni::JNIEnv&, jfloat, jfloat, jfloat);
+ static jni::Local<jni::Object<Position>> fromPosition(jni::JNIEnv&, jfloat, jfloat, jfloat);
static void registerNative(jni::JNIEnv&);
- static float getRadialCoordinate(jni::JNIEnv&, jni::Object<Position>);
- static float getAzimuthalAngle(jni::JNIEnv&, jni::Object<Position>);
- static float getPolarAngle(jni::JNIEnv&, jni::Object<Position>);
+ static float getRadialCoordinate(jni::JNIEnv&, const jni::Object<Position>&);
+ static float getAzimuthalAngle(jni::JNIEnv&, const jni::Object<Position>&);
+ static float getPolarAngle(jni::JNIEnv&, const jni::Object<Position>&);
};
} // namespace android
diff --git a/platform/android/src/style/sources/custom_geometry_source.cpp b/platform/android/src/style/sources/custom_geometry_source.cpp
index 9012948b0b..057f5c99ba 100644
--- a/platform/android/src/style/sources/custom_geometry_source.cpp
+++ b/platform/android/src/style/sources/custom_geometry_source.cpp
@@ -1,4 +1,5 @@
#include "custom_geometry_source.hpp"
+#include "../../attach_env.hpp"
#include <mbgl/renderer/query.hpp>
@@ -21,7 +22,7 @@ namespace android {
// the value was originally a CustomGeometrySourceOptions object on the Java side. If it fails
// to convert, it's a bug in our serialization or Java-side static typing.
static style::CustomGeometrySource::Options convertCustomGeometrySourceOptions(jni::JNIEnv& env,
- jni::Local<jni::Object<>> options,
+ const jni::Object<>& options,
style::TileFunction fetchFn,
style::TileFunction cancelFn) {
using namespace mbgl::style::conversion;
@@ -29,7 +30,7 @@ namespace android {
return style::CustomGeometrySource::Options();
}
Error error;
- optional<style::CustomGeometrySource::Options> result = convert<style::CustomGeometrySource::Options>(Value(env, std::move(options)), error);
+ optional<style::CustomGeometrySource::Options> result = convert<style::CustomGeometrySource::Options>(Value(env, options), error);
if (!result) {
throw std::logic_error(error.message);
}
@@ -39,11 +40,11 @@ namespace android {
}
CustomGeometrySource::CustomGeometrySource(jni::JNIEnv& env,
- jni::String sourceId,
- jni::Object<> options)
+ const jni::String& sourceId,
+ const jni::Object<>& options)
: Source(env, std::make_unique<mbgl::style::CustomGeometrySource>(
jni::Make<std::string>(env, sourceId),
- convertCustomGeometrySourceOptions(env, jni::SeizeLocal(env, std::move(options)),
+ convertCustomGeometrySourceOptions(env, options,
std::bind(&CustomGeometrySource::fetchTile, this, std::placeholders::_1),
std::bind(&CustomGeometrySource::cancelTile, this, std::placeholders::_1)))) {
}
@@ -61,48 +62,48 @@ namespace android {
void CustomGeometrySource::fetchTile (const mbgl::CanonicalTileID& tileID) {
android::UniqueEnv _env = android::AttachEnv();
- static auto javaClass = jni::Class<CustomGeometrySource>::Singleton(*_env);
+ static auto& javaClass = jni::Class<CustomGeometrySource>::Singleton(*_env);
static auto fetchTile = javaClass.GetMethod<void (jni::jint, jni::jint, jni::jint)>(*_env, "fetchTile");
assert(javaPeer);
- auto peer = jni::Cast(*_env, javaClass, *javaPeer);
+ auto peer = jni::Cast(*_env, javaClass, javaPeer);
peer.Call(*_env, fetchTile, (int)tileID.z, (int)tileID.x, (int)tileID.y);
};
void CustomGeometrySource::cancelTile(const mbgl::CanonicalTileID& tileID) {
android::UniqueEnv _env = android::AttachEnv();
- static auto javaClass = jni::Class<CustomGeometrySource>::Singleton(*_env);
+ static auto& javaClass = jni::Class<CustomGeometrySource>::Singleton(*_env);
static auto cancelTile = javaClass.GetMethod<void (jni::jint, jni::jint, jni::jint)>(*_env, "cancelTile");
assert(javaPeer);
- auto peer = jni::Cast(*_env, javaClass, *javaPeer);
+ auto peer = jni::Cast(*_env, javaClass, javaPeer);
peer.Call(*_env, cancelTile, (int)tileID.z, (int)tileID.x, (int)tileID.y);
};
void CustomGeometrySource::startThreads() {
android::UniqueEnv _env = android::AttachEnv();
- static auto javaClass = jni::Class<CustomGeometrySource>::Singleton(*_env);
+ static auto& javaClass = jni::Class<CustomGeometrySource>::Singleton(*_env);
static auto startThreads = javaClass.GetMethod<void ()>(*_env, "startThreads");
assert(javaPeer);
- auto peer = jni::Cast(*_env, javaClass, *javaPeer);
+ auto peer = jni::Cast(*_env, javaClass, javaPeer);
peer.Call(*_env, startThreads);
}
void CustomGeometrySource::releaseThreads() {
android::UniqueEnv _env = android::AttachEnv();
- static auto javaClass = jni::Class<CustomGeometrySource>::Singleton(*_env);
+ static auto& javaClass = jni::Class<CustomGeometrySource>::Singleton(*_env);
static auto releaseThreads = javaClass.GetMethod<void ()>(*_env, "releaseThreads");
assert(javaPeer);
- auto peer = jni::Cast(*_env, javaClass, *javaPeer);
+ auto peer = jni::Cast(*_env, javaClass, javaPeer);
peer.Call(*_env, releaseThreads);
};
@@ -111,12 +112,12 @@ namespace android {
jni::jint y) {
android::UniqueEnv _env = android::AttachEnv();
- static auto javaClass = jni::Class<CustomGeometrySource>::Singleton(*_env);
+ static auto& javaClass = jni::Class<CustomGeometrySource>::Singleton(*_env);
static auto isCancelled = javaClass.GetMethod<jboolean (jni::jint, jni::jint, jni::jint)>(*_env, "isCancelled");
assert(javaPeer);
- auto peer = jni::Cast(*_env, javaClass, *javaPeer);
+ auto peer = jni::Cast(*_env, javaClass, javaPeer);
return peer.Call(*_env, isCancelled, z, x, y);
};
@@ -124,7 +125,7 @@ namespace android {
jni::jint z,
jni::jint x,
jni::jint y,
- jni::Object<geojson::FeatureCollection> jFeatures) {
+ const jni::Object<geojson::FeatureCollection>& jFeatures) {
using namespace mbgl::android::geojson;
// Convert the jni object
@@ -140,36 +141,35 @@ namespace android {
source.as<mbgl::style::CustomGeometrySource>()->CustomGeometrySource::invalidateTile(CanonicalTileID(z, x, y));
}
- void CustomGeometrySource::invalidateBounds(jni::JNIEnv& env, jni::Object<LatLngBounds> jBounds) {
+ void CustomGeometrySource::invalidateBounds(jni::JNIEnv& env, const jni::Object<LatLngBounds>& jBounds) {
auto bounds = LatLngBounds::getLatLngBounds(env, jBounds);
source.as<mbgl::style::CustomGeometrySource>()->CustomGeometrySource::invalidateRegion(bounds);
}
- jni::Array<jni::Object<geojson::Feature>> CustomGeometrySource::querySourceFeatures(jni::JNIEnv& env,
- jni::Array<jni::Object<>> jfilter) {
+ jni::Local<jni::Array<jni::Object<geojson::Feature>>> CustomGeometrySource::querySourceFeatures(jni::JNIEnv& env,
+ const jni::Array<jni::Object<>>& jfilter) {
using namespace mbgl::android::conversion;
using namespace mbgl::android::geojson;
std::vector<mbgl::Feature> features;
if (rendererFrontend) {
- features = rendererFrontend->querySourceFeatures(source.getID(),
- { {}, toFilter(env, jni::SeizeLocal(env, std::move(jfilter))) });
+ features = rendererFrontend->querySourceFeatures(source.getID(), { {}, toFilter(env, jfilter) });
}
return Feature::convert(env, features);
}
- jni::Object<Source> CustomGeometrySource::createJavaPeer(jni::JNIEnv& env) {
- static auto javaClass = jni::Class<CustomGeometrySource>::Singleton(env);
+ jni::Local<jni::Object<Source>> CustomGeometrySource::createJavaPeer(jni::JNIEnv& env) {
+ static auto& javaClass = jni::Class<CustomGeometrySource>::Singleton(env);
static auto constructor = javaClass.GetConstructor<jni::jlong>(env);
- return jni::Object<Source>(javaClass.New(env, constructor, reinterpret_cast<jni::jlong>(this)).Get());
+ return javaClass.New(env, constructor, reinterpret_cast<jni::jlong>(this));
}
- void CustomGeometrySource::addToMap(JNIEnv& env, jni::Object<Source> obj, mbgl::Map& map, AndroidRendererFrontend& frontend) {
+ void CustomGeometrySource::addToMap(JNIEnv& env, const jni::Object<Source>& obj, mbgl::Map& map, AndroidRendererFrontend& frontend) {
Source::addToMap(env, obj, map, frontend);
startThreads();
}
- bool CustomGeometrySource::removeFromMap(JNIEnv& env, jni::Object<Source> source, mbgl::Map& map) {
+ bool CustomGeometrySource::removeFromMap(JNIEnv& env, const jni::Object<Source>& source, mbgl::Map& map) {
bool successfullyRemoved = Source::removeFromMap(env, source, map);
if (successfullyRemoved) {
releaseThreads();
@@ -179,14 +179,14 @@ namespace android {
void CustomGeometrySource::registerNative(jni::JNIEnv& env) {
// Lookup the class
- static auto javaClass = jni::Class<CustomGeometrySource>::Singleton(env);
+ static auto& javaClass = jni::Class<CustomGeometrySource>::Singleton(env);
#define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
// Register the peer
jni::RegisterNativePeer<CustomGeometrySource>(
env, javaClass, "nativePtr",
- std::make_unique<CustomGeometrySource, JNIEnv&, jni::String, jni::Object<>>,
+ jni::MakePeer<CustomGeometrySource, const jni::String&, const jni::Object<>&>,
"initialize",
"finalize",
METHOD(&CustomGeometrySource::querySourceFeatures, "querySourceFeatures"),
diff --git a/platform/android/src/style/sources/custom_geometry_source.hpp b/platform/android/src/style/sources/custom_geometry_source.hpp
index ecfadd659c..52e4027dd8 100644
--- a/platform/android/src/style/sources/custom_geometry_source.hpp
+++ b/platform/android/src/style/sources/custom_geometry_source.hpp
@@ -15,17 +15,17 @@ namespace android {
class CustomGeometrySource : public Source {
public:
-
+ using SuperTag = Source;
static constexpr auto Name() { return "com/mapbox/mapboxsdk/style/sources/CustomGeometrySource"; };
static void registerNative(jni::JNIEnv&);
- CustomGeometrySource(jni::JNIEnv&, jni::String, jni::Object<>);
+ CustomGeometrySource(jni::JNIEnv&, const jni::String&, const jni::Object<>&);
CustomGeometrySource(jni::JNIEnv&, mbgl::style::Source&, AndroidRendererFrontend&);
~CustomGeometrySource();
- bool removeFromMap(JNIEnv&, jni::Object<Source>, mbgl::Map&) override;
- void addToMap(JNIEnv&, jni::Object<Source>, mbgl::Map&, AndroidRendererFrontend&) override;
+ bool removeFromMap(JNIEnv&, const jni::Object<Source>&, mbgl::Map&) override;
+ void addToMap(JNIEnv&, const jni::Object<Source>&, mbgl::Map&, AndroidRendererFrontend&) override;
void fetchTile(const mbgl::CanonicalTileID& tileID);
void cancelTile(const mbgl::CanonicalTileID& tileID);
@@ -34,15 +34,15 @@ public:
void releaseThreads();
private:
- void setTileData(jni::JNIEnv& env, jni::jint z, jni::jint x, jni::jint y, jni::Object<geojson::FeatureCollection> jf);
+ void setTileData(jni::JNIEnv& env, jni::jint z, jni::jint x, jni::jint y, const jni::Object<geojson::FeatureCollection>& jf);
void invalidateTile(jni::JNIEnv& env, jni::jint z, jni::jint x, jni::jint y);
- void invalidateBounds(jni::JNIEnv& env, jni::Object<LatLngBounds> bounds);
+ void invalidateBounds(jni::JNIEnv& env, const jni::Object<LatLngBounds>& bounds);
- jni::Array<jni::Object<geojson::Feature>> querySourceFeatures(jni::JNIEnv&,
- jni::Array<jni::Object<>> );
+ jni::Local<jni::Array<jni::Object<geojson::Feature>>> querySourceFeatures(jni::JNIEnv&,
+ const jni::Array<jni::Object<>>& );
- jni::Object<Source> createJavaPeer(jni::JNIEnv&);
+ jni::Local<jni::Object<Source>> createJavaPeer(jni::JNIEnv&);
}; // class CustomGeometrySource
diff --git a/platform/android/src/style/sources/geojson_source.cpp b/platform/android/src/style/sources/geojson_source.cpp
index 943cc48386..d0ad5fb699 100644
--- a/platform/android/src/style/sources/geojson_source.cpp
+++ b/platform/android/src/style/sources/geojson_source.cpp
@@ -1,4 +1,5 @@
#include "geojson_source.hpp"
+#include "../../attach_env.hpp"
#include <mbgl/renderer/query.hpp>
@@ -29,24 +30,24 @@ namespace android {
// This conversion is expected not to fail because it's used only in contexts where
// the value was originally a GeoJsonOptions object on the Java side. If it fails
// to convert, it's a bug in our serialization or Java-side static typing.
- static style::GeoJSONOptions convertGeoJSONOptions(jni::JNIEnv& env, jni::Local<jni::Object<>> options) {
+ static style::GeoJSONOptions convertGeoJSONOptions(jni::JNIEnv& env, const jni::Object<>& options) {
using namespace mbgl::style::conversion;
if (!options) {
return style::GeoJSONOptions();
}
Error error;
optional<style::GeoJSONOptions> result = convert<style::GeoJSONOptions>(
- mbgl::android::Value(env, std::move(options)), error);
+ mbgl::android::Value(env, options), error);
if (!result) {
throw std::logic_error(error.message);
}
return *result;
}
- GeoJSONSource::GeoJSONSource(jni::JNIEnv& env, jni::String sourceId, jni::Object<> options)
+ GeoJSONSource::GeoJSONSource(jni::JNIEnv& env, const jni::String& sourceId, const jni::Object<>& options)
: Source(env, std::make_unique<mbgl::style::GeoJSONSource>(
jni::Make<std::string>(env, sourceId),
- convertGeoJSONOptions(env, jni::SeizeLocal(env, std::move(options)))))
+ convertGeoJSONOptions(env, options)))
, threadPool(sharedThreadPool())
, converter(std::make_unique<Actor<FeatureConverter>>(*threadPool)) {
}
@@ -61,7 +62,7 @@ namespace android {
GeoJSONSource::~GeoJSONSource() = default;
- void GeoJSONSource::setGeoJSONString(jni::JNIEnv& env, jni::String jString) {
+ void GeoJSONSource::setGeoJSONString(jni::JNIEnv& env, const jni::String& jString) {
std::shared_ptr<std::string> json = std::make_shared<std::string>(jni::Make<std::string>(env, jString));
@@ -72,54 +73,54 @@ namespace android {
setAsync(converterFn);
}
- void GeoJSONSource::setFeatureCollection(jni::JNIEnv& env, jni::Object<geojson::FeatureCollection> jFeatures) {
+ void GeoJSONSource::setFeatureCollection(jni::JNIEnv& env, const jni::Object<geojson::FeatureCollection>& jFeatures) {
setCollectionAsync(env, jFeatures);
}
- void GeoJSONSource::setFeature(jni::JNIEnv& env, jni::Object<geojson::Feature> jFeature) {
+ void GeoJSONSource::setFeature(jni::JNIEnv& env, const jni::Object<geojson::Feature>& jFeature) {
setCollectionAsync(env, jFeature);
}
- void GeoJSONSource::setGeometry(jni::JNIEnv& env, jni::Object<geojson::Geometry> jGeometry) {
+ void GeoJSONSource::setGeometry(jni::JNIEnv& env, const jni::Object<geojson::Geometry>& jGeometry) {
setCollectionAsync(env, jGeometry);
}
- void GeoJSONSource::setURL(jni::JNIEnv& env, jni::String url) {
+ void GeoJSONSource::setURL(jni::JNIEnv& env, const jni::String& url) {
// Update the core source
source.as<mbgl::style::GeoJSONSource>()->GeoJSONSource::setURL(jni::Make<std::string>(env, url));
}
- jni::String GeoJSONSource::getURL(jni::JNIEnv& env) {
+ jni::Local<jni::String> GeoJSONSource::getURL(jni::JNIEnv& env) {
optional<std::string> url = source.as<mbgl::style::GeoJSONSource>()->GeoJSONSource::getURL();
- return url ? jni::Make<jni::String>(env, *url) : jni::String();
+ return url ? jni::Make<jni::String>(env, *url) : jni::Local<jni::String>();
}
- jni::Array<jni::Object<geojson::Feature>> GeoJSONSource::querySourceFeatures(jni::JNIEnv& env,
- jni::Array<jni::Object<>> jfilter) {
+ jni::Local<jni::Array<jni::Object<geojson::Feature>>> GeoJSONSource::querySourceFeatures(jni::JNIEnv& env,
+ const jni::Array<jni::Object<>>& jfilter) {
using namespace mbgl::android::conversion;
using namespace mbgl::android::geojson;
std::vector<mbgl::Feature> features;
if (rendererFrontend) {
features = rendererFrontend->querySourceFeatures(source.getID(),
- { {}, toFilter(env, jni::SeizeLocal(env, std::move(jfilter))) });
+ { {}, toFilter(env, jfilter) });
}
return Feature::convert(env, features);
}
- jni::Object<Source> GeoJSONSource::createJavaPeer(jni::JNIEnv& env) {
- static auto javaClass = jni::Class<GeoJSONSource>::Singleton(env);
+ jni::Local<jni::Object<Source>> GeoJSONSource::createJavaPeer(jni::JNIEnv& env) {
+ static auto& javaClass = jni::Class<GeoJSONSource>::Singleton(env);
static auto constructor = javaClass.GetConstructor<jni::jlong>(env);
- return jni::Object<Source>(javaClass.New(env, constructor, reinterpret_cast<jni::jlong>(this)).Get());
+ return javaClass.New(env, constructor, reinterpret_cast<jni::jlong>(this));
}
template <class JNIType>
- void GeoJSONSource::setCollectionAsync(jni::JNIEnv& env, jni::Object<JNIType> jObject) {
-
- std::shared_ptr<jni::jobject> object = std::shared_ptr<jni::jobject>(jObject.NewGlobalRef(env).release().Get(), GenericGlobalRefDeleter());
+ void GeoJSONSource::setCollectionAsync(jni::JNIEnv& env, const jni::Object<JNIType>& jObject) {
+ auto global = jni::NewGlobal<jni::EnvAttachingDeleter>(env, jObject);
+ auto object = std::make_shared<decltype(global)>(std::move(global));
Update::Converter converterFn = [this, object](ActorRef<Callback> _callback) {
- converter->self().invoke(&FeatureConverter::convertObject<JNIType>, jni::Object<JNIType>(*object), _callback);
+ converter->self().invoke(&FeatureConverter::convertObject<JNIType>, object, _callback);
};
setAsync(converterFn);
@@ -159,14 +160,14 @@ namespace android {
void GeoJSONSource::registerNative(jni::JNIEnv& env) {
// Lookup the class
- static auto javaClass = jni::Class<GeoJSONSource>::Singleton(env);
+ static auto& javaClass = jni::Class<GeoJSONSource>::Singleton(env);
#define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
// Register the peer
jni::RegisterNativePeer<GeoJSONSource>(
env, javaClass, "nativePtr",
- std::make_unique<GeoJSONSource, JNIEnv&, jni::String, jni::Object<>>,
+ jni::MakePeer<GeoJSONSource, const jni::String&, const jni::Object<>&>,
"initialize",
"finalize",
METHOD(&GeoJSONSource::setGeoJSONString, "nativeSetGeoJsonString"),
@@ -196,13 +197,13 @@ namespace android {
callback.invoke(&Callback::operator(), *converted);
}
- template<class JNIType>
- void FeatureConverter::convertObject(jni::Object<JNIType> jObject, ActorRef<Callback> callback) {
+ template <class JNIType>
+ void FeatureConverter::convertObject(std::shared_ptr<jni::Global<jni::Object<JNIType>, jni::EnvAttachingDeleter>> jObject, ActorRef<Callback> callback) {
using namespace mbgl::android::geojson;
android::UniqueEnv _env = android::AttachEnv();
// Convert the jni object
- auto geometry = JNIType::convert(*_env, jObject);
+ auto geometry = JNIType::convert(*_env, *jObject);
callback.invoke(&Callback::operator(), GeoJSON(geometry));
}
diff --git a/platform/android/src/style/sources/geojson_source.hpp b/platform/android/src/style/sources/geojson_source.hpp
index eb28e2470b..20e8b6873b 100644
--- a/platform/android/src/style/sources/geojson_source.hpp
+++ b/platform/android/src/style/sources/geojson_source.hpp
@@ -16,7 +16,7 @@ struct FeatureConverter {
void convertJson(std::shared_ptr<std::string>, ActorRef<Callback>);
template <class JNIType>
- void convertObject(jni::Object<JNIType>, ActorRef<Callback>);
+ void convertObject(std::shared_ptr<jni::Global<jni::Object<JNIType>, jni::EnvAttachingDeleter>>, ActorRef<Callback>);
};
struct Update {
@@ -30,34 +30,35 @@ struct Update {
class GeoJSONSource : public Source {
public:
+ using SuperTag = Source;
static constexpr auto Name() { return "com/mapbox/mapboxsdk/style/sources/GeoJsonSource"; };
static void registerNative(jni::JNIEnv&);
- GeoJSONSource(jni::JNIEnv&, jni::String, jni::Object<>);
+ GeoJSONSource(jni::JNIEnv&, const jni::String&, const jni::Object<>&);
GeoJSONSource(jni::JNIEnv&, mbgl::style::Source&, AndroidRendererFrontend&);
~GeoJSONSource();
private:
- void setGeoJSONString(jni::JNIEnv&, jni::String);
- void setFeatureCollection(jni::JNIEnv&, jni::Object<geojson::FeatureCollection>);
- void setFeature(jni::JNIEnv&, jni::Object<geojson::Feature>);
- void setGeometry(jni::JNIEnv&, jni::Object<geojson::Geometry>);
- void setURL(jni::JNIEnv&, jni::String);
+ void setGeoJSONString(jni::JNIEnv&, const jni::String&);
+ void setFeatureCollection(jni::JNIEnv&, const jni::Object<geojson::FeatureCollection>&);
+ void setFeature(jni::JNIEnv&, const jni::Object<geojson::Feature>&);
+ void setGeometry(jni::JNIEnv&, const jni::Object<geojson::Geometry>&);
+ void setURL(jni::JNIEnv&, const jni::String&);
- jni::Array<jni::Object<geojson::Feature>> querySourceFeatures(jni::JNIEnv&,
- jni::Array<jni::Object<>>);
+ jni::Local<jni::Array<jni::Object<geojson::Feature>>> querySourceFeatures(jni::JNIEnv&,
+ const jni::Array<jni::Object<>>&);
- jni::String getURL(jni::JNIEnv&);
+ jni::Local<jni::String> getURL(jni::JNIEnv&);
- jni::Object<Source> createJavaPeer(jni::JNIEnv&);
+ jni::Local<jni::Object<Source>> createJavaPeer(jni::JNIEnv&);
std::unique_ptr<Update> awaitingUpdate;
std::unique_ptr<Update> update;
std::shared_ptr<ThreadPool> threadPool;
std::unique_ptr<Actor<FeatureConverter>> converter;
template <class JNIType>
- void setCollectionAsync(jni::JNIEnv&, jni::Object<JNIType>);
+ void setCollectionAsync(jni::JNIEnv&, const jni::Object<JNIType>&);
void setAsync(Update::Converter);
diff --git a/platform/android/src/style/sources/image_source.cpp b/platform/android/src/style/sources/image_source.cpp
index 343b7439c8..b42e0e5a51 100644
--- a/platform/android/src/style/sources/image_source.cpp
+++ b/platform/android/src/style/sources/image_source.cpp
@@ -15,7 +15,7 @@
namespace mbgl {
namespace android {
- ImageSource::ImageSource(jni::JNIEnv& env, jni::String sourceId, jni::Object<LatLngQuad> coordinatesObject)
+ ImageSource::ImageSource(jni::JNIEnv& env, const jni::String& sourceId, const jni::Object<LatLngQuad>& coordinatesObject)
: Source(env, std::make_unique<mbgl::style::ImageSource>(
jni::Make<std::string>(env, sourceId),
LatLngQuad::getLatLngArray(env, coordinatesObject)
@@ -31,41 +31,41 @@ namespace android {
ImageSource::~ImageSource() = default;
- void ImageSource::setURL(jni::JNIEnv& env, jni::String url) {
+ void ImageSource::setURL(jni::JNIEnv& env, const jni::String& url) {
// Update the core source
source.as<mbgl::style::ImageSource>()->ImageSource::setURL(jni::Make<std::string>(env, url));
}
- jni::String ImageSource::getURL(jni::JNIEnv& env) {
+ jni::Local<jni::String> ImageSource::getURL(jni::JNIEnv& env) {
optional<std::string> url = source.as<mbgl::style::ImageSource>()->ImageSource::getURL();
- return url ? jni::Make<jni::String>(env, *url) : jni::String();
+ return url ? jni::Make<jni::String>(env, *url) : jni::Local<jni::String>();
}
- void ImageSource::setImage(jni::JNIEnv& env, jni::Object<Bitmap> bitmap) {
+ void ImageSource::setImage(jni::JNIEnv& env, const jni::Object<Bitmap>& bitmap) {
source.as<mbgl::style::ImageSource>()->setImage(Bitmap::GetImage(env, bitmap));
}
- void ImageSource::setCoordinates(jni::JNIEnv& env, jni::Object<LatLngQuad> coordinatesObject) {
+ void ImageSource::setCoordinates(jni::JNIEnv& env, const jni::Object<LatLngQuad>& coordinatesObject) {
source.as<mbgl::style::ImageSource>()->setCoordinates(
LatLngQuad::getLatLngArray(env, coordinatesObject));
}
- jni::Object<Source> ImageSource::createJavaPeer(jni::JNIEnv& env) {
- static auto javaClass = jni::Class<ImageSource>::Singleton(env);
+ jni::Local<jni::Object<Source>> ImageSource::createJavaPeer(jni::JNIEnv& env) {
+ static auto& javaClass = jni::Class<ImageSource>::Singleton(env);
static auto constructor = javaClass.GetConstructor<jni::jlong>(env);
- return jni::Object<Source>(javaClass.New(env, constructor, reinterpret_cast<jni::jlong>(this)).Get());
+ return javaClass.New(env, constructor, reinterpret_cast<jni::jlong>(this));
}
void ImageSource::registerNative(jni::JNIEnv& env) {
// Lookup the class
- static auto javaClass = jni::Class<ImageSource>::Singleton(env);
+ static auto& javaClass = jni::Class<ImageSource>::Singleton(env);
#define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
// Register the peer
jni::RegisterNativePeer<ImageSource>(
env, javaClass, "nativePtr",
- std::make_unique<ImageSource, JNIEnv&, jni::String, jni::Object<LatLngQuad>>,
+ jni::MakePeer<ImageSource, const jni::String&, const jni::Object<LatLngQuad>&>,
"initialize",
"finalize",
METHOD(&ImageSource::setURL, "nativeSetUrl"),
diff --git a/platform/android/src/style/sources/image_source.hpp b/platform/android/src/style/sources/image_source.hpp
index b09d4f8c95..6c359bf0ee 100644
--- a/platform/android/src/style/sources/image_source.hpp
+++ b/platform/android/src/style/sources/image_source.hpp
@@ -12,26 +12,26 @@ class Bitmap;
class ImageSource : public Source {
public:
-
+ using SuperTag = Source;
static constexpr auto Name() { return "com/mapbox/mapboxsdk/style/sources/ImageSource"; };
static void registerNative(jni::JNIEnv&);
- ImageSource(jni::JNIEnv&, jni::String, jni::Object<LatLngQuad>);
+ ImageSource(jni::JNIEnv&, const jni::String&, const jni::Object<LatLngQuad>&);
ImageSource(jni::JNIEnv&, mbgl::style::Source&, AndroidRendererFrontend&);
~ImageSource();
- void setURL(jni::JNIEnv&, jni::String);
- jni::String getURL(jni::JNIEnv&);
+ void setURL(jni::JNIEnv&, const jni::String&);
+ jni::Local<jni::String> getURL(jni::JNIEnv&);
- void setImage(jni::JNIEnv&, jni::Object<Bitmap>);
+ void setImage(jni::JNIEnv&, const jni::Object<Bitmap>&);
- void setCoordinates(jni::JNIEnv&, jni::Object<LatLngQuad>);
+ void setCoordinates(jni::JNIEnv&, const jni::Object<LatLngQuad>&);
private:
- jni::Object<Source> createJavaPeer(jni::JNIEnv&);
+ jni::Local<jni::Object<Source>> createJavaPeer(jni::JNIEnv&);
}; // class ImageSource
diff --git a/platform/android/src/style/sources/raster_dem_source.cpp b/platform/android/src/style/sources/raster_dem_source.cpp
index 73d04f27c1..f60526a9b7 100644
--- a/platform/android/src/style/sources/raster_dem_source.cpp
+++ b/platform/android/src/style/sources/raster_dem_source.cpp
@@ -12,12 +12,12 @@
namespace mbgl {
namespace android {
- RasterDEMSource::RasterDEMSource(jni::JNIEnv& env, jni::String sourceId, jni::Object<> urlOrTileSet, jni::jint tileSize)
+ RasterDEMSource::RasterDEMSource(jni::JNIEnv& env, const jni::String& sourceId, const jni::Object<>& urlOrTileSet, jni::jint tileSize)
: Source(
env,
std::make_unique<mbgl::style::RasterDEMSource>(
jni::Make<std::string>(env, sourceId),
- convertURLOrTileset(Value(env, jni::SeizeLocal(env, std::move(urlOrTileSet)))),
+ convertURLOrTileset(Value(env, urlOrTileSet)),
tileSize
)
) {
@@ -31,27 +31,27 @@ namespace android {
RasterDEMSource::~RasterDEMSource() = default;
- jni::String RasterDEMSource::getURL(jni::JNIEnv& env) {
+ jni::Local<jni::String> RasterDEMSource::getURL(jni::JNIEnv& env) {
optional<std::string> url = source.as<mbgl::style::RasterDEMSource>()->RasterDEMSource::getURL();
- return url ? jni::Make<jni::String>(env, *url) : jni::String();
+ return url ? jni::Make<jni::String>(env, *url) : jni::Local<jni::String>();
}
- jni::Object<Source> RasterDEMSource::createJavaPeer(jni::JNIEnv& env) {
- static auto javaClass = jni::Class<RasterDEMSource>::Singleton(env);
+ jni::Local<jni::Object<Source>> RasterDEMSource::createJavaPeer(jni::JNIEnv& env) {
+ static auto& javaClass = jni::Class<RasterDEMSource>::Singleton(env);
static auto constructor = javaClass.GetConstructor<jni::jlong>(env);
- return jni::Object<Source>(javaClass.New(env, constructor, reinterpret_cast<jni::jlong>(this)).Get());
+ return javaClass.New(env, constructor, reinterpret_cast<jni::jlong>(this));
}
void RasterDEMSource::registerNative(jni::JNIEnv& env) {
// Lookup the class
- static auto javaClass = jni::Class<RasterDEMSource>::Singleton(env);
+ static auto& javaClass = jni::Class<RasterDEMSource>::Singleton(env);
#define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
// Register the peer
jni::RegisterNativePeer<RasterDEMSource>(
env, javaClass, "nativePtr",
- std::make_unique<RasterDEMSource, JNIEnv&, jni::String, jni::Object<>, jni::jint>,
+ jni::MakePeer<RasterDEMSource, const jni::String&, const jni::Object<>&, jni::jint>,
"initialize",
"finalize",
METHOD(&RasterDEMSource::getURL, "nativeGetUrl")
diff --git a/platform/android/src/style/sources/raster_dem_source.hpp b/platform/android/src/style/sources/raster_dem_source.hpp
index 25d9fe90cd..0b31c4ecd3 100644
--- a/platform/android/src/style/sources/raster_dem_source.hpp
+++ b/platform/android/src/style/sources/raster_dem_source.hpp
@@ -9,18 +9,19 @@ namespace android {
class RasterDEMSource : public Source {
public:
+ using SuperTag = Source;
static constexpr auto Name() { return "com/mapbox/mapboxsdk/style/sources/RasterDemSource"; };
static void registerNative(jni::JNIEnv&);
- RasterDEMSource(jni::JNIEnv&, jni::String, jni::Object<>, jni::jint);
+ RasterDEMSource(jni::JNIEnv&, const jni::String&, const jni::Object<>&, jni::jint);
RasterDEMSource(jni::JNIEnv&, mbgl::style::Source&, AndroidRendererFrontend&);
~RasterDEMSource();
- jni::String getURL(jni::JNIEnv&);
+ jni::Local<jni::String> getURL(jni::JNIEnv&);
private:
- jni::Object<Source> createJavaPeer(jni::JNIEnv&);
+ jni::Local<jni::Object<Source>> createJavaPeer(jni::JNIEnv&);
}; // class RasterDEMSource
diff --git a/platform/android/src/style/sources/raster_source.cpp b/platform/android/src/style/sources/raster_source.cpp
index 4eef41c8b1..535f899c99 100644
--- a/platform/android/src/style/sources/raster_source.cpp
+++ b/platform/android/src/style/sources/raster_source.cpp
@@ -11,12 +11,12 @@
namespace mbgl {
namespace android {
- RasterSource::RasterSource(jni::JNIEnv& env, jni::String sourceId, jni::Object<> urlOrTileSet, jni::jint tileSize)
+ RasterSource::RasterSource(jni::JNIEnv& env, const jni::String& sourceId, const jni::Object<>& urlOrTileSet, jni::jint tileSize)
: Source(
env,
std::make_unique<mbgl::style::RasterSource>(
jni::Make<std::string>(env, sourceId),
- convertURLOrTileset(Value(env, jni::SeizeLocal(env, std::move(urlOrTileSet)))),
+ convertURLOrTileset(Value(env, urlOrTileSet)),
tileSize
)
) {
@@ -30,27 +30,27 @@ namespace android {
RasterSource::~RasterSource() = default;
- jni::String RasterSource::getURL(jni::JNIEnv& env) {
+ jni::Local<jni::String> RasterSource::getURL(jni::JNIEnv& env) {
optional<std::string> url = source.as<mbgl::style::RasterSource>()->RasterSource::getURL();
- return url ? jni::Make<jni::String>(env, *url) : jni::String();
+ return url ? jni::Make<jni::String>(env, *url) : jni::Local<jni::String>();
}
- jni::Object<Source> RasterSource::createJavaPeer(jni::JNIEnv& env) {
- static auto javaClass = jni::Class<RasterSource>::Singleton(env);
+ jni::Local<jni::Object<Source>> RasterSource::createJavaPeer(jni::JNIEnv& env) {
+ static auto& javaClass = jni::Class<RasterSource>::Singleton(env);
static auto constructor = javaClass.GetConstructor<jni::jlong>(env);
- return jni::Object<Source>(javaClass.New(env, constructor, reinterpret_cast<jni::jlong>(this)).Get());
+ return javaClass.New(env, constructor, reinterpret_cast<jni::jlong>(this));
}
void RasterSource::registerNative(jni::JNIEnv& env) {
// Lookup the class
- static auto javaClass = jni::Class<RasterSource>::Singleton(env);
+ static auto& javaClass = jni::Class<RasterSource>::Singleton(env);
#define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
// Register the peer
jni::RegisterNativePeer<RasterSource>(
env, javaClass, "nativePtr",
- std::make_unique<RasterSource, JNIEnv&, jni::String, jni::Object<>, jni::jint>,
+ jni::MakePeer<RasterSource, const jni::String&, const jni::Object<>&, jni::jint>,
"initialize",
"finalize",
METHOD(&RasterSource::getURL, "nativeGetUrl")
diff --git a/platform/android/src/style/sources/raster_source.hpp b/platform/android/src/style/sources/raster_source.hpp
index 888d9f601d..08648f79aa 100644
--- a/platform/android/src/style/sources/raster_source.hpp
+++ b/platform/android/src/style/sources/raster_source.hpp
@@ -9,18 +9,19 @@ namespace android {
class RasterSource : public Source {
public:
+ using SuperTag = Source;
static constexpr auto Name() { return "com/mapbox/mapboxsdk/style/sources/RasterSource"; };
static void registerNative(jni::JNIEnv&);
- RasterSource(jni::JNIEnv&, jni::String, jni::Object<>, jni::jint);
+ RasterSource(jni::JNIEnv&, const jni::String&, const jni::Object<>&, jni::jint);
RasterSource(jni::JNIEnv&, mbgl::style::Source&, AndroidRendererFrontend&);
~RasterSource();
- jni::String getURL(jni::JNIEnv&);
+ jni::Local<jni::String> getURL(jni::JNIEnv&);
private:
- jni::Object<Source> createJavaPeer(jni::JNIEnv&);
+ jni::Local<jni::Object<Source>> createJavaPeer(jni::JNIEnv&);
}; // class RasterSource
diff --git a/platform/android/src/style/sources/source.cpp b/platform/android/src/style/sources/source.cpp
index c7968786ec..e13f55aff1 100644
--- a/platform/android/src/style/sources/source.cpp
+++ b/platform/android/src/style/sources/source.cpp
@@ -1,5 +1,6 @@
#include "source.hpp"
#include "../android_conversion.hpp"
+#include "../../attach_env.hpp"
#include <jni/jni.hpp>
@@ -47,16 +48,16 @@ namespace android {
}
}
- jni::Object<Source> Source::peerForCoreSource(jni::JNIEnv& env, mbgl::style::Source& coreSource, AndroidRendererFrontend& frontend) {
+ const jni::Object<Source>& Source::peerForCoreSource(jni::JNIEnv& env, mbgl::style::Source& coreSource, AndroidRendererFrontend& frontend) {
if (!coreSource.peer.has_value()) {
coreSource.peer = createSourcePeer(env, coreSource, frontend);
}
- return *coreSource.peer.get<std::unique_ptr<Source>>()->javaPeer;
+ return coreSource.peer.get<std::unique_ptr<Source>>()->javaPeer;
}
- Source::Source(jni::JNIEnv& env, mbgl::style::Source& coreSource, jni::Object<Source> obj, AndroidRendererFrontend& frontend)
+ Source::Source(jni::JNIEnv& env, mbgl::style::Source& coreSource, const jni::Object<Source>& obj, AndroidRendererFrontend& frontend)
: source(coreSource)
- , javaPeer(obj.NewGlobalRef(env))
+ , javaPeer(jni::NewGlobal(env, obj))
, rendererFrontend(&frontend) {
}
@@ -76,23 +77,23 @@ namespace android {
if (ownedSource.get() == nullptr && javaPeer.get() != nullptr) {
// Manually clear the java peer
android::UniqueEnv env = android::AttachEnv();
- static auto javaClass = jni::Class<Source>::Singleton(*env);
+ static auto& javaClass = jni::Class<Source>::Singleton(*env);
static auto nativePtrField = javaClass.GetField<jlong>(*env, "nativePtr");
- javaPeer->Set(*env, nativePtrField, (jlong) 0);
+ javaPeer.Set(*env, nativePtrField, (jlong) 0);
javaPeer.reset();
}
}
- jni::String Source::getId(jni::JNIEnv& env) {
+ jni::Local<jni::String> Source::getId(jni::JNIEnv& env) {
return jni::Make<jni::String>(env, source.getID());
}
- jni::String Source::getAttribution(jni::JNIEnv& env) {
+ jni::Local<jni::String> Source::getAttribution(jni::JNIEnv& env) {
auto attribution = source.getAttribution();
return attribution ? jni::Make<jni::String>(env, attribution.value()) : jni::Make<jni::String>(env,"");
}
- void Source::addToMap(JNIEnv& env, jni::Object<Source> obj, mbgl::Map& map, AndroidRendererFrontend& frontend) {
+ void Source::addToMap(JNIEnv& env, const jni::Object<Source>& obj, mbgl::Map& map, AndroidRendererFrontend& frontend) {
// Check to see if we own the source first
if (!ownedSource) {
throw std::runtime_error("Cannot add source twice");
@@ -105,12 +106,12 @@ namespace android {
source.peer = std::unique_ptr<Source>(this);
// Add strong reference to java source
- javaPeer = obj.NewGlobalRef(env);
+ javaPeer = jni::NewGlobal(env, obj);
rendererFrontend = &frontend;
}
- bool Source::removeFromMap(JNIEnv&, jni::Object<Source>, mbgl::Map& map) {
+ bool Source::removeFromMap(JNIEnv&, const jni::Object<Source>&, mbgl::Map& map) {
// Cannot remove if not attached yet
if (ownedSource) {
throw std::runtime_error("Cannot remove detached source");
@@ -143,7 +144,7 @@ namespace android {
void Source::registerNative(jni::JNIEnv& env) {
// Lookup the class
- static auto javaClass = jni::Class<Source>::Singleton(env);
+ static auto& javaClass = jni::Class<Source>::Singleton(env);
#define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
diff --git a/platform/android/src/style/sources/source.hpp b/platform/android/src/style/sources/source.hpp
index 492be8dfec..93b706425a 100644
--- a/platform/android/src/style/sources/source.hpp
+++ b/platform/android/src/style/sources/source.hpp
@@ -19,12 +19,12 @@ public:
static void registerNative(jni::JNIEnv&);
- static jni::Object<Source> peerForCoreSource(jni::JNIEnv&, mbgl::style::Source&, AndroidRendererFrontend&);
+ static const jni::Object<Source>& peerForCoreSource(jni::JNIEnv&, mbgl::style::Source&, AndroidRendererFrontend&);
/*
* Called when a Java object is created for a core source that belongs to a map.
*/
- Source(jni::JNIEnv&, mbgl::style::Source&, jni::Object<Source>, AndroidRendererFrontend&);
+ Source(jni::JNIEnv&, mbgl::style::Source&, const jni::Object<Source>&, AndroidRendererFrontend&);
/*
* Called when a Java object is created for a new core source that does not belong to a map.
@@ -33,15 +33,15 @@ public:
virtual ~Source();
- virtual void addToMap(JNIEnv&, jni::Object<Source>, mbgl::Map&, AndroidRendererFrontend&);
+ virtual void addToMap(JNIEnv&, const jni::Object<Source>&, mbgl::Map&, AndroidRendererFrontend&);
- virtual bool removeFromMap(JNIEnv&, jni::Object<Source>, mbgl::Map&);
+ virtual bool removeFromMap(JNIEnv&, const jni::Object<Source>&, mbgl::Map&);
void releaseJavaPeer();
- jni::String getId(jni::JNIEnv&);
+ jni::Local<jni::String> getId(jni::JNIEnv&);
- jni::String getAttribution(jni::JNIEnv&);
+ jni::Local<jni::String> getAttribution(jni::JNIEnv&);
protected:
// Set on newly created sources until added to the map.
diff --git a/platform/android/src/style/sources/unknown_source.cpp b/platform/android/src/style/sources/unknown_source.cpp
index 8e91798392..b5285a5f9f 100644
--- a/platform/android/src/style/sources/unknown_source.cpp
+++ b/platform/android/src/style/sources/unknown_source.cpp
@@ -18,15 +18,15 @@ namespace android {
: Source(env, coreSource, createJavaPeer(env), frontend) {
}
- jni::Object<Source> UnknownSource::createJavaPeer(jni::JNIEnv& env) {
- static auto javaClass = jni::Class<UnknownSource>::Singleton(env);
+ jni::Local<jni::Object<Source>> UnknownSource::createJavaPeer(jni::JNIEnv& env) {
+ static auto& javaClass = jni::Class<UnknownSource>::Singleton(env);
static auto constructor = javaClass.GetConstructor<jni::jlong>(env);
- return jni::Object<Source>(javaClass.New(env, constructor, reinterpret_cast<jni::jlong>(this)).Get());
+ return javaClass.New(env, constructor, reinterpret_cast<jni::jlong>(this));
}
void UnknownSource::registerNative(jni::JNIEnv& env) {
// Lookup the class
- static auto javaClass = jni::Class<UnknownSource>::Singleton(env);
+ static auto& javaClass = jni::Class<UnknownSource>::Singleton(env);
#define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
diff --git a/platform/android/src/style/sources/unknown_source.hpp b/platform/android/src/style/sources/unknown_source.hpp
index 855aea7c63..f042e2042c 100644
--- a/platform/android/src/style/sources/unknown_source.hpp
+++ b/platform/android/src/style/sources/unknown_source.hpp
@@ -9,7 +9,7 @@ namespace android {
class UnknownSource : public Source {
public:
-
+ using SuperTag = Source;
static constexpr auto Name() { return "com/mapbox/mapboxsdk/style/sources/UnknownSource"; };
static void registerNative(jni::JNIEnv&);
@@ -19,7 +19,7 @@ public:
~UnknownSource() = default;
private:
- jni::Object<Source> createJavaPeer(jni::JNIEnv&);
+ jni::Local<jni::Object<Source>> createJavaPeer(jni::JNIEnv&);
}; // class UnknownSource
diff --git a/platform/android/src/style/sources/vector_source.cpp b/platform/android/src/style/sources/vector_source.cpp
index 48eb4ca51c..e46fc1a94e 100644
--- a/platform/android/src/style/sources/vector_source.cpp
+++ b/platform/android/src/style/sources/vector_source.cpp
@@ -20,12 +20,12 @@
namespace mbgl {
namespace android {
- VectorSource::VectorSource(jni::JNIEnv& env, jni::String sourceId, jni::Object<> urlOrTileSet)
+ VectorSource::VectorSource(jni::JNIEnv& env, const jni::String& sourceId, const jni::Object<>& urlOrTileSet)
: Source(
env,
std::make_unique<mbgl::style::VectorSource>(
jni::Make<std::string>(env, sourceId),
- convertURLOrTileset(Value(env, jni::SeizeLocal(env, std::move(urlOrTileSet))))
+ convertURLOrTileset(Value(env, urlOrTileSet))
)
) {
}
@@ -38,41 +38,41 @@ namespace android {
VectorSource::~VectorSource() = default;
- jni::String VectorSource::getURL(jni::JNIEnv& env) {
+ jni::Local<jni::String> VectorSource::getURL(jni::JNIEnv& env) {
optional<std::string> url = source.as<mbgl::style::VectorSource>()->VectorSource::getURL();
- return url ? jni::Make<jni::String>(env, *url) : jni::String();
+ return url ? jni::Make<jni::String>(env, *url) : jni::Local<jni::String>();
}
- jni::Array<jni::Object<geojson::Feature>> VectorSource::querySourceFeatures(jni::JNIEnv& env,
- jni::Array<jni::String> jSourceLayerIds,
- jni::Array<jni::Object<>> jfilter) {
+ jni::Local<jni::Array<jni::Object<geojson::Feature>>> VectorSource::querySourceFeatures(jni::JNIEnv& env,
+ const jni::Array<jni::String>& jSourceLayerIds,
+ const jni::Array<jni::Object<>>& jfilter) {
using namespace mbgl::android::conversion;
using namespace mbgl::android::geojson;
std::vector<mbgl::Feature> features;
if (rendererFrontend) {
features = rendererFrontend->querySourceFeatures(source.getID(),
- { toVector(env, jSourceLayerIds), toFilter(env, jni::SeizeLocal(env, std::move(jfilter))) });
+ { toVector(env, jSourceLayerIds), toFilter(env, jfilter) });
}
return Feature::convert(env, features);
}
- jni::Object<Source> VectorSource::createJavaPeer(jni::JNIEnv& env) {
- static auto javaClass = jni::Class<VectorSource>::Singleton(env);
+ jni::Local<jni::Object<Source>> VectorSource::createJavaPeer(jni::JNIEnv& env) {
+ static auto& javaClass = jni::Class<VectorSource>::Singleton(env);
static auto constructor = javaClass.GetConstructor<jni::jlong>(env);
- return jni::Object<Source>(javaClass.New(env, constructor, reinterpret_cast<jni::jlong>(this)).Get());
+ return javaClass.New(env, constructor, reinterpret_cast<jni::jlong>(this));
}
void VectorSource::registerNative(jni::JNIEnv& env) {
// Lookup the class
- static auto javaClass = jni::Class<VectorSource>::Singleton(env);
+ static auto& javaClass = jni::Class<VectorSource>::Singleton(env);
#define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
// Register the peer
jni::RegisterNativePeer<VectorSource>(
env, javaClass, "nativePtr",
- std::make_unique<VectorSource, JNIEnv&, jni::String, jni::Object<>>,
+ jni::MakePeer<VectorSource, const jni::String&, const jni::Object<>&>,
"initialize",
"finalize",
METHOD(&VectorSource::querySourceFeatures, "querySourceFeatures"),
diff --git a/platform/android/src/style/sources/vector_source.hpp b/platform/android/src/style/sources/vector_source.hpp
index 587a4be208..4cb46c6c62 100644
--- a/platform/android/src/style/sources/vector_source.hpp
+++ b/platform/android/src/style/sources/vector_source.hpp
@@ -10,21 +10,22 @@ namespace android {
class VectorSource : public Source {
public:
+ using SuperTag = Source;
static constexpr auto Name() { return "com/mapbox/mapboxsdk/style/sources/VectorSource"; };
static void registerNative(jni::JNIEnv&);
- VectorSource(jni::JNIEnv&, jni::String, jni::Object<>);
+ VectorSource(jni::JNIEnv&, const jni::String&, const jni::Object<>&);
VectorSource(jni::JNIEnv&, mbgl::style::Source&, AndroidRendererFrontend&);
~VectorSource();
private:
- jni::Array<jni::Object<geojson::Feature>> querySourceFeatures(jni::JNIEnv&, jni::Array<jni::String>,
- jni::Array<jni::Object<>> jfilter);
+ jni::Local<jni::Array<jni::Object<geojson::Feature>>> querySourceFeatures(jni::JNIEnv&, const jni::Array<jni::String>&,
+ const jni::Array<jni::Object<>>& jfilter);
- jni::String getURL(jni::JNIEnv&);
+ jni::Local<jni::String> getURL(jni::JNIEnv&);
- jni::Object<Source> createJavaPeer(jni::JNIEnv&);
+ jni::Local<jni::Object<Source>> createJavaPeer(jni::JNIEnv&);
}; // class VectorSource
diff --git a/platform/android/src/style/transition_options.cpp b/platform/android/src/style/transition_options.cpp
index 84bd909125..b908c37089 100644
--- a/platform/android/src/style/transition_options.cpp
+++ b/platform/android/src/style/transition_options.cpp
@@ -3,8 +3,8 @@
namespace mbgl {
namespace android {
-jni::Object<TransitionOptions> TransitionOptions::fromTransitionOptions(jni::JNIEnv& env, jlong duration, jlong delay) {
- static auto javaClass = jni::Class<TransitionOptions>::Singleton(env);
+jni::Local<jni::Object<TransitionOptions>> TransitionOptions::fromTransitionOptions(jni::JNIEnv& env, jlong duration, jlong delay) {
+ static auto& javaClass = jni::Class<TransitionOptions>::Singleton(env);
static auto method = javaClass.GetStaticMethod<jni::Object<TransitionOptions> (jlong, jlong)>(env, "fromTransitionOptions");
return javaClass.Call(env, method, duration, delay);
}
diff --git a/platform/android/src/style/transition_options.hpp b/platform/android/src/style/transition_options.hpp
index 83276ca1d8..0bac43fa16 100644
--- a/platform/android/src/style/transition_options.hpp
+++ b/platform/android/src/style/transition_options.hpp
@@ -11,7 +11,7 @@ class TransitionOptions : private mbgl::util::noncopyable {
public:
static constexpr auto Name() { return "com/mapbox/mapboxsdk/style/layers/TransitionOptions"; };
- static jni::Object<TransitionOptions> fromTransitionOptions(jni::JNIEnv&, jlong duration, jlong offset);
+ static jni::Local<jni::Object<TransitionOptions>> fromTransitionOptions(jni::JNIEnv&, jlong duration, jlong offset);
static void registerNative(jni::JNIEnv&);
};
diff --git a/platform/android/src/style/value.cpp b/platform/android/src/style/value.cpp
index 6cdf134931..f916909687 100644
--- a/platform/android/src/style/value.cpp
+++ b/platform/android/src/style/value.cpp
@@ -10,64 +10,67 @@ namespace android {
: env(_env),
value(std::move(_value)) {}
+ Value::Value(jni::JNIEnv& _env, const jni::Object<>& _value)
+ : env(_env),
+ value(jni::NewLocal(_env, _value)) {}
+
bool Value::isNull() const {
return !value;
}
bool Value::isArray() const {
- return jni::IsInstanceOf(env, value->Get(), *java::ObjectArray::jclass);
+ return jni::IsInstanceOf(env, value.get(), *java::ObjectArray::jclass);
}
bool Value::isObject() const {
- return jni::IsInstanceOf(env, value->Get(), *java::Map::jclass);
+ return jni::IsInstanceOf(env, value.get(), *java::Map::jclass);
}
bool Value::isString() const {
- return jni::IsInstanceOf(env, value->Get(), *java::String::jclass);
+ return jni::IsInstanceOf(env, value.get(), *java::String::jclass);
}
bool Value::isBool() const {
- return jni::IsInstanceOf(env, value->Get(), *java::Boolean::jclass);
+ return jni::IsInstanceOf(env, value.get(), *java::Boolean::jclass);
}
bool Value::isNumber() const {
- return jni::IsInstanceOf(env, value->Get(), *java::Number::jclass);
+ return jni::IsInstanceOf(env, value.get(), *java::Number::jclass);
}
std::string Value::toString() const {
- jni::jstring* string = reinterpret_cast<jni::jstring*>(value->Get());
- return jni::Make<std::string>(env, jni::String(string));
+ return jni::Make<std::string>(env, jni::Cast(env, jni::Class<jni::StringTag>::Singleton(env), value));
}
float Value::toFloat() const {
- return jni::CallMethod<jni::jfloat>(env, value->Get(), *java::Number::floatValueMethodId);
+ return jni::CallMethod<jni::jfloat>(env, value.get(), *java::Number::floatValueMethodId);
}
double Value::toDouble() const {
- return jni::CallMethod<jni::jdouble>(env, value->Get(), *java::Number::doubleValueMethodId);
+ return jni::CallMethod<jni::jdouble>(env, value.get(), *java::Number::doubleValueMethodId);
}
long Value::toLong() const {
- return jni::CallMethod<jni::jlong>(env, value->Get(), *java::Number::longValueMethodId);
+ return jni::CallMethod<jni::jlong>(env, value.get(), *java::Number::longValueMethodId);
}
bool Value::toBool() const {
- return jni::CallMethod<jni::jboolean>(env, value->Get(), *java::Boolean::booleanValueMethodId);
+ return jni::CallMethod<jni::jboolean>(env, value.get(), *java::Boolean::booleanValueMethodId);
}
Value Value::get(const char* key) const {
- jni::jobject* member = jni::CallMethod<jni::jobject*>(env, value->Get(), *java::Map::getMethodId, jni::Make<jni::String>(env, std::string(key)).Get());
- return Value(env, jni::SeizeLocal(env, jni::Object<>(member)));
+ jni::jobject* member = jni::CallMethod<jni::jobject*>(env, value.get(), *java::Map::getMethodId, jni::Make<jni::String>(env, std::string(key)).get());
+ return Value(env, jni::Local<jni::Object<>>(env, member));
}
int Value::getLength() const {
- auto array = (jni::jarray<jni::jobject>*) value->Get();
+ auto array = (jni::jarray<jni::jobject>*) value.get();
return jni::GetArrayLength(env, *array);
}
Value Value::get(const int index) const {
- auto array = (jni::jarray<jni::jobject>*) value->Get();
- return Value(env, jni::SeizeLocal(env, jni::Object<>(jni::GetObjectArrayElement(env, *array, index))));
+ auto array = (jni::jarray<jni::jobject>*) value.get();
+ return Value(env, jni::Local<jni::Object<>>(env, jni::GetObjectArrayElement(env, *array, index)));
}
}
}
diff --git a/platform/android/src/style/value.hpp b/platform/android/src/style/value.hpp
index bd1c552be0..b3e665e57b 100644
--- a/platform/android/src/style/value.hpp
+++ b/platform/android/src/style/value.hpp
@@ -10,6 +10,7 @@ namespace android {
class Value {
public:
Value(jni::JNIEnv&, jni::Local<jni::Object<>>);
+ Value(jni::JNIEnv&, const jni::Object<>&);
Value(Value&&) = default;
Value& operator=(Value&&) = default;
diff --git a/platform/android/src/test/main.jni.cpp b/platform/android/src/test/main.jni.cpp
index f96dd6aa5e..1cd0d26d2c 100644
--- a/platform/android/src/test/main.jni.cpp
+++ b/platform/android/src/test/main.jni.cpp
@@ -18,7 +18,7 @@ struct Main {
/**
* JNI Bound to Main#runAllTests()
*/
- static void runAllTests(jni::JNIEnv& env, jni::Object<Main>, jni::Array<jni::String> args) {
+ static void runAllTests(jni::JNIEnv& env, const jni::Object<Main>&, const jni::Array<jni::String>& args) {
mbgl::Log::Warning(mbgl::Event::JNI, "Starting tests");
// We need to create a copy of the argv data since Java-internals are stored in UTF-16.
@@ -69,7 +69,7 @@ extern "C" JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *) {
// Load the test library jni bindings
mbgl::Log::Info(mbgl::Event::JNI, "Registering test JNI Methods");
- jni::RegisterNatives(env, jni::Class<Main>::Find(env),
+ jni::RegisterNatives(env, *jni::Class<Main>::Find(env),
jni::MakeNativeMethod<decltype(Main::runAllTests), &Main::runAllTests>("runAllTests"));
return JNI_VERSION_1_6;
diff --git a/platform/android/src/text/collator.cpp b/platform/android/src/text/collator.cpp
index 86e72a1dac..04da53832a 100644
--- a/platform/android/src/text/collator.cpp
+++ b/platform/android/src/text/collator.cpp
@@ -16,20 +16,20 @@ void Collator::registerNative(jni::JNIEnv& env) {
jni::Class<Collator>::Singleton(env);
}
-jni::Object<Collator> Collator::getInstance(jni::JNIEnv& env, jni::Object<Locale> locale) {
- static auto javaClass = jni::Class<Collator>::Singleton(env);
+jni::Local<jni::Object<Collator>> Collator::getInstance(jni::JNIEnv& env, const jni::Object<Locale>& locale) {
+ static auto& javaClass = jni::Class<Collator>::Singleton(env);
static auto method = javaClass.GetStaticMethod<jni::Object<Collator> (jni::Object<Locale>)>(env, "getInstance");
return javaClass.Call(env, method, locale);
}
-void Collator::setStrength(jni::JNIEnv& env, jni::Object<Collator> collator, jni::jint strength) {
- static auto javaClass = jni::Class<Collator>::Singleton(env);
+void Collator::setStrength(jni::JNIEnv& env, const jni::Object<Collator>& collator, jni::jint strength) {
+ static auto& javaClass = jni::Class<Collator>::Singleton(env);
static auto method = javaClass.GetMethod<void (jni::jint)>(env, "setStrength");
collator.Call(env, method, strength);
}
-jni::jint Collator::compare(jni::JNIEnv& env, jni::Object<Collator> collator, jni::String lhs, jni::String rhs) {
- static auto javaClass = jni::Class<Collator>::Singleton(env);
+jni::jint Collator::compare(jni::JNIEnv& env, const jni::Object<Collator>& collator, const jni::String& lhs, const jni::String& rhs) {
+ static auto& javaClass = jni::Class<Collator>::Singleton(env);
auto static method = javaClass.GetMethod<jni::jint (jni::String, jni::String)>(env, "compare");
return collator.Call(env, method, lhs, rhs);
}
@@ -54,32 +54,32 @@ jni::String Locale::toLanguageTag(jni::JNIEnv& env, jni::Object<Locale> locale)
}
*/
-jni::String Locale::getLanguage(jni::JNIEnv& env, jni::Object<Locale> locale) {
- static auto javaClass = jni::Class<Locale>::Singleton(env);
+jni::Local<jni::String> Locale::getLanguage(jni::JNIEnv& env, const jni::Object<Locale>& locale) {
+ static auto& javaClass = jni::Class<Locale>::Singleton(env);
static auto method = javaClass.GetMethod<jni::String ()>(env, "getLanguage");
return locale.Call(env, method);
}
-jni::String Locale::getCountry(jni::JNIEnv& env, jni::Object<Locale> locale) {
- static auto javaClass = jni::Class<Locale>::Singleton(env);
+jni::Local<jni::String> Locale::getCountry(jni::JNIEnv& env, const jni::Object<Locale>& locale) {
+ static auto& javaClass = jni::Class<Locale>::Singleton(env);
static auto method = javaClass.GetMethod<jni::String ()>(env, "getCountry");
return locale.Call(env, method);
}
-jni::Object<Locale> Locale::getDefault(jni::JNIEnv& env) {
- static auto javaClass = jni::Class<Locale>::Singleton(env);
+jni::Local<jni::Object<Locale>> Locale::getDefault(jni::JNIEnv& env) {
+ static auto& javaClass = jni::Class<Locale>::Singleton(env);
static auto method = javaClass.GetStaticMethod<jni::Object<Locale> ()>(env, "getDefault");
return javaClass.Call(env, method);
}
-jni::Object<Locale> Locale::New(jni::JNIEnv& env, jni::String language) {
- static auto javaClass = jni::Class<Locale>::Singleton(env);
+jni::Local<jni::Object<Locale>> Locale::New(jni::JNIEnv& env, const jni::String& language) {
+ static auto& javaClass = jni::Class<Locale>::Singleton(env);
static auto constructor = javaClass.GetConstructor<jni::String>(env);
return javaClass.New(env, constructor, language);
}
-jni::Object<Locale> Locale::New(jni::JNIEnv& env, jni::String language, jni::String region) {
- static auto javaClass = jni::Class<Locale>::Singleton(env);
+jni::Local<jni::Object<Locale>> Locale::New(jni::JNIEnv& env, const jni::String& language, const jni::String& region) {
+ static auto& javaClass = jni::Class<Locale>::Singleton(env);
static auto constructor = javaClass.GetConstructor<jni::String, jni::String>(env);
return javaClass.New(env, constructor, language, region);
}
@@ -98,26 +98,25 @@ public:
{
LanguageTag languageTag = locale_ ? LanguageTag::fromBCP47(*locale_) : LanguageTag();
if (!languageTag.language) {
- locale = android::Locale::getDefault(*env).NewGlobalRef(*env);
+ locale = jni::NewGlobal(*env,
+ android::Locale::getDefault(*env));
} else if (!languageTag.region) {
- locale = android::Locale::New(*env,
- jni::Make<jni::String>(*env, *(languageTag.language)))
- .NewGlobalRef(*env);
+ locale = jni::NewGlobal(*env,
+ android::Locale::New(*env, jni::Make<jni::String>(*env, *languageTag.language)));
} else {
- locale = android::Locale::New(*env,
- jni::Make<jni::String>(*env, *(languageTag.language)),
- jni::Make<jni::String>(*env, *(languageTag.region)))
- .NewGlobalRef(*env);
+ locale = jni::NewGlobal(*env,
+ android::Locale::New(*env, jni::Make<jni::String>(*env, *languageTag.language),
+ jni::Make<jni::String>(*env, *languageTag.region)));
}
- collator = android::Collator::getInstance(*env, *locale).NewGlobalRef(*env);;
+ collator = jni::NewGlobal(*env, android::Collator::getInstance(*env, locale));
if (!diacriticSensitive && !caseSensitive) {
- android::Collator::setStrength(*env, *collator, 0 /*PRIMARY*/);
+ android::Collator::setStrength(*env, collator, 0 /*PRIMARY*/);
} else if (diacriticSensitive && !caseSensitive) {
- android::Collator::setStrength(*env, *collator, 1 /*SECONDARY*/);
+ android::Collator::setStrength(*env, collator, 1 /*SECONDARY*/);
} else if (caseSensitive) {
// If we're case-sensitive and diacritic-sensitive, we use a case-sensitive collator
// and a fallback implementation of diacritic-insensitivity.
- android::Collator::setStrength(*env, *collator, 2 /*TERTIARY*/);
+ android::Collator::setStrength(*env, collator, 2 /*TERTIARY*/);
}
}
@@ -135,23 +134,21 @@ public:
// Because of the difference in locale-awareness, this means turning on case-sensitivity
// can _potentially_ change compare results for strings that don't actually have any case
// differences.
- jni::Local<jni::String> jlhs = jni::SeizeLocal(*env, jni::Make<jni::String>(*env, useUnaccent ?
+ jni::Local<jni::String> jlhs = jni::Make<jni::String>(*env, useUnaccent ?
platform::unaccent(lhs) :
- lhs));
- jni::Local<jni::String> jrhs = jni::SeizeLocal(*env, jni::Make<jni::String>(*env, useUnaccent ?
+ lhs);
+ jni::Local<jni::String> jrhs = jni::Make<jni::String>(*env, useUnaccent ?
platform::unaccent(rhs) :
- rhs));
+ rhs);
- jni::jint result = android::Collator::compare(*env, *collator, *jlhs, *jrhs);
+ jni::jint result = android::Collator::compare(*env, collator, jlhs, jrhs);
return result;
}
std::string resolvedLocale() const {
- std::string language = jni::Make<std::string>(*env,
- *jni::SeizeLocal(*env, android::Locale::getLanguage(*env, *locale)));
- std::string region = jni::Make<std::string>(*env,
- *jni::SeizeLocal(*env, android::Locale::getCountry(*env, *locale)));
+ std::string language = jni::Make<std::string>(*env, android::Locale::getLanguage(*env, locale));
+ std::string region = jni::Make<std::string>(*env, android::Locale::getCountry(*env, locale));
optional<std::string> resultLanguage;
if (!language.empty()) resultLanguage = language;
diff --git a/platform/android/src/text/collator_jni.hpp b/platform/android/src/text/collator_jni.hpp
index 30fb6a4369..e5e82c34fd 100644
--- a/platform/android/src/text/collator_jni.hpp
+++ b/platform/android/src/text/collator_jni.hpp
@@ -24,12 +24,12 @@ public:
static jni::Object<Locale> forLanguageTag(jni::JNIEnv&, jni::String);
static jni::String toLanguageTag(jni::JNIEnv&, jni::Object<Locale>);
*/
- static jni::Object<Locale> getDefault(jni::JNIEnv&);
- static jni::String getLanguage(jni::JNIEnv&, jni::Object<Locale>);
- static jni::String getCountry(jni::JNIEnv&, jni::Object<Locale>);
+ static jni::Local<jni::Object<Locale>> getDefault(jni::JNIEnv&);
+ static jni::Local<jni::String> getLanguage(jni::JNIEnv&, const jni::Object<Locale>&);
+ static jni::Local<jni::String> getCountry(jni::JNIEnv&, const jni::Object<Locale>&);
- static jni::Object<Locale> New(jni::JNIEnv&, jni::String);
- static jni::Object<Locale> New(jni::JNIEnv&, jni::String, jni::String);
+ static jni::Local<jni::Object<Locale>> New(jni::JNIEnv&, const jni::String&);
+ static jni::Local<jni::Object<Locale>> New(jni::JNIEnv&, const jni::String&, const jni::String&);
static void registerNative(jni::JNIEnv&);
@@ -39,11 +39,11 @@ class Collator {
public:
static constexpr auto Name() { return "java/text/Collator"; };
- static jni::Object<Collator> getInstance(jni::JNIEnv&, jni::Object<Locale>);
+ static jni::Local<jni::Object<Collator>> getInstance(jni::JNIEnv&, const jni::Object<Locale>&);
- static void setStrength(jni::JNIEnv&, jni::Object<Collator>, jni::jint);
+ static void setStrength(jni::JNIEnv&, const jni::Object<Collator>&, jni::jint);
- static jni::jint compare(jni::JNIEnv&, jni::Object<Collator>, jni::String, jni::String);
+ static jni::jint compare(jni::JNIEnv&, const jni::Object<Collator>&, const jni::String&, const jni::String&);
static void registerNative(jni::JNIEnv&);
diff --git a/platform/android/src/text/local_glyph_rasterizer.cpp b/platform/android/src/text/local_glyph_rasterizer.cpp
index adfa0559f3..8892ee3f37 100644
--- a/platform/android/src/text/local_glyph_rasterizer.cpp
+++ b/platform/android/src/text/local_glyph_rasterizer.cpp
@@ -36,25 +36,24 @@ namespace android {
LocalGlyphRasterizer::LocalGlyphRasterizer() {
UniqueEnv env { AttachEnv() };
- static auto javaClass = jni::Class<LocalGlyphRasterizer>::Singleton(*env);
+ static auto& javaClass = jni::Class<LocalGlyphRasterizer>::Singleton(*env);
static auto constructor = javaClass.GetConstructor(*env);
- javaObject = javaClass.New(*env, constructor).NewGlobalRef(*env);
+ javaObject = jni::NewGlobal(*env, javaClass.New(*env, constructor));
}
PremultipliedImage LocalGlyphRasterizer::drawGlyphBitmap(const std::string& fontFamily, const bool bold, const GlyphID glyphID) {
UniqueEnv env { AttachEnv() };
- static auto javaClass = jni::Class<LocalGlyphRasterizer>::Singleton(*env);
+ static auto& javaClass = jni::Class<LocalGlyphRasterizer>::Singleton(*env);
static auto drawGlyphBitmap = javaClass.GetMethod<jni::Object<Bitmap> (jni::String, jni::jboolean, jni::jchar)>(*env, "drawGlyphBitmap");
- auto javaBitmap = jni::SeizeLocal(*env,
- javaObject->Call(*env, drawGlyphBitmap,
- *jni::SeizeLocal(*env, jni::Make<jni::String>(*env, fontFamily)),
- static_cast<jni::jboolean>(bold),
- static_cast<jni::jchar>(glyphID)));
-
- return Bitmap::GetImage(*env, *javaBitmap);
+ return Bitmap::GetImage(*env,
+ javaObject.Call(*env,
+ drawGlyphBitmap,
+ jni::Make<jni::String>(*env, fontFamily),
+ static_cast<jni::jboolean>(bold),
+ static_cast<jni::jchar>(glyphID)));
}
void LocalGlyphRasterizer::registerNative(jni::JNIEnv& env) {