Skip to content

Commit

Permalink
Making java_frame movable
Browse files Browse the repository at this point in the history
  • Loading branch information
gershnik committed May 7, 2024
1 parent ce81ce2 commit 9fbaec3
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions inc/smjni/java_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,21 @@ namespace smjni
if (m_pushed)
m_env->PopLocalFrame(nullptr);
}

java_frame(java_frame && src):
m_env(std::exchange(src.m_env, nullptr)),
m_pushed(std::exchange(src.m_pushed, false))
{
}

java_frame & operator=(java_frame && src)
{
if (this != &src) {
this->~java_frame();
new (this) java_frame(std::move(src));
}
return *this;
}

template<typename T>
T pop(T obj)
Expand All @@ -57,8 +72,6 @@ namespace smjni

java_frame(const java_frame &) = delete;
java_frame & operator=(const java_frame &) = delete;
java_frame(java_frame &&) = delete;
java_frame & operator=(java_frame &&) = delete;
private:
JNIEnv * m_env;
bool m_pushed;
Expand Down

0 comments on commit 9fbaec3

Please sign in to comment.