-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dce18bc
commit 04748da
Showing
12 changed files
with
97 additions
and
60 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 macros_h | ||
#define macros_h | ||
|
||
#define HOSTFN(name) \ | ||
jsi::Function::createFromHostFunction( \ | ||
rt, \ | ||
jsi::PropNameID::forAscii(rt, name), \ | ||
0, \ | ||
[=](jsi::Runtime &rt, const jsi::Value &thisValue, const jsi::Value *args, size_t count) -> jsi::Value | ||
|
||
#endif /* macros_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,21 @@ | ||
#include "react-native-rapier.h" | ||
#include "macros.h" | ||
|
||
|
||
namespace callstack { | ||
namespace react_native_rapier { | ||
void install(jsi::Runtime& rt) { | ||
auto multiply = HOSTFN("multiply") { | ||
auto num1 = args[0].asNumber(); | ||
auto num2 = args[1].asNumber(); | ||
return jsi::Value(num1 + num2); | ||
}); | ||
|
||
auto rapier = jsi::Object { rt }; | ||
rapier.setProperty(rt, "multiply", std::move(multiply)); | ||
|
||
rt.global().setProperty(rt, "__RapierProxy", std::move(rapier)); | ||
} | ||
} | ||
} | ||
|
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,9 @@ | ||
#include <ReactCommon/TurboModule.h> | ||
|
||
using namespace facebook; | ||
|
||
namespace callstack { | ||
namespace react_native_rapier { | ||
void install(jsi::Runtime& rt); | ||
} | ||
} |
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
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
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 |
---|---|---|
@@ -1,8 +1,6 @@ | ||
import type { TurboModule } from 'react-native'; | ||
import { TurboModuleRegistry } from 'react-native'; | ||
|
||
export interface Spec extends TurboModule { | ||
multiply(a: number, b: number): Promise<number>; | ||
} | ||
export interface Spec extends TurboModule {} | ||
|
||
export default TurboModuleRegistry.getEnforcing<Spec>('ReactNativeRapier'); |
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