From 760172471aa7410b1894a2d2c3b9e2e3b8dcc38f Mon Sep 17 00:00:00 2001 From: Marc Rousavy Date: Thu, 9 Jan 2025 14:21:18 +0100 Subject: [PATCH] fix: Fix downcasting WOOHOOO --- .../src/syntax/kotlin/KotlinCxxBridgedType.ts | 38 ++++- .../nitrogen/src/syntax/kotlin/KotlinEnum.ts | 1 + .../src/syntax/kotlin/KotlinFunction.ts | 145 ++++++++++++++---- .../src/syntax/kotlin/KotlinStruct.ts | 1 + .../generated/android/NitroImageOnLoad.cpp | 32 ++-- .../nitrogen/generated/android/c++/JCar.hpp | 1 + ...JFunc_std__shared_ptr_Promise_double__.hpp | 45 ++++-- ...ise_std__shared_ptr_Promise_double____.hpp | 56 +++++-- ...omise_std__shared_ptr_ArrayBuffer_____.hpp | 56 +++++-- ..._std__shared_ptr_Promise_std__string__.hpp | 45 ++++-- .../generated/android/c++/JFunc_void.hpp | 33 ++-- .../android/c++/JFunc_void_double.hpp | 33 ++-- .../c++/JFunc_void_std__optional_double_.hpp | 33 ++-- .../android/c++/JFunc_void_std__string.hpp | 33 ++-- .../JFunc_void_std__vector_Powertrain_.hpp | 41 +++-- .../android/c++/JHybridImageSpec.cpp | 2 +- .../c++/JHybridTestObjectSwiftKotlinSpec.cpp | 42 +++-- .../generated/android/c++/JImageFormat.hpp | 1 + .../generated/android/c++/JImageSize.hpp | 1 + .../generated/android/c++/JJsStyleStruct.hpp | 14 +- .../generated/android/c++/JOldEnum.hpp | 1 + .../generated/android/c++/JPerson.hpp | 1 + .../generated/android/c++/JPixelFormat.hpp | 1 + .../generated/android/c++/JPowertrain.hpp | 1 + .../Func_std__shared_ptr_Promise_double__.kt | 55 +++++-- ...mise_std__shared_ptr_Promise_double____.kt | 55 +++++-- ...romise_std__shared_ptr_ArrayBuffer_____.kt | 55 +++++-- ...c_std__shared_ptr_Promise_std__string__.kt | 55 +++++-- .../com/margelo/nitro/image/Func_void.kt | 55 +++++-- .../margelo/nitro/image/Func_void_double.kt | 55 +++++-- .../image/Func_void_std__optional_double_.kt | 55 +++++-- .../nitro/image/Func_void_std__string.kt | 55 +++++-- .../Func_void_std__vector_Powertrain_.kt | 55 +++++-- .../margelo/nitro/image/HybridImageSpec.kt | 2 +- .../image/HybridTestObjectSwiftKotlinSpec.kt | 24 +-- .../com/margelo/nitro/image/JsStyleStruct.kt | 4 - 36 files changed, 902 insertions(+), 280 deletions(-) diff --git a/packages/nitrogen/src/syntax/kotlin/KotlinCxxBridgedType.ts b/packages/nitrogen/src/syntax/kotlin/KotlinCxxBridgedType.ts index 9bd63e880..af598ef3e 100644 --- a/packages/nitrogen/src/syntax/kotlin/KotlinCxxBridgedType.ts +++ b/packages/nitrogen/src/syntax/kotlin/KotlinCxxBridgedType.ts @@ -440,9 +440,9 @@ export class KotlinCxxBridgedType implements BridgedType<'kotlin', 'c++'> { switch (language) { case 'c++': const func = getTypeAs(this.type, FunctionType) - return `J${func.specializationName}::fromCpp(${parameterName})` + return `J${func.specializationName}_cxx::fromCpp(${parameterName})` case 'kotlin': - return `${parameterName}.toLambda()` + return `${parameterName} /* TODO: Does this work? */` default: return parameterName } @@ -690,14 +690,44 @@ export class KotlinCxxBridgedType implements BridgedType<'kotlin', 'c++'> { true ) return `${parameterName} != nullptr ? std::make_optional(${parsed}) : std::nullopt` + case 'kotlin': + if (bridge.needsSpecialHandling) { + return `${parameterName}?.let { ${bridge.parseFromKotlinToCpp('it', language, isBoxed)} }` + } else { + return parameterName + } default: return parameterName } } case 'function': { + const functionType = getTypeAs(this.type, FunctionType) switch (language) { - case 'c++': - return `${parameterName}->cthis()->getFunction()` + case 'c++': { + const returnType = functionType.returnType.getCode('c++') + const params = functionType.parameters.map( + (p) => `${p.getCode('c++')} ${p.escapedName}` + ) + const paramsForward = functionType.parameters.map( + (p) => p.escapedName + ) + const jniType = `J${functionType.specializationName}_cxx` + return ` +[&]() -> ${functionType.getCode('c++')} { + if (${parameterName}->isInstanceOf(${jniType}::javaClassStatic())) [[likely]] { + auto downcast = jni::static_ref_cast<${jniType}::javaobject>(${parameterName}); + return downcast->cthis()->getFunction(); + } else { + return [${parameterName}](${params.join(', ')}) -> ${returnType} { + return ${parameterName}->invoke(${paramsForward}); + }; + } +}() + `.trim() + } + case 'kotlin': { + return `${functionType.specializationName}_java(${parameterName})` + } default: return parameterName } diff --git a/packages/nitrogen/src/syntax/kotlin/KotlinEnum.ts b/packages/nitrogen/src/syntax/kotlin/KotlinEnum.ts index 2ca6d99e1..c5f4b83fa 100644 --- a/packages/nitrogen/src/syntax/kotlin/KotlinEnum.ts +++ b/packages/nitrogen/src/syntax/kotlin/KotlinEnum.ts @@ -60,6 +60,7 @@ namespace ${cxxNamespace} { * Convert this Java/Kotlin-based enum to the C++ enum ${enumType.enumName}. */ [[maybe_unused]] + [[nodiscard]] ${enumType.enumName} toCpp() const { static const auto clazz = javaClassStatic(); static const auto fieldOrdinal = clazz->getField("_ordinal"); diff --git a/packages/nitrogen/src/syntax/kotlin/KotlinFunction.ts b/packages/nitrogen/src/syntax/kotlin/KotlinFunction.ts index 6940aac39..3272098c7 100644 --- a/packages/nitrogen/src/syntax/kotlin/KotlinFunction.ts +++ b/packages/nitrogen/src/syntax/kotlin/KotlinFunction.ts @@ -14,7 +14,11 @@ export function createKotlinFunction(functionType: FunctionType): SourceFile[] { const kotlinParams = functionType.parameters.map( (p) => `${p.escapedName}: ${p.getCode('kotlin')}` ) - const lambdaSignature = `(${kotlinParams.join(', ')}) -> ${kotlinReturnType}` + const kotlinParamTypes = functionType.parameters.map((p) => + p.getCode('kotlin') + ) + const kotlinParamsForward = functionType.parameters.map((p) => p.escapedName) + const lambdaSignature = `(${kotlinParamTypes.join(', ')}) -> ${kotlinReturnType}` const kotlinCode = ` ${createFileMetadataString(`${name}.kt`)} @@ -27,14 +31,37 @@ import com.facebook.proguard.annotations.DoNotStrip import com.margelo.nitro.core.* import dalvik.annotation.optimization.FastNative +/** + * Represents the JavaScript callback \`${functionType.jsName}\`. + * This can be either implemented in C++ (in which case it might be a callback coming from JS), + * or in Kotlin/Java (in which case it is a native callback). + */ +@DoNotStrip +@Keep +@Suppress("ClassName", "RedundantUnitReturnType") +fun interface ${name}: ${lambdaSignature} { + /** + * Call the given JS callback. + * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted. + */ + @DoNotStrip + @Keep + override fun invoke(${kotlinParams.join(', ')}): ${kotlinReturnType} +} + /** * Represents the JavaScript callback \`${functionType.jsName}\`. * This is implemented in C++, via a \`std::function<...>\`. + * The callback might be coming from JS. */ @DoNotStrip @Keep -@Suppress("RedundantSuppression", "ConvertSecondaryConstructorToPrimary", "RedundantUnitReturnType", "KotlinJniMissingFunction", "ClassName", "unused", "LocalVariableName") -class ${name} { +@Suppress( + "KotlinJniMissingFunction", "unused", + "RedundantSuppression", "RedundantUnitReturnType", + "ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName", +) +class ${name}_cxx: ${name} { @DoNotStrip @Keep private val mHybridData: HybridData @@ -45,23 +72,37 @@ class ${name} { mHybridData = hybridData } - /** - * Converts this function to a Kotlin Lambda. - * This exists purely as syntactic sugar, and has minimal runtime overhead. - */ - fun toLambda(): ${lambdaSignature} = this::call - - /** - * Call the given JS callback. - * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted. - */ @FastNative - external fun call(${kotlinParams.join(', ')}): ${kotlinReturnType} + external override fun invoke(${kotlinParams.join(', ')}): ${kotlinReturnType} +} + +/** + * Represents the JavaScript callback \`${functionType.jsName}\`. + * This is implemented in Java/Kotlin, via a \`${lambdaSignature}\`. + * The callback is always coming from native. + */ +@DoNotStrip +@Keep +@Suppress("ClassName", "RedundantUnitReturnType", "unused") +class ${name}_java(private val function: ${lambdaSignature}): ${name} { + @DoNotStrip + @Keep + override fun invoke(${kotlinParams.join(', ')}): ${kotlinReturnType} { + return this.function(${kotlinParamsForward.join(', ')}) + } } `.trim() + const jniInterfaceDescriptor = NitroConfig.getAndroidPackage('c++/jni', name) + const jniClassDescriptor = NitroConfig.getAndroidPackage( + 'c++/jni', + `${name}_cxx` + ) const bridgedReturn = new KotlinCxxBridgedType(functionType.returnType) + const cxxNamespace = NitroConfig.getCxxNamespace('c++') + const typename = functionType.getCode('c++') + // call() Java -> C++ const cppParams = functionType.parameters.map((p) => { const bridge = new KotlinCxxBridgedType(p) const type = bridge.asJniReferenceType('alias') @@ -71,19 +112,49 @@ class ${name} { const bridge = new KotlinCxxBridgedType(p) return bridge.parseFromKotlinToCpp(p.escapedName, 'c++', false) }) - const jniClassDescriptor = NitroConfig.getAndroidPackage('c++/jni', name) - const cxxNamespace = NitroConfig.getCxxNamespace('c++') - const typename = functionType.getCode('c++') - let callBody: string + + // call() C++ -> Java + const jniParams = functionType.parameters.map((p) => { + if (p.canBePassedByReference) { + return `const ${p.getCode('c++')}& ${p.escapedName}` + } else { + return `${p.getCode('c++')} ${p.escapedName}` + } + }) + const jniParamsForward = [ + 'self()', + ...functionType.parameters.map((p) => { + const bridge = new KotlinCxxBridgedType(p) + return bridge.parseFromCppToKotlin(p.escapedName, 'c++', false) + }), + ] + const jniSignature = `${bridgedReturn.asJniReferenceType('local')}(${functionType.parameters + .map((p) => { + const bridge = new KotlinCxxBridgedType(p) + return `${bridge.asJniReferenceType('alias')} /* ${p.escapedName} */` + }) + .join(', ')})` + + let cppCallBody: string + let jniCallBody: string if (functionType.returnType.kind === 'void') { // It returns void - callBody = `_func(${indent(paramsForward.join(', '), ' ')});` + cppCallBody = `_func(${indent(paramsForward.join(', '), ' ')});` + jniCallBody = ` +static const auto method = getClass()->getMethod<${jniSignature}>("invoke"); +method(${jniParamsForward.join(', ')}); + `.trim() } else { // It returns a type! - callBody = ` + cppCallBody = ` ${functionType.returnType.getCode('c++')} __result = _func(${indent(paramsForward.join(', '), ' ')}); return ${bridgedReturn.parseFromCppToKotlin('__result', 'c++')}; `.trim() + jniCallBody = ` +static const auto method = getClass()->getMethod<${jniSignature}>("invoke"); +auto __result = method(${jniParamsForward.join(', ')}); +return ${bridgedReturn.parseFromKotlinToCpp('__result', 'c++', false)}; + `.trim() } const bridged = new KotlinCxxBridgedType(functionType) @@ -107,21 +178,35 @@ namespace ${cxxNamespace} { using namespace facebook; /** - * C++ representation of the callback ${name}. - * This is a Kotlin \`${functionType.getCode('kotlin')}\`, backed by a \`std::function<...>\`. + * Represents the Java/Kotlin callback \`${functionType.getCode('kotlin')}\`. + * This can be passed around between C++ and Java/Kotlin. + */ + struct J${name}: public jni::JavaClass { + public: + static auto constexpr kJavaDescriptor = "L${jniInterfaceDescriptor};"; + + public: + ${functionType.returnType.getCode('c++')} invoke(${jniParams.join(', ')}) const { + ${indent(jniCallBody, ' ')} + } + }; + + /** + * An implementation of ${name} that is backed by a C++ implementation (using \`std::function<...>\`) */ - struct J${name} final: public jni::HybridClass { + struct J${name}_cxx final: public jni::HybridClass { public: - static jni::local_ref fromCpp(const ${typename}& func) { - return J${name}::newObjectCxxArgs(func); + static jni::local_ref fromCpp(const ${typename}& func) { + return J${name}_cxx::newObjectCxxArgs(func); } public: - ${bridgedReturn.asJniReferenceType('local')} call(${cppParams.join(', ')}) { - ${indent(callBody, ' ')} + ${bridgedReturn.asJniReferenceType('local')} invoke_cxx(${cppParams.join(', ')}) { + ${indent(cppCallBody, ' ')} } public: + [[nodiscard]] inline const ${typename}& getFunction() const { return _func; } @@ -129,11 +214,11 @@ namespace ${cxxNamespace} { public: static auto constexpr kJavaDescriptor = "L${jniClassDescriptor};"; static void registerNatives() { - registerHybrid({makeNativeMethod("call", J${name}::call)}); + registerHybrid({makeNativeMethod("invoke", J${name}_cxx::invoke_cxx)}); } private: - explicit J${name}(const ${typename}& func): _func(func) { } + explicit J${name}_cxx(const ${typename}& func): _func(func) { } private: friend HybridBase; @@ -146,7 +231,7 @@ namespace ${cxxNamespace} { // Make sure we register all native JNI methods on app startup addJNINativeRegistration({ namespace: cxxNamespace, - className: `J${name}`, + className: `J${name}_cxx`, import: { name: `J${name}.hpp`, space: 'user', diff --git a/packages/nitrogen/src/syntax/kotlin/KotlinStruct.ts b/packages/nitrogen/src/syntax/kotlin/KotlinStruct.ts index 79951b88d..ccd15eea9 100644 --- a/packages/nitrogen/src/syntax/kotlin/KotlinStruct.ts +++ b/packages/nitrogen/src/syntax/kotlin/KotlinStruct.ts @@ -101,6 +101,7 @@ namespace ${cxxNamespace} { * Convert this Java/Kotlin-based struct to the C++ struct ${structType.structName} by copying all values to C++. */ [[maybe_unused]] + [[nodiscard]] ${structType.structName} toCpp() const { ${indent(jniStructInitializerBody, ' ')} } diff --git a/packages/react-native-nitro-image/nitrogen/generated/android/NitroImageOnLoad.cpp b/packages/react-native-nitro-image/nitrogen/generated/android/NitroImageOnLoad.cpp index 49930ff29..634ac2f87 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/android/NitroImageOnLoad.cpp +++ b/packages/react-native-nitro-image/nitrogen/generated/android/NitroImageOnLoad.cpp @@ -43,24 +43,24 @@ int initialize(JavaVM* vm) { return facebook::jni::initialize(vm, [] { // Register native JNI methods margelo::nitro::image::JHybridImageSpec::registerNatives(); - margelo::nitro::image::JFunc_void_std__string::registerNatives(); + margelo::nitro::image::JFunc_void_std__string_cxx::registerNatives(); margelo::nitro::image::JHybridImageFactorySpec::registerNatives(); margelo::nitro::image::JHybridTestObjectSwiftKotlinSpec::registerNatives(); - margelo::nitro::image::JFunc_void_double::registerNatives(); - margelo::nitro::image::JFunc_void_double::registerNatives(); - margelo::nitro::image::JFunc_void_std__vector_Powertrain_::registerNatives(); - margelo::nitro::image::JFunc_void::registerNatives(); - margelo::nitro::image::JFunc_void::registerNatives(); - margelo::nitro::image::JFunc_void::registerNatives(); - margelo::nitro::image::JFunc_void::registerNatives(); - margelo::nitro::image::JFunc_void_std__optional_double_::registerNatives(); - margelo::nitro::image::JFunc_std__shared_ptr_Promise_double__::registerNatives(); - margelo::nitro::image::JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_double____::registerNatives(); - margelo::nitro::image::JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer_____::registerNatives(); - margelo::nitro::image::JFunc_std__shared_ptr_Promise_double__::registerNatives(); - margelo::nitro::image::JFunc_std__shared_ptr_Promise_std__string__::registerNatives(); - margelo::nitro::image::JFunc_void_std__string::registerNatives(); - margelo::nitro::image::JFunc_void_double::registerNatives(); + margelo::nitro::image::JFunc_void_double_cxx::registerNatives(); + margelo::nitro::image::JFunc_void_double_cxx::registerNatives(); + margelo::nitro::image::JFunc_void_std__vector_Powertrain__cxx::registerNatives(); + margelo::nitro::image::JFunc_void_cxx::registerNatives(); + margelo::nitro::image::JFunc_void_cxx::registerNatives(); + margelo::nitro::image::JFunc_void_cxx::registerNatives(); + margelo::nitro::image::JFunc_void_cxx::registerNatives(); + margelo::nitro::image::JFunc_void_std__optional_double__cxx::registerNatives(); + margelo::nitro::image::JFunc_std__shared_ptr_Promise_double___cxx::registerNatives(); + margelo::nitro::image::JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_double_____cxx::registerNatives(); + margelo::nitro::image::JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer______cxx::registerNatives(); + margelo::nitro::image::JFunc_std__shared_ptr_Promise_double___cxx::registerNatives(); + margelo::nitro::image::JFunc_std__shared_ptr_Promise_std__string___cxx::registerNatives(); + margelo::nitro::image::JFunc_void_std__string_cxx::registerNatives(); + margelo::nitro::image::JFunc_void_double_cxx::registerNatives(); margelo::nitro::image::JHybridBaseSpec::registerNatives(); margelo::nitro::image::JHybridChildSpec::registerNatives(); diff --git a/packages/react-native-nitro-image/nitrogen/generated/android/c++/JCar.hpp b/packages/react-native-nitro-image/nitrogen/generated/android/c++/JCar.hpp index db06c58ee..c3e457351 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/android/c++/JCar.hpp +++ b/packages/react-native-nitro-image/nitrogen/generated/android/c++/JCar.hpp @@ -33,6 +33,7 @@ namespace margelo::nitro::image { * Convert this Java/Kotlin-based struct to the C++ struct Car by copying all values to C++. */ [[maybe_unused]] + [[nodiscard]] Car toCpp() const { static const auto clazz = javaClassStatic(); static const auto fieldYear = clazz->getField("year"); diff --git a/packages/react-native-nitro-image/nitrogen/generated/android/c++/JFunc_std__shared_ptr_Promise_double__.hpp b/packages/react-native-nitro-image/nitrogen/generated/android/c++/JFunc_std__shared_ptr_Promise_double__.hpp index 684b54fb9..8e158aab9 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/android/c++/JFunc_std__shared_ptr_Promise_double__.hpp +++ b/packages/react-native-nitro-image/nitrogen/generated/android/c++/JFunc_std__shared_ptr_Promise_double__.hpp @@ -19,17 +19,43 @@ namespace margelo::nitro::image { using namespace facebook; /** - * C++ representation of the callback Func_std__shared_ptr_Promise_double__. - * This is a Kotlin `() -> Promise`, backed by a `std::function<...>`. + * Represents the Java/Kotlin callback `() -> Promise`. + * This can be passed around between C++ and Java/Kotlin. */ - struct JFunc_std__shared_ptr_Promise_double__ final: public jni::HybridClass { + struct JFunc_std__shared_ptr_Promise_double__: public jni::JavaClass { public: - static jni::local_ref fromCpp(const std::function>()>& func) { - return JFunc_std__shared_ptr_Promise_double__::newObjectCxxArgs(func); + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_std__shared_ptr_Promise_double__;"; + + public: + std::shared_ptr> invoke() const { + static const auto method = getClass()->getMethod()>("invoke"); + auto __result = method(self()); + return [&]() { + auto __promise = Promise::create(); + __result->cthis()->addOnResolvedListener([=](const jni::alias_ref& __boxedResult) { + auto __result = jni::static_ref_cast(__boxedResult); + __promise->resolve(__result->value()); + }); + __result->cthis()->addOnRejectedListener([=](const jni::alias_ref& __throwable) { + jni::JniException __jniError(__throwable); + __promise->reject(std::make_exception_ptr(__jniError)); + }); + return __promise; + }(); } + }; + /** + * An implementation of Func_std__shared_ptr_Promise_double__ that is backed by a C++ implementation (using `std::function<...>`) + */ + struct JFunc_std__shared_ptr_Promise_double___cxx final: public jni::HybridClass { public: - jni::local_ref call() { + static jni::local_ref fromCpp(const std::function>()>& func) { + return JFunc_std__shared_ptr_Promise_double___cxx::newObjectCxxArgs(func); + } + + public: + jni::local_ref invoke_cxx() { std::shared_ptr> __result = _func(); return [&]() { jni::local_ref __localPromise = JPromise::create(); @@ -46,18 +72,19 @@ namespace margelo::nitro::image { } public: + [[nodiscard]] inline const std::function>()>& getFunction() const { return _func; } public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_std__shared_ptr_Promise_double__;"; + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_std__shared_ptr_Promise_double___cxx;"; static void registerNatives() { - registerHybrid({makeNativeMethod("call", JFunc_std__shared_ptr_Promise_double__::call)}); + registerHybrid({makeNativeMethod("invoke", JFunc_std__shared_ptr_Promise_double___cxx::invoke_cxx)}); } private: - explicit JFunc_std__shared_ptr_Promise_double__(const std::function>()>& func): _func(func) { } + explicit JFunc_std__shared_ptr_Promise_double___cxx(const std::function>()>& func): _func(func) { } private: friend HybridBase; diff --git a/packages/react-native-nitro-image/nitrogen/generated/android/c++/JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_double____.hpp b/packages/react-native-nitro-image/nitrogen/generated/android/c++/JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_double____.hpp index df79df6ed..d8f6cc669 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/android/c++/JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_double____.hpp +++ b/packages/react-native-nitro-image/nitrogen/generated/android/c++/JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_double____.hpp @@ -19,17 +19,54 @@ namespace margelo::nitro::image { using namespace facebook; /** - * C++ representation of the callback Func_std__shared_ptr_Promise_std__shared_ptr_Promise_double____. - * This is a Kotlin `() -> Promise>`, backed by a `std::function<...>`. + * Represents the Java/Kotlin callback `() -> Promise>`. + * This can be passed around between C++ and Java/Kotlin. */ - struct JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_double____ final: public jni::HybridClass { + struct JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_double____: public jni::JavaClass { public: - static jni::local_ref fromCpp(const std::function>>>()>& func) { - return JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_double____::newObjectCxxArgs(func); + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_std__shared_ptr_Promise_std__shared_ptr_Promise_double____;"; + + public: + std::shared_ptr>>> invoke() const { + static const auto method = getClass()->getMethod()>("invoke"); + auto __result = method(self()); + return [&]() { + auto __promise = Promise>>::create(); + __result->cthis()->addOnResolvedListener([=](const jni::alias_ref& __boxedResult) { + auto __result = jni::static_ref_cast(__boxedResult); + __promise->resolve([&]() { + auto __promise = Promise::create(); + __result->cthis()->addOnResolvedListener([=](const jni::alias_ref& __boxedResult) { + auto __result = jni::static_ref_cast(__boxedResult); + __promise->resolve(__result->value()); + }); + __result->cthis()->addOnRejectedListener([=](const jni::alias_ref& __throwable) { + jni::JniException __jniError(__throwable); + __promise->reject(std::make_exception_ptr(__jniError)); + }); + return __promise; + }()); + }); + __result->cthis()->addOnRejectedListener([=](const jni::alias_ref& __throwable) { + jni::JniException __jniError(__throwable); + __promise->reject(std::make_exception_ptr(__jniError)); + }); + return __promise; + }(); + } + }; + + /** + * An implementation of Func_std__shared_ptr_Promise_std__shared_ptr_Promise_double____ that is backed by a C++ implementation (using `std::function<...>`) + */ + struct JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_double_____cxx final: public jni::HybridClass { + public: + static jni::local_ref fromCpp(const std::function>>>()>& func) { + return JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_double_____cxx::newObjectCxxArgs(func); } public: - jni::local_ref call() { + jni::local_ref invoke_cxx() { std::shared_ptr>>> __result = _func(); return [&]() { jni::local_ref __localPromise = JPromise::create(); @@ -57,18 +94,19 @@ namespace margelo::nitro::image { } public: + [[nodiscard]] inline const std::function>>>()>& getFunction() const { return _func; } public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_std__shared_ptr_Promise_std__shared_ptr_Promise_double____;"; + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_std__shared_ptr_Promise_std__shared_ptr_Promise_double_____cxx;"; static void registerNatives() { - registerHybrid({makeNativeMethod("call", JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_double____::call)}); + registerHybrid({makeNativeMethod("invoke", JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_double_____cxx::invoke_cxx)}); } private: - explicit JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_double____(const std::function>>>()>& func): _func(func) { } + explicit JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_double_____cxx(const std::function>>>()>& func): _func(func) { } private: friend HybridBase; diff --git a/packages/react-native-nitro-image/nitrogen/generated/android/c++/JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer_____.hpp b/packages/react-native-nitro-image/nitrogen/generated/android/c++/JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer_____.hpp index 37863b857..bc545bcd5 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/android/c++/JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer_____.hpp +++ b/packages/react-native-nitro-image/nitrogen/generated/android/c++/JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer_____.hpp @@ -22,17 +22,54 @@ namespace margelo::nitro::image { using namespace facebook; /** - * C++ representation of the callback Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer_____. - * This is a Kotlin `() -> Promise>`, backed by a `std::function<...>`. + * Represents the Java/Kotlin callback `() -> Promise>`. + * This can be passed around between C++ and Java/Kotlin. */ - struct JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer_____ final: public jni::HybridClass { + struct JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer_____: public jni::JavaClass { public: - static jni::local_ref fromCpp(const std::function>>>>()>& func) { - return JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer_____::newObjectCxxArgs(func); + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer_____;"; + + public: + std::shared_ptr>>>> invoke() const { + static const auto method = getClass()->getMethod()>("invoke"); + auto __result = method(self()); + return [&]() { + auto __promise = Promise>>>::create(); + __result->cthis()->addOnResolvedListener([=](const jni::alias_ref& __boxedResult) { + auto __result = jni::static_ref_cast(__boxedResult); + __promise->resolve([&]() { + auto __promise = Promise>::create(); + __result->cthis()->addOnResolvedListener([=](const jni::alias_ref& __boxedResult) { + auto __result = jni::static_ref_cast(__boxedResult); + __promise->resolve(__result->cthis()->getArrayBuffer()); + }); + __result->cthis()->addOnRejectedListener([=](const jni::alias_ref& __throwable) { + jni::JniException __jniError(__throwable); + __promise->reject(std::make_exception_ptr(__jniError)); + }); + return __promise; + }()); + }); + __result->cthis()->addOnRejectedListener([=](const jni::alias_ref& __throwable) { + jni::JniException __jniError(__throwable); + __promise->reject(std::make_exception_ptr(__jniError)); + }); + return __promise; + }(); + } + }; + + /** + * An implementation of Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer_____ that is backed by a C++ implementation (using `std::function<...>`) + */ + struct JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer______cxx final: public jni::HybridClass { + public: + static jni::local_ref fromCpp(const std::function>>>>()>& func) { + return JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer______cxx::newObjectCxxArgs(func); } public: - jni::local_ref call() { + jni::local_ref invoke_cxx() { std::shared_ptr>>>> __result = _func(); return [&]() { jni::local_ref __localPromise = JPromise::create(); @@ -60,18 +97,19 @@ namespace margelo::nitro::image { } public: + [[nodiscard]] inline const std::function>>>>()>& getFunction() const { return _func; } public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer_____;"; + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer______cxx;"; static void registerNatives() { - registerHybrid({makeNativeMethod("call", JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer_____::call)}); + registerHybrid({makeNativeMethod("invoke", JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer______cxx::invoke_cxx)}); } private: - explicit JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer_____(const std::function>>>>()>& func): _func(func) { } + explicit JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer______cxx(const std::function>>>>()>& func): _func(func) { } private: friend HybridBase; diff --git a/packages/react-native-nitro-image/nitrogen/generated/android/c++/JFunc_std__shared_ptr_Promise_std__string__.hpp b/packages/react-native-nitro-image/nitrogen/generated/android/c++/JFunc_std__shared_ptr_Promise_std__string__.hpp index bfde03c7a..51ddb92ee 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/android/c++/JFunc_std__shared_ptr_Promise_std__string__.hpp +++ b/packages/react-native-nitro-image/nitrogen/generated/android/c++/JFunc_std__shared_ptr_Promise_std__string__.hpp @@ -20,17 +20,43 @@ namespace margelo::nitro::image { using namespace facebook; /** - * C++ representation of the callback Func_std__shared_ptr_Promise_std__string__. - * This is a Kotlin `() -> Promise`, backed by a `std::function<...>`. + * Represents the Java/Kotlin callback `() -> Promise`. + * This can be passed around between C++ and Java/Kotlin. */ - struct JFunc_std__shared_ptr_Promise_std__string__ final: public jni::HybridClass { + struct JFunc_std__shared_ptr_Promise_std__string__: public jni::JavaClass { public: - static jni::local_ref fromCpp(const std::function>()>& func) { - return JFunc_std__shared_ptr_Promise_std__string__::newObjectCxxArgs(func); + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_std__shared_ptr_Promise_std__string__;"; + + public: + std::shared_ptr> invoke() const { + static const auto method = getClass()->getMethod()>("invoke"); + auto __result = method(self()); + return [&]() { + auto __promise = Promise::create(); + __result->cthis()->addOnResolvedListener([=](const jni::alias_ref& __boxedResult) { + auto __result = jni::static_ref_cast(__boxedResult); + __promise->resolve(__result->toStdString()); + }); + __result->cthis()->addOnRejectedListener([=](const jni::alias_ref& __throwable) { + jni::JniException __jniError(__throwable); + __promise->reject(std::make_exception_ptr(__jniError)); + }); + return __promise; + }(); } + }; + /** + * An implementation of Func_std__shared_ptr_Promise_std__string__ that is backed by a C++ implementation (using `std::function<...>`) + */ + struct JFunc_std__shared_ptr_Promise_std__string___cxx final: public jni::HybridClass { public: - jni::local_ref call() { + static jni::local_ref fromCpp(const std::function>()>& func) { + return JFunc_std__shared_ptr_Promise_std__string___cxx::newObjectCxxArgs(func); + } + + public: + jni::local_ref invoke_cxx() { std::shared_ptr> __result = _func(); return [&]() { jni::local_ref __localPromise = JPromise::create(); @@ -47,18 +73,19 @@ namespace margelo::nitro::image { } public: + [[nodiscard]] inline const std::function>()>& getFunction() const { return _func; } public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_std__shared_ptr_Promise_std__string__;"; + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_std__shared_ptr_Promise_std__string___cxx;"; static void registerNatives() { - registerHybrid({makeNativeMethod("call", JFunc_std__shared_ptr_Promise_std__string__::call)}); + registerHybrid({makeNativeMethod("invoke", JFunc_std__shared_ptr_Promise_std__string___cxx::invoke_cxx)}); } private: - explicit JFunc_std__shared_ptr_Promise_std__string__(const std::function>()>& func): _func(func) { } + explicit JFunc_std__shared_ptr_Promise_std__string___cxx(const std::function>()>& func): _func(func) { } private: friend HybridBase; diff --git a/packages/react-native-nitro-image/nitrogen/generated/android/c++/JFunc_void.hpp b/packages/react-native-nitro-image/nitrogen/generated/android/c++/JFunc_void.hpp index 5303f96f2..6626a59e9 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/android/c++/JFunc_void.hpp +++ b/packages/react-native-nitro-image/nitrogen/generated/android/c++/JFunc_void.hpp @@ -17,33 +17,48 @@ namespace margelo::nitro::image { using namespace facebook; /** - * C++ representation of the callback Func_void. - * This is a Kotlin `() -> Unit`, backed by a `std::function<...>`. + * Represents the Java/Kotlin callback `() -> Unit`. + * This can be passed around between C++ and Java/Kotlin. */ - struct JFunc_void final: public jni::HybridClass { + struct JFunc_void: public jni::JavaClass { public: - static jni::local_ref fromCpp(const std::function& func) { - return JFunc_void::newObjectCxxArgs(func); + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_void;"; + + public: + void invoke() const { + static const auto method = getClass()->getMethod("invoke"); + method(self()); + } + }; + + /** + * An implementation of Func_void that is backed by a C++ implementation (using `std::function<...>`) + */ + struct JFunc_void_cxx final: public jni::HybridClass { + public: + static jni::local_ref fromCpp(const std::function& func) { + return JFunc_void_cxx::newObjectCxxArgs(func); } public: - void call() { + void invoke_cxx() { _func(); } public: + [[nodiscard]] inline const std::function& getFunction() const { return _func; } public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_void;"; + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_void_cxx;"; static void registerNatives() { - registerHybrid({makeNativeMethod("call", JFunc_void::call)}); + registerHybrid({makeNativeMethod("invoke", JFunc_void_cxx::invoke_cxx)}); } private: - explicit JFunc_void(const std::function& func): _func(func) { } + explicit JFunc_void_cxx(const std::function& func): _func(func) { } private: friend HybridBase; diff --git a/packages/react-native-nitro-image/nitrogen/generated/android/c++/JFunc_void_double.hpp b/packages/react-native-nitro-image/nitrogen/generated/android/c++/JFunc_void_double.hpp index 1567a6284..8c3ecdac4 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/android/c++/JFunc_void_double.hpp +++ b/packages/react-native-nitro-image/nitrogen/generated/android/c++/JFunc_void_double.hpp @@ -17,33 +17,48 @@ namespace margelo::nitro::image { using namespace facebook; /** - * C++ representation of the callback Func_void_double. - * This is a Kotlin `(num: Double) -> Unit`, backed by a `std::function<...>`. + * Represents the Java/Kotlin callback `(num: Double) -> Unit`. + * This can be passed around between C++ and Java/Kotlin. */ - struct JFunc_void_double final: public jni::HybridClass { + struct JFunc_void_double: public jni::JavaClass { public: - static jni::local_ref fromCpp(const std::function& func) { - return JFunc_void_double::newObjectCxxArgs(func); + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_void_double;"; + + public: + void invoke(double num) const { + static const auto method = getClass()->getMethod("invoke"); + method(self(), num); + } + }; + + /** + * An implementation of Func_void_double that is backed by a C++ implementation (using `std::function<...>`) + */ + struct JFunc_void_double_cxx final: public jni::HybridClass { + public: + static jni::local_ref fromCpp(const std::function& func) { + return JFunc_void_double_cxx::newObjectCxxArgs(func); } public: - void call(double num) { + void invoke_cxx(double num) { _func(num); } public: + [[nodiscard]] inline const std::function& getFunction() const { return _func; } public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_void_double;"; + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_void_double_cxx;"; static void registerNatives() { - registerHybrid({makeNativeMethod("call", JFunc_void_double::call)}); + registerHybrid({makeNativeMethod("invoke", JFunc_void_double_cxx::invoke_cxx)}); } private: - explicit JFunc_void_double(const std::function& func): _func(func) { } + explicit JFunc_void_double_cxx(const std::function& func): _func(func) { } private: friend HybridBase; diff --git a/packages/react-native-nitro-image/nitrogen/generated/android/c++/JFunc_void_std__optional_double_.hpp b/packages/react-native-nitro-image/nitrogen/generated/android/c++/JFunc_void_std__optional_double_.hpp index 86d919c35..75c87c022 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/android/c++/JFunc_void_std__optional_double_.hpp +++ b/packages/react-native-nitro-image/nitrogen/generated/android/c++/JFunc_void_std__optional_double_.hpp @@ -18,33 +18,48 @@ namespace margelo::nitro::image { using namespace facebook; /** - * C++ representation of the callback Func_void_std__optional_double_. - * This is a Kotlin `(maybe: Double?) -> Unit`, backed by a `std::function<...>`. + * Represents the Java/Kotlin callback `(maybe: Double?) -> Unit`. + * This can be passed around between C++ and Java/Kotlin. */ - struct JFunc_void_std__optional_double_ final: public jni::HybridClass { + struct JFunc_void_std__optional_double_: public jni::JavaClass { public: - static jni::local_ref fromCpp(const std::function /* maybe */)>& func) { - return JFunc_void_std__optional_double_::newObjectCxxArgs(func); + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_void_std__optional_double_;"; + + public: + void invoke(std::optional maybe) const { + static const auto method = getClass()->getMethod /* maybe */)>("invoke"); + method(self(), maybe.has_value() ? jni::JDouble::valueOf(maybe.value()) : nullptr); + } + }; + + /** + * An implementation of Func_void_std__optional_double_ that is backed by a C++ implementation (using `std::function<...>`) + */ + struct JFunc_void_std__optional_double__cxx final: public jni::HybridClass { + public: + static jni::local_ref fromCpp(const std::function /* maybe */)>& func) { + return JFunc_void_std__optional_double__cxx::newObjectCxxArgs(func); } public: - void call(jni::alias_ref maybe) { + void invoke_cxx(jni::alias_ref maybe) { _func(maybe != nullptr ? std::make_optional(maybe->value()) : std::nullopt); } public: + [[nodiscard]] inline const std::function /* maybe */)>& getFunction() const { return _func; } public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_void_std__optional_double_;"; + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_void_std__optional_double__cxx;"; static void registerNatives() { - registerHybrid({makeNativeMethod("call", JFunc_void_std__optional_double_::call)}); + registerHybrid({makeNativeMethod("invoke", JFunc_void_std__optional_double__cxx::invoke_cxx)}); } private: - explicit JFunc_void_std__optional_double_(const std::function /* maybe */)>& func): _func(func) { } + explicit JFunc_void_std__optional_double__cxx(const std::function /* maybe */)>& func): _func(func) { } private: friend HybridBase; diff --git a/packages/react-native-nitro-image/nitrogen/generated/android/c++/JFunc_void_std__string.hpp b/packages/react-native-nitro-image/nitrogen/generated/android/c++/JFunc_void_std__string.hpp index 74ba49b31..cb8b4b642 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/android/c++/JFunc_void_std__string.hpp +++ b/packages/react-native-nitro-image/nitrogen/generated/android/c++/JFunc_void_std__string.hpp @@ -18,33 +18,48 @@ namespace margelo::nitro::image { using namespace facebook; /** - * C++ representation of the callback Func_void_std__string. - * This is a Kotlin `(valueFromJs: String) -> Unit`, backed by a `std::function<...>`. + * Represents the Java/Kotlin callback `(valueFromJs: String) -> Unit`. + * This can be passed around between C++ and Java/Kotlin. */ - struct JFunc_void_std__string final: public jni::HybridClass { + struct JFunc_void_std__string: public jni::JavaClass { public: - static jni::local_ref fromCpp(const std::function& func) { - return JFunc_void_std__string::newObjectCxxArgs(func); + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_void_std__string;"; + + public: + void invoke(const std::string& valueFromJs) const { + static const auto method = getClass()->getMethod /* valueFromJs */)>("invoke"); + method(self(), jni::make_jstring(valueFromJs)); + } + }; + + /** + * An implementation of Func_void_std__string that is backed by a C++ implementation (using `std::function<...>`) + */ + struct JFunc_void_std__string_cxx final: public jni::HybridClass { + public: + static jni::local_ref fromCpp(const std::function& func) { + return JFunc_void_std__string_cxx::newObjectCxxArgs(func); } public: - void call(jni::alias_ref valueFromJs) { + void invoke_cxx(jni::alias_ref valueFromJs) { _func(valueFromJs->toStdString()); } public: + [[nodiscard]] inline const std::function& getFunction() const { return _func; } public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_void_std__string;"; + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_void_std__string_cxx;"; static void registerNatives() { - registerHybrid({makeNativeMethod("call", JFunc_void_std__string::call)}); + registerHybrid({makeNativeMethod("invoke", JFunc_void_std__string_cxx::invoke_cxx)}); } private: - explicit JFunc_void_std__string(const std::function& func): _func(func) { } + explicit JFunc_void_std__string_cxx(const std::function& func): _func(func) { } private: friend HybridBase; diff --git a/packages/react-native-nitro-image/nitrogen/generated/android/c++/JFunc_void_std__vector_Powertrain_.hpp b/packages/react-native-nitro-image/nitrogen/generated/android/c++/JFunc_void_std__vector_Powertrain_.hpp index 289ccbc9b..371c9cee9 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/android/c++/JFunc_void_std__vector_Powertrain_.hpp +++ b/packages/react-native-nitro-image/nitrogen/generated/android/c++/JFunc_void_std__vector_Powertrain_.hpp @@ -20,17 +20,39 @@ namespace margelo::nitro::image { using namespace facebook; /** - * C++ representation of the callback Func_void_std__vector_Powertrain_. - * This is a Kotlin `(array: Array) -> Unit`, backed by a `std::function<...>`. + * Represents the Java/Kotlin callback `(array: Array) -> Unit`. + * This can be passed around between C++ and Java/Kotlin. */ - struct JFunc_void_std__vector_Powertrain_ final: public jni::HybridClass { + struct JFunc_void_std__vector_Powertrain_: public jni::JavaClass { public: - static jni::local_ref fromCpp(const std::function& /* array */)>& func) { - return JFunc_void_std__vector_Powertrain_::newObjectCxxArgs(func); + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_void_std__vector_Powertrain_;"; + + public: + void invoke(const std::vector& array) const { + static const auto method = getClass()->getMethod> /* array */)>("invoke"); + method(self(), [&]() { + size_t __size = array.size(); + jni::local_ref> __array = jni::JArrayClass::newArray(__size); + for (size_t __i = 0; __i < __size; __i++) { + const auto& __element = array[__i]; + __array->setElement(__i, *JPowertrain::fromCpp(__element)); + } + return __array; + }()); + } + }; + + /** + * An implementation of Func_void_std__vector_Powertrain_ that is backed by a C++ implementation (using `std::function<...>`) + */ + struct JFunc_void_std__vector_Powertrain__cxx final: public jni::HybridClass { + public: + static jni::local_ref fromCpp(const std::function& /* array */)>& func) { + return JFunc_void_std__vector_Powertrain__cxx::newObjectCxxArgs(func); } public: - void call(jni::alias_ref> array) { + void invoke_cxx(jni::alias_ref> array) { _func([&]() { size_t __size = array->size(); std::vector __vector; @@ -44,18 +66,19 @@ namespace margelo::nitro::image { } public: + [[nodiscard]] inline const std::function& /* array */)>& getFunction() const { return _func; } public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_void_std__vector_Powertrain_;"; + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_void_std__vector_Powertrain__cxx;"; static void registerNatives() { - registerHybrid({makeNativeMethod("call", JFunc_void_std__vector_Powertrain_::call)}); + registerHybrid({makeNativeMethod("invoke", JFunc_void_std__vector_Powertrain__cxx::invoke_cxx)}); } private: - explicit JFunc_void_std__vector_Powertrain_(const std::function& /* array */)>& func): _func(func) { } + explicit JFunc_void_std__vector_Powertrain__cxx(const std::function& /* array */)>& func): _func(func) { } private: friend HybridBase; diff --git a/packages/react-native-nitro-image/nitrogen/generated/android/c++/JHybridImageSpec.cpp b/packages/react-native-nitro-image/nitrogen/generated/android/c++/JHybridImageSpec.cpp index d4640eecc..ce23a066b 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/android/c++/JHybridImageSpec.cpp +++ b/packages/react-native-nitro-image/nitrogen/generated/android/c++/JHybridImageSpec.cpp @@ -102,7 +102,7 @@ namespace margelo::nitro::image { try { static const auto method = _javaPart->getClass()->getMethod /* path */, jni::alias_ref /* onFinished */)>("saveToFile_cxx"); - method(_javaPart, jni::make_jstring(path), JFunc_void_std__string::fromCpp(onFinished)); + method(_javaPart, jni::make_jstring(path), JFunc_void_std__string_cxx::fromCpp(onFinished)); } catch (const jni::JniException& exc) { throw std::runtime_error(exc.what()); diff --git a/packages/react-native-nitro-image/nitrogen/generated/android/c++/JHybridTestObjectSwiftKotlinSpec.cpp b/packages/react-native-nitro-image/nitrogen/generated/android/c++/JHybridTestObjectSwiftKotlinSpec.cpp index c96efef17..0fbe784fc 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/android/c++/JHybridTestObjectSwiftKotlinSpec.cpp +++ b/packages/react-native-nitro-image/nitrogen/generated/android/c++/JHybridTestObjectSwiftKotlinSpec.cpp @@ -352,7 +352,16 @@ namespace margelo::nitro::image { static const auto method = _javaPart->getClass()->getMethod()>("getOptionalCallback_cxx"); auto __result = method(_javaPart); - return __result != nullptr ? std::make_optional(__result->cthis()->getFunction()) : std::nullopt; + return __result != nullptr ? std::make_optional([&]() -> std::function { + if (__result->isInstanceOf(JFunc_void_double_cxx::javaClassStatic())) [[likely]] { + auto downcast = jni::static_ref_cast(__result); + return downcast->cthis()->getFunction(); + } else { + return [__result](double value) -> void { + return __result->invoke(value); + }; + } + }()) : std::nullopt; } catch (const jni::JniException& exc) { throw std::runtime_error(exc.what()); @@ -362,7 +371,7 @@ namespace margelo::nitro::image { try { static const auto method = _javaPart->getClass()->getMethod /* optionalCallback */)>("setOptionalCallback_cxx"); - method(_javaPart, optionalCallback.has_value() ? JFunc_void_double::fromCpp(optionalCallback.value()) : nullptr); + method(_javaPart, optionalCallback.has_value() ? JFunc_void_double_cxx::fromCpp(optionalCallback.value()) : nullptr); } catch (const jni::JniException& exc) { throw std::runtime_error(exc.what()); @@ -561,7 +570,7 @@ namespace margelo::nitro::image { __array->setElement(__i, *JPowertrain::fromCpp(__element)); } return __array; - }(), JFunc_void_std__vector_Powertrain_::fromCpp(callback)); + }(), JFunc_void_std__vector_Powertrain__cxx::fromCpp(callback)); } catch (const jni::JniException& exc) { throw std::runtime_error(exc.what()); @@ -841,7 +850,7 @@ namespace margelo::nitro::image { try { static const auto method = _javaPart->getClass()->getMethod /* callback */)>("callCallback_cxx"); - method(_javaPart, JFunc_void::fromCpp(callback)); + method(_javaPart, JFunc_void_cxx::fromCpp(callback)); } catch (const jni::JniException& exc) { throw std::runtime_error(exc.what()); @@ -851,7 +860,7 @@ namespace margelo::nitro::image { try { static const auto method = _javaPart->getClass()->getMethod /* first */, jni::alias_ref /* second */, jni::alias_ref /* third */)>("callAll_cxx"); - method(_javaPart, JFunc_void::fromCpp(first), JFunc_void::fromCpp(second), JFunc_void::fromCpp(third)); + method(_javaPart, JFunc_void_cxx::fromCpp(first), JFunc_void_cxx::fromCpp(second), JFunc_void_cxx::fromCpp(third)); } catch (const jni::JniException& exc) { throw std::runtime_error(exc.what()); @@ -861,7 +870,7 @@ namespace margelo::nitro::image { try { static const auto method = _javaPart->getClass()->getMethod /* value */, jni::alias_ref /* callback */)>("callWithOptional_cxx"); - method(_javaPart, value.has_value() ? jni::JDouble::valueOf(value.value()) : nullptr, JFunc_void_std__optional_double_::fromCpp(callback)); + method(_javaPart, value.has_value() ? jni::JDouble::valueOf(value.value()) : nullptr, JFunc_void_std__optional_double__cxx::fromCpp(callback)); } catch (const jni::JniException& exc) { throw std::runtime_error(exc.what()); @@ -871,7 +880,7 @@ namespace margelo::nitro::image { try { static const auto method = _javaPart->getClass()->getMethod(jni::alias_ref /* callback */, double /* n */)>("callSumUpNTimes_cxx"); - auto __result = method(_javaPart, JFunc_std__shared_ptr_Promise_double__::fromCpp(callback), n); + auto __result = method(_javaPart, JFunc_std__shared_ptr_Promise_double___cxx::fromCpp(callback), n); return [&]() { auto __promise = Promise::create(); __result->cthis()->addOnResolvedListener([=](const jni::alias_ref& __boxedResult) { @@ -893,7 +902,7 @@ namespace margelo::nitro::image { try { static const auto method = _javaPart->getClass()->getMethod(jni::alias_ref /* callback */)>("callbackAsyncPromise_cxx"); - auto __result = method(_javaPart, JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_double____::fromCpp(callback)); + auto __result = method(_javaPart, JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_double_____cxx::fromCpp(callback)); return [&]() { auto __promise = Promise::create(); __result->cthis()->addOnResolvedListener([=](const jni::alias_ref& __boxedResult) { @@ -915,7 +924,7 @@ namespace margelo::nitro::image { try { static const auto method = _javaPart->getClass()->getMethod(jni::alias_ref /* callback */)>("callbackAsyncPromiseBuffer_cxx"); - auto __result = method(_javaPart, JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer_____::fromCpp(callback)); + auto __result = method(_javaPart, JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer______cxx::fromCpp(callback)); return [&]() { auto __promise = Promise>::create(); __result->cthis()->addOnResolvedListener([=](const jni::alias_ref& __boxedResult) { @@ -938,7 +947,16 @@ namespace margelo::nitro::image { static const auto method = _javaPart->getClass()->getMethod()>("getComplexCallback_cxx"); auto __result = method(_javaPart); - return __result->cthis()->getFunction(); + return [&]() -> std::function { + if (__result->isInstanceOf(JFunc_void_double_cxx::javaClassStatic())) [[likely]] { + auto downcast = jni::static_ref_cast(__result); + return downcast->cthis()->getFunction(); + } else { + return [__result](double value) -> void { + return __result->invoke(value); + }; + } + }(); } catch (const jni::JniException& exc) { throw std::runtime_error(exc.what()); @@ -948,7 +966,7 @@ namespace margelo::nitro::image { try { static const auto method = _javaPart->getClass()->getMethod(jni::alias_ref /* getValue */)>("getValueFromJSCallbackAndWait_cxx"); - auto __result = method(_javaPart, JFunc_std__shared_ptr_Promise_double__::fromCpp(getValue)); + auto __result = method(_javaPart, JFunc_std__shared_ptr_Promise_double___cxx::fromCpp(getValue)); return [&]() { auto __promise = Promise::create(); __result->cthis()->addOnResolvedListener([=](const jni::alias_ref& __boxedResult) { @@ -970,7 +988,7 @@ namespace margelo::nitro::image { try { static const auto method = _javaPart->getClass()->getMethod(jni::alias_ref /* callback */, jni::alias_ref /* andThenCall */)>("getValueFromJsCallback_cxx"); - auto __result = method(_javaPart, JFunc_std__shared_ptr_Promise_std__string__::fromCpp(callback), JFunc_void_std__string::fromCpp(andThenCall)); + auto __result = method(_javaPart, JFunc_std__shared_ptr_Promise_std__string___cxx::fromCpp(callback), JFunc_void_std__string_cxx::fromCpp(andThenCall)); return [&]() { auto __promise = Promise::create(); __result->cthis()->addOnResolvedListener([=](const jni::alias_ref& /* unit */) { diff --git a/packages/react-native-nitro-image/nitrogen/generated/android/c++/JImageFormat.hpp b/packages/react-native-nitro-image/nitrogen/generated/android/c++/JImageFormat.hpp index 38aa6806d..9d7e973f8 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/android/c++/JImageFormat.hpp +++ b/packages/react-native-nitro-image/nitrogen/generated/android/c++/JImageFormat.hpp @@ -26,6 +26,7 @@ namespace margelo::nitro::image { * Convert this Java/Kotlin-based enum to the C++ enum ImageFormat. */ [[maybe_unused]] + [[nodiscard]] ImageFormat toCpp() const { static const auto clazz = javaClassStatic(); static const auto fieldOrdinal = clazz->getField("_ordinal"); diff --git a/packages/react-native-nitro-image/nitrogen/generated/android/c++/JImageSize.hpp b/packages/react-native-nitro-image/nitrogen/generated/android/c++/JImageSize.hpp index bb0c071b5..49ce88f67 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/android/c++/JImageSize.hpp +++ b/packages/react-native-nitro-image/nitrogen/generated/android/c++/JImageSize.hpp @@ -28,6 +28,7 @@ namespace margelo::nitro::image { * Convert this Java/Kotlin-based struct to the C++ struct ImageSize by copying all values to C++. */ [[maybe_unused]] + [[nodiscard]] ImageSize toCpp() const { static const auto clazz = javaClassStatic(); static const auto fieldWidth = clazz->getField("width"); diff --git a/packages/react-native-nitro-image/nitrogen/generated/android/c++/JJsStyleStruct.hpp b/packages/react-native-nitro-image/nitrogen/generated/android/c++/JJsStyleStruct.hpp index 7ba72a918..9007975a6 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/android/c++/JJsStyleStruct.hpp +++ b/packages/react-native-nitro-image/nitrogen/generated/android/c++/JJsStyleStruct.hpp @@ -29,6 +29,7 @@ namespace margelo::nitro::image { * Convert this Java/Kotlin-based struct to the C++ struct JsStyleStruct by copying all values to C++. */ [[maybe_unused]] + [[nodiscard]] JsStyleStruct toCpp() const { static const auto clazz = javaClassStatic(); static const auto fieldValue = clazz->getField("value"); @@ -37,7 +38,16 @@ namespace margelo::nitro::image { jni::local_ref onChanged = this->getFieldValue(fieldOnChanged); return JsStyleStruct( value, - onChanged->cthis()->getFunction() + [&]() -> std::function { + if (onChanged->isInstanceOf(JFunc_void_double_cxx::javaClassStatic())) [[likely]] { + auto downcast = jni::static_ref_cast(onChanged); + return downcast->cthis()->getFunction(); + } else { + return [onChanged](double num) -> void { + return onChanged->invoke(num); + }; + } + }() ); } @@ -49,7 +59,7 @@ namespace margelo::nitro::image { static jni::local_ref fromCpp(const JsStyleStruct& value) { return newInstance( value.value, - JFunc_void_double::fromCpp(value.onChanged) + JFunc_void_double_cxx::fromCpp(value.onChanged) ); } }; diff --git a/packages/react-native-nitro-image/nitrogen/generated/android/c++/JOldEnum.hpp b/packages/react-native-nitro-image/nitrogen/generated/android/c++/JOldEnum.hpp index 06952445d..97d62ebba 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/android/c++/JOldEnum.hpp +++ b/packages/react-native-nitro-image/nitrogen/generated/android/c++/JOldEnum.hpp @@ -26,6 +26,7 @@ namespace margelo::nitro::image { * Convert this Java/Kotlin-based enum to the C++ enum OldEnum. */ [[maybe_unused]] + [[nodiscard]] OldEnum toCpp() const { static const auto clazz = javaClassStatic(); static const auto fieldOrdinal = clazz->getField("_ordinal"); diff --git a/packages/react-native-nitro-image/nitrogen/generated/android/c++/JPerson.hpp b/packages/react-native-nitro-image/nitrogen/generated/android/c++/JPerson.hpp index 0959d1647..c30b0a291 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/android/c++/JPerson.hpp +++ b/packages/react-native-nitro-image/nitrogen/generated/android/c++/JPerson.hpp @@ -28,6 +28,7 @@ namespace margelo::nitro::image { * Convert this Java/Kotlin-based struct to the C++ struct Person by copying all values to C++. */ [[maybe_unused]] + [[nodiscard]] Person toCpp() const { static const auto clazz = javaClassStatic(); static const auto fieldName = clazz->getField("name"); diff --git a/packages/react-native-nitro-image/nitrogen/generated/android/c++/JPixelFormat.hpp b/packages/react-native-nitro-image/nitrogen/generated/android/c++/JPixelFormat.hpp index cfb0727dc..d9f7e2a13 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/android/c++/JPixelFormat.hpp +++ b/packages/react-native-nitro-image/nitrogen/generated/android/c++/JPixelFormat.hpp @@ -26,6 +26,7 @@ namespace margelo::nitro::image { * Convert this Java/Kotlin-based enum to the C++ enum PixelFormat. */ [[maybe_unused]] + [[nodiscard]] PixelFormat toCpp() const { static const auto clazz = javaClassStatic(); static const auto fieldOrdinal = clazz->getField("_ordinal"); diff --git a/packages/react-native-nitro-image/nitrogen/generated/android/c++/JPowertrain.hpp b/packages/react-native-nitro-image/nitrogen/generated/android/c++/JPowertrain.hpp index 31567f3b5..b150b829c 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/android/c++/JPowertrain.hpp +++ b/packages/react-native-nitro-image/nitrogen/generated/android/c++/JPowertrain.hpp @@ -26,6 +26,7 @@ namespace margelo::nitro::image { * Convert this Java/Kotlin-based enum to the C++ enum Powertrain. */ [[maybe_unused]] + [[nodiscard]] Powertrain toCpp() const { static const auto clazz = javaClassStatic(); static const auto fieldOrdinal = clazz->getField("_ordinal"); diff --git a/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/Func_std__shared_ptr_Promise_double__.kt b/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/Func_std__shared_ptr_Promise_double__.kt index cfa990fc2..df857a61b 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/Func_std__shared_ptr_Promise_double__.kt +++ b/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/Func_std__shared_ptr_Promise_double__.kt @@ -13,14 +13,37 @@ import com.facebook.proguard.annotations.DoNotStrip import com.margelo.nitro.core.* import dalvik.annotation.optimization.FastNative +/** + * Represents the JavaScript callback `() => std::shared_ptr>`. + * This can be either implemented in C++ (in which case it might be a callback coming from JS), + * or in Kotlin/Java (in which case it is a native callback). + */ +@DoNotStrip +@Keep +@Suppress("ClassName", "RedundantUnitReturnType") +fun interface Func_std__shared_ptr_Promise_double__: () -> Promise { + /** + * Call the given JS callback. + * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted. + */ + @DoNotStrip + @Keep + override fun invoke(): Promise +} + /** * Represents the JavaScript callback `() => std::shared_ptr>`. * This is implemented in C++, via a `std::function<...>`. + * The callback might be coming from JS. */ @DoNotStrip @Keep -@Suppress("RedundantSuppression", "ConvertSecondaryConstructorToPrimary", "RedundantUnitReturnType", "KotlinJniMissingFunction", "ClassName", "unused", "LocalVariableName") -class Func_std__shared_ptr_Promise_double__ { +@Suppress( + "KotlinJniMissingFunction", "unused", + "RedundantSuppression", "RedundantUnitReturnType", + "ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName", +) +class Func_std__shared_ptr_Promise_double___cxx: Func_std__shared_ptr_Promise_double__ { @DoNotStrip @Keep private val mHybridData: HybridData @@ -31,16 +54,22 @@ class Func_std__shared_ptr_Promise_double__ { mHybridData = hybridData } - /** - * Converts this function to a Kotlin Lambda. - * This exists purely as syntactic sugar, and has minimal runtime overhead. - */ - fun toLambda(): () -> Promise = this::call - - /** - * Call the given JS callback. - * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted. - */ @FastNative - external fun call(): Promise + external override fun invoke(): Promise +} + +/** + * Represents the JavaScript callback `() => std::shared_ptr>`. + * This is implemented in Java/Kotlin, via a `() -> Promise`. + * The callback is always coming from native. + */ +@DoNotStrip +@Keep +@Suppress("ClassName", "RedundantUnitReturnType", "unused") +class Func_std__shared_ptr_Promise_double___java(private val function: () -> Promise): Func_std__shared_ptr_Promise_double__ { + @DoNotStrip + @Keep + override fun invoke(): Promise { + return this.function() + } } diff --git a/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/Func_std__shared_ptr_Promise_std__shared_ptr_Promise_double____.kt b/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/Func_std__shared_ptr_Promise_std__shared_ptr_Promise_double____.kt index d54642b8b..d607dab39 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/Func_std__shared_ptr_Promise_std__shared_ptr_Promise_double____.kt +++ b/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/Func_std__shared_ptr_Promise_std__shared_ptr_Promise_double____.kt @@ -13,14 +13,37 @@ import com.facebook.proguard.annotations.DoNotStrip import com.margelo.nitro.core.* import dalvik.annotation.optimization.FastNative +/** + * Represents the JavaScript callback `() => std::shared_ptr>>>`. + * This can be either implemented in C++ (in which case it might be a callback coming from JS), + * or in Kotlin/Java (in which case it is a native callback). + */ +@DoNotStrip +@Keep +@Suppress("ClassName", "RedundantUnitReturnType") +fun interface Func_std__shared_ptr_Promise_std__shared_ptr_Promise_double____: () -> Promise> { + /** + * Call the given JS callback. + * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted. + */ + @DoNotStrip + @Keep + override fun invoke(): Promise> +} + /** * Represents the JavaScript callback `() => std::shared_ptr>>>`. * This is implemented in C++, via a `std::function<...>`. + * The callback might be coming from JS. */ @DoNotStrip @Keep -@Suppress("RedundantSuppression", "ConvertSecondaryConstructorToPrimary", "RedundantUnitReturnType", "KotlinJniMissingFunction", "ClassName", "unused", "LocalVariableName") -class Func_std__shared_ptr_Promise_std__shared_ptr_Promise_double____ { +@Suppress( + "KotlinJniMissingFunction", "unused", + "RedundantSuppression", "RedundantUnitReturnType", + "ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName", +) +class Func_std__shared_ptr_Promise_std__shared_ptr_Promise_double_____cxx: Func_std__shared_ptr_Promise_std__shared_ptr_Promise_double____ { @DoNotStrip @Keep private val mHybridData: HybridData @@ -31,16 +54,22 @@ class Func_std__shared_ptr_Promise_std__shared_ptr_Promise_double____ { mHybridData = hybridData } - /** - * Converts this function to a Kotlin Lambda. - * This exists purely as syntactic sugar, and has minimal runtime overhead. - */ - fun toLambda(): () -> Promise> = this::call - - /** - * Call the given JS callback. - * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted. - */ @FastNative - external fun call(): Promise> + external override fun invoke(): Promise> +} + +/** + * Represents the JavaScript callback `() => std::shared_ptr>>>`. + * This is implemented in Java/Kotlin, via a `() -> Promise>`. + * The callback is always coming from native. + */ +@DoNotStrip +@Keep +@Suppress("ClassName", "RedundantUnitReturnType", "unused") +class Func_std__shared_ptr_Promise_std__shared_ptr_Promise_double_____java(private val function: () -> Promise>): Func_std__shared_ptr_Promise_std__shared_ptr_Promise_double____ { + @DoNotStrip + @Keep + override fun invoke(): Promise> { + return this.function() + } } diff --git a/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer_____.kt b/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer_____.kt index b31e9dc6f..a4f6bb72d 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer_____.kt +++ b/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer_____.kt @@ -13,14 +13,37 @@ import com.facebook.proguard.annotations.DoNotStrip import com.margelo.nitro.core.* import dalvik.annotation.optimization.FastNative +/** + * Represents the JavaScript callback `() => std::shared_ptr>>>>`. + * This can be either implemented in C++ (in which case it might be a callback coming from JS), + * or in Kotlin/Java (in which case it is a native callback). + */ +@DoNotStrip +@Keep +@Suppress("ClassName", "RedundantUnitReturnType") +fun interface Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer_____: () -> Promise> { + /** + * Call the given JS callback. + * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted. + */ + @DoNotStrip + @Keep + override fun invoke(): Promise> +} + /** * Represents the JavaScript callback `() => std::shared_ptr>>>>`. * This is implemented in C++, via a `std::function<...>`. + * The callback might be coming from JS. */ @DoNotStrip @Keep -@Suppress("RedundantSuppression", "ConvertSecondaryConstructorToPrimary", "RedundantUnitReturnType", "KotlinJniMissingFunction", "ClassName", "unused", "LocalVariableName") -class Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer_____ { +@Suppress( + "KotlinJniMissingFunction", "unused", + "RedundantSuppression", "RedundantUnitReturnType", + "ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName", +) +class Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer______cxx: Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer_____ { @DoNotStrip @Keep private val mHybridData: HybridData @@ -31,16 +54,22 @@ class Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_Array mHybridData = hybridData } - /** - * Converts this function to a Kotlin Lambda. - * This exists purely as syntactic sugar, and has minimal runtime overhead. - */ - fun toLambda(): () -> Promise> = this::call - - /** - * Call the given JS callback. - * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted. - */ @FastNative - external fun call(): Promise> + external override fun invoke(): Promise> +} + +/** + * Represents the JavaScript callback `() => std::shared_ptr>>>>`. + * This is implemented in Java/Kotlin, via a `() -> Promise>`. + * The callback is always coming from native. + */ +@DoNotStrip +@Keep +@Suppress("ClassName", "RedundantUnitReturnType", "unused") +class Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer______java(private val function: () -> Promise>): Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer_____ { + @DoNotStrip + @Keep + override fun invoke(): Promise> { + return this.function() + } } diff --git a/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/Func_std__shared_ptr_Promise_std__string__.kt b/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/Func_std__shared_ptr_Promise_std__string__.kt index 1b2d4e058..d9b5b9415 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/Func_std__shared_ptr_Promise_std__string__.kt +++ b/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/Func_std__shared_ptr_Promise_std__string__.kt @@ -13,14 +13,37 @@ import com.facebook.proguard.annotations.DoNotStrip import com.margelo.nitro.core.* import dalvik.annotation.optimization.FastNative +/** + * Represents the JavaScript callback `() => std::shared_ptr>`. + * This can be either implemented in C++ (in which case it might be a callback coming from JS), + * or in Kotlin/Java (in which case it is a native callback). + */ +@DoNotStrip +@Keep +@Suppress("ClassName", "RedundantUnitReturnType") +fun interface Func_std__shared_ptr_Promise_std__string__: () -> Promise { + /** + * Call the given JS callback. + * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted. + */ + @DoNotStrip + @Keep + override fun invoke(): Promise +} + /** * Represents the JavaScript callback `() => std::shared_ptr>`. * This is implemented in C++, via a `std::function<...>`. + * The callback might be coming from JS. */ @DoNotStrip @Keep -@Suppress("RedundantSuppression", "ConvertSecondaryConstructorToPrimary", "RedundantUnitReturnType", "KotlinJniMissingFunction", "ClassName", "unused", "LocalVariableName") -class Func_std__shared_ptr_Promise_std__string__ { +@Suppress( + "KotlinJniMissingFunction", "unused", + "RedundantSuppression", "RedundantUnitReturnType", + "ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName", +) +class Func_std__shared_ptr_Promise_std__string___cxx: Func_std__shared_ptr_Promise_std__string__ { @DoNotStrip @Keep private val mHybridData: HybridData @@ -31,16 +54,22 @@ class Func_std__shared_ptr_Promise_std__string__ { mHybridData = hybridData } - /** - * Converts this function to a Kotlin Lambda. - * This exists purely as syntactic sugar, and has minimal runtime overhead. - */ - fun toLambda(): () -> Promise = this::call - - /** - * Call the given JS callback. - * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted. - */ @FastNative - external fun call(): Promise + external override fun invoke(): Promise +} + +/** + * Represents the JavaScript callback `() => std::shared_ptr>`. + * This is implemented in Java/Kotlin, via a `() -> Promise`. + * The callback is always coming from native. + */ +@DoNotStrip +@Keep +@Suppress("ClassName", "RedundantUnitReturnType", "unused") +class Func_std__shared_ptr_Promise_std__string___java(private val function: () -> Promise): Func_std__shared_ptr_Promise_std__string__ { + @DoNotStrip + @Keep + override fun invoke(): Promise { + return this.function() + } } diff --git a/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/Func_void.kt b/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/Func_void.kt index 838b23309..81142b3c6 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/Func_void.kt +++ b/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/Func_void.kt @@ -13,14 +13,37 @@ import com.facebook.proguard.annotations.DoNotStrip import com.margelo.nitro.core.* import dalvik.annotation.optimization.FastNative +/** + * Represents the JavaScript callback `() => void`. + * This can be either implemented in C++ (in which case it might be a callback coming from JS), + * or in Kotlin/Java (in which case it is a native callback). + */ +@DoNotStrip +@Keep +@Suppress("ClassName", "RedundantUnitReturnType") +fun interface Func_void: () -> Unit { + /** + * Call the given JS callback. + * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted. + */ + @DoNotStrip + @Keep + override fun invoke(): Unit +} + /** * Represents the JavaScript callback `() => void`. * This is implemented in C++, via a `std::function<...>`. + * The callback might be coming from JS. */ @DoNotStrip @Keep -@Suppress("RedundantSuppression", "ConvertSecondaryConstructorToPrimary", "RedundantUnitReturnType", "KotlinJniMissingFunction", "ClassName", "unused", "LocalVariableName") -class Func_void { +@Suppress( + "KotlinJniMissingFunction", "unused", + "RedundantSuppression", "RedundantUnitReturnType", + "ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName", +) +class Func_void_cxx: Func_void { @DoNotStrip @Keep private val mHybridData: HybridData @@ -31,16 +54,22 @@ class Func_void { mHybridData = hybridData } - /** - * Converts this function to a Kotlin Lambda. - * This exists purely as syntactic sugar, and has minimal runtime overhead. - */ - fun toLambda(): () -> Unit = this::call - - /** - * Call the given JS callback. - * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted. - */ @FastNative - external fun call(): Unit + external override fun invoke(): Unit +} + +/** + * Represents the JavaScript callback `() => void`. + * This is implemented in Java/Kotlin, via a `() -> Unit`. + * The callback is always coming from native. + */ +@DoNotStrip +@Keep +@Suppress("ClassName", "RedundantUnitReturnType", "unused") +class Func_void_java(private val function: () -> Unit): Func_void { + @DoNotStrip + @Keep + override fun invoke(): Unit { + return this.function() + } } diff --git a/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/Func_void_double.kt b/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/Func_void_double.kt index 781866a18..1670876c9 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/Func_void_double.kt +++ b/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/Func_void_double.kt @@ -13,14 +13,37 @@ import com.facebook.proguard.annotations.DoNotStrip import com.margelo.nitro.core.* import dalvik.annotation.optimization.FastNative +/** + * Represents the JavaScript callback `(num: number) => void`. + * This can be either implemented in C++ (in which case it might be a callback coming from JS), + * or in Kotlin/Java (in which case it is a native callback). + */ +@DoNotStrip +@Keep +@Suppress("ClassName", "RedundantUnitReturnType") +fun interface Func_void_double: (Double) -> Unit { + /** + * Call the given JS callback. + * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted. + */ + @DoNotStrip + @Keep + override fun invoke(num: Double): Unit +} + /** * Represents the JavaScript callback `(num: number) => void`. * This is implemented in C++, via a `std::function<...>`. + * The callback might be coming from JS. */ @DoNotStrip @Keep -@Suppress("RedundantSuppression", "ConvertSecondaryConstructorToPrimary", "RedundantUnitReturnType", "KotlinJniMissingFunction", "ClassName", "unused", "LocalVariableName") -class Func_void_double { +@Suppress( + "KotlinJniMissingFunction", "unused", + "RedundantSuppression", "RedundantUnitReturnType", + "ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName", +) +class Func_void_double_cxx: Func_void_double { @DoNotStrip @Keep private val mHybridData: HybridData @@ -31,16 +54,22 @@ class Func_void_double { mHybridData = hybridData } - /** - * Converts this function to a Kotlin Lambda. - * This exists purely as syntactic sugar, and has minimal runtime overhead. - */ - fun toLambda(): (num: Double) -> Unit = this::call - - /** - * Call the given JS callback. - * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted. - */ @FastNative - external fun call(num: Double): Unit + external override fun invoke(num: Double): Unit +} + +/** + * Represents the JavaScript callback `(num: number) => void`. + * This is implemented in Java/Kotlin, via a `(Double) -> Unit`. + * The callback is always coming from native. + */ +@DoNotStrip +@Keep +@Suppress("ClassName", "RedundantUnitReturnType", "unused") +class Func_void_double_java(private val function: (Double) -> Unit): Func_void_double { + @DoNotStrip + @Keep + override fun invoke(num: Double): Unit { + return this.function(num) + } } diff --git a/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/Func_void_std__optional_double_.kt b/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/Func_void_std__optional_double_.kt index 919f0f83a..960800ae5 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/Func_void_std__optional_double_.kt +++ b/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/Func_void_std__optional_double_.kt @@ -13,14 +13,37 @@ import com.facebook.proguard.annotations.DoNotStrip import com.margelo.nitro.core.* import dalvik.annotation.optimization.FastNative +/** + * Represents the JavaScript callback `(maybe: optional) => void`. + * This can be either implemented in C++ (in which case it might be a callback coming from JS), + * or in Kotlin/Java (in which case it is a native callback). + */ +@DoNotStrip +@Keep +@Suppress("ClassName", "RedundantUnitReturnType") +fun interface Func_void_std__optional_double_: (Double?) -> Unit { + /** + * Call the given JS callback. + * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted. + */ + @DoNotStrip + @Keep + override fun invoke(maybe: Double?): Unit +} + /** * Represents the JavaScript callback `(maybe: optional) => void`. * This is implemented in C++, via a `std::function<...>`. + * The callback might be coming from JS. */ @DoNotStrip @Keep -@Suppress("RedundantSuppression", "ConvertSecondaryConstructorToPrimary", "RedundantUnitReturnType", "KotlinJniMissingFunction", "ClassName", "unused", "LocalVariableName") -class Func_void_std__optional_double_ { +@Suppress( + "KotlinJniMissingFunction", "unused", + "RedundantSuppression", "RedundantUnitReturnType", + "ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName", +) +class Func_void_std__optional_double__cxx: Func_void_std__optional_double_ { @DoNotStrip @Keep private val mHybridData: HybridData @@ -31,16 +54,22 @@ class Func_void_std__optional_double_ { mHybridData = hybridData } - /** - * Converts this function to a Kotlin Lambda. - * This exists purely as syntactic sugar, and has minimal runtime overhead. - */ - fun toLambda(): (maybe: Double?) -> Unit = this::call - - /** - * Call the given JS callback. - * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted. - */ @FastNative - external fun call(maybe: Double?): Unit + external override fun invoke(maybe: Double?): Unit +} + +/** + * Represents the JavaScript callback `(maybe: optional) => void`. + * This is implemented in Java/Kotlin, via a `(Double?) -> Unit`. + * The callback is always coming from native. + */ +@DoNotStrip +@Keep +@Suppress("ClassName", "RedundantUnitReturnType", "unused") +class Func_void_std__optional_double__java(private val function: (Double?) -> Unit): Func_void_std__optional_double_ { + @DoNotStrip + @Keep + override fun invoke(maybe: Double?): Unit { + return this.function(maybe) + } } diff --git a/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/Func_void_std__string.kt b/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/Func_void_std__string.kt index 3c184b8df..f1e304121 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/Func_void_std__string.kt +++ b/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/Func_void_std__string.kt @@ -13,14 +13,37 @@ import com.facebook.proguard.annotations.DoNotStrip import com.margelo.nitro.core.* import dalvik.annotation.optimization.FastNative +/** + * Represents the JavaScript callback `(valueFromJs: string) => void`. + * This can be either implemented in C++ (in which case it might be a callback coming from JS), + * or in Kotlin/Java (in which case it is a native callback). + */ +@DoNotStrip +@Keep +@Suppress("ClassName", "RedundantUnitReturnType") +fun interface Func_void_std__string: (String) -> Unit { + /** + * Call the given JS callback. + * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted. + */ + @DoNotStrip + @Keep + override fun invoke(valueFromJs: String): Unit +} + /** * Represents the JavaScript callback `(valueFromJs: string) => void`. * This is implemented in C++, via a `std::function<...>`. + * The callback might be coming from JS. */ @DoNotStrip @Keep -@Suppress("RedundantSuppression", "ConvertSecondaryConstructorToPrimary", "RedundantUnitReturnType", "KotlinJniMissingFunction", "ClassName", "unused", "LocalVariableName") -class Func_void_std__string { +@Suppress( + "KotlinJniMissingFunction", "unused", + "RedundantSuppression", "RedundantUnitReturnType", + "ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName", +) +class Func_void_std__string_cxx: Func_void_std__string { @DoNotStrip @Keep private val mHybridData: HybridData @@ -31,16 +54,22 @@ class Func_void_std__string { mHybridData = hybridData } - /** - * Converts this function to a Kotlin Lambda. - * This exists purely as syntactic sugar, and has minimal runtime overhead. - */ - fun toLambda(): (valueFromJs: String) -> Unit = this::call - - /** - * Call the given JS callback. - * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted. - */ @FastNative - external fun call(valueFromJs: String): Unit + external override fun invoke(valueFromJs: String): Unit +} + +/** + * Represents the JavaScript callback `(valueFromJs: string) => void`. + * This is implemented in Java/Kotlin, via a `(String) -> Unit`. + * The callback is always coming from native. + */ +@DoNotStrip +@Keep +@Suppress("ClassName", "RedundantUnitReturnType", "unused") +class Func_void_std__string_java(private val function: (String) -> Unit): Func_void_std__string { + @DoNotStrip + @Keep + override fun invoke(valueFromJs: String): Unit { + return this.function(valueFromJs) + } } diff --git a/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/Func_void_std__vector_Powertrain_.kt b/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/Func_void_std__vector_Powertrain_.kt index 1e4501f30..01e439a7d 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/Func_void_std__vector_Powertrain_.kt +++ b/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/Func_void_std__vector_Powertrain_.kt @@ -13,14 +13,37 @@ import com.facebook.proguard.annotations.DoNotStrip import com.margelo.nitro.core.* import dalvik.annotation.optimization.FastNative +/** + * Represents the JavaScript callback `(array: array) => void`. + * This can be either implemented in C++ (in which case it might be a callback coming from JS), + * or in Kotlin/Java (in which case it is a native callback). + */ +@DoNotStrip +@Keep +@Suppress("ClassName", "RedundantUnitReturnType") +fun interface Func_void_std__vector_Powertrain_: (Array) -> Unit { + /** + * Call the given JS callback. + * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted. + */ + @DoNotStrip + @Keep + override fun invoke(array: Array): Unit +} + /** * Represents the JavaScript callback `(array: array) => void`. * This is implemented in C++, via a `std::function<...>`. + * The callback might be coming from JS. */ @DoNotStrip @Keep -@Suppress("RedundantSuppression", "ConvertSecondaryConstructorToPrimary", "RedundantUnitReturnType", "KotlinJniMissingFunction", "ClassName", "unused", "LocalVariableName") -class Func_void_std__vector_Powertrain_ { +@Suppress( + "KotlinJniMissingFunction", "unused", + "RedundantSuppression", "RedundantUnitReturnType", + "ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName", +) +class Func_void_std__vector_Powertrain__cxx: Func_void_std__vector_Powertrain_ { @DoNotStrip @Keep private val mHybridData: HybridData @@ -31,16 +54,22 @@ class Func_void_std__vector_Powertrain_ { mHybridData = hybridData } - /** - * Converts this function to a Kotlin Lambda. - * This exists purely as syntactic sugar, and has minimal runtime overhead. - */ - fun toLambda(): (array: Array) -> Unit = this::call - - /** - * Call the given JS callback. - * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted. - */ @FastNative - external fun call(array: Array): Unit + external override fun invoke(array: Array): Unit +} + +/** + * Represents the JavaScript callback `(array: array) => void`. + * This is implemented in Java/Kotlin, via a `(Array) -> Unit`. + * The callback is always coming from native. + */ +@DoNotStrip +@Keep +@Suppress("ClassName", "RedundantUnitReturnType", "unused") +class Func_void_std__vector_Powertrain__java(private val function: (Array) -> Unit): Func_void_std__vector_Powertrain_ { + @DoNotStrip + @Keep + override fun invoke(array: Array): Unit { + return this.function(array) + } } diff --git a/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/HybridImageSpec.kt b/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/HybridImageSpec.kt index cf1115f74..79ca3fe03 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/HybridImageSpec.kt +++ b/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/HybridImageSpec.kt @@ -66,7 +66,7 @@ abstract class HybridImageSpec: HybridObject() { @DoNotStrip @Keep private fun saveToFile_cxx(path: String, onFinished: Func_void_std__string): Unit { - val __result = saveToFile(path, onFinished.toLambda()) + val __result = saveToFile(path, onFinished /* TODO: Does this work? */) return __result } diff --git a/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/HybridTestObjectSwiftKotlinSpec.kt b/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/HybridTestObjectSwiftKotlinSpec.kt index 9607db479..eeb1c2a1e 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/HybridTestObjectSwiftKotlinSpec.kt +++ b/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/HybridTestObjectSwiftKotlinSpec.kt @@ -118,12 +118,12 @@ abstract class HybridTestObjectSwiftKotlinSpec: HybridObject() { @Keep @DoNotStrip get() { - return optionalCallback + return optionalCallback?.let { Func_void_double_java(it) } } @Keep @DoNotStrip set(value) { - optionalCallback = value?.let { it.toLambda() } + optionalCallback = value?.let { it /* TODO: Does this work? */ } } @get:DoNotStrip @@ -174,7 +174,7 @@ abstract class HybridTestObjectSwiftKotlinSpec: HybridObject() { @DoNotStrip @Keep private fun complexEnumCallback_cxx(array: Array, callback: Func_void_std__vector_Powertrain_): Unit { - val __result = complexEnumCallback(array, callback.toLambda()) + val __result = complexEnumCallback(array, callback /* TODO: Does this work? */) return __result } @@ -243,7 +243,7 @@ abstract class HybridTestObjectSwiftKotlinSpec: HybridObject() { @DoNotStrip @Keep private fun callCallback_cxx(callback: Func_void): Unit { - val __result = callCallback(callback.toLambda()) + val __result = callCallback(callback /* TODO: Does this work? */) return __result } @@ -252,7 +252,7 @@ abstract class HybridTestObjectSwiftKotlinSpec: HybridObject() { @DoNotStrip @Keep private fun callAll_cxx(first: Func_void, second: Func_void, third: Func_void): Unit { - val __result = callAll(first.toLambda(), second.toLambda(), third.toLambda()) + val __result = callAll(first /* TODO: Does this work? */, second /* TODO: Does this work? */, third /* TODO: Does this work? */) return __result } @@ -261,7 +261,7 @@ abstract class HybridTestObjectSwiftKotlinSpec: HybridObject() { @DoNotStrip @Keep private fun callWithOptional_cxx(value: Double?, callback: Func_void_std__optional_double_): Unit { - val __result = callWithOptional(value, callback.toLambda()) + val __result = callWithOptional(value, callback /* TODO: Does this work? */) return __result } @@ -270,7 +270,7 @@ abstract class HybridTestObjectSwiftKotlinSpec: HybridObject() { @DoNotStrip @Keep private fun callSumUpNTimes_cxx(callback: Func_std__shared_ptr_Promise_double__, n: Double): Promise { - val __result = callSumUpNTimes(callback.toLambda(), n) + val __result = callSumUpNTimes(callback /* TODO: Does this work? */, n) return __result } @@ -279,7 +279,7 @@ abstract class HybridTestObjectSwiftKotlinSpec: HybridObject() { @DoNotStrip @Keep private fun callbackAsyncPromise_cxx(callback: Func_std__shared_ptr_Promise_std__shared_ptr_Promise_double____): Promise { - val __result = callbackAsyncPromise(callback.toLambda()) + val __result = callbackAsyncPromise(callback /* TODO: Does this work? */) return __result } @@ -288,7 +288,7 @@ abstract class HybridTestObjectSwiftKotlinSpec: HybridObject() { @DoNotStrip @Keep private fun callbackAsyncPromiseBuffer_cxx(callback: Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer_____): Promise { - val __result = callbackAsyncPromiseBuffer(callback.toLambda()) + val __result = callbackAsyncPromiseBuffer(callback /* TODO: Does this work? */) return __result } @@ -298,7 +298,7 @@ abstract class HybridTestObjectSwiftKotlinSpec: HybridObject() { @Keep private fun getComplexCallback_cxx(): Func_void_double { val __result = getComplexCallback() - throw Error("not yet implemented!") + return Func_void_double_java(__result) } abstract fun getValueFromJSCallbackAndWait(getValue: () -> Promise): Promise @@ -306,7 +306,7 @@ abstract class HybridTestObjectSwiftKotlinSpec: HybridObject() { @DoNotStrip @Keep private fun getValueFromJSCallbackAndWait_cxx(getValue: Func_std__shared_ptr_Promise_double__): Promise { - val __result = getValueFromJSCallbackAndWait(getValue.toLambda()) + val __result = getValueFromJSCallbackAndWait(getValue /* TODO: Does this work? */) return __result } @@ -315,7 +315,7 @@ abstract class HybridTestObjectSwiftKotlinSpec: HybridObject() { @DoNotStrip @Keep private fun getValueFromJsCallback_cxx(callback: Func_std__shared_ptr_Promise_std__string__, andThenCall: Func_void_std__string): Promise { - val __result = getValueFromJsCallback(callback.toLambda(), andThenCall.toLambda()) + val __result = getValueFromJsCallback(callback /* TODO: Does this work? */, andThenCall /* TODO: Does this work? */) return __result } diff --git a/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/JsStyleStruct.kt b/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/JsStyleStruct.kt index 1a70c66db..7ff8a00a1 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/JsStyleStruct.kt +++ b/packages/react-native-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/JsStyleStruct.kt @@ -20,8 +20,4 @@ data class JsStyleStruct( val value: Double, val onChanged: (num: Double) -> Unit ) { - @DoNotStrip - @Keep - private constructor(value: Double, onChanged: Func_void_double) - : this(value, onChanged.toLambda()) }