Skip to content

Commit

Permalink
Misc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
teodorciuraru committed Mar 27, 2024
1 parent 8697519 commit ec48c85
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
Binary file modified android/librust_multiply_lib.a
Binary file not shown.
13 changes: 6 additions & 7 deletions cpp/react-native-jsi-module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@

extern "C"
{
int multiply(int a, int b); // Declaration of the Rust function
double multiply(double a, double b); // Declaration of the Rust function
}

namespace jsimodule
{
void bridgeJSIFunctions(Runtime &jsi)
{
// Define the `multiply` function using JSI idioms
auto multiplyFunction = Function::createFromHostFunction(
// Define `multiplyJSI` using JSI idioms.
auto multiplyJSI = Function::createFromHostFunction(
jsi,
PropNameID::forAscii(jsi, "multiplyFunction"),
PropNameID::forAscii(jsi, "multiplyJSI"),
2, // number of arguments
[](Runtime &runtime, const Value &thisValue, const Value *arguments, size_t count) -> Value
{
Expand All @@ -25,12 +25,11 @@ namespace jsimodule
double a = arguments[0].asNumber();
double b = arguments[1].asNumber();

return Value();
// return multiply(a, b);
return multiply(a, b);
});

// Export the `multiply` function to React Native's global object
jsi.global().setProperty(jsi, "multiply", std::move(multiplyFunction));
jsi.global().setProperty(jsi, "multiply", std::move(multiplyJSI));
}

} // namespace jsimodule
Binary file added ios/librust_multiply_lib.a
Binary file not shown.
2 changes: 1 addition & 1 deletion react-native-jsi-module.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Pod::Spec.new do |s|
s.authors = package["author"]

s.platforms = { :ios => min_ios_version_supported }
s.source = { :git => "https://github.com/teodorciuraru/react-native-jsi-module.git", :tag => "#{s.version}" }
s.source = { :git => "https://github.com/teodorciuraru/rn-jsi-rust-bridging", :tag => "#{s.version}" }

s.source_files = "ios/**/*.{h,m,mm}", "cpp/**/*.{hpp,cpp,c,h}"
s.vendored_libraries = 'ios/librust_multiply_lib.a'
Expand Down

0 comments on commit ec48c85

Please sign in to comment.