Skip to content

Commit

Permalink
khnykin/final_classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Hsilgos committed May 14, 2024
1 parent e943d28 commit 3e52f89
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
!}}
namespace
{
struct Dummy{{resolveName external.java.converter "mangled"}}Type {};
struct Dummy{{resolveName external.java.converter "mangled"}}Type final {};
}

REGISTER_JNI_CLASS_CACHE("{{resolveName external.java.converter ""}}", {{!!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ call_java_method_impl( JNIEnv* jni_env,
}

template< bool IsResultTypeDerivedFromJObject, class ResultType >
struct ProcessJavaMethodCall
struct ProcessJavaMethodCall final
{
};

template<class ResultType>
struct ProcessJavaMethodCall<false, ResultType>
struct ProcessJavaMethodCall<false, ResultType> final
{
template <class ... Args>
static ResultType call( JNIEnv* jni_env,
Expand All @@ -69,7 +69,7 @@ struct ProcessJavaMethodCall<false, ResultType>
};

template<class ResultType >
struct ProcessJavaMethodCall<true, ResultType>
struct ProcessJavaMethodCall<true, ResultType> final
{
template <class ... Args>
static JniReference<ResultType> call( JNIEnv* jni_env,
Expand All @@ -83,7 +83,7 @@ struct ProcessJavaMethodCall<true, ResultType>
};

template<>
struct ProcessJavaMethodCall<false, void>
struct ProcessJavaMethodCall<false, void> final
{
template <class ... Args>
static void call( JNIEnv* jni_env,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private:
};

template <class ... CppTypes>
class CachedJavaClass : public CachedJavaClassBase
class CachedJavaClass final : public CachedJavaClassBase
{
public:
using CachedJavaClassBase::CachedJavaClassBase;
Expand All @@ -74,7 +74,7 @@ private:
};

template <class ... CppTypes>
class CachedJavaInterface : public CachedJavaClassBase
class CachedJavaInterface final : public CachedJavaClassBase
{
public:
using CachedJavaClassBase::CachedJavaClassBase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ namespace {{.}}
{{/internalNamespace}}
namespace jni
{
class JNIEXPORT JniExceptionThrower final
{
public:
explicit JniExceptionThrower(JNIEnv* jni_env) noexcept;
class JNIEXPORT JniExceptionThrower final
{
public:
explicit JniExceptionThrower(JNIEnv* jni_env) noexcept;
~JniExceptionThrower() noexcept;
~JniExceptionThrower() noexcept;
void register_exception(JniReference<jobject> exception) noexcept;
private:
JNIEnv* const m_jni_env;
JniReference<jobject> m_exception;
};
void register_exception(JniReference<jobject> exception) noexcept;
private:
JNIEnv* const m_jni_env;
JniReference<jobject> m_exception;
};
}
{{#internalNamespace}}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace jni
{
template <class Type>
struct IsDerivedFromJObject :
struct IsDerivedFromJObject final:
std::conditional<
std::is_base_of< typename std::remove_pointer<jobject>::type,
typename std::remove_pointer<Type>::type >::value,
Expand All @@ -45,13 +45,13 @@ struct IsDerivedFromJObject :
};

template<class... T>
struct JniMethodArgumentTypeChecker
struct JniMethodArgumentTypeChecker final
{
static constexpr bool are_all_jni_types = true;
};

template<class T, class ... Args>
struct JniMethodArgumentTypeChecker< T, Args... >
struct JniMethodArgumentTypeChecker< T, Args... > final
{
static constexpr bool are_all_jni_types =
( std::is_same< T, jboolean >::value ||
Expand All @@ -68,49 +68,49 @@ struct JniMethodArgumentTypeChecker< T, Args... >
};

template< typename ResultType, bool IsDerivedFromJObject >
struct JniMethodForType
struct JniMethodForType final
{
// If result type is wrong you should have compilation error here
};

template<>
struct JniMethodForType<void, false>
struct JniMethodForType<void, false> final
{
static constexpr auto method_ptr = &JNIEnv::CallVoidMethod;
};

template<>
struct JniMethodForType<jboolean, false>
struct JniMethodForType<jboolean, false> final
{
static constexpr auto method_ptr = &JNIEnv::CallBooleanMethod;
};

template<>
struct JniMethodForType<jbyte, false>
struct JniMethodForType<jbyte, false> final
{
static constexpr auto method_ptr = &JNIEnv::CallByteMethod;
};

template<>
struct JniMethodForType<jchar, false>
struct JniMethodForType<jchar, false> final
{
static constexpr auto method_ptr = &JNIEnv::CallCharMethod;
};

template<>
struct JniMethodForType<jshort, false>
struct JniMethodForType<jshort, false> final
{
static constexpr auto method_ptr = &JNIEnv::CallShortMethod;
};

template<>
struct JniMethodForType<jint, false>
struct JniMethodForType<jint, false> final
{
static constexpr auto method_ptr = &JNIEnv::CallIntMethod;
};

template<>
struct JniMethodForType<jlong, false>
struct JniMethodForType<jlong, false> final
{
static constexpr auto method_ptr = &JNIEnv::CallLongMethod;
};
Expand All @@ -119,43 +119,43 @@ struct JniMethodForType<jlong, false>
// This specialisation doesn't make sense on such systems (jlong doesn't derive from jobject),
// otherwise prevents from compilation error.
template<>
struct JniMethodForType<std::int64_t, std::is_same<std::int64_t, jlong>::value>
struct JniMethodForType<std::int64_t, std::is_same<std::int64_t, jlong>::value> final
{
static constexpr auto method_ptr = JniMethodForType<jlong, false>::method_ptr;
};

template<>
struct JniMethodForType<jfloat, false>
struct JniMethodForType<jfloat, false> final
{
static constexpr auto method_ptr = &JNIEnv::CallFloatMethod;
};

template<>
struct JniMethodForType<jdouble, false>
struct JniMethodForType<jdouble, false> final
{
static constexpr auto method_ptr = &JNIEnv::CallDoubleMethod;
};

template<>
struct JniMethodForType<jobject, true>
struct JniMethodForType<jobject, true> final
{
static constexpr auto method_ptr = &JNIEnv::CallObjectMethod;
};

template<typename ResultType>
struct JniMethodForType<ResultType, true>
struct JniMethodForType<ResultType, true> final
{
static constexpr auto method_ptr = JniMethodForType<jobject, true>::method_ptr;
};

template<class T>
struct JniMethodReturnTypeChecker
struct JniMethodReturnTypeChecker final
{
static constexpr bool is_jni_type = JniMethodArgumentTypeChecker<T>::are_all_jni_types;
};

template<>
struct JniMethodReturnTypeChecker<void>
struct JniMethodReturnTypeChecker<void> final
{
static constexpr bool is_jni_type = true;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace {{.}}
namespace jni
{
class JNIEXPORT JniWrapperCache
class JNIEXPORT JniWrapperCache final
{
public:
template<class T>
Expand Down

0 comments on commit 3e52f89

Please sign in to comment.