From 3a4bbdb419f67de5d0ce1db22850cb173b445cfa Mon Sep 17 00:00:00 2001 From: Christoph Purrer Date: Mon, 4 Dec 2023 13:45:17 -0800 Subject: [PATCH] Update GenerateModuleH fixture (#41780) Summary: This updates our test fixture with more concrete examples from: https://github.com/facebook/react-native/blob/main/packages/rn-tester/NativeCxxModuleExample/NativeCxxModuleExample.js Changelog: [Internal] Reviewed By: rshest Differential Revision: D51804559 --- .../modules/__test_fixtures__/fixtures.js | 683 ++++++++++++-- .../GenerateModuleCpp-test.js.snap | 191 +++- .../GenerateModuleH-test.js.snap | 853 ++++++++++++++++-- 3 files changed, 1547 insertions(+), 180 deletions(-) diff --git a/packages/react-native-codegen/src/generators/modules/__test_fixtures__/fixtures.js b/packages/react-native-codegen/src/generators/modules/__test_fixtures__/fixtures.js index 8f96919d4c3843..1cbd0c977ab39a 100644 --- a/packages/react-native-codegen/src/generators/modules/__test_fixtures__/fixtures.js +++ b/packages/react-native-codegen/src/generators/modules/__test_fixtures__/fixtures.js @@ -1569,7 +1569,117 @@ const CXX_ONLY_NATIVE_MODULES: SchemaType = { NativeSampleTurboModule: { type: 'NativeModule', aliasMap: { - ObjectAlias: { + ConstantsStruct: { + type: 'ObjectTypeAnnotation', + properties: [ + { + name: 'const1', + optional: false, + typeAnnotation: { + type: 'BooleanTypeAnnotation', + }, + }, + { + name: 'const2', + optional: false, + typeAnnotation: { + type: 'NumberTypeAnnotation', + }, + }, + { + name: 'const3', + optional: false, + typeAnnotation: { + type: 'StringTypeAnnotation', + }, + }, + ], + }, + CustomHostObject: { + type: 'ObjectTypeAnnotation', + properties: [], + }, + BinaryTreeNode: { + type: 'ObjectTypeAnnotation', + properties: [ + { + name: 'left', + optional: true, + typeAnnotation: { + type: 'TypeAliasTypeAnnotation', + name: 'BinaryTreeNode', + }, + }, + { + name: 'value', + optional: false, + typeAnnotation: { + type: 'NumberTypeAnnotation', + }, + }, + { + name: 'right', + optional: true, + typeAnnotation: { + type: 'TypeAliasTypeAnnotation', + name: 'BinaryTreeNode', + }, + }, + ], + }, + GraphNode: { + type: 'ObjectTypeAnnotation', + properties: [ + { + name: 'label', + optional: false, + typeAnnotation: { + type: 'StringTypeAnnotation', + }, + }, + { + name: 'neighbors', + optional: true, + typeAnnotation: { + type: 'ArrayTypeAnnotation', + elementType: { + type: 'TypeAliasTypeAnnotation', + name: 'GraphNode', + }, + }, + }, + ], + }, + ObjectStruct: { + type: 'ObjectTypeAnnotation', + properties: [ + { + name: 'a', + optional: false, + typeAnnotation: { + type: 'NumberTypeAnnotation', + }, + }, + { + name: 'b', + optional: false, + typeAnnotation: { + type: 'StringTypeAnnotation', + }, + }, + { + name: 'c', + optional: true, + typeAnnotation: { + type: 'NullableTypeAnnotation', + typeAnnotation: { + type: 'StringTypeAnnotation', + }, + }, + }, + ], + }, + ValueStruct: { type: 'ObjectTypeAnnotation', properties: [ { @@ -1579,56 +1689,82 @@ const CXX_ONLY_NATIVE_MODULES: SchemaType = { type: 'NumberTypeAnnotation', }, }, + { + name: 'y', + optional: false, + typeAnnotation: { + type: 'StringTypeAnnotation', + }, + }, + { + name: 'z', + optional: false, + typeAnnotation: { + type: 'TypeAliasTypeAnnotation', + name: 'ObjectStruct', + }, + }, ], }, }, enumMap: { - NumEnum: { + EnumInt: { + name: 'EnumInt', type: 'EnumDeclarationWithMembers', - name: 'NumEnum', memberType: 'NumberTypeAnnotation', members: [ { - name: 'ONE', - value: '1', + name: 'IA', + value: '23', }, { - name: 'TWO', - value: '2', + name: 'IB', + value: '42', }, ], }, - FloatEnum: { + EnumFloat: { + name: 'EnumFloat', type: 'EnumDeclarationWithMembers', - name: 'FloatEnum', memberType: 'NumberTypeAnnotation', members: [ { - name: 'POINT_ZERO', - value: '0.0', + name: 'FA', + value: '1.23', }, { - name: 'POINT_ONE', - value: '0.1', + name: 'FB', + value: '4.56', + }, + ], + }, + EnumNone: { + name: 'EnumNone', + type: 'EnumDeclarationWithMembers', + memberType: 'StringTypeAnnotation', + members: [ + { + name: 'NA', + value: 'NA', }, { - name: 'POINT_TWO', - value: '0.2', + name: 'NB', + value: 'NB', }, ], }, - StringEnum: { + EnumStr: { + name: 'EnumStr', type: 'EnumDeclarationWithMembers', - name: 'StringEnum', memberType: 'StringTypeAnnotation', members: [ { - name: 'HELLO', - value: 'hello', + name: 'SA', + value: 's---a', }, { - name: 'GoodBye', - value: 'goodbye', + name: 'SB', + value: 's---b', }, ], }, @@ -1636,128 +1772,192 @@ const CXX_ONLY_NATIVE_MODULES: SchemaType = { spec: { properties: [ { - name: 'getMixed', + name: 'getArray', optional: false, typeAnnotation: { type: 'FunctionTypeAnnotation', returnTypeAnnotation: { - type: 'MixedTypeAnnotation', + type: 'ArrayTypeAnnotation', }, params: [ { name: 'arg', optional: false, typeAnnotation: { - type: 'MixedTypeAnnotation', + type: 'ArrayTypeAnnotation', }, }, ], }, }, { - name: 'getNullableNumberFromNullableAlias', + name: 'getBool', optional: false, typeAnnotation: { type: 'FunctionTypeAnnotation', returnTypeAnnotation: { - type: 'NullableTypeAnnotation', - typeAnnotation: { - type: 'NumberTypeAnnotation', - }, + type: 'BooleanTypeAnnotation', }, params: [ { - name: 'a', + name: 'arg', optional: false, typeAnnotation: { - type: 'NullableTypeAnnotation', - typeAnnotation: { - type: 'TypeAliasTypeAnnotation', - name: 'ObjectAlias', - }, + type: 'BooleanTypeAnnotation', }, }, ], }, }, { - name: 'getEnums', + name: 'getConstants', optional: false, typeAnnotation: { type: 'FunctionTypeAnnotation', returnTypeAnnotation: { - type: 'StringTypeAnnotation', + type: 'TypeAliasTypeAnnotation', + name: 'ConstantsStruct', + }, + params: [], + }, + }, + { + name: 'getCustomEnum', + optional: false, + typeAnnotation: { + type: 'FunctionTypeAnnotation', + returnTypeAnnotation: { + name: 'EnumInt', + type: 'EnumDeclaration', + memberType: 'NumberTypeAnnotation', }, params: [ { - name: 'enumInt', + name: 'arg', optional: false, typeAnnotation: { - name: 'NumEnum', + name: 'EnumInt', type: 'EnumDeclaration', memberType: 'NumberTypeAnnotation', }, }, + ], + }, + }, + { + name: 'getCustomHostObject', + optional: false, + typeAnnotation: { + type: 'FunctionTypeAnnotation', + returnTypeAnnotation: { + type: 'TypeAliasTypeAnnotation', + name: 'CustomHostObject', + }, + params: [], + }, + }, + { + name: 'consumeCustomHostObject', + optional: false, + typeAnnotation: { + type: 'FunctionTypeAnnotation', + returnTypeAnnotation: { + type: 'StringTypeAnnotation', + }, + params: [ { - name: 'enumFloat', + name: 'customHostObject', optional: false, typeAnnotation: { - name: 'FloatEnum', - type: 'EnumDeclaration', - memberType: 'NumberTypeAnnotation', + type: 'TypeAliasTypeAnnotation', + name: 'CustomHostObject', }, }, + ], + }, + }, + { + name: 'getBinaryTreeNode', + optional: false, + typeAnnotation: { + type: 'FunctionTypeAnnotation', + returnTypeAnnotation: { + type: 'TypeAliasTypeAnnotation', + name: 'BinaryTreeNode', + }, + params: [ { - name: 'enumString', + name: 'arg', optional: false, typeAnnotation: { - name: 'StringEnum', - type: 'EnumDeclaration', - memberType: 'StringTypeAnnotation', + type: 'TypeAliasTypeAnnotation', + name: 'BinaryTreeNode', }, }, ], }, }, { - name: 'getUnion', + name: 'getGraphNode', optional: false, typeAnnotation: { type: 'FunctionTypeAnnotation', returnTypeAnnotation: { - type: 'UnionTypeAnnotation', - memberType: 'ObjectTypeAnnotation', + type: 'TypeAliasTypeAnnotation', + name: 'GraphNode', }, params: [ { - name: 'chooseInt', + name: 'arg', optional: false, typeAnnotation: { - type: 'UnionTypeAnnotation', - memberType: 'NumberTypeAnnotation', + type: 'TypeAliasTypeAnnotation', + name: 'GraphNode', }, }, + ], + }, + }, + { + name: 'getNumEnum', + optional: false, + typeAnnotation: { + type: 'FunctionTypeAnnotation', + returnTypeAnnotation: { + name: 'EnumFloat', + type: 'EnumDeclaration', + memberType: 'NumberTypeAnnotation', + }, + params: [ { - name: 'chooseFloat', + name: 'arg', optional: false, typeAnnotation: { - type: 'UnionTypeAnnotation', + name: 'EnumInt', + type: 'EnumDeclaration', memberType: 'NumberTypeAnnotation', }, }, + ], + }, + }, + { + name: 'getStrEnum', + optional: false, + typeAnnotation: { + type: 'FunctionTypeAnnotation', + returnTypeAnnotation: { + name: 'EnumStr', + type: 'EnumDeclaration', + memberType: 'StringTypeAnnotation', + }, + params: [ { - name: 'chooseObject', - optional: false, - typeAnnotation: { - type: 'UnionTypeAnnotation', - memberType: 'ObjectTypeAnnotation', - }, - }, - { - name: 'chooseString', + name: 'arg', optional: false, typeAnnotation: { - type: 'UnionTypeAnnotation', + name: 'EnumNone', + type: 'EnumDeclaration', memberType: 'StringTypeAnnotation', }, }, @@ -1765,16 +1965,359 @@ const CXX_ONLY_NATIVE_MODULES: SchemaType = { }, }, { - name: 'getEnumReturn', + name: 'getMap', optional: false, typeAnnotation: { type: 'FunctionTypeAnnotation', returnTypeAnnotation: { - type: 'EnumDeclaration', - name: 'NumEnum', - memberType: 'NumberTypeAnnotation', + type: 'GenericObjectTypeAnnotation', + dictionaryValueType: { + type: 'NullableTypeAnnotation', + typeAnnotation: { + type: 'NumberTypeAnnotation', + }, + }, }, - params: [], + params: [ + { + name: 'arg', + optional: false, + typeAnnotation: { + type: 'GenericObjectTypeAnnotation', + dictionaryValueType: { + type: 'NullableTypeAnnotation', + typeAnnotation: { + type: 'NumberTypeAnnotation', + }, + }, + }, + }, + ], + }, + }, + { + name: 'getNumber', + optional: false, + typeAnnotation: { + type: 'FunctionTypeAnnotation', + returnTypeAnnotation: { + type: 'NumberTypeAnnotation', + }, + params: [ + { + name: 'arg', + optional: false, + typeAnnotation: { + type: 'NumberTypeAnnotation', + }, + }, + ], + }, + }, + { + name: 'getObject', + optional: false, + typeAnnotation: { + type: 'FunctionTypeAnnotation', + returnTypeAnnotation: { + type: 'TypeAliasTypeAnnotation', + name: 'ObjectStruct', + }, + params: [ + { + name: 'arg', + optional: false, + typeAnnotation: { + type: 'TypeAliasTypeAnnotation', + name: 'ObjectStruct', + }, + }, + ], + }, + }, + { + name: 'getSet', + optional: false, + typeAnnotation: { + type: 'FunctionTypeAnnotation', + returnTypeAnnotation: { + type: 'ArrayTypeAnnotation', + elementType: { + type: 'NumberTypeAnnotation', + }, + }, + params: [ + { + name: 'arg', + optional: false, + typeAnnotation: { + type: 'ArrayTypeAnnotation', + elementType: { + type: 'NumberTypeAnnotation', + }, + }, + }, + ], + }, + }, + { + name: 'getString', + optional: false, + typeAnnotation: { + type: 'FunctionTypeAnnotation', + returnTypeAnnotation: { + type: 'StringTypeAnnotation', + }, + params: [ + { + name: 'arg', + optional: false, + typeAnnotation: { + type: 'StringTypeAnnotation', + }, + }, + ], + }, + }, + { + name: 'getUnion', + optional: false, + typeAnnotation: { + type: 'FunctionTypeAnnotation', + returnTypeAnnotation: { + type: 'StringTypeAnnotation', + }, + params: [ + { + name: 'x', + optional: false, + typeAnnotation: { + type: 'UnionTypeAnnotation', + memberType: 'NumberTypeAnnotation', + }, + }, + { + name: 'y', + optional: false, + typeAnnotation: { + type: 'UnionTypeAnnotation', + memberType: 'StringTypeAnnotation', + }, + }, + { + name: 'z', + optional: false, + typeAnnotation: { + type: 'UnionTypeAnnotation', + memberType: 'ObjectTypeAnnotation', + }, + }, + ], + }, + }, + { + name: 'getValue', + optional: false, + typeAnnotation: { + type: 'FunctionTypeAnnotation', + returnTypeAnnotation: { + type: 'TypeAliasTypeAnnotation', + name: 'ValueStruct', + }, + params: [ + { + name: 'x', + optional: false, + typeAnnotation: { + type: 'NumberTypeAnnotation', + }, + }, + { + name: 'y', + optional: false, + typeAnnotation: { + type: 'StringTypeAnnotation', + }, + }, + { + name: 'z', + optional: false, + typeAnnotation: { + type: 'TypeAliasTypeAnnotation', + name: 'ObjectStruct', + }, + }, + ], + }, + }, + { + name: 'getValueWithCallback', + optional: false, + typeAnnotation: { + type: 'FunctionTypeAnnotation', + returnTypeAnnotation: { + type: 'VoidTypeAnnotation', + }, + params: [ + { + name: 'callback', + optional: false, + typeAnnotation: { + type: 'FunctionTypeAnnotation', + returnTypeAnnotation: { + type: 'VoidTypeAnnotation', + }, + params: [ + { + name: 'value', + optional: false, + typeAnnotation: { + type: 'StringTypeAnnotation', + }, + }, + ], + }, + }, + ], + }, + }, + { + name: 'getValueWithPromise', + optional: false, + typeAnnotation: { + type: 'FunctionTypeAnnotation', + returnTypeAnnotation: { + type: 'PromiseTypeAnnotation', + elementType: { + type: 'StringTypeAnnotation', + }, + }, + params: [ + { + name: 'error', + optional: false, + typeAnnotation: { + type: 'BooleanTypeAnnotation', + }, + }, + ], + }, + }, + { + name: 'getWithWithOptionalArgs', + optional: false, + typeAnnotation: { + type: 'FunctionTypeAnnotation', + returnTypeAnnotation: { + type: 'NullableTypeAnnotation', + typeAnnotation: { + type: 'BooleanTypeAnnotation', + }, + }, + params: [ + { + name: 'optionalArg', + optional: true, + typeAnnotation: { + type: 'BooleanTypeAnnotation', + }, + }, + ], + }, + }, + { + name: 'voidFunc', + optional: false, + typeAnnotation: { + type: 'FunctionTypeAnnotation', + returnTypeAnnotation: { + type: 'VoidTypeAnnotation', + }, + params: [], + }, + }, + { + name: 'emitCustomDeviceEvent', + optional: false, + typeAnnotation: { + type: 'FunctionTypeAnnotation', + returnTypeAnnotation: { + type: 'VoidTypeAnnotation', + }, + params: [ + { + name: 'eventName', + optional: false, + typeAnnotation: { + type: 'StringTypeAnnotation', + }, + }, + ], + }, + }, + { + name: 'voidFuncThrows', + optional: false, + typeAnnotation: { + type: 'FunctionTypeAnnotation', + returnTypeAnnotation: { + type: 'VoidTypeAnnotation', + }, + params: [], + }, + }, + + { + name: 'getObjectThrows', + optional: false, + typeAnnotation: { + type: 'FunctionTypeAnnotation', + returnTypeAnnotation: { + type: 'TypeAliasTypeAnnotation', + name: 'ObjectStruct', + }, + params: [ + { + name: 'arg', + optional: false, + typeAnnotation: { + type: 'TypeAliasTypeAnnotation', + name: 'ObjectStruct', + }, + }, + ], + }, + }, + { + name: 'voidFuncAssert', + optional: false, + typeAnnotation: { + type: 'FunctionTypeAnnotation', + returnTypeAnnotation: { + type: 'VoidTypeAnnotation', + }, + params: [], + }, + }, + { + name: 'getObjectAssert', + optional: false, + typeAnnotation: { + type: 'FunctionTypeAnnotation', + returnTypeAnnotation: { + type: 'TypeAliasTypeAnnotation', + name: 'ObjectStruct', + }, + params: [ + { + name: 'arg', + optional: false, + typeAnnotation: { + type: 'TypeAliasTypeAnnotation', + name: 'ObjectStruct', + }, + }, + ], }, }, ], diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleCpp-test.js.snap b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleCpp-test.js.snap index b04d1afa0b57c8..7a06f13398fe43 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleCpp-test.js.snap @@ -128,49 +128,196 @@ Map { namespace facebook { namespace react { -static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getMixed(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { - return static_cast(&turboModule)->getMixed( +static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getArray(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + return static_cast(&turboModule)->getArray( rt, - jsi::Value(rt, args[0]) + args[0].asObject(rt).asArray(rt) ); } -static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getNullableNumberFromNullableAlias(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { - auto result = static_cast(&turboModule)->getNullableNumberFromNullableAlias( +static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getBool(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + return static_cast(&turboModule)->getBool( rt, - args[0].isNull() || args[0].isUndefined() ? std::nullopt : std::make_optional(args[0].asObject(rt)) + args[0].asBool() ); - return result ? jsi::Value(std::move(*result)) : jsi::Value::null(); } -static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getEnums(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { - return static_cast(&turboModule)->getEnums( +static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getConstants(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + return static_cast(&turboModule)->getConstants( + rt + ); +} +static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getCustomEnum(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + return static_cast(&turboModule)->getCustomEnum( rt, - args[0].asNumber(), - args[1].asNumber(), - args[2].asString(rt) + args[0].asNumber() + ); +} +static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getCustomHostObject(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + return static_cast(&turboModule)->getCustomHostObject( + rt + ); +} +static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_consumeCustomHostObject(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + return static_cast(&turboModule)->consumeCustomHostObject( + rt, + args[0].asObject(rt) + ); +} +static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getBinaryTreeNode(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + return static_cast(&turboModule)->getBinaryTreeNode( + rt, + args[0].asObject(rt) + ); +} +static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getGraphNode(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + return static_cast(&turboModule)->getGraphNode( + rt, + args[0].asObject(rt) + ); +} +static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getNumEnum(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + return static_cast(&turboModule)->getNumEnum( + rt, + args[0].asNumber() + ); +} +static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getStrEnum(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + return static_cast(&turboModule)->getStrEnum( + rt, + args[0].asString(rt) + ); +} +static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getMap(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + return static_cast(&turboModule)->getMap( + rt, + args[0].asObject(rt) + ); +} +static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getNumber(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + return static_cast(&turboModule)->getNumber( + rt, + args[0].asNumber() + ); +} +static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getObject(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + return static_cast(&turboModule)->getObject( + rt, + args[0].asObject(rt) + ); +} +static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getSet(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + return static_cast(&turboModule)->getSet( + rt, + args[0].asObject(rt).asArray(rt) + ); +} +static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getString(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + return static_cast(&turboModule)->getString( + rt, + args[0].asString(rt) ); } static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getUnion(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { return static_cast(&turboModule)->getUnion( rt, args[0].asNumber(), - args[1].asNumber(), - args[2].asObject(rt), - args[3].asString(rt) + args[1].asString(rt), + args[2].asObject(rt) ); } -static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getEnumReturn(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { - return static_cast(&turboModule)->getEnumReturn( +static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getValue(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + return static_cast(&turboModule)->getValue( + rt, + args[0].asNumber(), + args[1].asString(rt), + args[2].asObject(rt) + ); +} +static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getValueWithCallback(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + static_cast(&turboModule)->getValueWithCallback( + rt, + args[0].asObject(rt).asFunction(rt) + ); + return jsi::Value::undefined(); +} +static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getValueWithPromise(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + return static_cast(&turboModule)->getValueWithPromise( + rt, + args[0].asBool() + ); +} +static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getWithWithOptionalArgs(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + auto result = static_cast(&turboModule)->getWithWithOptionalArgs( + rt, + count <= 0 || args[0].isNull() || args[0].isUndefined() ? std::nullopt : std::make_optional(args[0].asBool()) + ); + return result ? jsi::Value(std::move(*result)) : jsi::Value::null(); +} +static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_voidFunc(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + static_cast(&turboModule)->voidFunc( + rt + ); + return jsi::Value::undefined(); +} +static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_emitCustomDeviceEvent(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + static_cast(&turboModule)->emitCustomDeviceEvent( + rt, + args[0].asString(rt) + ); + return jsi::Value::undefined(); +} +static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_voidFuncThrows(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + static_cast(&turboModule)->voidFuncThrows( rt ); + return jsi::Value::undefined(); +} +static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getObjectThrows(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + return static_cast(&turboModule)->getObjectThrows( + rt, + args[0].asObject(rt) + ); +} +static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_voidFuncAssert(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + static_cast(&turboModule)->voidFuncAssert( + rt + ); + return jsi::Value::undefined(); +} +static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getObjectAssert(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + return static_cast(&turboModule)->getObjectAssert( + rt, + args[0].asObject(rt) + ); } NativeSampleTurboModuleCxxSpecJSI::NativeSampleTurboModuleCxxSpecJSI(std::shared_ptr jsInvoker) : TurboModule(\\"SampleTurboModuleCxx\\", jsInvoker) { - methodMap_[\\"getMixed\\"] = MethodMetadata {1, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getMixed}; - methodMap_[\\"getNullableNumberFromNullableAlias\\"] = MethodMetadata {1, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getNullableNumberFromNullableAlias}; - methodMap_[\\"getEnums\\"] = MethodMetadata {3, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getEnums}; - methodMap_[\\"getUnion\\"] = MethodMetadata {4, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getUnion}; - methodMap_[\\"getEnumReturn\\"] = MethodMetadata {0, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getEnumReturn}; + methodMap_[\\"getArray\\"] = MethodMetadata {1, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getArray}; + methodMap_[\\"getBool\\"] = MethodMetadata {1, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getBool}; + methodMap_[\\"getConstants\\"] = MethodMetadata {0, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getConstants}; + methodMap_[\\"getCustomEnum\\"] = MethodMetadata {1, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getCustomEnum}; + methodMap_[\\"getCustomHostObject\\"] = MethodMetadata {0, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getCustomHostObject}; + methodMap_[\\"consumeCustomHostObject\\"] = MethodMetadata {1, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_consumeCustomHostObject}; + methodMap_[\\"getBinaryTreeNode\\"] = MethodMetadata {1, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getBinaryTreeNode}; + methodMap_[\\"getGraphNode\\"] = MethodMetadata {1, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getGraphNode}; + methodMap_[\\"getNumEnum\\"] = MethodMetadata {1, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getNumEnum}; + methodMap_[\\"getStrEnum\\"] = MethodMetadata {1, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getStrEnum}; + methodMap_[\\"getMap\\"] = MethodMetadata {1, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getMap}; + methodMap_[\\"getNumber\\"] = MethodMetadata {1, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getNumber}; + methodMap_[\\"getObject\\"] = MethodMetadata {1, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getObject}; + methodMap_[\\"getSet\\"] = MethodMetadata {1, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getSet}; + methodMap_[\\"getString\\"] = MethodMetadata {1, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getString}; + methodMap_[\\"getUnion\\"] = MethodMetadata {3, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getUnion}; + methodMap_[\\"getValue\\"] = MethodMetadata {3, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getValue}; + methodMap_[\\"getValueWithCallback\\"] = MethodMetadata {1, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getValueWithCallback}; + methodMap_[\\"getValueWithPromise\\"] = MethodMetadata {1, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getValueWithPromise}; + methodMap_[\\"getWithWithOptionalArgs\\"] = MethodMetadata {1, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getWithWithOptionalArgs}; + methodMap_[\\"voidFunc\\"] = MethodMetadata {0, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_voidFunc}; + methodMap_[\\"emitCustomDeviceEvent\\"] = MethodMetadata {1, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_emitCustomDeviceEvent}; + methodMap_[\\"voidFuncThrows\\"] = MethodMetadata {0, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_voidFuncThrows}; + methodMap_[\\"getObjectThrows\\"] = MethodMetadata {1, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getObjectThrows}; + methodMap_[\\"voidFuncAssert\\"] = MethodMetadata {0, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_voidFuncAssert}; + methodMap_[\\"getObjectAssert\\"] = MethodMetadata {1, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getObjectAssert}; } diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleH-test.js.snap b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleH-test.js.snap index aa012fe2c151e3..4e83f1060a7e62 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleH-test.js.snap +++ b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleH-test.js.snap @@ -209,112 +209,354 @@ namespace facebook { namespace react { -#pragma mark - SampleTurboModuleCxxNumEnum +#pragma mark - SampleTurboModuleCxxEnumInt -enum SampleTurboModuleCxxNumEnum { ONE, TWO }; +enum SampleTurboModuleCxxEnumInt { IA, IB }; template <> -struct Bridging { - static SampleTurboModuleCxxNumEnum fromJs(jsi::Runtime &rt, const jsi::Value &rawValue) { +struct Bridging { + static SampleTurboModuleCxxEnumInt fromJs(jsi::Runtime &rt, const jsi::Value &rawValue) { double value = (double)rawValue.asNumber(); - if (value == 1) { - return SampleTurboModuleCxxNumEnum::ONE; - } else if (value == 2) { - return SampleTurboModuleCxxNumEnum::TWO; + if (value == 23) { + return SampleTurboModuleCxxEnumInt::IA; + } else if (value == 42) { + return SampleTurboModuleCxxEnumInt::IB; } else { throw jsi::JSError(rt, \\"No appropriate enum member found for value\\"); } } - static jsi::Value toJs(jsi::Runtime &rt, SampleTurboModuleCxxNumEnum value) { - if (value == SampleTurboModuleCxxNumEnum::ONE) { - return bridging::toJs(rt, 1); - } else if (value == SampleTurboModuleCxxNumEnum::TWO) { - return bridging::toJs(rt, 2); + static jsi::Value toJs(jsi::Runtime &rt, SampleTurboModuleCxxEnumInt value) { + if (value == SampleTurboModuleCxxEnumInt::IA) { + return bridging::toJs(rt, 23); + } else if (value == SampleTurboModuleCxxEnumInt::IB) { + return bridging::toJs(rt, 42); } else { throw jsi::JSError(rt, \\"No appropriate enum member found for enum value\\"); } } }; -#pragma mark - SampleTurboModuleCxxFloatEnum +#pragma mark - SampleTurboModuleCxxEnumFloat -enum SampleTurboModuleCxxFloatEnum { POINT_ZERO, POINT_ONE, POINT_TWO }; +enum SampleTurboModuleCxxEnumFloat { FA, FB }; template <> -struct Bridging { - static SampleTurboModuleCxxFloatEnum fromJs(jsi::Runtime &rt, const jsi::Value &rawValue) { +struct Bridging { + static SampleTurboModuleCxxEnumFloat fromJs(jsi::Runtime &rt, const jsi::Value &rawValue) { double value = (double)rawValue.asNumber(); - if (value == 0.0f) { - return SampleTurboModuleCxxFloatEnum::POINT_ZERO; - } else if (value == 0.1f) { - return SampleTurboModuleCxxFloatEnum::POINT_ONE; - } else if (value == 0.2f) { - return SampleTurboModuleCxxFloatEnum::POINT_TWO; + if (value == 1.23f) { + return SampleTurboModuleCxxEnumFloat::FA; + } else if (value == 4.56f) { + return SampleTurboModuleCxxEnumFloat::FB; } else { throw jsi::JSError(rt, \\"No appropriate enum member found for value\\"); } } - static jsi::Value toJs(jsi::Runtime &rt, SampleTurboModuleCxxFloatEnum value) { - if (value == SampleTurboModuleCxxFloatEnum::POINT_ZERO) { - return bridging::toJs(rt, 0.0f); - } else if (value == SampleTurboModuleCxxFloatEnum::POINT_ONE) { - return bridging::toJs(rt, 0.1f); - } else if (value == SampleTurboModuleCxxFloatEnum::POINT_TWO) { - return bridging::toJs(rt, 0.2f); + static jsi::Value toJs(jsi::Runtime &rt, SampleTurboModuleCxxEnumFloat value) { + if (value == SampleTurboModuleCxxEnumFloat::FA) { + return bridging::toJs(rt, 1.23f); + } else if (value == SampleTurboModuleCxxEnumFloat::FB) { + return bridging::toJs(rt, 4.56f); } else { throw jsi::JSError(rt, \\"No appropriate enum member found for enum value\\"); } } }; -#pragma mark - SampleTurboModuleCxxStringEnum +#pragma mark - SampleTurboModuleCxxEnumNone -enum SampleTurboModuleCxxStringEnum { HELLO, GoodBye }; +enum SampleTurboModuleCxxEnumNone { NA, NB }; template <> -struct Bridging { - static SampleTurboModuleCxxStringEnum fromJs(jsi::Runtime &rt, const jsi::String &rawValue) { +struct Bridging { + static SampleTurboModuleCxxEnumNone fromJs(jsi::Runtime &rt, const jsi::String &rawValue) { std::string value = rawValue.utf8(rt); - if (value == \\"hello\\") { - return SampleTurboModuleCxxStringEnum::HELLO; - } else if (value == \\"goodbye\\") { - return SampleTurboModuleCxxStringEnum::GoodBye; + if (value == \\"NA\\") { + return SampleTurboModuleCxxEnumNone::NA; + } else if (value == \\"NB\\") { + return SampleTurboModuleCxxEnumNone::NB; } else { throw jsi::JSError(rt, \\"No appropriate enum member found for value\\"); } } - static jsi::String toJs(jsi::Runtime &rt, SampleTurboModuleCxxStringEnum value) { - if (value == SampleTurboModuleCxxStringEnum::HELLO) { - return bridging::toJs(rt, \\"hello\\"); - } else if (value == SampleTurboModuleCxxStringEnum::GoodBye) { - return bridging::toJs(rt, \\"goodbye\\"); + static jsi::String toJs(jsi::Runtime &rt, SampleTurboModuleCxxEnumNone value) { + if (value == SampleTurboModuleCxxEnumNone::NA) { + return bridging::toJs(rt, \\"NA\\"); + } else if (value == SampleTurboModuleCxxEnumNone::NB) { + return bridging::toJs(rt, \\"NB\\"); + } else { + throw jsi::JSError(rt, \\"No appropriate enum member found for enum value\\"); + } + } +}; + +#pragma mark - SampleTurboModuleCxxEnumStr + +enum SampleTurboModuleCxxEnumStr { SA, SB }; + +template <> +struct Bridging { + static SampleTurboModuleCxxEnumStr fromJs(jsi::Runtime &rt, const jsi::String &rawValue) { + std::string value = rawValue.utf8(rt); + if (value == \\"s---a\\") { + return SampleTurboModuleCxxEnumStr::SA; + } else if (value == \\"s---b\\") { + return SampleTurboModuleCxxEnumStr::SB; + } else { + throw jsi::JSError(rt, \\"No appropriate enum member found for value\\"); + } + } + + static jsi::String toJs(jsi::Runtime &rt, SampleTurboModuleCxxEnumStr value) { + if (value == SampleTurboModuleCxxEnumStr::SA) { + return bridging::toJs(rt, \\"s---a\\"); + } else if (value == SampleTurboModuleCxxEnumStr::SB) { + return bridging::toJs(rt, \\"s---b\\"); } else { throw jsi::JSError(rt, \\"No appropriate enum member found for enum value\\"); } } }; -#pragma mark - SampleTurboModuleCxxBaseObjectAlias +#pragma mark - SampleTurboModuleCxxBaseConstantsStruct -template -struct [[deprecated(\\"Use SampleTurboModuleCxxObjectAlias instead.\\")]] SampleTurboModuleCxxBaseObjectAlias { +template +struct [[deprecated(\\"Use SampleTurboModuleCxxConstantsStruct instead.\\")]] SampleTurboModuleCxxBaseConstantsStruct { + P0 const1; + P1 const2; + P2 const3; + bool operator==(const SampleTurboModuleCxxBaseConstantsStruct &other) const { + return const1 == other.const1 && const2 == other.const2 && const3 == other.const3; + } +}; + +template +struct [[deprecated(\\"Use SampleTurboModuleCxxConstantsStructBridging instead.\\")]] SampleTurboModuleCxxBaseConstantsStructBridging { + static SampleTurboModuleCxxBaseConstantsStruct fromJs( + jsi::Runtime &rt, + const jsi::Object &value, + const std::shared_ptr &jsInvoker) { + SampleTurboModuleCxxBaseConstantsStruct result{ + bridging::fromJs(rt, value.getProperty(rt, \\"const1\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"const2\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"const3\\"), jsInvoker)}; + return result; + } + +#ifdef DEBUG + static bool const1ToJs(jsi::Runtime &rt, P0 value) { + return bridging::toJs(rt, value); + } + + static double const2ToJs(jsi::Runtime &rt, P1 value) { + return bridging::toJs(rt, value); + } + + static jsi::String const3ToJs(jsi::Runtime &rt, P2 value) { + return bridging::toJs(rt, value); + } +#endif + + static jsi::Object toJs( + jsi::Runtime &rt, + const SampleTurboModuleCxxBaseConstantsStruct &value, + const std::shared_ptr &jsInvoker) { + auto result = facebook::jsi::Object(rt); + result.setProperty(rt, \\"const1\\", bridging::toJs(rt, value.const1, jsInvoker)); + result.setProperty(rt, \\"const2\\", bridging::toJs(rt, value.const2, jsInvoker)); + result.setProperty(rt, \\"const3\\", bridging::toJs(rt, value.const3, jsInvoker)); + return result; + } +}; + + + + +#pragma mark - SampleTurboModuleCxxBaseBinaryTreeNode + +template +struct [[deprecated(\\"Use SampleTurboModuleCxxBinaryTreeNode instead.\\")]] SampleTurboModuleCxxBaseBinaryTreeNode { + P0 left; + P1 value; + P2 right; + bool operator==(const SampleTurboModuleCxxBaseBinaryTreeNode &other) const { + return left == other.left && value == other.value && right == other.right; + } +}; + +template +struct [[deprecated(\\"Use SampleTurboModuleCxxBinaryTreeNodeBridging instead.\\")]] SampleTurboModuleCxxBaseBinaryTreeNodeBridging { + static SampleTurboModuleCxxBaseBinaryTreeNode fromJs( + jsi::Runtime &rt, + const jsi::Object &value, + const std::shared_ptr &jsInvoker) { + SampleTurboModuleCxxBaseBinaryTreeNode result{ + bridging::fromJs(rt, value.getProperty(rt, \\"left\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"value\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"right\\"), jsInvoker)}; + return result; + } + +#ifdef DEBUG + static jsi::Object leftToJs(jsi::Runtime &rt, P0 value) { + return bridging::toJs(rt, value); + } + + static double valueToJs(jsi::Runtime &rt, P1 value) { + return bridging::toJs(rt, value); + } + + static jsi::Object rightToJs(jsi::Runtime &rt, P2 value) { + return bridging::toJs(rt, value); + } +#endif + + static jsi::Object toJs( + jsi::Runtime &rt, + const SampleTurboModuleCxxBaseBinaryTreeNode &value, + const std::shared_ptr &jsInvoker) { + auto result = facebook::jsi::Object(rt); + if (value.left) { + result.setProperty(rt, \\"left\\", bridging::toJs(rt, value.left.value(), jsInvoker)); + } + result.setProperty(rt, \\"value\\", bridging::toJs(rt, value.value, jsInvoker)); + if (value.right) { + result.setProperty(rt, \\"right\\", bridging::toJs(rt, value.right.value(), jsInvoker)); + } + return result; + } +}; + + + +#pragma mark - SampleTurboModuleCxxBaseGraphNode + +template +struct [[deprecated(\\"Use SampleTurboModuleCxxGraphNode instead.\\")]] SampleTurboModuleCxxBaseGraphNode { + P0 label; + P1 neighbors; + bool operator==(const SampleTurboModuleCxxBaseGraphNode &other) const { + return label == other.label && neighbors == other.neighbors; + } +}; + +template +struct [[deprecated(\\"Use SampleTurboModuleCxxGraphNodeBridging instead.\\")]] SampleTurboModuleCxxBaseGraphNodeBridging { + static SampleTurboModuleCxxBaseGraphNode fromJs( + jsi::Runtime &rt, + const jsi::Object &value, + const std::shared_ptr &jsInvoker) { + SampleTurboModuleCxxBaseGraphNode result{ + bridging::fromJs(rt, value.getProperty(rt, \\"label\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"neighbors\\"), jsInvoker)}; + return result; + } + +#ifdef DEBUG + static jsi::String labelToJs(jsi::Runtime &rt, P0 value) { + return bridging::toJs(rt, value); + } + + static jsi::Array neighborsToJs(jsi::Runtime &rt, P1 value) { + return bridging::toJs(rt, value); + } +#endif + + static jsi::Object toJs( + jsi::Runtime &rt, + const SampleTurboModuleCxxBaseGraphNode &value, + const std::shared_ptr &jsInvoker) { + auto result = facebook::jsi::Object(rt); + result.setProperty(rt, \\"label\\", bridging::toJs(rt, value.label, jsInvoker)); + if (value.neighbors) { + result.setProperty(rt, \\"neighbors\\", bridging::toJs(rt, value.neighbors.value(), jsInvoker)); + } + return result; + } +}; + + + +#pragma mark - SampleTurboModuleCxxBaseObjectStruct + +template +struct [[deprecated(\\"Use SampleTurboModuleCxxObjectStruct instead.\\")]] SampleTurboModuleCxxBaseObjectStruct { + P0 a; + P1 b; + P2 c; + bool operator==(const SampleTurboModuleCxxBaseObjectStruct &other) const { + return a == other.a && b == other.b && c == other.c; + } +}; + +template +struct [[deprecated(\\"Use SampleTurboModuleCxxObjectStructBridging instead.\\")]] SampleTurboModuleCxxBaseObjectStructBridging { + static SampleTurboModuleCxxBaseObjectStruct fromJs( + jsi::Runtime &rt, + const jsi::Object &value, + const std::shared_ptr &jsInvoker) { + SampleTurboModuleCxxBaseObjectStruct result{ + bridging::fromJs(rt, value.getProperty(rt, \\"a\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"b\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"c\\"), jsInvoker)}; + return result; + } + +#ifdef DEBUG + static double aToJs(jsi::Runtime &rt, P0 value) { + return bridging::toJs(rt, value); + } + + static jsi::String bToJs(jsi::Runtime &rt, P1 value) { + return bridging::toJs(rt, value); + } + + static std::optional cToJs(jsi::Runtime &rt, P2 value) { + return bridging::toJs(rt, value); + } +#endif + + static jsi::Object toJs( + jsi::Runtime &rt, + const SampleTurboModuleCxxBaseObjectStruct &value, + const std::shared_ptr &jsInvoker) { + auto result = facebook::jsi::Object(rt); + result.setProperty(rt, \\"a\\", bridging::toJs(rt, value.a, jsInvoker)); + result.setProperty(rt, \\"b\\", bridging::toJs(rt, value.b, jsInvoker)); + if (value.c) { + result.setProperty(rt, \\"c\\", bridging::toJs(rt, value.c.value(), jsInvoker)); + } + return result; + } +}; + + + +#pragma mark - SampleTurboModuleCxxBaseValueStruct + +template +struct [[deprecated(\\"Use SampleTurboModuleCxxValueStruct instead.\\")]] SampleTurboModuleCxxBaseValueStruct { P0 x; - bool operator==(const SampleTurboModuleCxxBaseObjectAlias &other) const { - return x == other.x; + P1 y; + P2 z; + bool operator==(const SampleTurboModuleCxxBaseValueStruct &other) const { + return x == other.x && y == other.y && z == other.z; } }; -template -struct [[deprecated(\\"Use SampleTurboModuleCxxObjectAliasBridging instead.\\")]] SampleTurboModuleCxxBaseObjectAliasBridging { - static SampleTurboModuleCxxBaseObjectAlias fromJs( +template +struct [[deprecated(\\"Use SampleTurboModuleCxxValueStructBridging instead.\\")]] SampleTurboModuleCxxBaseValueStructBridging { + static SampleTurboModuleCxxBaseValueStruct fromJs( jsi::Runtime &rt, const jsi::Object &value, const std::shared_ptr &jsInvoker) { - SampleTurboModuleCxxBaseObjectAlias result{ - bridging::fromJs(rt, value.getProperty(rt, \\"x\\"), jsInvoker)}; + SampleTurboModuleCxxBaseValueStruct result{ + bridging::fromJs(rt, value.getProperty(rt, \\"x\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"y\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"z\\"), jsInvoker)}; return result; } @@ -322,31 +564,265 @@ struct [[deprecated(\\"Use SampleTurboModuleCxxObjectAliasBridging instead.\\")] static double xToJs(jsi::Runtime &rt, P0 value) { return bridging::toJs(rt, value); } + + static jsi::String yToJs(jsi::Runtime &rt, P1 value) { + return bridging::toJs(rt, value); + } + + static jsi::Object zToJs(jsi::Runtime &rt, P2 value) { + return bridging::toJs(rt, value); + } #endif static jsi::Object toJs( jsi::Runtime &rt, - const SampleTurboModuleCxxBaseObjectAlias &value, + const SampleTurboModuleCxxBaseValueStruct &value, const std::shared_ptr &jsInvoker) { auto result = facebook::jsi::Object(rt); result.setProperty(rt, \\"x\\", bridging::toJs(rt, value.x, jsInvoker)); + result.setProperty(rt, \\"y\\", bridging::toJs(rt, value.y, jsInvoker)); + result.setProperty(rt, \\"z\\", bridging::toJs(rt, value.z, jsInvoker)); + return result; + } +}; + + +#pragma mark - SampleTurboModuleCxxConstantsStruct + +template +struct SampleTurboModuleCxxConstantsStruct { + P0 const1; + P1 const2; + P2 const3; + bool operator==(const SampleTurboModuleCxxConstantsStruct &other) const { + return const1 == other.const1 && const2 == other.const2 && const3 == other.const3; + } +}; + +template +struct SampleTurboModuleCxxConstantsStructBridging { + static T types; + + static T fromJs( + jsi::Runtime &rt, + const jsi::Object &value, + const std::shared_ptr &jsInvoker) { + T result{ + bridging::fromJs(rt, value.getProperty(rt, \\"const1\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"const2\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"const3\\"), jsInvoker)}; + return result; + } + +#ifdef DEBUG + static bool const1ToJs(jsi::Runtime &rt, decltype(types.const1) value) { + return bridging::toJs(rt, value); + } + + static double const2ToJs(jsi::Runtime &rt, decltype(types.const2) value) { + return bridging::toJs(rt, value); + } + + static jsi::String const3ToJs(jsi::Runtime &rt, decltype(types.const3) value) { + return bridging::toJs(rt, value); + } +#endif + + static jsi::Object toJs( + jsi::Runtime &rt, + const T &value, + const std::shared_ptr &jsInvoker) { + auto result = facebook::jsi::Object(rt); + result.setProperty(rt, \\"const1\\", bridging::toJs(rt, value.const1, jsInvoker)); + result.setProperty(rt, \\"const2\\", bridging::toJs(rt, value.const2, jsInvoker)); + result.setProperty(rt, \\"const3\\", bridging::toJs(rt, value.const3, jsInvoker)); + return result; + } +}; + + + + +#pragma mark - SampleTurboModuleCxxBinaryTreeNode + +template +struct SampleTurboModuleCxxBinaryTreeNode { + std::unique_ptr> left; + P0 value; + std::unique_ptr> right; + bool operator==(const SampleTurboModuleCxxBinaryTreeNode &other) const { + return left == other.left && value == other.value && right == other.right; + } +}; + +template +struct SampleTurboModuleCxxBinaryTreeNodeBridging { + static T types; + + static T fromJs( + jsi::Runtime &rt, + const jsi::Object &value, + const std::shared_ptr &jsInvoker) { + T result{ + value.hasProperty(rt, \\"left\\") ? std::make_unique(bridging::fromJs(rt, value.getProperty(rt, \\"left\\"), jsInvoker)) : nullptr, + bridging::fromJs(rt, value.getProperty(rt, \\"value\\"), jsInvoker), + value.hasProperty(rt, \\"right\\") ? std::make_unique(bridging::fromJs(rt, value.getProperty(rt, \\"right\\"), jsInvoker)) : nullptr}; + return result; + } + +#ifdef DEBUG + static jsi::Object leftToJs(jsi::Runtime &rt, decltype(types.left) value) { + return bridging::toJs(rt, value); + } + + static double valueToJs(jsi::Runtime &rt, decltype(types.value) value) { + return bridging::toJs(rt, value); + } + + static jsi::Object rightToJs(jsi::Runtime &rt, decltype(types.right) value) { + return bridging::toJs(rt, value); + } +#endif + + static jsi::Object toJs( + jsi::Runtime &rt, + const T &value, + const std::shared_ptr &jsInvoker) { + auto result = facebook::jsi::Object(rt); + if (value.left) { + result.setProperty(rt, \\"left\\", bridging::toJs(rt, *value.left, jsInvoker)); + } + result.setProperty(rt, \\"value\\", bridging::toJs(rt, value.value, jsInvoker)); + if (value.right) { + result.setProperty(rt, \\"right\\", bridging::toJs(rt, *value.right, jsInvoker)); + } return result; } }; -#pragma mark - SampleTurboModuleCxxObjectAlias + +#pragma mark - SampleTurboModuleCxxGraphNode template -struct SampleTurboModuleCxxObjectAlias { +struct SampleTurboModuleCxxGraphNode { + P0 label; + std::optional>> neighbors; + bool operator==(const SampleTurboModuleCxxGraphNode &other) const { + return label == other.label && neighbors == other.neighbors; + } +}; + +template +struct SampleTurboModuleCxxGraphNodeBridging { + static T types; + + static T fromJs( + jsi::Runtime &rt, + const jsi::Object &value, + const std::shared_ptr &jsInvoker) { + T result{ + bridging::fromJs(rt, value.getProperty(rt, \\"label\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"neighbors\\"), jsInvoker)}; + return result; + } + +#ifdef DEBUG + static jsi::String labelToJs(jsi::Runtime &rt, decltype(types.label) value) { + return bridging::toJs(rt, value); + } + + static jsi::Array neighborsToJs(jsi::Runtime &rt, decltype(types.neighbors) value) { + return bridging::toJs(rt, value); + } +#endif + + static jsi::Object toJs( + jsi::Runtime &rt, + const T &value, + const std::shared_ptr &jsInvoker) { + auto result = facebook::jsi::Object(rt); + result.setProperty(rt, \\"label\\", bridging::toJs(rt, value.label, jsInvoker)); + if (value.neighbors) { + result.setProperty(rt, \\"neighbors\\", bridging::toJs(rt, value.neighbors.value(), jsInvoker)); + } + return result; + } +}; + + + +#pragma mark - SampleTurboModuleCxxObjectStruct + +template +struct SampleTurboModuleCxxObjectStruct { + P0 a; + P1 b; + P2 c; + bool operator==(const SampleTurboModuleCxxObjectStruct &other) const { + return a == other.a && b == other.b && c == other.c; + } +}; + +template +struct SampleTurboModuleCxxObjectStructBridging { + static T types; + + static T fromJs( + jsi::Runtime &rt, + const jsi::Object &value, + const std::shared_ptr &jsInvoker) { + T result{ + bridging::fromJs(rt, value.getProperty(rt, \\"a\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"b\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"c\\"), jsInvoker)}; + return result; + } + +#ifdef DEBUG + static double aToJs(jsi::Runtime &rt, decltype(types.a) value) { + return bridging::toJs(rt, value); + } + + static jsi::String bToJs(jsi::Runtime &rt, decltype(types.b) value) { + return bridging::toJs(rt, value); + } + + static std::optional cToJs(jsi::Runtime &rt, decltype(types.c) value) { + return bridging::toJs(rt, value); + } +#endif + + static jsi::Object toJs( + jsi::Runtime &rt, + const T &value, + const std::shared_ptr &jsInvoker) { + auto result = facebook::jsi::Object(rt); + result.setProperty(rt, \\"a\\", bridging::toJs(rt, value.a, jsInvoker)); + result.setProperty(rt, \\"b\\", bridging::toJs(rt, value.b, jsInvoker)); + if (value.c) { + result.setProperty(rt, \\"c\\", bridging::toJs(rt, value.c.value(), jsInvoker)); + } + return result; + } +}; + + + +#pragma mark - SampleTurboModuleCxxValueStruct + +template +struct SampleTurboModuleCxxValueStruct { P0 x; - bool operator==(const SampleTurboModuleCxxObjectAlias &other) const { - return x == other.x; + P1 y; + P2 z; + bool operator==(const SampleTurboModuleCxxValueStruct &other) const { + return x == other.x && y == other.y && z == other.z; } }; template -struct SampleTurboModuleCxxObjectAliasBridging { +struct SampleTurboModuleCxxValueStructBridging { static T types; static T fromJs( @@ -354,7 +830,9 @@ struct SampleTurboModuleCxxObjectAliasBridging { const jsi::Object &value, const std::shared_ptr &jsInvoker) { T result{ - bridging::fromJs(rt, value.getProperty(rt, \\"x\\"), jsInvoker)}; + bridging::fromJs(rt, value.getProperty(rt, \\"x\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"y\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"z\\"), jsInvoker)}; return result; } @@ -362,6 +840,14 @@ struct SampleTurboModuleCxxObjectAliasBridging { static double xToJs(jsi::Runtime &rt, decltype(types.x) value) { return bridging::toJs(rt, value); } + + static jsi::String yToJs(jsi::Runtime &rt, decltype(types.y) value) { + return bridging::toJs(rt, value); + } + + static jsi::Object zToJs(jsi::Runtime &rt, decltype(types.z) value) { + return bridging::toJs(rt, value); + } #endif static jsi::Object toJs( @@ -370,6 +856,8 @@ struct SampleTurboModuleCxxObjectAliasBridging { const std::shared_ptr &jsInvoker) { auto result = facebook::jsi::Object(rt); result.setProperty(rt, \\"x\\", bridging::toJs(rt, value.x, jsInvoker)); + result.setProperty(rt, \\"y\\", bridging::toJs(rt, value.y, jsInvoker)); + result.setProperty(rt, \\"z\\", bridging::toJs(rt, value.z, jsInvoker)); return result; } }; @@ -379,11 +867,32 @@ protected: NativeSampleTurboModuleCxxSpecJSI(std::shared_ptr jsInvoker); public: - virtual jsi::Value getMixed(jsi::Runtime &rt, jsi::Value arg) = 0; - virtual std::optional getNullableNumberFromNullableAlias(jsi::Runtime &rt, std::optional a) = 0; - virtual jsi::String getEnums(jsi::Runtime &rt, int enumInt, double enumFloat, jsi::String enumString) = 0; - virtual jsi::Object getUnion(jsi::Runtime &rt, double chooseInt, double chooseFloat, jsi::Object chooseObject, jsi::String chooseString) = 0; - virtual int getEnumReturn(jsi::Runtime &rt) = 0; + virtual jsi::Array getArray(jsi::Runtime &rt, jsi::Array arg) = 0; + virtual bool getBool(jsi::Runtime &rt, bool arg) = 0; + virtual jsi::Object getConstants(jsi::Runtime &rt) = 0; + virtual int getCustomEnum(jsi::Runtime &rt, int arg) = 0; + virtual jsi::Object getCustomHostObject(jsi::Runtime &rt) = 0; + virtual jsi::String consumeCustomHostObject(jsi::Runtime &rt, jsi::Object customHostObject) = 0; + virtual jsi::Object getBinaryTreeNode(jsi::Runtime &rt, jsi::Object arg) = 0; + virtual jsi::Object getGraphNode(jsi::Runtime &rt, jsi::Object arg) = 0; + virtual double getNumEnum(jsi::Runtime &rt, int arg) = 0; + virtual jsi::String getStrEnum(jsi::Runtime &rt, jsi::String arg) = 0; + virtual jsi::Object getMap(jsi::Runtime &rt, jsi::Object arg) = 0; + virtual double getNumber(jsi::Runtime &rt, double arg) = 0; + virtual jsi::Object getObject(jsi::Runtime &rt, jsi::Object arg) = 0; + virtual jsi::Array getSet(jsi::Runtime &rt, jsi::Array arg) = 0; + virtual jsi::String getString(jsi::Runtime &rt, jsi::String arg) = 0; + virtual jsi::String getUnion(jsi::Runtime &rt, double x, jsi::String y, jsi::Object z) = 0; + virtual jsi::Object getValue(jsi::Runtime &rt, double x, jsi::String y, jsi::Object z) = 0; + virtual void getValueWithCallback(jsi::Runtime &rt, jsi::Function callback) = 0; + virtual jsi::Value getValueWithPromise(jsi::Runtime &rt, bool error) = 0; + virtual std::optional getWithWithOptionalArgs(jsi::Runtime &rt, std::optional optionalArg) = 0; + virtual void voidFunc(jsi::Runtime &rt) = 0; + virtual void emitCustomDeviceEvent(jsi::Runtime &rt, jsi::String eventName) = 0; + virtual void voidFuncThrows(jsi::Runtime &rt) = 0; + virtual jsi::Object getObjectThrows(jsi::Runtime &rt, jsi::Object arg) = 0; + virtual void voidFuncAssert(jsi::Runtime &rt) = 0; + virtual jsi::Object getObjectAssert(jsi::Runtime &rt, jsi::Object arg) = 0; }; @@ -407,45 +916,213 @@ private: Delegate(T *instance, std::shared_ptr jsInvoker) : NativeSampleTurboModuleCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {} - jsi::Value getMixed(jsi::Runtime &rt, jsi::Value arg) override { + jsi::Array getArray(jsi::Runtime &rt, jsi::Array arg) override { static_assert( - bridging::getParameterCount(&T::getMixed) == 2, - \\"Expected getMixed(...) to have 2 parameters\\"); + bridging::getParameterCount(&T::getArray) == 2, + \\"Expected getArray(...) to have 2 parameters\\"); - return bridging::callFromJs( - rt, &T::getMixed, jsInvoker_, instance_, std::move(arg)); + return bridging::callFromJs( + rt, &T::getArray, jsInvoker_, instance_, std::move(arg)); } - std::optional getNullableNumberFromNullableAlias(jsi::Runtime &rt, std::optional a) override { + bool getBool(jsi::Runtime &rt, bool arg) override { static_assert( - bridging::getParameterCount(&T::getNullableNumberFromNullableAlias) == 2, - \\"Expected getNullableNumberFromNullableAlias(...) to have 2 parameters\\"); + bridging::getParameterCount(&T::getBool) == 2, + \\"Expected getBool(...) to have 2 parameters\\"); - return bridging::callFromJs>( - rt, &T::getNullableNumberFromNullableAlias, jsInvoker_, instance_, std::move(a)); + return bridging::callFromJs( + rt, &T::getBool, jsInvoker_, instance_, std::move(arg)); } - jsi::String getEnums(jsi::Runtime &rt, int enumInt, double enumFloat, jsi::String enumString) override { + jsi::Object getConstants(jsi::Runtime &rt) override { static_assert( - bridging::getParameterCount(&T::getEnums) == 4, - \\"Expected getEnums(...) to have 4 parameters\\"); + bridging::getParameterCount(&T::getConstants) == 1, + \\"Expected getConstants(...) to have 1 parameters\\"); + + return bridging::callFromJs( + rt, &T::getConstants, jsInvoker_, instance_); + } + int getCustomEnum(jsi::Runtime &rt, int arg) override { + static_assert( + bridging::getParameterCount(&T::getCustomEnum) == 2, + \\"Expected getCustomEnum(...) to have 2 parameters\\"); + + return bridging::callFromJs( + rt, &T::getCustomEnum, jsInvoker_, instance_, std::move(arg)); + } + jsi::Object getCustomHostObject(jsi::Runtime &rt) override { + static_assert( + bridging::getParameterCount(&T::getCustomHostObject) == 1, + \\"Expected getCustomHostObject(...) to have 1 parameters\\"); + + return bridging::callFromJs( + rt, &T::getCustomHostObject, jsInvoker_, instance_); + } + jsi::String consumeCustomHostObject(jsi::Runtime &rt, jsi::Object customHostObject) override { + static_assert( + bridging::getParameterCount(&T::consumeCustomHostObject) == 2, + \\"Expected consumeCustomHostObject(...) to have 2 parameters\\"); return bridging::callFromJs( - rt, &T::getEnums, jsInvoker_, instance_, std::move(enumInt), std::move(enumFloat), std::move(enumString)); + rt, &T::consumeCustomHostObject, jsInvoker_, instance_, std::move(customHostObject)); } - jsi::Object getUnion(jsi::Runtime &rt, double chooseInt, double chooseFloat, jsi::Object chooseObject, jsi::String chooseString) override { + jsi::Object getBinaryTreeNode(jsi::Runtime &rt, jsi::Object arg) override { static_assert( - bridging::getParameterCount(&T::getUnion) == 5, - \\"Expected getUnion(...) to have 5 parameters\\"); + bridging::getParameterCount(&T::getBinaryTreeNode) == 2, + \\"Expected getBinaryTreeNode(...) to have 2 parameters\\"); return bridging::callFromJs( - rt, &T::getUnion, jsInvoker_, instance_, std::move(chooseInt), std::move(chooseFloat), std::move(chooseObject), std::move(chooseString)); + rt, &T::getBinaryTreeNode, jsInvoker_, instance_, std::move(arg)); } - int getEnumReturn(jsi::Runtime &rt) override { + jsi::Object getGraphNode(jsi::Runtime &rt, jsi::Object arg) override { static_assert( - bridging::getParameterCount(&T::getEnumReturn) == 1, - \\"Expected getEnumReturn(...) to have 1 parameters\\"); + bridging::getParameterCount(&T::getGraphNode) == 2, + \\"Expected getGraphNode(...) to have 2 parameters\\"); - return bridging::callFromJs( - rt, &T::getEnumReturn, jsInvoker_, instance_); + return bridging::callFromJs( + rt, &T::getGraphNode, jsInvoker_, instance_, std::move(arg)); + } + double getNumEnum(jsi::Runtime &rt, int arg) override { + static_assert( + bridging::getParameterCount(&T::getNumEnum) == 2, + \\"Expected getNumEnum(...) to have 2 parameters\\"); + + return bridging::callFromJs( + rt, &T::getNumEnum, jsInvoker_, instance_, std::move(arg)); + } + jsi::String getStrEnum(jsi::Runtime &rt, jsi::String arg) override { + static_assert( + bridging::getParameterCount(&T::getStrEnum) == 2, + \\"Expected getStrEnum(...) to have 2 parameters\\"); + + return bridging::callFromJs( + rt, &T::getStrEnum, jsInvoker_, instance_, std::move(arg)); + } + jsi::Object getMap(jsi::Runtime &rt, jsi::Object arg) override { + static_assert( + bridging::getParameterCount(&T::getMap) == 2, + \\"Expected getMap(...) to have 2 parameters\\"); + + return bridging::callFromJs( + rt, &T::getMap, jsInvoker_, instance_, std::move(arg)); + } + double getNumber(jsi::Runtime &rt, double arg) override { + static_assert( + bridging::getParameterCount(&T::getNumber) == 2, + \\"Expected getNumber(...) to have 2 parameters\\"); + + return bridging::callFromJs( + rt, &T::getNumber, jsInvoker_, instance_, std::move(arg)); + } + jsi::Object getObject(jsi::Runtime &rt, jsi::Object arg) override { + static_assert( + bridging::getParameterCount(&T::getObject) == 2, + \\"Expected getObject(...) to have 2 parameters\\"); + + return bridging::callFromJs( + rt, &T::getObject, jsInvoker_, instance_, std::move(arg)); + } + jsi::Array getSet(jsi::Runtime &rt, jsi::Array arg) override { + static_assert( + bridging::getParameterCount(&T::getSet) == 2, + \\"Expected getSet(...) to have 2 parameters\\"); + + return bridging::callFromJs( + rt, &T::getSet, jsInvoker_, instance_, std::move(arg)); + } + jsi::String getString(jsi::Runtime &rt, jsi::String arg) override { + static_assert( + bridging::getParameterCount(&T::getString) == 2, + \\"Expected getString(...) to have 2 parameters\\"); + + return bridging::callFromJs( + rt, &T::getString, jsInvoker_, instance_, std::move(arg)); + } + jsi::String getUnion(jsi::Runtime &rt, double x, jsi::String y, jsi::Object z) override { + static_assert( + bridging::getParameterCount(&T::getUnion) == 4, + \\"Expected getUnion(...) to have 4 parameters\\"); + + return bridging::callFromJs( + rt, &T::getUnion, jsInvoker_, instance_, std::move(x), std::move(y), std::move(z)); + } + jsi::Object getValue(jsi::Runtime &rt, double x, jsi::String y, jsi::Object z) override { + static_assert( + bridging::getParameterCount(&T::getValue) == 4, + \\"Expected getValue(...) to have 4 parameters\\"); + + return bridging::callFromJs( + rt, &T::getValue, jsInvoker_, instance_, std::move(x), std::move(y), std::move(z)); + } + void getValueWithCallback(jsi::Runtime &rt, jsi::Function callback) override { + static_assert( + bridging::getParameterCount(&T::getValueWithCallback) == 2, + \\"Expected getValueWithCallback(...) to have 2 parameters\\"); + + return bridging::callFromJs( + rt, &T::getValueWithCallback, jsInvoker_, instance_, std::move(callback)); + } + jsi::Value getValueWithPromise(jsi::Runtime &rt, bool error) override { + static_assert( + bridging::getParameterCount(&T::getValueWithPromise) == 2, + \\"Expected getValueWithPromise(...) to have 2 parameters\\"); + + return bridging::callFromJs( + rt, &T::getValueWithPromise, jsInvoker_, instance_, std::move(error)); + } + std::optional getWithWithOptionalArgs(jsi::Runtime &rt, std::optional optionalArg) override { + static_assert( + bridging::getParameterCount(&T::getWithWithOptionalArgs) == 2, + \\"Expected getWithWithOptionalArgs(...) to have 2 parameters\\"); + + return bridging::callFromJs>( + rt, &T::getWithWithOptionalArgs, jsInvoker_, instance_, std::move(optionalArg)); + } + void voidFunc(jsi::Runtime &rt) override { + static_assert( + bridging::getParameterCount(&T::voidFunc) == 1, + \\"Expected voidFunc(...) to have 1 parameters\\"); + + return bridging::callFromJs( + rt, &T::voidFunc, jsInvoker_, instance_); + } + void emitCustomDeviceEvent(jsi::Runtime &rt, jsi::String eventName) override { + static_assert( + bridging::getParameterCount(&T::emitCustomDeviceEvent) == 2, + \\"Expected emitCustomDeviceEvent(...) to have 2 parameters\\"); + + return bridging::callFromJs( + rt, &T::emitCustomDeviceEvent, jsInvoker_, instance_, std::move(eventName)); + } + void voidFuncThrows(jsi::Runtime &rt) override { + static_assert( + bridging::getParameterCount(&T::voidFuncThrows) == 1, + \\"Expected voidFuncThrows(...) to have 1 parameters\\"); + + return bridging::callFromJs( + rt, &T::voidFuncThrows, jsInvoker_, instance_); + } + jsi::Object getObjectThrows(jsi::Runtime &rt, jsi::Object arg) override { + static_assert( + bridging::getParameterCount(&T::getObjectThrows) == 2, + \\"Expected getObjectThrows(...) to have 2 parameters\\"); + + return bridging::callFromJs( + rt, &T::getObjectThrows, jsInvoker_, instance_, std::move(arg)); + } + void voidFuncAssert(jsi::Runtime &rt) override { + static_assert( + bridging::getParameterCount(&T::voidFuncAssert) == 1, + \\"Expected voidFuncAssert(...) to have 1 parameters\\"); + + return bridging::callFromJs( + rt, &T::voidFuncAssert, jsInvoker_, instance_); + } + jsi::Object getObjectAssert(jsi::Runtime &rt, jsi::Object arg) override { + static_assert( + bridging::getParameterCount(&T::getObjectAssert) == 2, + \\"Expected getObjectAssert(...) to have 2 parameters\\"); + + return bridging::callFromJs( + rt, &T::getObjectAssert, jsInvoker_, instance_, std::move(arg)); } private: