Skip to content

Commit

Permalink
fix generics
Browse files Browse the repository at this point in the history
  • Loading branch information
mrousavy committed Feb 21, 2024
1 parent 0234630 commit 7ae941a
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 23 deletions.
2 changes: 1 addition & 1 deletion package/android/src/main/cpp/AndroidFilamentProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ using namespace facebook;
class AndroidFilamentProxy : public FilamentProxy {
public:
explicit AndroidFilamentProxy(jni::alias_ref<JFilamentProxy::javaobject> filamentProxy);
~AndroidFilamentProxy() override;
~AndroidFilamentProxy();

private:
// TODO(hanno): implement
Expand Down
2 changes: 1 addition & 1 deletion package/android/src/main/cpp/AndroidSurface.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ using namespace facebook;
class AndroidSurface : public Surface {
public:
explicit AndroidSurface(jni::alias_ref<jobject> javaSurface);
~AndroidSurface() override;
~AndroidSurface();

void* getSurface() override;
int getWidth() override;
Expand Down
11 changes: 0 additions & 11 deletions package/android/src/main/cpp/JNISharedPtr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,5 @@

namespace margelo {

void GlobalRefDeleter::operator()(jni::global_ref<jobject>* ref) {
if (ref) {
ref->release();
delete ref;
}
}

template <typename T, typename std::enable_if<std::is_base_of<jni::HybridClass<T>, T>::value>::type*>
std::shared_ptr<T> JNISharedPtr::make_shared_from_jni(jni::global_ref<typename T::javaobject> ref) {
return std::shared_ptr<T>(ref->cthis(), GlobalRefDeleter{});
}

} // namespace margelo
15 changes: 13 additions & 2 deletions package/android/src/main/cpp/JNISharedPtr.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,25 @@ namespace margelo {

using namespace facebook;

template<typename T>
struct GlobalRefDeleter {
void operator()(jni::global_ref<jobject>* ref);
explicit GlobalRefDeleter(jni::global_ref<typename T::javaobject> ref): _ref(ref) {}

void operator()(T* _) {
if (_ref) {
_ref.release();
}
}
private:
jni::global_ref<typename T::javaobject> _ref;
};

class JNISharedPtr {
public:
template <typename T, typename std::enable_if<std::is_base_of<jni::HybridClass<T>, T>::value>::type* = nullptr>
static std::shared_ptr<T> make_shared_from_jni(jni::global_ref<typename T::javaobject> ref);
static std::shared_ptr<T> make_shared_from_jni(jni::global_ref<typename T::javaobject> ref) {
return std::shared_ptr<T>(ref->cthis(), GlobalRefDeleter<T> {ref});
}
};

} // namespace margelo
3 changes: 0 additions & 3 deletions package/cpp/FilamentProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ namespace margelo {
using namespace facebook;

class FilamentProxy : public jsi::HostObject {
public:
virtual ~FilamentProxy() = 0;

private:
virtual int loadModel(const std::string& path) = 0;
virtual std::shared_ptr<FilamentView> findFilamentView(int id) = 0;
Expand Down
3 changes: 0 additions & 3 deletions package/cpp/FilamentView.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ namespace margelo {
using namespace facebook;

class FilamentView {
public:
virtual ~FilamentView() = 0;

public:
virtual const SurfaceProvider& getSurfaceProvider() = 0;
};
Expand Down
2 changes: 0 additions & 2 deletions package/cpp/Surface.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ namespace margelo {

class Surface {
public:
virtual ~Surface() = 0;

/**
* Returns the surface ("native window") that can be used as a render target.
* On Android, this is a `ANativeWindow*`, on iOS it is a `CAMetalLayer*`.
Expand Down

0 comments on commit 7ae941a

Please sign in to comment.