Skip to content

Commit b51ee83

Browse files
authored
feat: Expose getRuntime() and getCallInvoker() in FilamentProxy (#12)
1 parent d9e43e0 commit b51ee83

File tree

7 files changed

+38
-0
lines changed

7 files changed

+38
-0
lines changed

package/android/src/main/cpp/AndroidFilamentProxy.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,12 @@ std::shared_ptr<Choreographer> AndroidFilamentProxy::createChoreographer() {
2929
return _proxy->cthis()->createChoreographer();
3030
}
3131

32+
std::shared_ptr<react::CallInvoker> AndroidFilamentProxy::getCallInvoker() {
33+
return _proxy->cthis()->getCallInvoker();
34+
}
35+
36+
jsi::Runtime& AndroidFilamentProxy::getRuntime() {
37+
return _proxy->cthis()->getRuntime();
38+
}
39+
3240
} // namespace margelo

package/android/src/main/cpp/AndroidFilamentProxy.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ class AndroidFilamentProxy : public FilamentProxy {
2727
std::shared_ptr<FilamentView> findFilamentView(int id) override;
2828
std::shared_ptr<Choreographer> createChoreographer() override;
2929

30+
public:
31+
jsi::Runtime& getRuntime() override;
32+
std::shared_ptr<react::CallInvoker> getCallInvoker() override;
33+
3034
private:
3135
jni::global_ref<JFilamentProxy::javaobject> _proxy;
3236
};

package/android/src/main/cpp/java-bindings/JFilamentProxy.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ jsi::Runtime& JFilamentProxy::getRuntime() {
4949
return *_runtime;
5050
}
5151

52+
std::shared_ptr<react::CallInvoker> JFilamentProxy::getCallInvoker() {
53+
return _callInvoker;
54+
}
55+
5256
void JFilamentProxy::registerNatives() {
5357
registerHybrid({makeNativeMethod("initHybrid", JFilamentProxy::initHybrid)});
5458
}

package/android/src/main/cpp/java-bindings/JFilamentProxy.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class JFilamentProxy : public jni::HybridClass<JFilamentProxy> {
2929
std::shared_ptr<Choreographer> createChoreographer();
3030

3131
jsi::Runtime& getRuntime();
32+
std::shared_ptr<react::CallInvoker> getCallInvoker();
3233

3334
private:
3435
friend HybridBase;

package/cpp/FilamentProxy.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#include "FilamentView.h"
1212
#include "jsi/HybridObject.h"
1313
#include "test/TestHybridObject.h"
14+
#include <ReactCommon/CallInvoker.h>
15+
#include <jsi/jsi.h>
1416

1517
namespace margelo {
1618

@@ -24,6 +26,10 @@ class FilamentProxy : public HybridObject {
2426

2527
std::shared_ptr<TestHybridObject> createTestObject();
2628

29+
public:
30+
virtual jsi::Runtime& getRuntime() = 0;
31+
virtual std::shared_ptr<react::CallInvoker> getCallInvoker() = 0;
32+
2733
public:
2834
void loadHybridMethods() override;
2935
};

package/ios/src/AppleFilamentProxy.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ class AppleFilamentProxy : public FilamentProxy {
2525
std::shared_ptr<FilamentView> findFilamentView(int modelId) override;
2626
std::shared_ptr<Choreographer> createChoreographer() override;
2727

28+
jsi::Runtime& getRuntime() override;
29+
std::shared_ptr<react::CallInvoker> getCallInvoker() override;
30+
2831
private:
2932
jsi::Runtime* _runtime;
3033
std::shared_ptr<react::CallInvoker> _callInvoker;

package/ios/src/AppleFilamentProxy.mm

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@
2525
// TODO(hanno): cleanup here?
2626
}
2727

28+
jsi::Runtime& AppleFilamentProxy::getRuntime() {
29+
if (_runtime == nullptr) {
30+
[[unlikely]];
31+
throw std::runtime_error("JSI Runtime was null!");
32+
}
33+
return *_runtime;
34+
}
35+
36+
std::shared_ptr<react::CallInvoker> AppleFilamentProxy::getCallInvoker() {
37+
return _callInvoker;
38+
}
39+
2840
int AppleFilamentProxy::loadModel(std::string path) {
2941
// TODO(hanno): Implement model loading here
3042
return 13;

0 commit comments

Comments
 (0)