Skip to content

Commit

Permalink
Fix reported properties for native modules (facebook#46788)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#46788

Changelog: [internal]

This fixes the reported keys for C++ TurboModules. Before, we were trying to read the properties from the method map in the public `TurboModule`, but in this implementation all the logic is actually in its delegate (also a `TurboModule` instance, yeah, confusing).

This fixes the issue by forwarding the call to the delegate that has the right information.

Differential Revision: D63761381
  • Loading branch information
rubennorte authored and facebook-github-bot committed Oct 2, 2024
1 parent c430083 commit d1d1d92
Show file tree
Hide file tree
Showing 3 changed files with 176 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ public:
return delegate_.create(rt, propName);
}

std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
return delegate_.getPropertyNames(runtime);
}

static constexpr std::string_view kModuleName = \\"SampleTurboModule\\";

protected:
Expand Down Expand Up @@ -103,6 +107,10 @@ public:
return delegate_.create(rt, propName);
}

std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
return delegate_.getPropertyNames(runtime);
}

static constexpr std::string_view kModuleName = \\"SampleTurboModule\\";

protected:
Expand Down Expand Up @@ -162,6 +170,10 @@ public:
return delegate_.create(rt, propName);
}

std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
return delegate_.getPropertyNames(runtime);
}

static constexpr std::string_view kModuleName = \\"SampleTurboModule\\";

protected:
Expand Down Expand Up @@ -461,6 +473,10 @@ public:
return delegate_.create(rt, propName);
}

std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
return delegate_.getPropertyNames(runtime);
}

static constexpr std::string_view kModuleName = \\"NativeEnumTurboModule\\";

protected:
Expand Down Expand Up @@ -556,6 +572,10 @@ public:
return delegate_.create(rt, propName);
}

std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
return delegate_.getPropertyNames(runtime);
}

static constexpr std::string_view kModuleName = \\"SampleTurboModule\\";

protected:
Expand Down Expand Up @@ -647,6 +667,10 @@ public:
return delegate_.create(rt, propName);
}

std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
return delegate_.getPropertyNames(runtime);
}

static constexpr std::string_view kModuleName = \\"SampleTurboModule\\";

protected:
Expand Down Expand Up @@ -709,6 +733,10 @@ public:
return delegate_.create(rt, propName);
}

std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
return delegate_.getPropertyNames(runtime);
}

static constexpr std::string_view kModuleName = \\"SampleTurboModule\\";

protected:
Expand Down Expand Up @@ -791,6 +819,10 @@ public:
return delegate_.create(rt, propName);
}

std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
return delegate_.getPropertyNames(runtime);
}

static constexpr std::string_view kModuleName = \\"SampleTurboModule\\";

protected:
Expand Down Expand Up @@ -893,6 +925,10 @@ public:
return delegate_.create(rt, propName);
}

std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
return delegate_.getPropertyNames(runtime);
}

static constexpr std::string_view kModuleName = \\"NativePartialAnnotationTurboModule\\";

protected:
Expand Down Expand Up @@ -968,6 +1004,10 @@ public:
return delegate_.create(rt, propName);
}

std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
return delegate_.getPropertyNames(runtime);
}

static constexpr std::string_view kModuleName = \\"SampleTurboModule\\";

protected:
Expand Down Expand Up @@ -1078,6 +1118,10 @@ public:
return delegate_.create(rt, propName);
}

std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
return delegate_.getPropertyNames(runtime);
}

static constexpr std::string_view kModuleName = \\"SampleTurboModule\\";

protected:
Expand Down Expand Up @@ -1276,6 +1320,10 @@ public:
return delegate_.create(rt, propName);
}

std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
return delegate_.getPropertyNames(runtime);
}

static constexpr std::string_view kModuleName = \\"SampleTurboModuleArrays\\";

protected:
Expand Down Expand Up @@ -1474,6 +1522,10 @@ public:
return delegate_.create(rt, propName);
}

std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
return delegate_.getPropertyNames(runtime);
}

static constexpr std::string_view kModuleName = \\"SampleTurboModuleNullable\\";

protected:
Expand Down Expand Up @@ -1674,6 +1726,10 @@ public:
return delegate_.create(rt, propName);
}

std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
return delegate_.getPropertyNames(runtime);
}

static constexpr std::string_view kModuleName = \\"SampleTurboModuleNullableAndOptional\\";

protected:
Expand Down Expand Up @@ -1874,6 +1930,10 @@ public:
return delegate_.create(rt, propName);
}

std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
return delegate_.getPropertyNames(runtime);
}

static constexpr std::string_view kModuleName = \\"SampleTurboModuleOptional\\";

protected:
Expand Down Expand Up @@ -2021,6 +2081,10 @@ public:
return delegate_.create(rt, propName);
}

std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
return delegate_.getPropertyNames(runtime);
}

static constexpr std::string_view kModuleName = \\"SampleTurboModule\\";

protected:
Expand Down Expand Up @@ -2102,6 +2166,10 @@ public:
return delegate_.create(rt, propName);
}

std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
return delegate_.getPropertyNames(runtime);
}

static constexpr std::string_view kModuleName = \\"SampleTurboModule\\";

protected:
Expand Down Expand Up @@ -2169,6 +2237,10 @@ public:
return delegate_.create(rt, propName);
}

std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
return delegate_.getPropertyNames(runtime);
}

static constexpr std::string_view kModuleName = \\"SampleTurboModule\\";

protected:
Expand Down Expand Up @@ -2228,6 +2300,10 @@ public:
return delegate_.create(rt, propName);
}

std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
return delegate_.getPropertyNames(runtime);
}

static constexpr std::string_view kModuleName = \\"SampleTurboModule\\";

protected:
Expand Down Expand Up @@ -2527,6 +2603,10 @@ public:
return delegate_.create(rt, propName);
}

std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
return delegate_.getPropertyNames(runtime);
}

static constexpr std::string_view kModuleName = \\"NativeEnumTurboModule\\";

protected:
Expand Down Expand Up @@ -2622,6 +2702,10 @@ public:
return delegate_.create(rt, propName);
}

std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
return delegate_.getPropertyNames(runtime);
}

static constexpr std::string_view kModuleName = \\"SampleTurboModule\\";

protected:
Expand Down Expand Up @@ -2713,6 +2797,10 @@ public:
return delegate_.create(rt, propName);
}

std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
return delegate_.getPropertyNames(runtime);
}

static constexpr std::string_view kModuleName = \\"SampleTurboModule\\";

protected:
Expand Down Expand Up @@ -2775,6 +2863,10 @@ public:
return delegate_.create(rt, propName);
}

std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
return delegate_.getPropertyNames(runtime);
}

static constexpr std::string_view kModuleName = \\"SampleTurboModule\\";

protected:
Expand Down Expand Up @@ -2857,6 +2949,10 @@ public:
return delegate_.create(rt, propName);
}

std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
return delegate_.getPropertyNames(runtime);
}

static constexpr std::string_view kModuleName = \\"SampleTurboModule\\";

protected:
Expand Down Expand Up @@ -2959,6 +3055,10 @@ public:
return delegate_.create(rt, propName);
}

std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
return delegate_.getPropertyNames(runtime);
}

static constexpr std::string_view kModuleName = \\"NativePartialAnnotationTurboModule\\";

protected:
Expand Down Expand Up @@ -3034,6 +3134,10 @@ public:
return delegate_.create(rt, propName);
}

std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
return delegate_.getPropertyNames(runtime);
}

static constexpr std::string_view kModuleName = \\"SampleTurboModule\\";

protected:
Expand Down Expand Up @@ -3144,6 +3248,10 @@ public:
return delegate_.create(rt, propName);
}

std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
return delegate_.getPropertyNames(runtime);
}

static constexpr std::string_view kModuleName = \\"SampleTurboModule\\";

protected:
Expand Down Expand Up @@ -3342,6 +3450,10 @@ public:
return delegate_.create(rt, propName);
}

std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
return delegate_.getPropertyNames(runtime);
}

static constexpr std::string_view kModuleName = \\"SampleTurboModuleArrays\\";

protected:
Expand Down Expand Up @@ -3540,6 +3652,10 @@ public:
return delegate_.create(rt, propName);
}

std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
return delegate_.getPropertyNames(runtime);
}

static constexpr std::string_view kModuleName = \\"SampleTurboModuleNullable\\";

protected:
Expand Down Expand Up @@ -3740,6 +3856,10 @@ public:
return delegate_.create(rt, propName);
}

std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
return delegate_.getPropertyNames(runtime);
}

static constexpr std::string_view kModuleName = \\"SampleTurboModuleNullableAndOptional\\";

protected:
Expand Down Expand Up @@ -3940,6 +4060,10 @@ public:
return delegate_.create(rt, propName);
}

std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
return delegate_.getPropertyNames(runtime);
}

static constexpr std::string_view kModuleName = \\"SampleTurboModuleOptional\\";

protected:
Expand Down Expand Up @@ -4087,6 +4211,10 @@ public:
return delegate_.create(rt, propName);
}

std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
return delegate_.getPropertyNames(runtime);
}

static constexpr std::string_view kModuleName = \\"SampleTurboModule\\";

protected:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ public:
return delegate_.create(rt, propName);
}
std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
return delegate_.getPropertyNames(runtime);
}
static constexpr std::string_view kModuleName = "${moduleName}";
protected:
Expand Down
Loading

0 comments on commit d1d1d92

Please sign in to comment.