diff --git a/implementation/global_object_test.cc b/implementation/global_object_test.cc index 8048606a..85d04836 100644 --- a/implementation/global_object_test.cc +++ b/implementation/global_object_test.cc @@ -28,11 +28,11 @@ using ::jni::AdoptGlobal; using ::jni::AdoptLocal; using ::jni::Class; using ::jni::Constructor; -using ::jni::CreateCopy; using ::jni::Field; using ::jni::GlobalObject; using ::jni::LocalObject; using ::jni::Method; +using ::jni::NewRef; using ::jni::Params; using ::jni::PromoteToGlobal; using ::jni::test::AsGlobal; @@ -133,7 +133,7 @@ TEST_F(JniTest, GlobalObject_CallsNewGlobalRefOnCopy) { EXPECT_CALL(*env_, DeleteGlobalRef(Fake(2))); EXPECT_CALL(*env_, DeleteLocalRef(Fake(1))).Times(0); - GlobalObject global_object{CreateCopy{}, Fake(1)}; + GlobalObject global_object{NewRef{}, Fake(1)}; EXPECT_EQ(jobject{global_object}, Fake(2)); } diff --git a/implementation/local_object_test.cc b/implementation/local_object_test.cc index dadc2cd3..e2d4efa5 100644 --- a/implementation/local_object_test.cc +++ b/implementation/local_object_test.cc @@ -27,12 +27,12 @@ namespace { using ::jni::Class; -using ::jni::CreateCopy; using ::jni::Field; using ::jni::kDefaultClassLoader; using ::jni::kDefaultJvm; using ::jni::LocalObject; using ::jni::Method; +using ::jni::NewRef; using ::jni::Params; using ::jni::test::AsNewLocalReference; using ::jni::test::Fake; @@ -82,7 +82,7 @@ TEST_F(JniTest, LocalObject_CallsNewLocalRefOnCopy) { EXPECT_CALL(*env_, NewLocalRef).WillOnce(::testing::Return(Fake(2))); EXPECT_CALL(*env_, DeleteLocalRef(Fake(2))); - LocalObject obj{CreateCopy{}, Fake(1)}; + LocalObject obj{NewRef{}, Fake(1)}; EXPECT_EQ(jobject{obj}, Fake(2)); } diff --git a/implementation/promotion_mechanics.h b/implementation/promotion_mechanics.h index d50bb6f6..bb719cb5 100644 --- a/implementation/promotion_mechanics.h +++ b/implementation/promotion_mechanics.h @@ -51,7 +51,7 @@ struct EntryBase : public Base { EntryBase(AdoptLocal, ViableSpan object) : Base(object) {} // "Copy" constructor: Additional reference to object will be created. - EntryBase(CreateCopy, ViableSpan object) + EntryBase(NewRef, ViableSpan object) : EntryBase(AdoptLocal{}, object ? static_cast( @@ -122,7 +122,7 @@ struct EntryBase : public Base { LifecycleType::GLOBAL>::Promote(rhs.Release())) {} // "Copy" constructor: Additional reference to object will be created. - EntryBase(CreateCopy, ViableSpan object) + EntryBase(NewRef, ViableSpan object) : Base(static_cast( LifecycleHelper::NewReference( static_cast(object)))) {} diff --git a/implementation/promotion_mechanics_tags.h b/implementation/promotion_mechanics_tags.h index 1af18755..de165e2b 100644 --- a/implementation/promotion_mechanics_tags.h +++ b/implementation/promotion_mechanics_tags.h @@ -23,7 +23,7 @@ struct AdoptLocal {}; // Creates an additional reference to the underlying object. // When used for local, presumes local, for global, presumes global. -struct CreateCopy {}; +struct NewRef {}; // This tag allows the constructor to promote underlying jobject for you. struct PromoteToGlobal {}; diff --git a/implementation/string_ref_test.cc b/implementation/string_ref_test.cc index 7ccf08c9..97c49247 100644 --- a/implementation/string_ref_test.cc +++ b/implementation/string_ref_test.cc @@ -21,12 +21,12 @@ namespace { using ::jni::AdoptGlobal; -using ::jni::CreateCopy; using ::jni::GlobalObject; using ::jni::GlobalString; using ::jni::kJavaLangString; using ::jni::LocalObject; using ::jni::LocalString; +using ::jni::NewRef; using ::jni::UtfStringView; using ::jni::test::AsNewLocalReference; using ::jni::test::Fake; @@ -68,7 +68,7 @@ TEST_F(JniTest, LocalString_CopiesFromObject) { EXPECT_CALL(*env_, DeleteLocalRef(AsNewLocalReference(Fake()))); EXPECT_CALL(*env_, NewLocalRef(Fake())); - LocalString decorated_object{CreateCopy{}, Fake()}; + LocalString decorated_object{NewRef{}, Fake()}; EXPECT_EQ(jstring{decorated_object}, AsNewLocalReference(Fake())); } @@ -78,7 +78,7 @@ TEST_F(JniTest, LocalString_CopiesFromJString) { EXPECT_CALL(*env_, NewLocalRef(Fake(1))) .WillOnce(::testing::Return(Fake(2))); - LocalString decorated_object{CreateCopy{}, Fake(1)}; + LocalString decorated_object{NewRef{}, Fake(1)}; EXPECT_EQ(jstring{decorated_object}, Fake(2)); } diff --git a/javatests/com/jnibind/test/context_test_jni.cc b/javatests/com/jnibind/test/context_test_jni.cc index 43ca13a4..0786406c 100644 --- a/javatests/com/jnibind/test/context_test_jni.cc +++ b/javatests/com/jnibind/test/context_test_jni.cc @@ -21,8 +21,8 @@ namespace { -using ::jni::CreateCopy; using ::jni::GlobalObject; +using ::jni::NewRef; using ::jni::PromoteToGlobal; // A struct that could represent context to be maintained across multiple native @@ -72,7 +72,7 @@ Java_com_jnibind_test_ContextTest_nativeCreateContextWithCopy(JNIEnv* env, jclass, jobject val) { return reinterpret_cast(new ContextStruct{ - .obj = GlobalObject{CreateCopy{}, val}}); + .obj = GlobalObject{NewRef{}, val}}); } JNIEXPORT jobject JNICALL diff --git a/javatests/com/jnibind/test/string_test_jni.cc b/javatests/com/jnibind/test/string_test_jni.cc index c6448151..1556b527 100644 --- a/javatests/com/jnibind/test/string_test_jni.cc +++ b/javatests/com/jnibind/test/string_test_jni.cc @@ -20,11 +20,11 @@ #include "jni_bind.h" using ::jni::Class; -using ::jni::CreateCopy; using ::jni::GlobalString; using ::jni::LocalObject; using ::jni::LocalString; using ::jni::Method; +using ::jni::NewRef; using ::jni::Params; using ::jni::PromoteToGlobal; using ::jni::Return; @@ -66,7 +66,7 @@ Java_com_jnibind_test_StringTest_jniPassesStringsInManyWays( JNIEnv* env, jclass, jobject test_fixture_object, jstring input) { LocalObject fixture{test_fixture_object}; - GlobalString global_string_lval{CreateCopy{}, input}; + GlobalString global_string_lval{NewRef{}, input}; LocalString string_lval{input}; const char* kSimpleTestString{"SimpleTestString"}; diff --git a/jni_bind_release.h b/jni_bind_release.h index 6b427968..eb425a6e 100644 --- a/jni_bind_release.h +++ b/jni_bind_release.h @@ -6951,7 +6951,7 @@ namespace jni { // Creates an additional reference to the underlying object. // When used for local, presumes local, for global, presumes global. -struct CreateCopy {}; +struct NewRef {}; // This tag allows the constructor to promote underlying jobject for you. struct PromoteToGlobal {}; @@ -6977,7 +6977,7 @@ struct EntryBase : public Base { EntryBase(T&& rhs) : Base(rhs.Release()) {} // "Copy" constructor: Additional reference to object will be created. - EntryBase(CreateCopy, ViableSpan object) + EntryBase(NewRef, ViableSpan object) : Base(static_cast( LifecycleHelper::NewReference( static_cast(object)))) {} @@ -7033,7 +7033,7 @@ struct EntryBase : public Base { LifecycleType::GLOBAL>::Promote(rhs.Release())) {} // "Copy" constructor: Additional reference to object will be created. - EntryBase(CreateCopy, ViableSpan object) + EntryBase(NewRef, ViableSpan object) : Base(static_cast( LifecycleHelper::NewReference( static_cast(object)))) {}