From 45b2bb6f66e07a551ca544755f3ed69622ceea3b Mon Sep 17 00:00:00 2001 From: Yauheni Khnykin <4347948+Hsilgos@users.noreply.github.com> Date: Mon, 22 Apr 2024 15:46:53 +0200 Subject: [PATCH] Move implementation of CppProxyBase to cpp (#1579) Signed-off-by: Yauheni Khnykin --- .../templates/jni/CppProxyHeader.mustache | 4 +- .../jni/CppProxyImplementation.mustache | 4 +- .../jni/utils/CppProxyBaseHeader.mustache | 114 +++------- .../utils/CppProxyBaseImplementation.mustache | 182 ++++++++++------ .../src/main/resources/version.properties | 2 +- ...mple_smoke_DurationInterfaceImplCppProxy.h | 12 +- ...mple_smoke_ErrorsInterfaceImplCppProxy.cpp | 42 +++- ...xample_smoke_ErrorsInterfaceImplCppProxy.h | 14 +- ..._example_package_InterfaceImplCppProxy.cpp | 9 +- ...ample_smoke_ChildInterfaceImplCppProxy.cpp | 40 +++- ...example_smoke_ChildInterfaceImplCppProxy.h | 17 +- ...e_smoke_Lambdas_ConfounderImplCppProxy.cpp | 18 +- ...mple_smoke_Lambdas_IndexerImplCppProxy.cpp | 18 +- ...ple_smoke_Lambdas_ProducerImplCppProxy.cpp | 18 +- ...ample_smoke_Lambdas_ProducerImplCppProxy.h | 12 +- .../output/android/jni/CppProxyBase.cpp | 197 +++++++++++++----- ...e_smoke_CalculatorListenerImplCppProxy.cpp | 47 ++++- ...ple_smoke_CalculatorListenerImplCppProxy.h | 17 +- ..._smoke_InterfaceWithStaticImplCppProxy.cpp | 35 +++- ...le_smoke_InterfaceWithStaticImplCppProxy.h | 16 +- ...smoke_ListenerWithNullableImplCppProxy.cpp | 88 +++++++- ...oke_ListenerWithPropertiesImplCppProxy.cpp | 130 +++++++++++- ..._ListenersWithReturnValuesImplCppProxy.cpp | 60 +++++- ...ke_OuterClass_InnerInterfaceImplCppProxy.h | 12 +- ...OuterStruct_InnerInterfaceImplCppProxy.cpp | 18 +- ...ke_OuterStruct_InnerLambdaImplCppProxy.cpp | 17 +- ...moke_OuterStruct_InnerLambdaImplCppProxy.h | 12 +- ..._example_smoke_barListenerImplCppProxy.cpp | 17 +- ...ple_smoke_EnableTagsInJavaImplCppProxy.cpp | 27 ++- ...om_example_smoke_SkipProxyImplCppProxy.cpp | 95 ++++++++- ...m_example_smoke_SkipSetterImplCppProxy.cpp | 26 ++- ...com_example_smoke_SkipSetterImplCppProxy.h | 15 +- ...ample_smoke_SkipTagsInJavaImplCppProxy.cpp | 25 ++- 33 files changed, 1086 insertions(+), 274 deletions(-) diff --git a/gluecodium/src/main/resources/templates/jni/CppProxyHeader.mustache b/gluecodium/src/main/resources/templates/jni/CppProxyHeader.mustache index c0622d45c3..ed75124c94 100644 --- a/gluecodium/src/main/resources/templates/jni/CppProxyHeader.mustache +++ b/gluecodium/src/main/resources/templates/jni/CppProxyHeader.mustache @@ -35,10 +35,10 @@ namespace {{.}} namespace jni { -class {{resolveName "mangled"}}_CppProxy : public CppProxyBase{{!! +class {{resolveName "mangled"}}_CppProxy final : public CppProxyBase{{!! }}{{#instanceOf this "LimeInterface"}}, public {{resolveName "C++ FQN"}}{{/instanceOf}} { public: - {{resolveName "mangled"}}_CppProxy( JNIEnv* _jenv, JniReference globalRef, jint _jHashCode ); + {{resolveName "mangled"}}_CppProxy( JniReference globalRef, jint _jHashCode ) noexcept; {{resolveName "mangled"}}_CppProxy( const {{resolveName "mangled"}}_CppProxy& ) = delete; {{resolveName "mangled"}}_CppProxy& operator=( const {{resolveName "mangled"}}_CppProxy& ) = delete; diff --git a/gluecodium/src/main/resources/templates/jni/CppProxyImplementation.mustache b/gluecodium/src/main/resources/templates/jni/CppProxyImplementation.mustache index c61189f4ed..3a79b61087 100644 --- a/gluecodium/src/main/resources/templates/jni/CppProxyImplementation.mustache +++ b/gluecodium/src/main/resources/templates/jni/CppProxyImplementation.mustache @@ -34,8 +34,8 @@ namespace jni { {{#container}} -{{resolveName "mangled"}}_CppProxy::{{resolveName "mangled"}}_CppProxy( JNIEnv* _jenv, JniReference globalRef, jint _jHashCode ) - : CppProxyBase( _jenv, std::move( globalRef ), _jHashCode, "{{resolveName "mangled"}}" ) { +{{resolveName "mangled"}}_CppProxy::{{resolveName "mangled"}}_CppProxy(JniReference globalRef, jint _jHashCode) noexcept + : CppProxyBase(std::move(globalRef), _jHashCode, "{{resolveName "mangled"}}") { } {{#inheritedFunctions}}{{#unless isStatic}} {{>proxyMethodImpl}} diff --git a/gluecodium/src/main/resources/templates/jni/utils/CppProxyBaseHeader.mustache b/gluecodium/src/main/resources/templates/jni/utils/CppProxyBaseHeader.mustache index e7a552447c..1f8f0f4141 100644 --- a/gluecodium/src/main/resources/templates/jni/utils/CppProxyBaseHeader.mustache +++ b/gluecodium/src/main/resources/templates/jni/utils/CppProxyBaseHeader.mustache @@ -30,10 +30,8 @@ #include "JniCallbackErrorChecking.h" #include -#include #include #include -#include {{#internalNamespace}} namespace {{.}} @@ -45,6 +43,28 @@ namespace jni class JNIEXPORT CppProxyBase { private: + using ReverseCacheKey = const void*; + using ProxyFactoryResult = std::pair, ReverseCacheKey>; + using ProxyFactoryFun = ProxyFactoryResult(*)(JniReference, jint); + + template + struct ProxyFactory { + static ProxyFactoryResult + create(JniReference globalRef, jint jHashCode) + { + ImplType* const newProxyInstance = new (::std::nothrow ) ImplType{std::move(globalRef), jHashCode}; + const ResultType* const castedToResult = newProxyInstance; + return std::make_pair(std::shared_ptr{newProxyInstance}, castedToResult); + } + }; + + static std::shared_ptr + createProxyImpl( JNIEnv* jenv, + const JniReference& jobj, + const ::std::string& type_key, + bool do_cache, + ProxyFactoryFun factory); + template < typename ResultType, typename ImplType > static void createProxy( JNIEnv* jenv, @@ -53,38 +73,9 @@ private: bool do_cache, ::std::shared_ptr< ResultType >& result ) { - JniReference globalRef = new_global_ref( jenv, jobj.get() ); - jint jHashCode = getHashCode( jenv, jobj.get() ); - ProxyCacheKey key{globalRef.get(), jHashCode, type_key}; - - ::std::lock_guard< GlobalJniLock > lock( sGlobalJniLock ); - sGlobalJniLock.setJniEnvForCurrentThread( jenv ); - - if (do_cache) { - auto iterator = sProxyCache.find( key ); - if ( iterator != sProxyCache.end( ) ) - { - auto cachedProxy = iterator->second.lock( ); - if ( cachedProxy ) - { - result = ::std::static_pointer_cast< ImplType >( cachedProxy ); - return; - } - } - } - - auto newProxyInstance = new (::std::nothrow ) ImplType( jenv, std::move(globalRef), jHashCode ); - if ( newProxyInstance == nullptr ) + if (auto proxy = createProxyImpl( jenv, jobj, type_key, do_cache, &ProxyFactory::create )) { - throw_runtime_exception( jenv, "Cannot allocate native memory." ); - return; - } - auto newProxy = ::std::shared_ptr< ImplType >( newProxyInstance ); - result = newProxy; - - if (do_cache) { - sProxyCache[ key ] = ::std::weak_ptr< ImplType >( newProxy ); - registerInReverseCache(newProxyInstance, result.get(), key.jObject); + result = ::std::static_pointer_cast< ImplType >( proxy );; } } @@ -115,7 +106,7 @@ public: } protected: - CppProxyBase( JNIEnv* jenv, JniReference globalRef, jint jHashCode, ::std::string type_key ); + CppProxyBase(JniReference globalRef, jint jHashCode, ::std::string type_key) noexcept; virtual ~CppProxyBase( ); @@ -129,69 +120,22 @@ protected: return call_java_method(jniEnv, mGlobalRef, methodName, jniSignature, args...); } - static JNIEnv* getJniEnvironment( ); - -private: - - struct ProxyCacheKey - { - jobject jObject; - jint jHashCode; - ::std::string type_key; - - bool operator==( const ProxyCacheKey& other ) const; - }; - - struct ProxyCacheKeyHash - { - inline size_t - operator( )( const ProxyCacheKey& key ) const - { - size_t result = 7; - result = 31 * result + key.jHashCode; - result = 31 * result + ::std::hash<::std::string>{}(key.type_key); - return result; - } - }; - - using ReverseCacheKey = const void*; - - class GlobalJniLock { - public: - void lock( ); - void unlock( ); - - void setJniEnvForCurrentThread( JNIEnv* env ); - JNIEnv* getJniEnvForCurrentThread( ); - - private: - ::std::mutex cacheMutex; - JNIEnv* jniEnvForCurrentThread = nullptr; - }; - - using ProxyCache - = ::std::unordered_map< ProxyCacheKey, ::std::weak_ptr< CppProxyBase >, ProxyCacheKeyHash >; - using ReverseProxyCache = ::std::unordered_map; + static JNIEnv* getJniEnvironment( ) noexcept; private: static jint getHashCode( JNIEnv* jniEnv, jobject jObj ); static void registerInReverseCache( CppProxyBase* proxyBase, ReverseCacheKey reverseCacheKey, - const jobject& jObj ); + jobject jObj ); void removeSelfFromReverseCache( ); static JniReference getJavaObjectFromReverseCache(JNIEnv* jniEnv, ReverseCacheKey reverseCacheKey); private: - JniReference mGlobalRef; - jint jHashCode; + const JniReference mGlobalRef; + const jint jHashCode; ReverseCacheKey mReverseCacheKey = nullptr; const ::std::string type_key; - -protected: - static ProxyCache sProxyCache; - static ReverseProxyCache sReverseProxyCache; - static GlobalJniLock sGlobalJniLock; }; } diff --git a/gluecodium/src/main/resources/templates/jni/utils/CppProxyBaseImplementation.mustache b/gluecodium/src/main/resources/templates/jni/utils/CppProxyBaseImplementation.mustache index ec9f15f2e8..4c9363407f 100644 --- a/gluecodium/src/main/resources/templates/jni/utils/CppProxyBaseImplementation.mustache +++ b/gluecodium/src/main/resources/templates/jni/utils/CppProxyBaseImplementation.mustache @@ -22,6 +22,9 @@ #include "CppProxyBase.h" #include "JniBase.h" + +#include +#include #include {{#internalNamespace}} @@ -30,86 +33,151 @@ namespace {{.}} {{/internalNamespace}} namespace jni { -CppProxyBase::ProxyCache CppProxyBase::sProxyCache{}; -CppProxyBase::ReverseProxyCache CppProxyBase::sReverseProxyCache{}; -CppProxyBase::GlobalJniLock CppProxyBase::sGlobalJniLock{}; -JNIEnv* -CppProxyBase::getJniEnvironment( ) +namespace { - return {{>common/InternalNamespace}}jni::getJniEnvironmentForCurrentThread( ); -} +class GlobalJniLock final { +public: + void + lock( ) + { + cacheMutex.lock( ); + } -CppProxyBase::CppProxyBase( JNIEnv* jenv, - {{>common/InternalNamespace}}jni::JniReference globalRef, - jint jHashCode, - ::std::string type_key ) - : mGlobalRef( std::move( globalRef ) ), jHashCode( jHashCode ), type_key( std::move( type_key ) ) -{ -} + void + unlock( ) + { + jniEnvForCurrentThread = nullptr; + cacheMutex.unlock( ); + } -CppProxyBase::~CppProxyBase( ) + void + setJniEnvForCurrentThread( JNIEnv* env ) noexcept + { + jniEnvForCurrentThread = env; + } + + JNIEnv* + getJniEnvForCurrentThread( ) noexcept + { + if ( jniEnvForCurrentThread == nullptr ) + { + jniEnvForCurrentThread = {{>common/InternalNamespace}}jni::getJniEnvironmentForCurrentThread( ); + } + return jniEnvForCurrentThread; + } + +private: + ::std::mutex cacheMutex; + JNIEnv* jniEnvForCurrentThread = nullptr; +}; + +static GlobalJniLock sGlobalJniLock; + +struct ProxyCacheKey final { - JNIEnv* jniEnv = getJniEnvironment( ); + jobject jObject; + jint jHashCode; + ::std::string type_key; + bool operator==( const ProxyCacheKey& other ) const noexcept { - ::std::lock_guard< GlobalJniLock > lock( sGlobalJniLock ); - sGlobalJniLock.setJniEnvForCurrentThread( jniEnv ); - sProxyCache.erase( ProxyCacheKey{mGlobalRef.get(), jHashCode, type_key} ); - removeSelfFromReverseCache( ); + return jHashCode == other.jHashCode && + sGlobalJniLock.getJniEnvForCurrentThread( )->IsSameObject( jObject, other.jObject ); } -} +}; -bool -CppProxyBase::ProxyCacheKey::operator==( const CppProxyBase::ProxyCacheKey& other ) const +struct ProxyCacheKeyHash final { - return jHashCode == other.jHashCode && - sGlobalJniLock.getJniEnvForCurrentThread( )->IsSameObject( jObject, other.jObject ); -} + inline size_t + operator( )( const ProxyCacheKey& key ) const noexcept + { + size_t result = 7; + result = 31 * result + key.jHashCode; + result = 31 * result + ::std::hash<::std::string>{}(key.type_key); + return result; + } +}; + +using ReverseCacheKey = const void*; +using ProxyCache = ::std::unordered_map< ProxyCacheKey, ::std::weak_ptr< CppProxyBase >, ProxyCacheKeyHash >; +using ReverseProxyCache = ::std::unordered_map; + +static ProxyCache sProxyCache; +static ReverseProxyCache sReverseProxyCache; +} // namespace -void -CppProxyBase::GlobalJniLock::lock( ) +JNIEnv* +CppProxyBase::getJniEnvironment( ) noexcept { - cacheMutex.lock( ); + return {{>common/InternalNamespace}}jni::getJniEnvironmentForCurrentThread( ); } -void -CppProxyBase::GlobalJniLock::unlock( ) +CppProxyBase::CppProxyBase( {{>common/InternalNamespace}}jni::JniReference globalRef, + jint jHashCode, + ::std::string type_key ) noexcept + : mGlobalRef( std::move( globalRef ) ), jHashCode( jHashCode ), type_key( std::move( type_key ) ) { - jniEnvForCurrentThread = nullptr; - cacheMutex.unlock( ); } -void -CppProxyBase::GlobalJniLock::setJniEnvForCurrentThread( JNIEnv* env ) +CppProxyBase::~CppProxyBase( ) { - jniEnvForCurrentThread = env; + JNIEnv* jniEnv = getJniEnvironment( ); + + const ::std::lock_guard< GlobalJniLock > lock( sGlobalJniLock ); + sGlobalJniLock.setJniEnvForCurrentThread( jniEnv ); + sProxyCache.erase( ProxyCacheKey{mGlobalRef.get(), jHashCode, type_key} ); + removeSelfFromReverseCache( ); } -JNIEnv* -CppProxyBase::GlobalJniLock::getJniEnvForCurrentThread( ) +std::shared_ptr +CppProxyBase::createProxyImpl( JNIEnv* const jenv, + const JniReference& jobj, + const ::std::string& type_key, + const bool do_cache, + const ProxyFactoryFun factory) { - if ( jniEnvForCurrentThread == nullptr ) - { - jniEnvForCurrentThread = CppProxyBase::getJniEnvironment( ); + JniReference globalRef = new_global_ref(jenv, jobj.get()); + const jint jHashCode = getHashCode(jenv, jobj.get()); + const ProxyCacheKey key{globalRef.get(), jHashCode, type_key}; + + const ::std::lock_guard< GlobalJniLock > lock( sGlobalJniLock ); + sGlobalJniLock.setJniEnvForCurrentThread( jenv ); + + if (do_cache) { + if (const auto it = sProxyCache.find(key); it != sProxyCache.end()) + { + if (auto cachedProxy = it->second.lock()) + { + return cachedProxy; + } + } + } + + auto [newProxy, reverseCacheKey] = factory(std::move(globalRef), jHashCode); + + if (newProxy == nullptr) { + throw_runtime_exception(jenv, "Cannot allocate native memory."); + } else if (do_cache) { + sProxyCache[key] = ::std::weak_ptr(newProxy); + registerInReverseCache(newProxy.get(), reverseCacheKey, key.jObject); } - return jniEnvForCurrentThread; + return newProxy; } jint -CppProxyBase::getHashCode( JNIEnv* jniEnv, jobject jObj ) +CppProxyBase::getHashCode(JNIEnv* const jniEnv, const jobject jObj) { - auto jClass = find_class(jniEnv, "java/lang/System" ); - jmethodID jMethodId - = jniEnv->GetStaticMethodID( jClass.get(), "identityHashCode", "(Ljava/lang/Object;)I" ); + const auto systemClass = find_class(jniEnv, "java/lang/System"); + const jmethodID jMethodId + = jniEnv->GetStaticMethodID(systemClass.get(), "identityHashCode", "(Ljava/lang/Object;)I"); - jint jResult = jniEnv->CallStaticIntMethod( jClass.get(), jMethodId, jObj ); - return jResult; + return jniEnv->CallStaticIntMethod(systemClass.get(), jMethodId, jObj); } -void CppProxyBase::registerInReverseCache( CppProxyBase* proxyBase, +void CppProxyBase::registerInReverseCache( CppProxyBase* const proxyBase, ReverseCacheKey reverseCacheKey, - const jobject& jObj ) + const jobject jObj ) { proxyBase->mReverseCacheKey = reverseCacheKey; sReverseProxyCache[reverseCacheKey] = jObj; @@ -126,17 +194,15 @@ void CppProxyBase::removeSelfFromReverseCache( ) JniReference CppProxyBase::getJavaObjectFromReverseCache(JNIEnv* jniEnv, ReverseCacheKey reverseCacheKey) { - ::std::lock_guard< GlobalJniLock > lock( sGlobalJniLock ); - - const auto iterator = sReverseProxyCache.find( reverseCacheKey ); - if (iterator == sReverseProxyCache.end( )) + const ::std::lock_guard< GlobalJniLock > lock( sGlobalJniLock ); + if (const auto it = sReverseProxyCache.find(reverseCacheKey); it != sReverseProxyCache.end()) { - return nullptr; + return make_local_ref(jniEnv, jniEnv->NewLocalRef(it->second)); } - return make_local_ref(jniEnv, jniEnv->NewLocalRef(iterator->second)); + return nullptr; } -} +} // namespace jni {{#internalNamespace}} -} +} // namespace {{.}} {{/internalNamespace}} diff --git a/gluecodium/src/main/resources/version.properties b/gluecodium/src/main/resources/version.properties index 5379c98669..c23092f741 100644 --- a/gluecodium/src/main/resources/version.properties +++ b/gluecodium/src/main/resources/version.properties @@ -1 +1 @@ -version = 13.8.2 +version = 13.9.0 diff --git a/gluecodium/src/test/resources/smoke/durations/output/android/jni/com_example_smoke_DurationInterfaceImplCppProxy.h b/gluecodium/src/test/resources/smoke/durations/output/android/jni/com_example_smoke_DurationInterfaceImplCppProxy.h index 1311f3aaf4..e8da5d1525 100644 --- a/gluecodium/src/test/resources/smoke/durations/output/android/jni/com_example_smoke_DurationInterfaceImplCppProxy.h +++ b/gluecodium/src/test/resources/smoke/durations/output/android/jni/com_example_smoke_DurationInterfaceImplCppProxy.h @@ -1,20 +1,28 @@ /* + * */ + #pragma once + #include "smoke/DurationInterface.h" #include "CppProxyBase.h" #include "JniReference.h" + namespace gluecodium { namespace jni { -class com_example_smoke_DurationInterface_CppProxy : public CppProxyBase, public ::smoke::DurationInterface { + +class com_example_smoke_DurationInterface_CppProxy final : public CppProxyBase, public ::smoke::DurationInterface { public: - com_example_smoke_DurationInterface_CppProxy( JNIEnv* _jenv, JniReference globalRef, jint _jHashCode ); + com_example_smoke_DurationInterface_CppProxy( JniReference globalRef, jint _jHashCode ) noexcept; com_example_smoke_DurationInterface_CppProxy( const com_example_smoke_DurationInterface_CppProxy& ) = delete; com_example_smoke_DurationInterface_CppProxy& operator=( const com_example_smoke_DurationInterface_CppProxy& ) = delete; + + ::std::string duration_function( const ::std::chrono::seconds ninput ) override; }; + } } diff --git a/gluecodium/src/test/resources/smoke/errors/output/android/jni/com_example_smoke_ErrorsInterfaceImplCppProxy.cpp b/gluecodium/src/test/resources/smoke/errors/output/android/jni/com_example_smoke_ErrorsInterfaceImplCppProxy.cpp index 5cd15fed42..7d122e6950 100644 --- a/gluecodium/src/test/resources/smoke/errors/output/android/jni/com_example_smoke_ErrorsInterfaceImplCppProxy.cpp +++ b/gluecodium/src/test/resources/smoke/errors/output/android/jni/com_example_smoke_ErrorsInterfaceImplCppProxy.cpp @@ -1,6 +1,8 @@ /* + * */ + #include "com_example_smoke_ErrorsInterfaceImplCppProxy.h" #include "com_example_smoke_ErrorsInterface_ExternalErrors__Conversion.h" #include "com_example_smoke_ErrorsInterface_InternalError__Conversion.h" @@ -8,17 +10,22 @@ #include "com_example_smoke_Payload__Conversion.h" #include "ArrayConversionUtils.h" #include "FieldAccessMethods.h" + namespace gluecodium { namespace jni { -com_example_smoke_ErrorsInterface_CppProxy::com_example_smoke_ErrorsInterface_CppProxy( JNIEnv* _jenv, JniReference globalRef, jint _jHashCode ) - : CppProxyBase( _jenv, std::move( globalRef ), _jHashCode, "com_example_smoke_ErrorsInterface" ) { + +com_example_smoke_ErrorsInterface_CppProxy::com_example_smoke_ErrorsInterface_CppProxy(JniReference globalRef, jint _jHashCode) noexcept + : CppProxyBase(std::move(globalRef), _jHashCode, "com_example_smoke_ErrorsInterface") { } + ::std::error_code com_example_smoke_ErrorsInterface_CppProxy::method_with_errors( ) { + JNIEnv* jniEnv = getJniEnvironment( ); callJavaMethod( "methodWithErrors", "()V", jniEnv ); + auto jException = make_local_ref(jniEnv, jniEnv->ExceptionOccurred( )); if ( jException ) { @@ -32,17 +39,28 @@ com_example_smoke_ErrorsInterface_CppProxy::method_with_errors( ) { jniEnv, jErrorValue, (::smoke::ErrorsInterface::InternalError*)nullptr ); + + return ::std::error_code{nErrorValue}; + } else { + + return ::std::error_code{}; + } + + } + ::std::error_code com_example_smoke_ErrorsInterface_CppProxy::method_with_external_errors( ) { + JNIEnv* jniEnv = getJniEnvironment( ); callJavaMethod( "methodWithExternalErrors", "()V", jniEnv ); + auto jException = make_local_ref(jniEnv, jniEnv->ExceptionOccurred( )); if ( jException ) { @@ -56,17 +74,28 @@ com_example_smoke_ErrorsInterface_CppProxy::method_with_external_errors( ) { jniEnv, jErrorValue, (::smoke::ErrorsInterface::ExternalErrors*)nullptr ); + + return ::std::error_code{nErrorValue}; + } else { + + return ::std::error_code{}; + } + + } + ::gluecodium::Return< ::std::string, ::std::error_code > com_example_smoke_ErrorsInterface_CppProxy::method_with_errors_and_return_value( ) { + JNIEnv* jniEnv = getJniEnvironment( ); auto _result = callJavaMethod( "methodWithErrorsAndReturnValue", "()Ljava/lang/String;", jniEnv ); + auto jException = make_local_ref(jniEnv, jniEnv->ExceptionOccurred( )); if ( jException ) { @@ -80,12 +109,21 @@ com_example_smoke_ErrorsInterface_CppProxy::method_with_errors_and_return_value( jniEnv, jErrorValue, (::smoke::ErrorsInterface::InternalError*)nullptr ); + + return ::std::error_code{nErrorValue}; + } else { + return convert_from_jni( jniEnv, _result, (::std::string*)nullptr ); + + } + + } + } } diff --git a/gluecodium/src/test/resources/smoke/errors/output/android/jni/com_example_smoke_ErrorsInterfaceImplCppProxy.h b/gluecodium/src/test/resources/smoke/errors/output/android/jni/com_example_smoke_ErrorsInterfaceImplCppProxy.h index f4bcb4dbf4..ebce0eecac 100644 --- a/gluecodium/src/test/resources/smoke/errors/output/android/jni/com_example_smoke_ErrorsInterfaceImplCppProxy.h +++ b/gluecodium/src/test/resources/smoke/errors/output/android/jni/com_example_smoke_ErrorsInterfaceImplCppProxy.h @@ -1,22 +1,32 @@ /* + * */ + #pragma once + #include "smoke/ErrorsInterface.h" #include "CppProxyBase.h" #include "JniReference.h" + namespace gluecodium { namespace jni { -class com_example_smoke_ErrorsInterface_CppProxy : public CppProxyBase, public ::smoke::ErrorsInterface { + +class com_example_smoke_ErrorsInterface_CppProxy final : public CppProxyBase, public ::smoke::ErrorsInterface { public: - com_example_smoke_ErrorsInterface_CppProxy( JNIEnv* _jenv, JniReference globalRef, jint _jHashCode ); + com_example_smoke_ErrorsInterface_CppProxy( JniReference globalRef, jint _jHashCode ) noexcept; com_example_smoke_ErrorsInterface_CppProxy( const com_example_smoke_ErrorsInterface_CppProxy& ) = delete; com_example_smoke_ErrorsInterface_CppProxy& operator=( const com_example_smoke_ErrorsInterface_CppProxy& ) = delete; + + ::std::error_code method_with_errors( ) override; + ::std::error_code method_with_external_errors( ) override; + ::gluecodium::Return< ::std::string, ::std::error_code > method_with_errors_and_return_value( ) override; }; + } } diff --git a/gluecodium/src/test/resources/smoke/escaped_names/output/android/jni/com_example_package_InterfaceImplCppProxy.cpp b/gluecodium/src/test/resources/smoke/escaped_names/output/android/jni/com_example_package_InterfaceImplCppProxy.cpp index a47d3faf6f..f444dae956 100644 --- a/gluecodium/src/test/resources/smoke/escaped_names/output/android/jni/com_example_package_InterfaceImplCppProxy.cpp +++ b/gluecodium/src/test/resources/smoke/escaped_names/output/android/jni/com_example_package_InterfaceImplCppProxy.cpp @@ -1,16 +1,21 @@ /* + * */ + #include "com_example_package_InterfaceImplCppProxy.h" #include "com_example_package_Interface__Conversion.h" #include "ArrayConversionUtils.h" #include "FieldAccessMethods.h" + namespace gluecodium { namespace jni { -com_example_package_Interface_CppProxy::com_example_package_Interface_CppProxy( JNIEnv* _jenv, JniReference globalRef, jint _jHashCode ) - : CppProxyBase( _jenv, std::move( globalRef ), _jHashCode, "com_example_package_Interface" ) { + +com_example_package_Interface_CppProxy::com_example_package_Interface_CppProxy(JniReference globalRef, jint _jHashCode) noexcept + : CppProxyBase(std::move(globalRef), _jHashCode, "com_example_package_Interface") { } + } } diff --git a/gluecodium/src/test/resources/smoke/inheritance/output/android/jni/com_example_smoke_ChildInterfaceImplCppProxy.cpp b/gluecodium/src/test/resources/smoke/inheritance/output/android/jni/com_example_smoke_ChildInterfaceImplCppProxy.cpp index 1b3978f2dd..8659623278 100644 --- a/gluecodium/src/test/resources/smoke/inheritance/output/android/jni/com_example_smoke_ChildInterfaceImplCppProxy.cpp +++ b/gluecodium/src/test/resources/smoke/inheritance/output/android/jni/com_example_smoke_ChildInterfaceImplCppProxy.cpp @@ -1,42 +1,76 @@ /* + * */ + #include "com_example_smoke_ChildInterfaceImplCppProxy.h" #include "com_example_smoke_ChildInterface__Conversion.h" #include "ArrayConversionUtils.h" #include "FieldAccessMethods.h" + namespace gluecodium { namespace jni { -com_example_smoke_ChildInterface_CppProxy::com_example_smoke_ChildInterface_CppProxy( JNIEnv* _jenv, JniReference globalRef, jint _jHashCode ) - : CppProxyBase( _jenv, std::move( globalRef ), _jHashCode, "com_example_smoke_ChildInterface" ) { + +com_example_smoke_ChildInterface_CppProxy::com_example_smoke_ChildInterface_CppProxy(JniReference globalRef, jint _jHashCode) noexcept + : CppProxyBase(std::move(globalRef), _jHashCode, "com_example_smoke_ChildInterface") { } + void com_example_smoke_ChildInterface_CppProxy::root_method( ) { + JNIEnv* jniEnv = getJniEnvironment( ); callJavaMethod( "rootMethod", "()V", jniEnv ); + checkExceptionAndReportIfAny(jniEnv); + + + } + + ::std::string com_example_smoke_ChildInterface_CppProxy::get_root_property( ) const { + JNIEnv* jniEnv = getJniEnvironment( ); auto _result = callJavaMethod( "getRootProperty", "()Ljava/lang/String;", jniEnv ); + checkExceptionAndReportIfAny(jniEnv); + return convert_from_jni( jniEnv, _result, (::std::string*)nullptr ); + + + } + + + void com_example_smoke_ChildInterface_CppProxy::set_root_property( const ::std::string& nvalue ) { + JNIEnv* jniEnv = getJniEnvironment( ); auto jvalue = convert_to_jni( jniEnv, nvalue ); callJavaMethod( "setRootProperty", "(Ljava/lang/String;)V", jniEnv , jvalue); + checkExceptionAndReportIfAny(jniEnv); + + + } + + void com_example_smoke_ChildInterface_CppProxy::child_method( ) { + JNIEnv* jniEnv = getJniEnvironment( ); callJavaMethod( "childMethod", "()V", jniEnv ); + checkExceptionAndReportIfAny(jniEnv); + + + +} + } } -} \ No newline at end of file diff --git a/gluecodium/src/test/resources/smoke/inheritance/output/android/jni/com_example_smoke_ChildInterfaceImplCppProxy.h b/gluecodium/src/test/resources/smoke/inheritance/output/android/jni/com_example_smoke_ChildInterfaceImplCppProxy.h index 829edd66ba..efe27f8c30 100644 --- a/gluecodium/src/test/resources/smoke/inheritance/output/android/jni/com_example_smoke_ChildInterfaceImplCppProxy.h +++ b/gluecodium/src/test/resources/smoke/inheritance/output/android/jni/com_example_smoke_ChildInterfaceImplCppProxy.h @@ -1,23 +1,36 @@ /* + * */ + #pragma once + #include "smoke/ChildInterface.h" #include "CppProxyBase.h" #include "JniReference.h" + namespace gluecodium { namespace jni { -class com_example_smoke_ChildInterface_CppProxy : public CppProxyBase, public ::smoke::ChildInterface { + +class com_example_smoke_ChildInterface_CppProxy final : public CppProxyBase, public ::smoke::ChildInterface { public: - com_example_smoke_ChildInterface_CppProxy( JNIEnv* _jenv, JniReference globalRef, jint _jHashCode ); + com_example_smoke_ChildInterface_CppProxy( JniReference globalRef, jint _jHashCode ) noexcept; com_example_smoke_ChildInterface_CppProxy( const com_example_smoke_ChildInterface_CppProxy& ) = delete; com_example_smoke_ChildInterface_CppProxy& operator=( const com_example_smoke_ChildInterface_CppProxy& ) = delete; + + void root_method( ) override; + + ::std::string get_root_property( ) const override; + void set_root_property( const ::std::string& nvalue ) override; + + void child_method( ) override; }; + } } diff --git a/gluecodium/src/test/resources/smoke/lambdas/output/android/jni/com_example_smoke_Lambdas_ConfounderImplCppProxy.cpp b/gluecodium/src/test/resources/smoke/lambdas/output/android/jni/com_example_smoke_Lambdas_ConfounderImplCppProxy.cpp index 4085f61a43..2fba1820fe 100644 --- a/gluecodium/src/test/resources/smoke/lambdas/output/android/jni/com_example_smoke_Lambdas_ConfounderImplCppProxy.cpp +++ b/gluecodium/src/test/resources/smoke/lambdas/output/android/jni/com_example_smoke_Lambdas_ConfounderImplCppProxy.cpp @@ -1,25 +1,37 @@ /* + * */ + #include "com_example_smoke_Lambdas_ConfounderImplCppProxy.h" #include "com_example_smoke_Lambdas_Confounder__Conversion.h" #include "com_example_smoke_Lambdas_Producer__Conversion.h" #include "ArrayConversionUtils.h" #include "FieldAccessMethods.h" + namespace gluecodium { namespace jni { -com_example_smoke_Lambdas_00024Confounder_CppProxy::com_example_smoke_Lambdas_00024Confounder_CppProxy( JNIEnv* _jenv, JniReference globalRef, jint _jHashCode ) - : CppProxyBase( _jenv, std::move( globalRef ), _jHashCode, "com_example_smoke_Lambdas_00024Confounder" ) { + +com_example_smoke_Lambdas_00024Confounder_CppProxy::com_example_smoke_Lambdas_00024Confounder_CppProxy(JniReference globalRef, jint _jHashCode) noexcept + : CppProxyBase(std::move(globalRef), _jHashCode, "com_example_smoke_Lambdas_00024Confounder") { } + ::smoke::Lambdas::Producer com_example_smoke_Lambdas_00024Confounder_CppProxy::operator()( const ::std::string& np0 ) { + JNIEnv* jniEnv = getJniEnvironment( ); auto jp0 = convert_to_jni( jniEnv, np0 ); auto _result = callJavaMethod( "confuse", "(Ljava/lang/String;)Lcom/example/smoke/Lambdas$Producer;", jniEnv , jp0); + checkExceptionAndReportIfAny(jniEnv); + return com_example_smoke_Lambdas_00024Producer_convert_from_jni( jniEnv, _result, (::smoke::Lambdas::Producer*)nullptr ); + + + +} + } } -} \ No newline at end of file diff --git a/gluecodium/src/test/resources/smoke/lambdas/output/android/jni/com_example_smoke_Lambdas_IndexerImplCppProxy.cpp b/gluecodium/src/test/resources/smoke/lambdas/output/android/jni/com_example_smoke_Lambdas_IndexerImplCppProxy.cpp index 2c7a74b1e9..3f265bca6a 100644 --- a/gluecodium/src/test/resources/smoke/lambdas/output/android/jni/com_example_smoke_Lambdas_IndexerImplCppProxy.cpp +++ b/gluecodium/src/test/resources/smoke/lambdas/output/android/jni/com_example_smoke_Lambdas_IndexerImplCppProxy.cpp @@ -1,25 +1,37 @@ /* + * */ + #include "com_example_smoke_Lambdas_IndexerImplCppProxy.h" #include "com_example_smoke_Lambdas_Indexer__Conversion.h" #include "ArrayConversionUtils.h" #include "FieldAccessMethods.h" + namespace gluecodium { namespace jni { -com_example_smoke_Lambdas_00024Indexer_CppProxy::com_example_smoke_Lambdas_00024Indexer_CppProxy( JNIEnv* _jenv, JniReference globalRef, jint _jHashCode ) - : CppProxyBase( _jenv, std::move( globalRef ), _jHashCode, "com_example_smoke_Lambdas_00024Indexer" ) { + +com_example_smoke_Lambdas_00024Indexer_CppProxy::com_example_smoke_Lambdas_00024Indexer_CppProxy(JniReference globalRef, jint _jHashCode) noexcept + : CppProxyBase(std::move(globalRef), _jHashCode, "com_example_smoke_Lambdas_00024Indexer") { } + int32_t com_example_smoke_Lambdas_00024Indexer_CppProxy::operator()( const ::std::string& np0, const float nindex ) { + JNIEnv* jniEnv = getJniEnvironment( ); auto jp0 = convert_to_jni( jniEnv, np0 ); jfloat jindex = nindex; auto _result = callJavaMethod( "apply", "(Ljava/lang/String;F)I", jniEnv , jp0, jindex); + checkExceptionAndReportIfAny(jniEnv); + return _result; + + + +} + } } -} \ No newline at end of file diff --git a/gluecodium/src/test/resources/smoke/lambdas/output/android/jni/com_example_smoke_Lambdas_ProducerImplCppProxy.cpp b/gluecodium/src/test/resources/smoke/lambdas/output/android/jni/com_example_smoke_Lambdas_ProducerImplCppProxy.cpp index cff6deaa2a..d4ab4106ff 100644 --- a/gluecodium/src/test/resources/smoke/lambdas/output/android/jni/com_example_smoke_Lambdas_ProducerImplCppProxy.cpp +++ b/gluecodium/src/test/resources/smoke/lambdas/output/android/jni/com_example_smoke_Lambdas_ProducerImplCppProxy.cpp @@ -1,23 +1,35 @@ /* + * */ + #include "com_example_smoke_Lambdas_ProducerImplCppProxy.h" #include "com_example_smoke_Lambdas_Producer__Conversion.h" #include "ArrayConversionUtils.h" #include "FieldAccessMethods.h" + namespace gluecodium { namespace jni { -com_example_smoke_Lambdas_00024Producer_CppProxy::com_example_smoke_Lambdas_00024Producer_CppProxy( JNIEnv* _jenv, JniReference globalRef, jint _jHashCode ) - : CppProxyBase( _jenv, std::move( globalRef ), _jHashCode, "com_example_smoke_Lambdas_00024Producer" ) { + +com_example_smoke_Lambdas_00024Producer_CppProxy::com_example_smoke_Lambdas_00024Producer_CppProxy(JniReference globalRef, jint _jHashCode) noexcept + : CppProxyBase(std::move(globalRef), _jHashCode, "com_example_smoke_Lambdas_00024Producer") { } + ::std::string com_example_smoke_Lambdas_00024Producer_CppProxy::operator()( ) { + JNIEnv* jniEnv = getJniEnvironment( ); auto _result = callJavaMethod( "apply", "()Ljava/lang/String;", jniEnv ); + checkExceptionAndReportIfAny(jniEnv); + return convert_from_jni( jniEnv, _result, (::std::string*)nullptr ); + + + +} + } } -} \ No newline at end of file diff --git a/gluecodium/src/test/resources/smoke/lambdas/output/android/jni/com_example_smoke_Lambdas_ProducerImplCppProxy.h b/gluecodium/src/test/resources/smoke/lambdas/output/android/jni/com_example_smoke_Lambdas_ProducerImplCppProxy.h index 657d4c3987..6b3987d53f 100644 --- a/gluecodium/src/test/resources/smoke/lambdas/output/android/jni/com_example_smoke_Lambdas_ProducerImplCppProxy.h +++ b/gluecodium/src/test/resources/smoke/lambdas/output/android/jni/com_example_smoke_Lambdas_ProducerImplCppProxy.h @@ -1,21 +1,29 @@ /* + * */ + #pragma once + #include "smoke/Lambdas.h" #include #include "CppProxyBase.h" #include "JniReference.h" + namespace gluecodium { namespace jni { -class com_example_smoke_Lambdas_00024Producer_CppProxy : public CppProxyBase { + +class com_example_smoke_Lambdas_00024Producer_CppProxy final : public CppProxyBase { public: - com_example_smoke_Lambdas_00024Producer_CppProxy( JNIEnv* _jenv, JniReference globalRef, jint _jHashCode ); + com_example_smoke_Lambdas_00024Producer_CppProxy( JniReference globalRef, jint _jHashCode ) noexcept; com_example_smoke_Lambdas_00024Producer_CppProxy( const com_example_smoke_Lambdas_00024Producer_CppProxy& ) = delete; com_example_smoke_Lambdas_00024Producer_CppProxy& operator=( const com_example_smoke_Lambdas_00024Producer_CppProxy& ) = delete; + + ::std::string operator()( ); }; + } } diff --git a/gluecodium/src/test/resources/smoke/listeners/output/android/jni/CppProxyBase.cpp b/gluecodium/src/test/resources/smoke/listeners/output/android/jni/CppProxyBase.cpp index e3e561f699..a67abb0bf2 100644 --- a/gluecodium/src/test/resources/smoke/listeners/output/android/jni/CppProxyBase.cpp +++ b/gluecodium/src/test/resources/smoke/listeners/output/android/jni/CppProxyBase.cpp @@ -1,85 +1,169 @@ /* + * */ + #include "CppProxyBase.h" #include "JniBase.h" + +#include +#include #include + namespace gluecodium { namespace jni { -CppProxyBase::ProxyCache CppProxyBase::sProxyCache{}; -CppProxyBase::ReverseProxyCache CppProxyBase::sReverseProxyCache{}; -CppProxyBase::GlobalJniLock CppProxyBase::sGlobalJniLock{}; + +namespace +{ +class GlobalJniLock final { +public: + void + lock( ) + { + cacheMutex.lock( ); + } + + void + unlock( ) + { + jniEnvForCurrentThread = nullptr; + cacheMutex.unlock( ); + } + + void + setJniEnvForCurrentThread( JNIEnv* env ) noexcept + { + jniEnvForCurrentThread = env; + } + + JNIEnv* + getJniEnvForCurrentThread( ) noexcept + { + if ( jniEnvForCurrentThread == nullptr ) + { + jniEnvForCurrentThread = ::gluecodium::jni::getJniEnvironmentForCurrentThread( ); + } + return jniEnvForCurrentThread; + } + +private: + ::std::mutex cacheMutex; + JNIEnv* jniEnvForCurrentThread = nullptr; +}; + +static GlobalJniLock sGlobalJniLock; + +struct ProxyCacheKey final +{ + jobject jObject; + jint jHashCode; + ::std::string type_key; + + bool operator==( const ProxyCacheKey& other ) const noexcept + { + return jHashCode == other.jHashCode && + sGlobalJniLock.getJniEnvForCurrentThread( )->IsSameObject( jObject, other.jObject ); + } +}; + +struct ProxyCacheKeyHash final +{ + inline size_t + operator( )( const ProxyCacheKey& key ) const noexcept + { + size_t result = 7; + result = 31 * result + key.jHashCode; + result = 31 * result + ::std::hash<::std::string>{}(key.type_key); + return result; + } +}; + +using ReverseCacheKey = const void*; +using ProxyCache = ::std::unordered_map< ProxyCacheKey, ::std::weak_ptr< CppProxyBase >, ProxyCacheKeyHash >; +using ReverseProxyCache = ::std::unordered_map; + +static ProxyCache sProxyCache; +static ReverseProxyCache sReverseProxyCache; +} // namespace + JNIEnv* -CppProxyBase::getJniEnvironment( ) +CppProxyBase::getJniEnvironment( ) noexcept { return ::gluecodium::jni::getJniEnvironmentForCurrentThread( ); } -CppProxyBase::CppProxyBase( JNIEnv* jenv, - ::gluecodium::jni::JniReference globalRef, + +CppProxyBase::CppProxyBase( ::gluecodium::jni::JniReference globalRef, jint jHashCode, - ::std::string type_key ) + ::std::string type_key ) noexcept : mGlobalRef( std::move( globalRef ) ), jHashCode( jHashCode ), type_key( std::move( type_key ) ) { } + CppProxyBase::~CppProxyBase( ) { JNIEnv* jniEnv = getJniEnvironment( ); - { - ::std::lock_guard< GlobalJniLock > lock( sGlobalJniLock ); - sGlobalJniLock.setJniEnvForCurrentThread( jniEnv ); - sProxyCache.erase( ProxyCacheKey{mGlobalRef.get(), jHashCode, type_key} ); - removeSelfFromReverseCache( ); - } -} -bool -CppProxyBase::ProxyCacheKey::operator==( const CppProxyBase::ProxyCacheKey& other ) const -{ - return jHashCode == other.jHashCode && - sGlobalJniLock.getJniEnvForCurrentThread( )->IsSameObject( jObject, other.jObject ); -} -void -CppProxyBase::GlobalJniLock::lock( ) -{ - cacheMutex.lock( ); -} -void -CppProxyBase::GlobalJniLock::unlock( ) -{ - jniEnvForCurrentThread = nullptr; - cacheMutex.unlock( ); + + const ::std::lock_guard< GlobalJniLock > lock( sGlobalJniLock ); + sGlobalJniLock.setJniEnvForCurrentThread( jniEnv ); + sProxyCache.erase( ProxyCacheKey{mGlobalRef.get(), jHashCode, type_key} ); + removeSelfFromReverseCache( ); } -void -CppProxyBase::GlobalJniLock::setJniEnvForCurrentThread( JNIEnv* env ) + +std::shared_ptr +CppProxyBase::createProxyImpl( JNIEnv* const jenv, + const JniReference& jobj, + const ::std::string& type_key, + const bool do_cache, + const ProxyFactoryFun factory) { - jniEnvForCurrentThread = env; -} -JNIEnv* -CppProxyBase::GlobalJniLock::getJniEnvForCurrentThread( ) -{ - if ( jniEnvForCurrentThread == nullptr ) - { - jniEnvForCurrentThread = CppProxyBase::getJniEnvironment( ); + JniReference globalRef = new_global_ref(jenv, jobj.get()); + const jint jHashCode = getHashCode(jenv, jobj.get()); + const ProxyCacheKey key{globalRef.get(), jHashCode, type_key}; + + const ::std::lock_guard< GlobalJniLock > lock( sGlobalJniLock ); + sGlobalJniLock.setJniEnvForCurrentThread( jenv ); + + if (do_cache) { + if (const auto it = sProxyCache.find(key); it != sProxyCache.end()) + { + if (auto cachedProxy = it->second.lock()) + { + return cachedProxy; + } + } } - return jniEnvForCurrentThread; + + auto [newProxy, reverseCacheKey] = factory(std::move(globalRef), jHashCode); + + if (newProxy == nullptr) { + throw_runtime_exception(jenv, "Cannot allocate native memory."); + } else if (do_cache) { + sProxyCache[key] = ::std::weak_ptr(newProxy); + registerInReverseCache(newProxy.get(), reverseCacheKey, key.jObject); + } + return newProxy; } + jint -CppProxyBase::getHashCode( JNIEnv* jniEnv, jobject jObj ) +CppProxyBase::getHashCode(JNIEnv* const jniEnv, const jobject jObj) { - auto jClass = find_class(jniEnv, "java/lang/System" ); - jmethodID jMethodId - = jniEnv->GetStaticMethodID( jClass.get(), "identityHashCode", "(Ljava/lang/Object;)I" ); - jint jResult = jniEnv->CallStaticIntMethod( jClass.get(), jMethodId, jObj ); - return jResult; + const auto systemClass = find_class(jniEnv, "java/lang/System"); + const jmethodID jMethodId + = jniEnv->GetStaticMethodID(systemClass.get(), "identityHashCode", "(Ljava/lang/Object;)I"); + + return jniEnv->CallStaticIntMethod(systemClass.get(), jMethodId, jObj); } -void CppProxyBase::registerInReverseCache( CppProxyBase* proxyBase, + +void CppProxyBase::registerInReverseCache( CppProxyBase* const proxyBase, ReverseCacheKey reverseCacheKey, - const jobject& jObj ) + const jobject jObj ) { proxyBase->mReverseCacheKey = reverseCacheKey; sReverseProxyCache[reverseCacheKey] = jObj; } + void CppProxyBase::removeSelfFromReverseCache( ) { if ( mReverseCacheKey != nullptr ) @@ -88,15 +172,16 @@ void CppProxyBase::removeSelfFromReverseCache( ) mReverseCacheKey = nullptr; } } + JniReference CppProxyBase::getJavaObjectFromReverseCache(JNIEnv* jniEnv, ReverseCacheKey reverseCacheKey) { - ::std::lock_guard< GlobalJniLock > lock( sGlobalJniLock ); - const auto iterator = sReverseProxyCache.find( reverseCacheKey ); - if (iterator == sReverseProxyCache.end( )) + const ::std::lock_guard< GlobalJniLock > lock( sGlobalJniLock ); + if (const auto it = sReverseProxyCache.find(reverseCacheKey); it != sReverseProxyCache.end()) { - return nullptr; + return make_local_ref(jniEnv, jniEnv->NewLocalRef(it->second)); } - return make_local_ref(jniEnv, jniEnv->NewLocalRef(iterator->second)); -} -} + return nullptr; } + +} // namespace jni +} // namespace gluecodium diff --git a/gluecodium/src/test/resources/smoke/listeners/output/android/jni/com_example_smoke_CalculatorListenerImplCppProxy.cpp b/gluecodium/src/test/resources/smoke/listeners/output/android/jni/com_example_smoke_CalculatorListenerImplCppProxy.cpp index 76ba57a57b..e2cd0d306e 100644 --- a/gluecodium/src/test/resources/smoke/listeners/output/android/jni/com_example_smoke_CalculatorListenerImplCppProxy.cpp +++ b/gluecodium/src/test/resources/smoke/listeners/output/android/jni/com_example_smoke_CalculatorListenerImplCppProxy.cpp @@ -1,60 +1,101 @@ /* + * */ + #include "com_example_smoke_CalculatorListenerImplCppProxy.h" #include "com_example_smoke_CalculationResult__Conversion.h" #include "com_example_smoke_CalculatorListener_ResultStruct__Conversion.h" #include "com_example_smoke_CalculatorListener__Conversion.h" #include "ArrayConversionUtils.h" #include "FieldAccessMethods.h" + namespace gluecodium { namespace jni { -com_example_smoke_CalculatorListener_CppProxy::com_example_smoke_CalculatorListener_CppProxy( JNIEnv* _jenv, JniReference globalRef, jint _jHashCode ) - : CppProxyBase( _jenv, std::move( globalRef ), _jHashCode, "com_example_smoke_CalculatorListener" ) { + +com_example_smoke_CalculatorListener_CppProxy::com_example_smoke_CalculatorListener_CppProxy(JniReference globalRef, jint _jHashCode) noexcept + : CppProxyBase(std::move(globalRef), _jHashCode, "com_example_smoke_CalculatorListener") { } + void com_example_smoke_CalculatorListener_CppProxy::on_calculation_result( const double ncalculationResult ) { + JNIEnv* jniEnv = getJniEnvironment( ); jdouble jcalculationResult = ncalculationResult; callJavaMethod( "onCalculationResult", "(D)V", jniEnv , jcalculationResult); + checkExceptionAndReportIfAny(jniEnv); + + + } + void com_example_smoke_CalculatorListener_CppProxy::on_calculation_result_const( const double ncalculationResult ) const { + JNIEnv* jniEnv = getJniEnvironment( ); jdouble jcalculationResult = ncalculationResult; callJavaMethod( "onCalculationResultConst", "(D)V", jniEnv , jcalculationResult); + checkExceptionAndReportIfAny(jniEnv); + + + } + void com_example_smoke_CalculatorListener_CppProxy::on_calculation_result_struct( const ::smoke::CalculatorListener::ResultStruct& ncalculationResult ) { + JNIEnv* jniEnv = getJniEnvironment( ); auto jcalculationResult = convert_to_jni( jniEnv, ncalculationResult ); callJavaMethod( "onCalculationResultStruct", "(Lcom/example/smoke/CalculatorListener$ResultStruct;)V", jniEnv , jcalculationResult); + checkExceptionAndReportIfAny(jniEnv); + + + } + void com_example_smoke_CalculatorListener_CppProxy::on_calculation_result_array( const ::std::vector< double >& ncalculationResult ) { + JNIEnv* jniEnv = getJniEnvironment( ); auto jcalculationResult = convert_to_jni( jniEnv, ncalculationResult ); callJavaMethod( "onCalculationResultArray", "(Ljava/util/List;)V", jniEnv , jcalculationResult); + checkExceptionAndReportIfAny(jniEnv); + + + } + void com_example_smoke_CalculatorListener_CppProxy::on_calculation_result_map( const ::smoke::CalculatorListener::NamedCalculationResults& ncalculationResults ) { + JNIEnv* jniEnv = getJniEnvironment( ); auto jcalculationResults = convert_to_jni( jniEnv, ncalculationResults ); callJavaMethod( "onCalculationResultMap", "(Ljava/util/Map;)V", jniEnv , jcalculationResults); + checkExceptionAndReportIfAny(jniEnv); + + + } + void com_example_smoke_CalculatorListener_CppProxy::on_calculation_result_instance( const ::std::shared_ptr< ::smoke::CalculationResult >& ncalculationResult ) { + JNIEnv* jniEnv = getJniEnvironment( ); auto jcalculationResult = convert_to_jni( jniEnv, ncalculationResult ); callJavaMethod( "onCalculationResultInstance", "(Lcom/example/smoke/CalculationResult;)V", jniEnv , jcalculationResult); + checkExceptionAndReportIfAny(jniEnv); + + + +} + } } -} \ No newline at end of file diff --git a/gluecodium/src/test/resources/smoke/listeners/output/android/jni/com_example_smoke_CalculatorListenerImplCppProxy.h b/gluecodium/src/test/resources/smoke/listeners/output/android/jni/com_example_smoke_CalculatorListenerImplCppProxy.h index e94a2ae301..af2fac6ef9 100644 --- a/gluecodium/src/test/resources/smoke/listeners/output/android/jni/com_example_smoke_CalculatorListenerImplCppProxy.h +++ b/gluecodium/src/test/resources/smoke/listeners/output/android/jni/com_example_smoke_CalculatorListenerImplCppProxy.h @@ -1,25 +1,38 @@ /* + * */ + #pragma once + #include "smoke/CalculatorListener.h" #include "CppProxyBase.h" #include "JniReference.h" + namespace gluecodium { namespace jni { -class com_example_smoke_CalculatorListener_CppProxy : public CppProxyBase, public ::smoke::CalculatorListener { + +class com_example_smoke_CalculatorListener_CppProxy final : public CppProxyBase, public ::smoke::CalculatorListener { public: - com_example_smoke_CalculatorListener_CppProxy( JNIEnv* _jenv, JniReference globalRef, jint _jHashCode ); + com_example_smoke_CalculatorListener_CppProxy( JniReference globalRef, jint _jHashCode ) noexcept; com_example_smoke_CalculatorListener_CppProxy( const com_example_smoke_CalculatorListener_CppProxy& ) = delete; com_example_smoke_CalculatorListener_CppProxy& operator=( const com_example_smoke_CalculatorListener_CppProxy& ) = delete; + + void on_calculation_result( const double ncalculationResult ) override; + void on_calculation_result_const( const double ncalculationResult ) const override; + void on_calculation_result_struct( const ::smoke::CalculatorListener::ResultStruct& ncalculationResult ) override; + void on_calculation_result_array( const ::std::vector< double >& ncalculationResult ) override; + void on_calculation_result_map( const ::smoke::CalculatorListener::NamedCalculationResults& ncalculationResults ) override; + void on_calculation_result_instance( const ::std::shared_ptr< ::smoke::CalculationResult >& ncalculationResult ) override; }; + } } diff --git a/gluecodium/src/test/resources/smoke/listeners/output/android/jni/com_example_smoke_InterfaceWithStaticImplCppProxy.cpp b/gluecodium/src/test/resources/smoke/listeners/output/android/jni/com_example_smoke_InterfaceWithStaticImplCppProxy.cpp index 94cff0c3a8..7107a51839 100644 --- a/gluecodium/src/test/resources/smoke/listeners/output/android/jni/com_example_smoke_InterfaceWithStaticImplCppProxy.cpp +++ b/gluecodium/src/test/resources/smoke/listeners/output/android/jni/com_example_smoke_InterfaceWithStaticImplCppProxy.cpp @@ -1,37 +1,66 @@ /* + * */ + #include "com_example_smoke_InterfaceWithStaticImplCppProxy.h" #include "com_example_smoke_InterfaceWithStatic__Conversion.h" #include "ArrayConversionUtils.h" #include "FieldAccessMethods.h" + namespace gluecodium { namespace jni { -com_example_smoke_InterfaceWithStatic_CppProxy::com_example_smoke_InterfaceWithStatic_CppProxy( JNIEnv* _jenv, JniReference globalRef, jint _jHashCode ) - : CppProxyBase( _jenv, std::move( globalRef ), _jHashCode, "com_example_smoke_InterfaceWithStatic" ) { + +com_example_smoke_InterfaceWithStatic_CppProxy::com_example_smoke_InterfaceWithStatic_CppProxy(JniReference globalRef, jint _jHashCode) noexcept + : CppProxyBase(std::move(globalRef), _jHashCode, "com_example_smoke_InterfaceWithStatic") { } + ::std::string com_example_smoke_InterfaceWithStatic_CppProxy::regular_function( ) { + JNIEnv* jniEnv = getJniEnvironment( ); auto _result = callJavaMethod( "regularFunction", "()Ljava/lang/String;", jniEnv ); + checkExceptionAndReportIfAny(jniEnv); + return convert_from_jni( jniEnv, _result, (::std::string*)nullptr ); + + + } + + ::std::string com_example_smoke_InterfaceWithStatic_CppProxy::get_regular_property( ) const { + JNIEnv* jniEnv = getJniEnvironment( ); auto _result = callJavaMethod( "getRegularProperty", "()Ljava/lang/String;", jniEnv ); + checkExceptionAndReportIfAny(jniEnv); + return convert_from_jni( jniEnv, _result, (::std::string*)nullptr ); + + + } + + + void com_example_smoke_InterfaceWithStatic_CppProxy::set_regular_property( const ::std::string& nvalue ) { + JNIEnv* jniEnv = getJniEnvironment( ); auto jvalue = convert_to_jni( jniEnv, nvalue ); callJavaMethod( "setRegularProperty", "(Ljava/lang/String;)V", jniEnv , jvalue); + checkExceptionAndReportIfAny(jniEnv); + + + +} + + } } -} \ No newline at end of file diff --git a/gluecodium/src/test/resources/smoke/listeners/output/android/jni/com_example_smoke_InterfaceWithStaticImplCppProxy.h b/gluecodium/src/test/resources/smoke/listeners/output/android/jni/com_example_smoke_InterfaceWithStaticImplCppProxy.h index 05a40130e9..ec48583bcd 100644 --- a/gluecodium/src/test/resources/smoke/listeners/output/android/jni/com_example_smoke_InterfaceWithStaticImplCppProxy.h +++ b/gluecodium/src/test/resources/smoke/listeners/output/android/jni/com_example_smoke_InterfaceWithStaticImplCppProxy.h @@ -1,22 +1,34 @@ /* + * */ + #pragma once + #include "smoke/InterfaceWithStatic.h" #include "CppProxyBase.h" #include "JniReference.h" + namespace gluecodium { namespace jni { -class com_example_smoke_InterfaceWithStatic_CppProxy : public CppProxyBase, public ::smoke::InterfaceWithStatic { + +class com_example_smoke_InterfaceWithStatic_CppProxy final : public CppProxyBase, public ::smoke::InterfaceWithStatic { public: - com_example_smoke_InterfaceWithStatic_CppProxy( JNIEnv* _jenv, JniReference globalRef, jint _jHashCode ); + com_example_smoke_InterfaceWithStatic_CppProxy( JniReference globalRef, jint _jHashCode ) noexcept; com_example_smoke_InterfaceWithStatic_CppProxy( const com_example_smoke_InterfaceWithStatic_CppProxy& ) = delete; com_example_smoke_InterfaceWithStatic_CppProxy& operator=( const com_example_smoke_InterfaceWithStatic_CppProxy& ) = delete; + + ::std::string regular_function( ) override; + + ::std::string get_regular_property( ) const override; + void set_regular_property( const ::std::string& nvalue ) override; + }; + } } diff --git a/gluecodium/src/test/resources/smoke/listeners/output/android/jni/com_example_smoke_ListenerWithNullableImplCppProxy.cpp b/gluecodium/src/test/resources/smoke/listeners/output/android/jni/com_example_smoke_ListenerWithNullableImplCppProxy.cpp index 1772cc0d93..c4b501704b 100644 --- a/gluecodium/src/test/resources/smoke/listeners/output/android/jni/com_example_smoke_ListenerWithNullableImplCppProxy.cpp +++ b/gluecodium/src/test/resources/smoke/listeners/output/android/jni/com_example_smoke_ListenerWithNullableImplCppProxy.cpp @@ -1,104 +1,186 @@ /* + * */ + #include "com_example_smoke_ListenerWithNullableImplCppProxy.h" #include "com_example_smoke_ListenerWithNullable__Conversion.h" #include "ArrayConversionUtils.h" #include "FieldAccessMethods.h" + namespace gluecodium { namespace jni { -com_example_smoke_ListenerWithNullable_CppProxy::com_example_smoke_ListenerWithNullable_CppProxy( JNIEnv* _jenv, JniReference globalRef, jint _jHashCode ) - : CppProxyBase( _jenv, std::move( globalRef ), _jHashCode, "com_example_smoke_ListenerWithNullable" ) { + +com_example_smoke_ListenerWithNullable_CppProxy::com_example_smoke_ListenerWithNullable_CppProxy(JniReference globalRef, jint _jHashCode) noexcept + : CppProxyBase(std::move(globalRef), _jHashCode, "com_example_smoke_ListenerWithNullable") { } + std::optional< int8_t > com_example_smoke_ListenerWithNullable_CppProxy::method_with_byte( const std::optional< int8_t >& ninput ) { + JNIEnv* jniEnv = getJniEnvironment( ); auto jinput = convert_to_jni( jniEnv, ninput ); auto _result = callJavaMethod( "methodWithByte", "(Ljava/lang/Byte;)Ljava/lang/Byte;", jniEnv , jinput); + checkExceptionAndReportIfAny(jniEnv); + return convert_from_jni( jniEnv, _result, (std::optional< int8_t >*)nullptr ); + + + } + std::optional< uint8_t > com_example_smoke_ListenerWithNullable_CppProxy::method_with_u_byte( const std::optional< uint8_t >& ninput ) { + JNIEnv* jniEnv = getJniEnvironment( ); auto jinput = convert_to_jni( jniEnv, ninput ); auto _result = callJavaMethod( "methodWithUByte", "(Ljava/lang/Short;)Ljava/lang/Short;", jniEnv , jinput); + checkExceptionAndReportIfAny(jniEnv); + return convert_from_jni( jniEnv, _result, (std::optional< uint8_t >*)nullptr ); + + + } + std::optional< int16_t > com_example_smoke_ListenerWithNullable_CppProxy::method_with_short( const std::optional< int16_t >& ninput ) { + JNIEnv* jniEnv = getJniEnvironment( ); auto jinput = convert_to_jni( jniEnv, ninput ); auto _result = callJavaMethod( "methodWithShort", "(Ljava/lang/Short;)Ljava/lang/Short;", jniEnv , jinput); + checkExceptionAndReportIfAny(jniEnv); + return convert_from_jni( jniEnv, _result, (std::optional< int16_t >*)nullptr ); + + + } + std::optional< uint16_t > com_example_smoke_ListenerWithNullable_CppProxy::method_with_u_short( const std::optional< uint16_t >& ninput ) { + JNIEnv* jniEnv = getJniEnvironment( ); auto jinput = convert_to_jni( jniEnv, ninput ); auto _result = callJavaMethod( "methodWithUShort", "(Ljava/lang/Integer;)Ljava/lang/Integer;", jniEnv , jinput); + checkExceptionAndReportIfAny(jniEnv); + return convert_from_jni( jniEnv, _result, (std::optional< uint16_t >*)nullptr ); + + + } + std::optional< int32_t > com_example_smoke_ListenerWithNullable_CppProxy::method_with_int( const std::optional< int32_t >& ninput ) { + JNIEnv* jniEnv = getJniEnvironment( ); auto jinput = convert_to_jni( jniEnv, ninput ); auto _result = callJavaMethod( "methodWithInt", "(Ljava/lang/Integer;)Ljava/lang/Integer;", jniEnv , jinput); + checkExceptionAndReportIfAny(jniEnv); + return convert_from_jni( jniEnv, _result, (std::optional< int32_t >*)nullptr ); + + + } + std::optional< uint32_t > com_example_smoke_ListenerWithNullable_CppProxy::method_with_u_int( const std::optional< uint32_t >& ninput ) { + JNIEnv* jniEnv = getJniEnvironment( ); auto jinput = convert_to_jni( jniEnv, ninput ); auto _result = callJavaMethod( "methodWithUInt", "(Ljava/lang/Long;)Ljava/lang/Long;", jniEnv , jinput); + checkExceptionAndReportIfAny(jniEnv); + return convert_from_jni( jniEnv, _result, (std::optional< uint32_t >*)nullptr ); + + + } + std::optional< int64_t > com_example_smoke_ListenerWithNullable_CppProxy::method_with_long( const std::optional< int64_t >& ninput ) { + JNIEnv* jniEnv = getJniEnvironment( ); auto jinput = convert_to_jni( jniEnv, ninput ); auto _result = callJavaMethod( "methodWithLong", "(Ljava/lang/Long;)Ljava/lang/Long;", jniEnv , jinput); + checkExceptionAndReportIfAny(jniEnv); + return convert_from_jni( jniEnv, _result, (std::optional< int64_t >*)nullptr ); + + + } + std::optional< uint64_t > com_example_smoke_ListenerWithNullable_CppProxy::method_with_u_long( const std::optional< uint64_t >& ninput ) { + JNIEnv* jniEnv = getJniEnvironment( ); auto jinput = convert_to_jni( jniEnv, ninput ); auto _result = callJavaMethod( "methodWithULong", "(Ljava/lang/Long;)Ljava/lang/Long;", jniEnv , jinput); + checkExceptionAndReportIfAny(jniEnv); + return convert_from_jni( jniEnv, _result, (std::optional< uint64_t >*)nullptr ); + + + } + std::optional< bool > com_example_smoke_ListenerWithNullable_CppProxy::method_with_double( const std::optional< bool >& ninput ) { + JNIEnv* jniEnv = getJniEnvironment( ); auto jinput = convert_to_jni( jniEnv, ninput ); auto _result = callJavaMethod( "methodWithDouble", "(Ljava/lang/Boolean;)Ljava/lang/Boolean;", jniEnv , jinput); + checkExceptionAndReportIfAny(jniEnv); + return convert_from_jni( jniEnv, _result, (std::optional< bool >*)nullptr ); + + + } + std::optional< float > com_example_smoke_ListenerWithNullable_CppProxy::method_with_float( const std::optional< float >& ninput ) { + JNIEnv* jniEnv = getJniEnvironment( ); auto jinput = convert_to_jni( jniEnv, ninput ); auto _result = callJavaMethod( "methodWithFloat", "(Ljava/lang/Float;)Ljava/lang/Float;", jniEnv , jinput); + checkExceptionAndReportIfAny(jniEnv); + return convert_from_jni( jniEnv, _result, (std::optional< float >*)nullptr ); + + + } + std::optional< double > com_example_smoke_ListenerWithNullable_CppProxy::method_with_double( const std::optional< double >& ninput ) { + JNIEnv* jniEnv = getJniEnvironment( ); auto jinput = convert_to_jni( jniEnv, ninput ); auto _result = callJavaMethod( "methodWithDouble", "(Ljava/lang/Double;)Ljava/lang/Double;", jniEnv , jinput); + checkExceptionAndReportIfAny(jniEnv); + return convert_from_jni( jniEnv, _result, (std::optional< double >*)nullptr ); + + + +} + } } -} \ No newline at end of file diff --git a/gluecodium/src/test/resources/smoke/listeners/output/android/jni/com_example_smoke_ListenerWithPropertiesImplCppProxy.cpp b/gluecodium/src/test/resources/smoke/listeners/output/android/jni/com_example_smoke_ListenerWithPropertiesImplCppProxy.cpp index 53813e0a66..04298e88b5 100644 --- a/gluecodium/src/test/resources/smoke/listeners/output/android/jni/com_example_smoke_ListenerWithPropertiesImplCppProxy.cpp +++ b/gluecodium/src/test/resources/smoke/listeners/output/android/jni/com_example_smoke_ListenerWithPropertiesImplCppProxy.cpp @@ -1,6 +1,8 @@ /* + * */ + #include "com_example_smoke_ListenerWithPropertiesImplCppProxy.h" #include "com_example_smoke_CalculationResult__Conversion.h" #include "com_example_smoke_ListenerWithProperties_ResultEnum__Conversion.h" @@ -8,110 +10,232 @@ #include "com_example_smoke_ListenerWithProperties__Conversion.h" #include "ArrayConversionUtils.h" #include "FieldAccessMethods.h" + namespace gluecodium { namespace jni { -com_example_smoke_ListenerWithProperties_CppProxy::com_example_smoke_ListenerWithProperties_CppProxy( JNIEnv* _jenv, JniReference globalRef, jint _jHashCode ) - : CppProxyBase( _jenv, std::move( globalRef ), _jHashCode, "com_example_smoke_ListenerWithProperties" ) { + +com_example_smoke_ListenerWithProperties_CppProxy::com_example_smoke_ListenerWithProperties_CppProxy(JniReference globalRef, jint _jHashCode) noexcept + : CppProxyBase(std::move(globalRef), _jHashCode, "com_example_smoke_ListenerWithProperties") { } + + ::std::string com_example_smoke_ListenerWithProperties_CppProxy::get_message( ) const { + JNIEnv* jniEnv = getJniEnvironment( ); auto _result = callJavaMethod( "getMessage", "()Ljava/lang/String;", jniEnv ); + checkExceptionAndReportIfAny(jniEnv); + return convert_from_jni( jniEnv, _result, (::std::string*)nullptr ); + + + } + + + void com_example_smoke_ListenerWithProperties_CppProxy::set_message( const ::std::string& nvalue ) { + JNIEnv* jniEnv = getJniEnvironment( ); auto jvalue = convert_to_jni( jniEnv, nvalue ); callJavaMethod( "setMessage", "(Ljava/lang/String;)V", jniEnv , jvalue); + checkExceptionAndReportIfAny(jniEnv); + + + } + + + ::std::shared_ptr< ::smoke::CalculationResult > com_example_smoke_ListenerWithProperties_CppProxy::get_packed_message( ) const { + JNIEnv* jniEnv = getJniEnvironment( ); auto _result = callJavaMethod( "getPackedMessage", "()Lcom/example/smoke/CalculationResult;", jniEnv ); + checkExceptionAndReportIfAny(jniEnv); + return convert_from_jni( jniEnv, _result, (::std::shared_ptr< ::smoke::CalculationResult >*)nullptr ); + + + } + + + void com_example_smoke_ListenerWithProperties_CppProxy::set_packed_message( const ::std::shared_ptr< ::smoke::CalculationResult >& nvalue ) { + JNIEnv* jniEnv = getJniEnvironment( ); auto jvalue = convert_to_jni( jniEnv, nvalue ); callJavaMethod( "setPackedMessage", "(Lcom/example/smoke/CalculationResult;)V", jniEnv , jvalue); + checkExceptionAndReportIfAny(jniEnv); + + + } + + + ::smoke::ListenerWithProperties::ResultStruct com_example_smoke_ListenerWithProperties_CppProxy::get_structured_message( ) const { + JNIEnv* jniEnv = getJniEnvironment( ); auto _result = callJavaMethod( "getStructuredMessage", "()Lcom/example/smoke/ListenerWithProperties$ResultStruct;", jniEnv ); + checkExceptionAndReportIfAny(jniEnv); + return convert_from_jni( jniEnv, _result, (::smoke::ListenerWithProperties::ResultStruct*)nullptr ); + + + } + + + void com_example_smoke_ListenerWithProperties_CppProxy::set_structured_message( const ::smoke::ListenerWithProperties::ResultStruct& nvalue ) { + JNIEnv* jniEnv = getJniEnvironment( ); auto jvalue = convert_to_jni( jniEnv, nvalue ); callJavaMethod( "setStructuredMessage", "(Lcom/example/smoke/ListenerWithProperties$ResultStruct;)V", jniEnv , jvalue); + checkExceptionAndReportIfAny(jniEnv); + + + } + + + ::smoke::ListenerWithProperties::ResultEnum com_example_smoke_ListenerWithProperties_CppProxy::get_enumerated_message( ) const { + JNIEnv* jniEnv = getJniEnvironment( ); auto _result = callJavaMethod( "getEnumeratedMessage", "()Lcom/example/smoke/ListenerWithProperties$ResultEnum;", jniEnv ); + checkExceptionAndReportIfAny(jniEnv); + return convert_from_jni( jniEnv, _result, (::smoke::ListenerWithProperties::ResultEnum*)nullptr ); + + + } + + + void com_example_smoke_ListenerWithProperties_CppProxy::set_enumerated_message( const ::smoke::ListenerWithProperties::ResultEnum nvalue ) { + JNIEnv* jniEnv = getJniEnvironment( ); auto jvalue = convert_to_jni( jniEnv, nvalue ); callJavaMethod( "setEnumeratedMessage", "(Lcom/example/smoke/ListenerWithProperties$ResultEnum;)V", jniEnv , jvalue); + checkExceptionAndReportIfAny(jniEnv); + + + } + + + ::std::vector< ::std::string > com_example_smoke_ListenerWithProperties_CppProxy::get_arrayed_message( ) const { + JNIEnv* jniEnv = getJniEnvironment( ); auto _result = callJavaMethod( "getArrayedMessage", "()Ljava/util/List;", jniEnv ); + checkExceptionAndReportIfAny(jniEnv); + return convert_from_jni( jniEnv, _result, (::std::vector< ::std::string >*)nullptr ); + + + } + + + void com_example_smoke_ListenerWithProperties_CppProxy::set_arrayed_message( const ::std::vector< ::std::string >& nvalue ) { + JNIEnv* jniEnv = getJniEnvironment( ); auto jvalue = convert_to_jni( jniEnv, nvalue ); callJavaMethod( "setArrayedMessage", "(Ljava/util/List;)V", jniEnv , jvalue); + checkExceptionAndReportIfAny(jniEnv); + + + } + + + ::smoke::ListenerWithProperties::StringToDouble com_example_smoke_ListenerWithProperties_CppProxy::get_mapped_message( ) const { + JNIEnv* jniEnv = getJniEnvironment( ); auto _result = callJavaMethod( "getMappedMessage", "()Ljava/util/Map;", jniEnv ); + checkExceptionAndReportIfAny(jniEnv); + return convert_from_jni( jniEnv, _result, (::smoke::ListenerWithProperties::StringToDouble*)nullptr ); + + + } + + + void com_example_smoke_ListenerWithProperties_CppProxy::set_mapped_message( const ::smoke::ListenerWithProperties::StringToDouble& nvalue ) { + JNIEnv* jniEnv = getJniEnvironment( ); auto jvalue = convert_to_jni( jniEnv, nvalue ); callJavaMethod( "setMappedMessage", "(Ljava/util/Map;)V", jniEnv , jvalue); + checkExceptionAndReportIfAny(jniEnv); + + + } + + + ::std::shared_ptr< ::std::vector< uint8_t > > com_example_smoke_ListenerWithProperties_CppProxy::get_buffered_message( ) const { + JNIEnv* jniEnv = getJniEnvironment( ); auto _result = callJavaMethod( "getBufferedMessage", "()[B", jniEnv ); + checkExceptionAndReportIfAny(jniEnv); + return convert_from_jni( jniEnv, _result, (::std::shared_ptr< ::std::vector< uint8_t > >*)nullptr ); + + + } + + + void com_example_smoke_ListenerWithProperties_CppProxy::set_buffered_message( const ::std::shared_ptr< ::std::vector< uint8_t > >& nvalue ) { + JNIEnv* jniEnv = getJniEnvironment( ); auto jvalue = convert_to_jni( jniEnv, nvalue ); callJavaMethod( "setBufferedMessage", "([B)V", jniEnv , jvalue); + checkExceptionAndReportIfAny(jniEnv); + + + +} + + } } -} \ No newline at end of file diff --git a/gluecodium/src/test/resources/smoke/listeners/output/android/jni/com_example_smoke_ListenersWithReturnValuesImplCppProxy.cpp b/gluecodium/src/test/resources/smoke/listeners/output/android/jni/com_example_smoke_ListenersWithReturnValuesImplCppProxy.cpp index 0462c4aa1c..498770336b 100644 --- a/gluecodium/src/test/resources/smoke/listeners/output/android/jni/com_example_smoke_ListenersWithReturnValuesImplCppProxy.cpp +++ b/gluecodium/src/test/resources/smoke/listeners/output/android/jni/com_example_smoke_ListenersWithReturnValuesImplCppProxy.cpp @@ -1,6 +1,8 @@ /* + * */ + #include "com_example_smoke_ListenersWithReturnValuesImplCppProxy.h" #include "com_example_smoke_CalculationResult__Conversion.h" #include "com_example_smoke_ListenersWithReturnValues_ResultEnum__Conversion.h" @@ -8,61 +10,113 @@ #include "com_example_smoke_ListenersWithReturnValues__Conversion.h" #include "ArrayConversionUtils.h" #include "FieldAccessMethods.h" + namespace gluecodium { namespace jni { -com_example_smoke_ListenersWithReturnValues_CppProxy::com_example_smoke_ListenersWithReturnValues_CppProxy( JNIEnv* _jenv, JniReference globalRef, jint _jHashCode ) - : CppProxyBase( _jenv, std::move( globalRef ), _jHashCode, "com_example_smoke_ListenersWithReturnValues" ) { + +com_example_smoke_ListenersWithReturnValues_CppProxy::com_example_smoke_ListenersWithReturnValues_CppProxy(JniReference globalRef, jint _jHashCode) noexcept + : CppProxyBase(std::move(globalRef), _jHashCode, "com_example_smoke_ListenersWithReturnValues") { } + double com_example_smoke_ListenersWithReturnValues_CppProxy::fetch_data_double( ) { + JNIEnv* jniEnv = getJniEnvironment( ); auto _result = callJavaMethod( "fetchDataDouble", "()D", jniEnv ); + checkExceptionAndReportIfAny(jniEnv); + return _result; + + + } + ::std::string com_example_smoke_ListenersWithReturnValues_CppProxy::fetch_data_string( ) { + JNIEnv* jniEnv = getJniEnvironment( ); auto _result = callJavaMethod( "fetchDataString", "()Ljava/lang/String;", jniEnv ); + checkExceptionAndReportIfAny(jniEnv); + return convert_from_jni( jniEnv, _result, (::std::string*)nullptr ); + + + } + ::smoke::ListenersWithReturnValues::ResultStruct com_example_smoke_ListenersWithReturnValues_CppProxy::fetch_data_struct( ) { + JNIEnv* jniEnv = getJniEnvironment( ); auto _result = callJavaMethod( "fetchDataStruct", "()Lcom/example/smoke/ListenersWithReturnValues$ResultStruct;", jniEnv ); + checkExceptionAndReportIfAny(jniEnv); + return convert_from_jni( jniEnv, _result, (::smoke::ListenersWithReturnValues::ResultStruct*)nullptr ); + + + } + ::smoke::ListenersWithReturnValues::ResultEnum com_example_smoke_ListenersWithReturnValues_CppProxy::fetch_data_enum( ) { + JNIEnv* jniEnv = getJniEnvironment( ); auto _result = callJavaMethod( "fetchDataEnum", "()Lcom/example/smoke/ListenersWithReturnValues$ResultEnum;", jniEnv ); + checkExceptionAndReportIfAny(jniEnv); + return convert_from_jni( jniEnv, _result, (::smoke::ListenersWithReturnValues::ResultEnum*)nullptr ); + + + } + ::std::vector< double > com_example_smoke_ListenersWithReturnValues_CppProxy::fetch_data_array( ) { + JNIEnv* jniEnv = getJniEnvironment( ); auto _result = callJavaMethod( "fetchDataArray", "()Ljava/util/List;", jniEnv ); + checkExceptionAndReportIfAny(jniEnv); + return convert_from_jni( jniEnv, _result, (::std::vector< double >*)nullptr ); + + + } + ::smoke::ListenersWithReturnValues::StringToDouble com_example_smoke_ListenersWithReturnValues_CppProxy::fetch_data_map( ) { + JNIEnv* jniEnv = getJniEnvironment( ); auto _result = callJavaMethod( "fetchDataMap", "()Ljava/util/Map;", jniEnv ); + checkExceptionAndReportIfAny(jniEnv); + return convert_from_jni( jniEnv, _result, (::smoke::ListenersWithReturnValues::StringToDouble*)nullptr ); + + + } + ::std::shared_ptr< ::smoke::CalculationResult > com_example_smoke_ListenersWithReturnValues_CppProxy::fetch_data_instance( ) { + JNIEnv* jniEnv = getJniEnvironment( ); auto _result = callJavaMethod( "fetchDataInstance", "()Lcom/example/smoke/CalculationResult;", jniEnv ); + checkExceptionAndReportIfAny(jniEnv); + return convert_from_jni( jniEnv, _result, (::std::shared_ptr< ::smoke::CalculationResult >*)nullptr ); + + + +} + } } -} \ No newline at end of file diff --git a/gluecodium/src/test/resources/smoke/nesting/output/android/jni/com_example_smoke_OuterClass_InnerInterfaceImplCppProxy.h b/gluecodium/src/test/resources/smoke/nesting/output/android/jni/com_example_smoke_OuterClass_InnerInterfaceImplCppProxy.h index 5e2b2416ff..d17f62cac7 100644 --- a/gluecodium/src/test/resources/smoke/nesting/output/android/jni/com_example_smoke_OuterClass_InnerInterfaceImplCppProxy.h +++ b/gluecodium/src/test/resources/smoke/nesting/output/android/jni/com_example_smoke_OuterClass_InnerInterfaceImplCppProxy.h @@ -1,20 +1,28 @@ /* + * */ + #pragma once + #include "smoke/OuterClass.h" #include "CppProxyBase.h" #include "JniReference.h" + namespace gluecodium { namespace jni { -class com_example_smoke_OuterClass_00024InnerInterface_CppProxy : public CppProxyBase, public ::smoke::OuterClass::InnerInterface { + +class com_example_smoke_OuterClass_00024InnerInterface_CppProxy final : public CppProxyBase, public ::smoke::OuterClass::InnerInterface { public: - com_example_smoke_OuterClass_00024InnerInterface_CppProxy( JNIEnv* _jenv, JniReference globalRef, jint _jHashCode ); + com_example_smoke_OuterClass_00024InnerInterface_CppProxy( JniReference globalRef, jint _jHashCode ) noexcept; com_example_smoke_OuterClass_00024InnerInterface_CppProxy( const com_example_smoke_OuterClass_00024InnerInterface_CppProxy& ) = delete; com_example_smoke_OuterClass_00024InnerInterface_CppProxy& operator=( const com_example_smoke_OuterClass_00024InnerInterface_CppProxy& ) = delete; + + ::std::string foo( const ::std::string& ninput ) override; }; + } } diff --git a/gluecodium/src/test/resources/smoke/nesting/output/android/jni/com_example_smoke_OuterStruct_InnerInterfaceImplCppProxy.cpp b/gluecodium/src/test/resources/smoke/nesting/output/android/jni/com_example_smoke_OuterStruct_InnerInterfaceImplCppProxy.cpp index 2e8edddaa1..a67045b379 100644 --- a/gluecodium/src/test/resources/smoke/nesting/output/android/jni/com_example_smoke_OuterStruct_InnerInterfaceImplCppProxy.cpp +++ b/gluecodium/src/test/resources/smoke/nesting/output/android/jni/com_example_smoke_OuterStruct_InnerInterfaceImplCppProxy.cpp @@ -1,23 +1,35 @@ /* + * */ + #include "com_example_smoke_OuterStruct_InnerInterfaceImplCppProxy.h" #include "com_example_smoke_OuterStruct_InnerInterface__Conversion.h" #include "ArrayConversionUtils.h" #include "FieldAccessMethods.h" + namespace gluecodium { namespace jni { -com_example_smoke_OuterStruct_00024InnerInterface_CppProxy::com_example_smoke_OuterStruct_00024InnerInterface_CppProxy( JNIEnv* _jenv, JniReference globalRef, jint _jHashCode ) - : CppProxyBase( _jenv, std::move( globalRef ), _jHashCode, "com_example_smoke_OuterStruct_00024InnerInterface" ) { + +com_example_smoke_OuterStruct_00024InnerInterface_CppProxy::com_example_smoke_OuterStruct_00024InnerInterface_CppProxy(JniReference globalRef, jint _jHashCode) noexcept + : CppProxyBase(std::move(globalRef), _jHashCode, "com_example_smoke_OuterStruct_00024InnerInterface") { } + ::std::unordered_map< ::std::string, ::std::shared_ptr< ::std::vector< uint8_t > > > com_example_smoke_OuterStruct_00024InnerInterface_CppProxy::bar_baz( ) { + JNIEnv* jniEnv = getJniEnvironment( ); auto _result = callJavaMethod( "barBaz", "()Ljava/util/Map;", jniEnv ); + checkExceptionAndReportIfAny(jniEnv); + return convert_from_jni( jniEnv, _result, (::std::unordered_map< ::std::string, ::std::shared_ptr< ::std::vector< uint8_t > > >*)nullptr ); + + + +} + } } -} \ No newline at end of file diff --git a/gluecodium/src/test/resources/smoke/nesting/output/android/jni/com_example_smoke_OuterStruct_InnerLambdaImplCppProxy.cpp b/gluecodium/src/test/resources/smoke/nesting/output/android/jni/com_example_smoke_OuterStruct_InnerLambdaImplCppProxy.cpp index d858339718..b7b1f69964 100644 --- a/gluecodium/src/test/resources/smoke/nesting/output/android/jni/com_example_smoke_OuterStruct_InnerLambdaImplCppProxy.cpp +++ b/gluecodium/src/test/resources/smoke/nesting/output/android/jni/com_example_smoke_OuterStruct_InnerLambdaImplCppProxy.cpp @@ -1,22 +1,33 @@ /* + * */ + #include "com_example_smoke_OuterStruct_InnerLambdaImplCppProxy.h" #include "com_example_smoke_OuterStruct_InnerLambda__Conversion.h" #include "ArrayConversionUtils.h" #include "FieldAccessMethods.h" + namespace gluecodium { namespace jni { -com_example_smoke_OuterStruct_00024InnerLambda_CppProxy::com_example_smoke_OuterStruct_00024InnerLambda_CppProxy( JNIEnv* _jenv, JniReference globalRef, jint _jHashCode ) - : CppProxyBase( _jenv, std::move( globalRef ), _jHashCode, "com_example_smoke_OuterStruct_00024InnerLambda" ) { + +com_example_smoke_OuterStruct_00024InnerLambda_CppProxy::com_example_smoke_OuterStruct_00024InnerLambda_CppProxy(JniReference globalRef, jint _jHashCode) noexcept + : CppProxyBase(std::move(globalRef), _jHashCode, "com_example_smoke_OuterStruct_00024InnerLambda") { } + void com_example_smoke_OuterStruct_00024InnerLambda_CppProxy::operator()( ) { + JNIEnv* jniEnv = getJniEnvironment( ); callJavaMethod( "apply", "()V", jniEnv ); + checkExceptionAndReportIfAny(jniEnv); + + + +} + } } -} \ No newline at end of file diff --git a/gluecodium/src/test/resources/smoke/nesting/output/android/jni/com_example_smoke_OuterStruct_InnerLambdaImplCppProxy.h b/gluecodium/src/test/resources/smoke/nesting/output/android/jni/com_example_smoke_OuterStruct_InnerLambdaImplCppProxy.h index 34297fb80d..f9c27070f4 100644 --- a/gluecodium/src/test/resources/smoke/nesting/output/android/jni/com_example_smoke_OuterStruct_InnerLambdaImplCppProxy.h +++ b/gluecodium/src/test/resources/smoke/nesting/output/android/jni/com_example_smoke_OuterStruct_InnerLambdaImplCppProxy.h @@ -1,21 +1,29 @@ /* + * */ + #pragma once + #include "smoke/OuterStruct.h" #include #include "CppProxyBase.h" #include "JniReference.h" + namespace gluecodium { namespace jni { -class com_example_smoke_OuterStruct_00024InnerLambda_CppProxy : public CppProxyBase { + +class com_example_smoke_OuterStruct_00024InnerLambda_CppProxy final : public CppProxyBase { public: - com_example_smoke_OuterStruct_00024InnerLambda_CppProxy( JNIEnv* _jenv, JniReference globalRef, jint _jHashCode ); + com_example_smoke_OuterStruct_00024InnerLambda_CppProxy( JniReference globalRef, jint _jHashCode ) noexcept; com_example_smoke_OuterStruct_00024InnerLambda_CppProxy( const com_example_smoke_OuterStruct_00024InnerLambda_CppProxy& ) = delete; com_example_smoke_OuterStruct_00024InnerLambda_CppProxy& operator=( const com_example_smoke_OuterStruct_00024InnerLambda_CppProxy& ) = delete; + + void operator()( ); }; + } } diff --git a/gluecodium/src/test/resources/smoke/platform_names/output/android/jni/com_example_smoke_barListenerImplCppProxy.cpp b/gluecodium/src/test/resources/smoke/platform_names/output/android/jni/com_example_smoke_barListenerImplCppProxy.cpp index 8a6523d0ee..2b340bd57e 100644 --- a/gluecodium/src/test/resources/smoke/platform_names/output/android/jni/com_example_smoke_barListenerImplCppProxy.cpp +++ b/gluecodium/src/test/resources/smoke/platform_names/output/android/jni/com_example_smoke_barListenerImplCppProxy.cpp @@ -1,23 +1,34 @@ /* + * */ + #include "com_example_smoke_barListenerImplCppProxy.h" #include "com_example_smoke_barListener__Conversion.h" #include "ArrayConversionUtils.h" #include "FieldAccessMethods.h" + namespace gluecodium { namespace jni { -com_example_smoke_barListener_CppProxy::com_example_smoke_barListener_CppProxy( JNIEnv* _jenv, JniReference globalRef, jint _jHashCode ) - : CppProxyBase( _jenv, std::move( globalRef ), _jHashCode, "com_example_smoke_barListener" ) { + +com_example_smoke_barListener_CppProxy::com_example_smoke_barListener_CppProxy(JniReference globalRef, jint _jHashCode) noexcept + : CppProxyBase(std::move(globalRef), _jHashCode, "com_example_smoke_barListener") { } + void com_example_smoke_barListener_CppProxy::FooMethod( const ::std::string& nBarParameter ) { + JNIEnv* jniEnv = getJniEnvironment( ); auto jBarParameter = convert_to_jni( jniEnv, nBarParameter ); callJavaMethod( "BarMethod", "(Ljava/lang/String;)V", jniEnv , jBarParameter); + checkExceptionAndReportIfAny(jniEnv); + + + +} + } } -} \ No newline at end of file diff --git a/gluecodium/src/test/resources/smoke/skip/output/android/jni/com_example_smoke_EnableTagsInJavaImplCppProxy.cpp b/gluecodium/src/test/resources/smoke/skip/output/android/jni/com_example_smoke_EnableTagsInJavaImplCppProxy.cpp index ac29071757..0cbfdbf947 100644 --- a/gluecodium/src/test/resources/smoke/skip/output/android/jni/com_example_smoke_EnableTagsInJavaImplCppProxy.cpp +++ b/gluecodium/src/test/resources/smoke/skip/output/android/jni/com_example_smoke_EnableTagsInJavaImplCppProxy.cpp @@ -1,31 +1,52 @@ /* + * */ + #include "com_example_smoke_EnableTagsInJavaImplCppProxy.h" #include "com_example_smoke_EnableTagsInJava__Conversion.h" #include "ArrayConversionUtils.h" #include "FieldAccessMethods.h" + namespace gluecodium { namespace jni { -com_example_smoke_EnableTagsInJava_CppProxy::com_example_smoke_EnableTagsInJava_CppProxy( JNIEnv* _jenv, JniReference globalRef, jint _jHashCode ) - : CppProxyBase( _jenv, std::move( globalRef ), _jHashCode, "com_example_smoke_EnableTagsInJava" ) { + +com_example_smoke_EnableTagsInJava_CppProxy::com_example_smoke_EnableTagsInJava_CppProxy(JniReference globalRef, jint _jHashCode) noexcept + : CppProxyBase(std::move(globalRef), _jHashCode, "com_example_smoke_EnableTagsInJava") { } + void com_example_smoke_EnableTagsInJava_CppProxy::enable_tagged( ) { + JNIEnv* jniEnv = getJniEnvironment( ); callJavaMethod( "enableTagged", "()V", jniEnv ); + checkExceptionAndReportIfAny(jniEnv); + + + } + void com_example_smoke_EnableTagsInJava_CppProxy::dont_enable_tagged( ) { + + + } + void com_example_smoke_EnableTagsInJava_CppProxy::enable_tagged_list( ) { + JNIEnv* jniEnv = getJniEnvironment( ); callJavaMethod( "enableTaggedList", "()V", jniEnv ); + checkExceptionAndReportIfAny(jniEnv); + + + +} + } } -} \ No newline at end of file diff --git a/gluecodium/src/test/resources/smoke/skip/output/android/jni/com_example_smoke_SkipProxyImplCppProxy.cpp b/gluecodium/src/test/resources/smoke/skip/output/android/jni/com_example_smoke_SkipProxyImplCppProxy.cpp index 0f422ad2e3..5f76683663 100644 --- a/gluecodium/src/test/resources/smoke/skip/output/android/jni/com_example_smoke_SkipProxyImplCppProxy.cpp +++ b/gluecodium/src/test/resources/smoke/skip/output/android/jni/com_example_smoke_SkipProxyImplCppProxy.cpp @@ -1,85 +1,174 @@ /* + * */ + #include "com_example_smoke_SkipProxyImplCppProxy.h" #include "com_example_smoke_SkipProxy__Conversion.h" #include "ArrayConversionUtils.h" #include "FieldAccessMethods.h" + namespace gluecodium { namespace jni { -com_example_smoke_SkipProxy_CppProxy::com_example_smoke_SkipProxy_CppProxy( JNIEnv* _jenv, JniReference globalRef, jint _jHashCode ) - : CppProxyBase( _jenv, std::move( globalRef ), _jHashCode, "com_example_smoke_SkipProxy" ) { + +com_example_smoke_SkipProxy_CppProxy::com_example_smoke_SkipProxy_CppProxy(JniReference globalRef, jint _jHashCode) noexcept + : CppProxyBase(std::move(globalRef), _jHashCode, "com_example_smoke_SkipProxy") { } + ::std::string com_example_smoke_SkipProxy_CppProxy::not_in_java( const ::std::string& ninput ) { + return {}; + } + bool com_example_smoke_SkipProxy_CppProxy::not_in_swift( const bool ninput ) { + JNIEnv* jniEnv = getJniEnvironment( ); jboolean jinput = ninput; auto _result = callJavaMethod( "notInSwift", "(Z)Z", jniEnv , jinput); + checkExceptionAndReportIfAny(jniEnv); + return _result; + + + } + float com_example_smoke_SkipProxy_CppProxy::not_in_dart( const float ninput ) { + JNIEnv* jniEnv = getJniEnvironment( ); jfloat jinput = ninput; auto _result = callJavaMethod( "notInDart", "(F)F", jniEnv , jinput); + checkExceptionAndReportIfAny(jniEnv); + return _result; + + + } + + ::std::string com_example_smoke_SkipProxy_CppProxy::get_skipped_in_java( ) const { + return {}; + } + + + void com_example_smoke_SkipProxy_CppProxy::set_skipped_in_java( const ::std::string& nvalue ) { + + + } + + + bool com_example_smoke_SkipProxy_CppProxy::is_skipped_in_swift( ) const { + JNIEnv* jniEnv = getJniEnvironment( ); auto _result = callJavaMethod( "isSkippedInSwift", "()Z", jniEnv ); + checkExceptionAndReportIfAny(jniEnv); + return _result; + + + } + + + void com_example_smoke_SkipProxy_CppProxy::set_skipped_in_swift( const bool nvalue ) { + JNIEnv* jniEnv = getJniEnvironment( ); jboolean jvalue = nvalue; callJavaMethod( "setSkippedInSwift", "(Z)V", jniEnv , jvalue); + checkExceptionAndReportIfAny(jniEnv); + + + } + + + float com_example_smoke_SkipProxy_CppProxy::get_skipped_in_dart( ) const { + JNIEnv* jniEnv = getJniEnvironment( ); auto _result = callJavaMethod( "getSkippedInDart", "()F", jniEnv ); + checkExceptionAndReportIfAny(jniEnv); + return _result; + + + } + + + void com_example_smoke_SkipProxy_CppProxy::set_skipped_in_dart( const float nvalue ) { + JNIEnv* jniEnv = getJniEnvironment( ); jfloat jvalue = nvalue; callJavaMethod( "setSkippedInDart", "(F)V", jniEnv , jvalue); + checkExceptionAndReportIfAny(jniEnv); + + + } + + + ::smoke::SkippedEverywhere com_example_smoke_SkipProxy_CppProxy::get_skipped_everywhere( ) const { + return {}; + } + + + void com_example_smoke_SkipProxy_CppProxy::set_skipped_everywhere( const ::smoke::SkippedEverywhere& nvalue ) { + + + } + + + ::smoke::SkippedEverywhereEnum com_example_smoke_SkipProxy_CppProxy::get_skipped_everywhere_too( ) const { + return {}; + } + + + void com_example_smoke_SkipProxy_CppProxy::set_skipped_everywhere_too( const ::smoke::SkippedEverywhereEnum nvalue ) { + + + +} + + } } -} \ No newline at end of file diff --git a/gluecodium/src/test/resources/smoke/skip/output/android/jni/com_example_smoke_SkipSetterImplCppProxy.cpp b/gluecodium/src/test/resources/smoke/skip/output/android/jni/com_example_smoke_SkipSetterImplCppProxy.cpp index 6b62caea15..89ca44d4b3 100644 --- a/gluecodium/src/test/resources/smoke/skip/output/android/jni/com_example_smoke_SkipSetterImplCppProxy.cpp +++ b/gluecodium/src/test/resources/smoke/skip/output/android/jni/com_example_smoke_SkipSetterImplCppProxy.cpp @@ -1,26 +1,46 @@ /* + * */ + #include "com_example_smoke_SkipSetterImplCppProxy.h" #include "com_example_smoke_SkipSetter__Conversion.h" #include "ArrayConversionUtils.h" #include "FieldAccessMethods.h" + namespace gluecodium { namespace jni { -com_example_smoke_SkipSetter_CppProxy::com_example_smoke_SkipSetter_CppProxy( JNIEnv* _jenv, JniReference globalRef, jint _jHashCode ) - : CppProxyBase( _jenv, std::move( globalRef ), _jHashCode, "com_example_smoke_SkipSetter" ) { + +com_example_smoke_SkipSetter_CppProxy::com_example_smoke_SkipSetter_CppProxy(JniReference globalRef, jint _jHashCode) noexcept + : CppProxyBase(std::move(globalRef), _jHashCode, "com_example_smoke_SkipSetter") { } + + ::std::string com_example_smoke_SkipSetter_CppProxy::get_foo( ) const { + JNIEnv* jniEnv = getJniEnvironment( ); auto _result = callJavaMethod( "getFoo", "()Ljava/lang/String;", jniEnv ); + checkExceptionAndReportIfAny(jniEnv); + return convert_from_jni( jniEnv, _result, (::std::string*)nullptr ); + + + } + + + void com_example_smoke_SkipSetter_CppProxy::set_foo( const ::std::string& nvalue ) { + + + +} + + } } -} \ No newline at end of file diff --git a/gluecodium/src/test/resources/smoke/skip/output/android/jni/com_example_smoke_SkipSetterImplCppProxy.h b/gluecodium/src/test/resources/smoke/skip/output/android/jni/com_example_smoke_SkipSetterImplCppProxy.h index 8417d5e7b0..63b70583a3 100644 --- a/gluecodium/src/test/resources/smoke/skip/output/android/jni/com_example_smoke_SkipSetterImplCppProxy.h +++ b/gluecodium/src/test/resources/smoke/skip/output/android/jni/com_example_smoke_SkipSetterImplCppProxy.h @@ -1,21 +1,32 @@ /* + * */ + #pragma once + #include "smoke/SkipSetter.h" #include "CppProxyBase.h" #include "JniReference.h" + namespace gluecodium { namespace jni { -class com_example_smoke_SkipSetter_CppProxy : public CppProxyBase, public ::smoke::SkipSetter { + +class com_example_smoke_SkipSetter_CppProxy final : public CppProxyBase, public ::smoke::SkipSetter { public: - com_example_smoke_SkipSetter_CppProxy( JNIEnv* _jenv, JniReference globalRef, jint _jHashCode ); + com_example_smoke_SkipSetter_CppProxy( JniReference globalRef, jint _jHashCode ) noexcept; com_example_smoke_SkipSetter_CppProxy( const com_example_smoke_SkipSetter_CppProxy& ) = delete; com_example_smoke_SkipSetter_CppProxy& operator=( const com_example_smoke_SkipSetter_CppProxy& ) = delete; + + + ::std::string get_foo( ) const override; + void set_foo( const ::std::string& nvalue ) override; + }; + } } diff --git a/gluecodium/src/test/resources/smoke/skip/output/android/jni/com_example_smoke_SkipTagsInJavaImplCppProxy.cpp b/gluecodium/src/test/resources/smoke/skip/output/android/jni/com_example_smoke_SkipTagsInJavaImplCppProxy.cpp index b7a51b5ea0..7944d37f16 100644 --- a/gluecodium/src/test/resources/smoke/skip/output/android/jni/com_example_smoke_SkipTagsInJavaImplCppProxy.cpp +++ b/gluecodium/src/test/resources/smoke/skip/output/android/jni/com_example_smoke_SkipTagsInJavaImplCppProxy.cpp @@ -1,28 +1,47 @@ /* + * */ + #include "com_example_smoke_SkipTagsInJavaImplCppProxy.h" #include "com_example_smoke_SkipTagsInJava__Conversion.h" #include "ArrayConversionUtils.h" #include "FieldAccessMethods.h" + namespace gluecodium { namespace jni { -com_example_smoke_SkipTagsInJava_CppProxy::com_example_smoke_SkipTagsInJava_CppProxy( JNIEnv* _jenv, JniReference globalRef, jint _jHashCode ) - : CppProxyBase( _jenv, std::move( globalRef ), _jHashCode, "com_example_smoke_SkipTagsInJava" ) { + +com_example_smoke_SkipTagsInJava_CppProxy::com_example_smoke_SkipTagsInJava_CppProxy(JniReference globalRef, jint _jHashCode) noexcept + : CppProxyBase(std::move(globalRef), _jHashCode, "com_example_smoke_SkipTagsInJava") { } + void com_example_smoke_SkipTagsInJava_CppProxy::skip_tagged( ) { + + + } + void com_example_smoke_SkipTagsInJava_CppProxy::dont_skip_tagged( ) { + JNIEnv* jniEnv = getJniEnvironment( ); callJavaMethod( "dontSkipTagged", "()V", jniEnv ); + checkExceptionAndReportIfAny(jniEnv); + + + } + void com_example_smoke_SkipTagsInJava_CppProxy::skip_tagged_list( ) { + + + +} + } } -} \ No newline at end of file