Skip to content

Commit dcef6a3

Browse files
committed
warnings
1 parent a2fed97 commit dcef6a3

File tree

2 files changed

+16
-19
lines changed

2 files changed

+16
-19
lines changed

CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
project(jmi)
2-
cmake_minimum_required(VERSION 3.0)
2+
cmake_minimum_required(VERSION 3.16)
33
option(BUILD_TESTS "build tests" OFF)
44

55
if(NOT CMAKE_CXX_STANDARD)
@@ -8,9 +8,6 @@ endif()
88
set(CMAKE_CXX_STANDARD_REQUIRED ON)
99
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
1010

11-
if(POLICY CMP0063) # visibility. since 3.3
12-
cmake_policy(SET CMP0063 NEW)
13-
endif()
1411
set(CMAKE_CXX_VISIBILITY_PRESET hidden) #use with -fdata-sections -ffunction-sections to reduce target size
1512
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
1613

jmi.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,13 @@ class JObject : public ClassTag
211211
static void callStatic(const string_view& name, Args&&... args);
212212

213213
template<typename T>
214-
T get(string_view&& fieldName) const;
214+
T get(string_view fieldName) const;
215215
template<typename T>
216-
bool set(string_view&& fieldName, T&& v);
216+
bool set(string_view fieldName, T&& v);
217217
template<typename T>
218-
static T getStatic(string_view&& fieldName);
218+
static T getStatic(string_view fieldName);
219219
template<typename T>
220-
static bool setStatic(string_view&& fieldName, T&& v);
220+
static bool setStatic(string_view fieldName, T&& v);
221221

222222
/*
223223
Field API
@@ -276,7 +276,7 @@ class JObject : public ClassTag
276276
private:
277277
static jclass classId(JNIEnv* env = nullptr);
278278
JObject& setError(const string& s) const {
279-
error_ = std::move(s);
279+
error_ = s;
280280
return *const_cast<JObject*>(this);
281281
}
282282

@@ -776,7 +776,7 @@ namespace detail {
776776
}
777777

778778
template<typename T, typename... Args>
779-
T call_with_methodID(jobject oid, jclass cid, jmethodID* pmid, function<void(string&& err)> err_cb, const char* signature, const char* name, Args&&... args) {
779+
T call_with_methodID(jobject oid, jclass cid, jmethodID* pmid, function<void(string&& err)>&& err_cb, const char* signature, const char* name, Args&&... args) {
780780
if (err_cb)
781781
err_cb(string());
782782
if (!cid)
@@ -807,7 +807,7 @@ namespace detail {
807807
}
808808

809809
template<typename T, typename... Args>
810-
T call_static_with_methodID(jclass cid, jmethodID* pmid, function<void(string&& err)> err_cb, const char* signature, const char* name, Args&&... args) {
810+
T call_static_with_methodID(jclass cid, jmethodID* pmid, function<void(string&& err)>&& err_cb, const char* signature, const char* name, Args&&... args) {
811811
if (err_cb)
812812
err_cb(string());
813813
if (!cid)
@@ -1060,7 +1060,7 @@ template<class CTag>
10601060
template<class FTag, typename T, detail::if_FieldTag<FTag>>
10611061
T JObject<CTag>::get() const {
10621062
static jfieldID fid = nullptr;
1063-
auto checker = detail::call_on_exit([=]{
1063+
auto checker = detail::call_on_exit([this]{
10641064
if (detail::handle_exception()) // TODO: check fid
10651065
setError(string("Failed to get field '") + FTag::name() + "' with signature '" + signature_of<T>().data() + "'.");
10661066
});
@@ -1070,7 +1070,7 @@ template<class CTag>
10701070
template<class FTag, typename T, detail::if_FieldTag<FTag>>
10711071
bool JObject<CTag>::set(T&& v) {
10721072
static jfieldID fid = nullptr;
1073-
auto checker = detail::call_on_exit([=]{
1073+
auto checker = detail::call_on_exit([this]{
10741074
if (detail::handle_exception())
10751075
setError(string("Failed to set field '") + FTag::name() + "' with signature '" + signature_of<T>().data() + "'.");
10761076
});
@@ -1123,19 +1123,19 @@ void JObject<CTag>::callStatic(const string_view &name, Args&&... args) {
11231123

11241124
template<class CTag>
11251125
template<typename T>
1126-
T JObject<CTag>::get(string_view&& fieldName) const {
1126+
T JObject<CTag>::get(string_view fieldName) const {
11271127
jfieldID fid = nullptr;
1128-
auto checker = detail::call_on_exit([=]{
1128+
auto checker = detail::call_on_exit([=, this]{
11291129
if (detail::handle_exception()) // TODO: check fid
11301130
setError(string("Failed to get field '") + fieldName.data() + "' with signature '" + signature_of<T>().data() + "'.");
11311131
});
11321132
return detail::get_field<T>(oid_, classId(), &fid, fieldName.data());
11331133
}
11341134
template<class CTag>
11351135
template<typename T>
1136-
bool JObject<CTag>::set(string_view&& fieldName, T&& v) {
1136+
bool JObject<CTag>::set(string_view fieldName, T&& v) {
11371137
jfieldID fid = nullptr;
1138-
auto checker = detail::call_on_exit([=]{
1138+
auto checker = detail::call_on_exit([=, this]{
11391139
if (detail::handle_exception())
11401140
setError(string("Failed to set field '") + fieldName.data() + "' with signature '" + signature_of<T>().data() + "'.");
11411141
});
@@ -1144,13 +1144,13 @@ bool JObject<CTag>::set(string_view&& fieldName, T&& v) {
11441144
}
11451145
template<class CTag>
11461146
template<typename T>
1147-
T JObject<CTag>::getStatic(string_view&& fieldName) {
1147+
T JObject<CTag>::getStatic(string_view fieldName) {
11481148
jfieldID fid = nullptr;
11491149
return detail::get_static_field<T>(classId(), &fid, fieldName.data());
11501150
}
11511151
template<class CTag>
11521152
template<typename T>
1153-
bool JObject<CTag>::setStatic(string_view&& fieldName, T&& v) {
1153+
bool JObject<CTag>::setStatic(string_view fieldName, T&& v) {
11541154
jfieldID fid = nullptr;
11551155
detail::set_static_field<T>(classId(), &fid, fieldName.data(), std::forward<T>(v));
11561156
return true;

0 commit comments

Comments
 (0)