Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/jsi and jni #235

Merged
merged 11 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/fabric-example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2157,7 +2157,7 @@ SPEC CHECKSUMS:
RNReanimated: 006a5d3961bf09c1e96d62ed436e02b2e43b89bb
RNScreens: e389d6a6a66a4f0d3662924ecae803073ccce8ec
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
Yoga: 1d66db49f38fd9e576a1d7c3b081e46ab4c28b9e
Yoga: f8ec45ce98bba1bc93dd28f2ee37215180e6d2b6

PODFILE CHECKSUM: d4b0da00bac00e3eab4bc0a377fa848fc7bb5276

Expand Down
4 changes: 2 additions & 2 deletions packages/react-native-audio-api/android/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ file(GLOB_RECURSE SOURCE_FILES
"../common/cpp/*.h"
"../common/cpp/core/*.cpp"
"../common/cpp/core/*.h"
"../common/cpp/wrappers/*.cpp"
"../common/cpp/wrappers/*.h"
"../common/cpp/HostObjects/*.cpp"
"../common/cpp/HostObjects/*.h"
"../common/cpp/utils/*.cpp"
"../common/cpp/utils/*.h"
"../common/cpp/jsi/*.h"
"../common/cpp/jsi/*.cpp"
"../common/cpp/types/*.h"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,8 @@ AudioAPIInstaller::AudioAPIInstaller(
jsCallInvoker_(jsCallInvoker) {}

void AudioAPIInstaller::install() {
auto audioAPIInstallerWrapper =
std::make_shared<AudioAPIInstallerWrapper>(this);
AudioAPIInstallerHostObject::createAndInstallFromWrapper(
audioAPIInstallerWrapper, rnRuntime_, jsCallInvoker_);
auto hostObject =
std::make_shared<AudioAPIInstallerHostObject>(rnRuntime_, jsCallInvoker_);
hostObject->install();
}

std::shared_ptr<AudioContext> AudioAPIInstaller::createAudioContext() {
return std::make_shared<AudioContext>();
}

} // namespace audioapi
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <utility>

#include "AudioAPIInstallerHostObject.h"
#include "AudioAPIInstallerWrapper.h"
#include "AudioContext.h"

namespace audioapi {
Expand Down Expand Up @@ -38,7 +37,6 @@ class AudioAPIInstaller : public jni::HybridClass<AudioAPIInstaller> {
});
}

std::shared_ptr<AudioContext> createAudioContext();
void install();

private:
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,43 @@
#include <utility>
#include <vector>

#include "AudioAPIInstallerWrapper.h"
#include <JsiHostObject.h>
#include <JsiPromise.h>
#include "AudioContextHostObject.h"
#include "JsiPromise.h"

namespace audioapi {
using namespace facebook;

class AudioAPIInstallerWrapper;

class AudioAPIInstallerHostObject : public jsi::HostObject {
class AudioAPIInstallerHostObject
: public JsiHostObject,
public std::enable_shared_from_this<AudioAPIInstallerHostObject> {
public:
explicit AudioAPIInstallerHostObject(
const std::shared_ptr<AudioAPIInstallerWrapper> &wrapper,
jsi::Runtime *runtime,
const std::shared_ptr<react::CallInvoker> &jsInvoker);

#ifdef ANDROID
static void createAndInstallFromWrapper(
const std::shared_ptr<AudioAPIInstallerWrapper> &wrapper,
jsi::Runtime *rnRuntime,
const std::shared_ptr<react::CallInvoker> &jsInvoker) {
auto hostObject = std::make_shared<AudioAPIInstallerHostObject>(
wrapper, rnRuntime, jsInvoker);
auto object = jsi::Object::createFromHostObject(*rnRuntime, hostObject);
rnRuntime->global().setProperty(
*rnRuntime, "__AudioAPIInstaller", std::move(object));
}
#endif
const std::shared_ptr<react::CallInvoker> &jsInvoker)
: rnRuntime_(runtime) {
promiseVendor_ = std::make_shared<PromiseVendor>(runtime, jsInvoker);

jsi::Value get(jsi::Runtime &runtime, const jsi::PropNameID &name) override;
addFunctions(
JSI_EXPORT_FUNCTION(AudioAPIInstallerHostObject, createAudioContext));
}

void set(
jsi::Runtime &runtime,
const jsi::PropNameID &name,
const jsi::Value &value) override;
void install() {
auto object =
jsi::Object::createFromHostObject(*rnRuntime_, shared_from_this());
rnRuntime_->global().setProperty(
*rnRuntime_, "__AudioAPIInstaller", std::move(object));
}

std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime &rt) override;
JSI_HOST_FUNCTION(createAudioContext) {
auto audioContext = std::make_shared<AudioContext>();
auto audioContextHostObject =
std::make_shared<AudioContextHostObject>(audioContext, promiseVendor_);
return jsi::Object::createFromHostObject(runtime, audioContextHostObject);
}

private:
std::shared_ptr<AudioAPIInstallerWrapper> wrapper_;
std::shared_ptr<JsiPromise::PromiseVendor> promiseVendor_;
std::shared_ptr<PromiseVendor> promiseVendor_;
jsi::Runtime *rnRuntime_;
};
} // namespace audioapi

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading