Skip to content

Commit

Permalink
Make RCTTurboModuleManagerDelegate getTurboModule accept native CallI…
Browse files Browse the repository at this point in the history
…nvoker and PerfLogger

Summary:
Might be worthwhile to just kill this method instead, since we're having all NativeModules provide their TurboModule jsi::HostObjects. But I'll leave that decision to a later time.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D20809201

fbshipit-source-id: ee73d4b5454a76460832a54f9b864841e5b2b9c0
  • Loading branch information
RSNara authored and facebook-github-bot committed Apr 3, 2020
1 parent 69698b2 commit 3a11f05
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
4 changes: 3 additions & 1 deletion RNTester/RNTester/AppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,10 @@ - (Class)getModuleClassFromName:(const char *)name
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
instance:(id<RCTTurboModule>)instance
jsInvoker:(std::shared_ptr<facebook::react::CallInvoker>)jsInvoker
nativeInvoker:(std::shared_ptr<facebook::react::CallInvoker>)nativeInvoker
perfLogger:(id<RCTTurboModulePerformanceLogger>)perfLogger
{
return facebook::react::RNTesterTurboModuleProvider(name, instance, jsInvoker);
return facebook::react::RNTesterTurboModuleProvider(name, instance, jsInvoker, nativeInvoker, perfLogger);
}

- (id<RCTTurboModule>)getModuleInstanceFromClass:(Class)moduleClass
Expand Down
4 changes: 3 additions & 1 deletion RNTester/RNTester/RNTesterTurboModuleProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ std::shared_ptr<TurboModule> RNTesterTurboModuleProvider(const std::string &name
*/
std::shared_ptr<TurboModule> RNTesterTurboModuleProvider(const std::string &name,
id<RCTTurboModule> instance,
std::shared_ptr<CallInvoker> jsInvoker);
std::shared_ptr<CallInvoker> jsInvoker,
std::shared_ptr<CallInvoker> nativeInvoker,
id<RCTTurboModulePerformanceLogger> perfLogger);

} // namespace react
} // namespace facebook
6 changes: 4 additions & 2 deletions RNTester/RNTester/RNTesterTurboModuleProvider.mm
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ Class RNTesterTurboModuleClassProvider(const char *name) {

std::shared_ptr<TurboModule> RNTesterTurboModuleProvider(const std::string &name,
id<RCTTurboModule> instance,
std::shared_ptr<CallInvoker> jsInvoker) {
std::shared_ptr<CallInvoker> jsInvoker,
std::shared_ptr<CallInvoker> nativeInvoker,
id<RCTTurboModulePerformanceLogger> perfLogger) {
if (name == "SampleTurboModule") {
return std::make_shared<NativeSampleTurboModuleSpecJSI>(instance, jsInvoker, nil);
return std::make_shared<NativeSampleTurboModuleSpecJSI>(instance, jsInvoker, nativeInvoker, perfLogger);
}

return nullptr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
// TODO: Move to xplat codegen.
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
instance:(id<RCTTurboModule>)instance
jsInvoker:
(std::shared_ptr<facebook::react::CallInvoker>)jsInvoker;
jsInvoker:(std::shared_ptr<facebook::react::CallInvoker>)jsInvoker
nativeInvoker:
(std::shared_ptr<facebook::react::CallInvoker>)nativeInvoker
perfLogger:(id<RCTTurboModulePerformanceLogger>)perfLogger;

@optional

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,11 @@ - (void)notifyAboutTurboModuleSetup:(const char *)name
* Step 2d: Return an exact sub-class of ObjC TurboModule
*/
[_performanceLogger getTurboModuleFromTMMDelegateStart:moduleName];
auto turboModule = [_delegate getTurboModule:moduleName instance:module jsInvoker:_jsInvoker];
auto turboModule = [_delegate getTurboModule:moduleName
instance:module
jsInvoker:_jsInvoker
nativeInvoker:nullptr
perfLogger:_performanceLogger];
[_performanceLogger getTurboModuleFromTMMDelegateEnd:moduleName];
if (turboModule != nullptr) {
_turboModuleCache.insert({moduleName, turboModule});
Expand Down

0 comments on commit 3a11f05

Please sign in to comment.