From 40dd48c6bdc8a9676eb4f9cd1a48b7ae10b6ad8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Osadnik?= Date: Wed, 14 Aug 2019 04:55:37 -0700 Subject: [PATCH] Fix name of key obtaining from dictionary in inline method in generated objcpp Summary: It was a mistake. We should obtain value by proper key always. Previously by a mistake I hardcoded 'a'. I wasn't break anything because it wasn't used in Internationalization. However, it was a bug Reviewed By: RSNara Differential Revision: D16782132 fbshipit-source-id: 59f7910f2be7753c07f16f00a201de856d57e29e --- .../modules/ObjCppUtils/GenerateStructs.js | 2 +- .../GenerateModuleHObjCpp-test.js.snap | 18 +++++++++--------- .../__snapshots__/GenerateStructs-test.js.snap | 18 +++++++++--------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/packages/react-native-codegen/src/generators/modules/ObjCppUtils/GenerateStructs.js b/packages/react-native-codegen/src/generators/modules/ObjCppUtils/GenerateStructs.js index d67dec7aa57..73614202abf 100644 --- a/packages/react-native-codegen/src/generators/modules/ObjCppUtils/GenerateStructs.js +++ b/packages/react-native-codegen/src/generators/modules/ObjCppUtils/GenerateStructs.js @@ -39,7 +39,7 @@ namespace JS { const inlineTemplate = ` inline ::_RETURN_TYPE_::JS::Native::_MODULE_NAME_::::Spec::_STRUCT_NAME_::::::_PROPERTY_NAME_::() const { - id const p = _v[@"a"]; + id const p = _v[@"::_PROPERTY_NAME_::"]; return ::_RETURN_VALUE_::; } `; diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleHObjCpp-test.js.snap b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleHObjCpp-test.js.snap index 5e6858d240e..f94625e7496 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleHObjCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleHObjCpp-test.js.snap @@ -86,63 +86,63 @@ namespace JS { inline bool JS::NativeSampleTurboModule::SpecDifficultA::D() const { - id const p = _v[@\\"a\\"]; + id const p = _v[@\\"D\\"]; return RCTBridgingToBool(p); } inline JS::NativeSampleTurboModule::SpecDifficultAE JS::NativeSampleTurboModule::SpecDifficultA::E() const { - id const p = _v[@\\"a\\"]; + id const p = _v[@\\"E\\"]; return JS::NativeSampleTurboModule::SpecDifficultAE(p); } inline NSString *JS::NativeSampleTurboModule::SpecDifficultA::F() const { - id const p = _v[@\\"a\\"]; + id const p = _v[@\\"F\\"]; return RCTBridgingToString(p); } inline bool JS::NativeSampleTurboModule::SpecDifficultReturnType::D() const { - id const p = _v[@\\"a\\"]; + id const p = _v[@\\"D\\"]; return RCTBridgingToBool(p); } inline double JS::NativeSampleTurboModule::SpecDifficultReturnType::E() const { - id const p = _v[@\\"a\\"]; + id const p = _v[@\\"E\\"]; return RCTBridgingToDouble(p); } inline NSString *JS::NativeSampleTurboModule::SpecDifficultReturnType::F() const { - id const p = _v[@\\"a\\"]; + id const p = _v[@\\"F\\"]; return RCTBridgingToString(p); } inline bool JS::NativeSampleTurboModule::SpecDifficultAE::D() const { - id const p = _v[@\\"a\\"]; + id const p = _v[@\\"D\\"]; return RCTBridgingToBool(p); } inline double JS::NativeSampleTurboModule::SpecDifficultAE::E() const { - id const p = _v[@\\"a\\"]; + id const p = _v[@\\"E\\"]; return RCTBridgingToDouble(p); } inline NSString *JS::NativeSampleTurboModule::SpecDifficultAE::F() const { - id const p = _v[@\\"a\\"]; + id const p = _v[@\\"F\\"]; return RCTBridgingToString(p); } diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateStructs-test.js.snap b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateStructs-test.js.snap index 533eb7201b8..69ed0165418 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateStructs-test.js.snap +++ b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateStructs-test.js.snap @@ -209,63 +209,63 @@ inline bool JS::NativeSampleTurboModule::SpecSampleFuncReturnType::a() const inline double JS::NativeSampleTurboModule::SpecSampleFuncReturnType::b() const { - id const p = _v[@\\"a\\"]; + id const p = _v[@\\"b\\"]; return RCTBridgingToDouble(p); } inline NSString *JS::NativeSampleTurboModule::SpecSampleFuncReturnType::c() const { - id const p = _v[@\\"a\\"]; + id const p = _v[@\\"c\\"]; return RCTBridgingToString(p); } inline JS::NativeSampleTurboModule::SpecSampleFuncReturnTypeD JS::NativeSampleTurboModule::SpecSampleFuncReturnType::d() const { - id const p = _v[@\\"a\\"]; + id const p = _v[@\\"d\\"]; return JS::NativeSampleTurboModule::SpecSampleFuncReturnTypeD(p); } inline bool JS::NativeSampleTurboModule::SpecSampleFuncReturnTypeD::e() const { - id const p = _v[@\\"a\\"]; + id const p = _v[@\\"e\\"]; return RCTBridgingToBool(p); } inline double JS::NativeSampleTurboModule::SpecSampleFuncReturnTypeD::f() const { - id const p = _v[@\\"a\\"]; + id const p = _v[@\\"f\\"]; return RCTBridgingToDouble(p); } inline JS::NativeSampleTurboModule::SpecSampleFuncReturnTypeDG JS::NativeSampleTurboModule::SpecSampleFuncReturnTypeD::g() const { - id const p = _v[@\\"a\\"]; + id const p = _v[@\\"g\\"]; return JS::NativeSampleTurboModule::SpecSampleFuncReturnTypeDG(p); } inline bool JS::NativeSampleTurboModule::SpecSampleFuncReturnTypeDG::h() const { - id const p = _v[@\\"a\\"]; + id const p = _v[@\\"h\\"]; return RCTBridgingToBool(p); } inline double JS::NativeSampleTurboModule::SpecSampleFuncReturnTypeDG::i() const { - id const p = _v[@\\"a\\"]; + id const p = _v[@\\"i\\"]; return RCTBridgingToDouble(p); } inline NSString *JS::NativeSampleTurboModule::SpecSampleFuncReturnTypeDG::j() const { - id const p = _v[@\\"a\\"]; + id const p = _v[@\\"j\\"]; return RCTBridgingToString(p); }