-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from SamuelScheit/ios-support
- Loading branch information
Showing
5 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#[no_mangle] | ||
pub extern "C" fn ExampleJsiModule_init( | ||
rt: *mut jsi::sys::Runtime, | ||
call_invoker: cxx::SharedPtr<jsi::sys::CallInvoker>, | ||
) { | ||
crate::init(rt, call_invoker); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
#ifndef ExampleJsiModule_h | ||
#define ExampleJsiModule_h | ||
|
||
#include <memory> | ||
|
||
extern "C" { | ||
void ExampleJsiModule_init(void* rt, std::shared_ptr<void> ctx); | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#ifndef RCTExampleJsiModule_h | ||
#define RCTExampleJsiModule_h | ||
|
||
#include "ExampleJsiModule.h" | ||
|
||
#import <React/RCTBridgeModule.h> | ||
@interface RCTExampleJsiModule : NSObject <RCTBridgeModule> | ||
@end | ||
|
||
|
||
#endif /* RCTExampleJsiModule_h */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#import <Foundation/Foundation.h> | ||
#import "RCTExampleJsiModule.h" | ||
|
||
#import <React/RCTBridge+Private.h> | ||
#import <React/RCTBridge.h> | ||
#import <React/RCTUtils.h> | ||
#import <jsi/jsi.h> | ||
#import <ReactCommon/RCTTurboModule.h> | ||
|
||
@implementation RCTExampleJsiModule | ||
|
||
@synthesize bridge = _bridge; | ||
|
||
RCT_EXPORT_MODULE(ExampleJsiModule) | ||
|
||
- (void)invalidate { | ||
_bridge = nil; | ||
} | ||
|
||
- (void)setBridge:(RCTBridge *)bridge { | ||
_bridge = bridge; | ||
} | ||
|
||
+ (BOOL)requiresMainQueueSetup { | ||
return YES; | ||
} | ||
|
||
|
||
void installApi(std::shared_ptr<facebook::react::CallInvoker> callInvoker, | ||
facebook::jsi::Runtime *runtime) { | ||
|
||
ExampleJsiModule_init((void*)runtime, (std::shared_ptr<void>) callInvoker); | ||
} | ||
|
||
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install) { | ||
RCTCxxBridge *cxxBridge = (RCTCxxBridge *)_bridge; | ||
if (cxxBridge.runtime != nullptr) { | ||
auto callInvoker = cxxBridge.jsCallInvoker; | ||
facebook::jsi::Runtime *jsRuntime = (facebook::jsi::Runtime *)cxxBridge.runtime; | ||
|
||
installApi(callInvoker, jsRuntime); | ||
return @true; | ||
} | ||
return @false; | ||
} | ||
|
||
|
||
@end |