Skip to content

Commit

Permalink
formatting cpp code
Browse files Browse the repository at this point in the history
  • Loading branch information
hannojg committed Oct 15, 2024
1 parent 985499d commit 4c7f90f
Show file tree
Hide file tree
Showing 26 changed files with 81 additions and 86 deletions.
2 changes: 1 addition & 1 deletion package/cpp/RNFChoreographer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Created by Marc Rousavy on 23.02.24.
//

#include "RNFLogger.h"
#include "RNFChoreographer.h"
#include "RNFListenerManager.h"
#include "RNFLogger.h"

namespace margelo {

Expand Down
2 changes: 1 addition & 1 deletion package/cpp/RNFChoreographer.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

#pragma once

#include "RNFLogger.h"
#include "RNFListener.h"
#include "RNFListenerManager.h"
#include "RNFLogger.h"
#include <functional>

namespace margelo {
Expand Down
2 changes: 1 addition & 1 deletion package/cpp/RNFChoreographerWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void ChoreographerWrapper::release() {
}

// TODO: nitro is this still needed? I don't think so
//void ChoreographerWrapper::onRuntimeDestroyed(jsi::Runtime*) {
// void ChoreographerWrapper::onRuntimeDestroyed(jsi::Runtime*) {
// std::unique_lock lock(_mutex);
// Logger::log(TAG, "Runtime destroyed...");
// stopAndRemoveListeners();
Expand Down
2 changes: 1 addition & 1 deletion package/cpp/RNFFilamentBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class FilamentBuffer : public PointerHolder<ManagedBuffer> {
public:
explicit FilamentBuffer(std::shared_ptr<ManagedBuffer> buffer) : PointerHolder("FilamentBuffer", buffer) {}
void loadHybridMethods() override {
PointerHolder::loadHybridMethods();
PointerHolder::loadHybridMethods();
}

std::shared_ptr<ManagedBuffer> getBuffer() {
Expand Down
4 changes: 2 additions & 2 deletions package/cpp/RNFFilamentProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ void FilamentProxy::loadHybridMethods() {
proto.registerHybridMethod("createRecorder", &FilamentProxy::createRecorder);
proto.registerRawHybridMethod("getCurrentDispatcher", 0, &FilamentProxy::getCurrentDispatcher);
proto.registerHybridGetter("hasWorklets", &FilamentProxy::getHasWorklets);
#if HAS_WORKLETS
#if HAS_WORKLETS
proto.registerHybridMethod("createWorkletContext", &FilamentProxy::createWorkletContext);
#endif
#endif
});
}

Expand Down
2 changes: 1 addition & 1 deletion package/cpp/RNFFilamentProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#pragma once

#if __has_include(<NitroModules/HybridObject.hpp>)
#include <NitroModules/HybridObject.hpp>
#include <NitroModules/Dispatcher.hpp>
#include <NitroModules/HybridObject.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
Expand Down
29 changes: 15 additions & 14 deletions package/cpp/RNFFilamentRecorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ namespace margelo {

using namespace facebook;

FilamentRecorder::FilamentRecorder(std::shared_ptr<nitro::Dispatcher> renderThreadDispatcher, int width, int height, int fps, double bitRate)
FilamentRecorder::FilamentRecorder(std::shared_ptr<nitro::Dispatcher> renderThreadDispatcher, int width, int height, int fps,
double bitRate)
: HybridObject("FilamentRecorder"), _renderThreadDispatcher(renderThreadDispatcher), _width(width), _height(height), _fps(fps),
_bitRate(bitRate), _listenerManager(ListenerManager<ReadyForMoreDataCallback>::create()) {
Logger::log(TAG, "Creating %zu x %zu @ %zu FPS (%f bps) FilamentRecorder...", width, height, fps, bitRate);
Expand All @@ -22,19 +23,19 @@ FilamentRecorder::~FilamentRecorder() {

void FilamentRecorder::loadHybridMethods() {
HybridObject::loadHybridMethods();
registerHybrids(this, [](nitro::Prototype& proto) {
proto.registerHybridGetter("width", &FilamentRecorder::getWidth);
proto.registerHybridGetter("height", &FilamentRecorder::getHeight);
proto.registerHybridGetter("fps", &FilamentRecorder::getFps);
proto.registerHybridGetter("bitRate", &FilamentRecorder::getBitRate);
proto.registerHybridGetter("outputFile", &FilamentRecorder::getOutputFile);
proto.registerHybridGetter("isRecording", &FilamentRecorder::getIsRecording);
proto.registerHybridMethod("startRecording", &FilamentRecorder::startRecording);
proto.registerHybridMethod("stopRecording", &FilamentRecorder::stopRecording);
proto.registerHybridMethod("renderFrame", &FilamentRecorder::renderFrame);
// TODO: nitro
// proto.registerHybridMethod("addOnReadyForMoreDataListener", &FilamentRecorder::addOnReadyForMoreDataListener);
});
registerHybrids(this, [](nitro::Prototype& proto) {
proto.registerHybridGetter("width", &FilamentRecorder::getWidth);
proto.registerHybridGetter("height", &FilamentRecorder::getHeight);
proto.registerHybridGetter("fps", &FilamentRecorder::getFps);
proto.registerHybridGetter("bitRate", &FilamentRecorder::getBitRate);
proto.registerHybridGetter("outputFile", &FilamentRecorder::getOutputFile);
proto.registerHybridGetter("isRecording", &FilamentRecorder::getIsRecording);
proto.registerHybridMethod("startRecording", &FilamentRecorder::startRecording);
proto.registerHybridMethod("stopRecording", &FilamentRecorder::stopRecording);
proto.registerHybridMethod("renderFrame", &FilamentRecorder::renderFrame);
// TODO: nitro
// proto.registerHybridMethod("addOnReadyForMoreDataListener", &FilamentRecorder::addOnReadyForMoreDataListener);
});
}

std::shared_ptr<Listener> FilamentRecorder::addOnReadyForMoreDataListener(const ReadyForMoreDataCallback& callback) {
Expand Down
2 changes: 1 addition & 1 deletion package/cpp/RNFFilamentRecorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
#include "RNFListener.h"
#include "RNFListenerManager.h"
#if __has_include(<NitroModules/HybridObject.hpp>)
#include <NitroModules/HybridObject.hpp>
#include <NitroModules/Dispatcher.hpp>
#include <NitroModules/HybridObject.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
Expand Down
4 changes: 1 addition & 3 deletions package/cpp/RNFListener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ Listener::~Listener() {

void Listener::loadHybridMethods() {
HybridObject::loadHybridMethods();
registerHybrids(this, [](nitro::Prototype& proto) {
proto.registerHybridMethod("remove", &Listener::remove);
});
registerHybrids(this, [](nitro::Prototype& proto) { proto.registerHybridMethod("remove", &Listener::remove); });
}

void Listener::remove() {
Expand Down
2 changes: 1 addition & 1 deletion package/cpp/RNFSurfaceProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#pragma once

#if __has_include(<NitroModules/HybridObject.hpp>)
#include <NitroModules/HybridObject.hpp>
#include <NitroModules/Dispatcher.hpp>
#include <NitroModules/HybridObject.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
Expand Down
21 changes: 11 additions & 10 deletions package/cpp/bullet/RNFBulletWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ namespace margelo {
void BulletWrapper::loadHybridMethods() {
HybridObject::loadHybridMethods();
registerHybrids(this, [](nitro::Prototype& proto) {
proto.registerHybridMethod("createDiscreteDynamicWorld", &BulletWrapper::createDiscreteDynamicWorld);
proto.registerHybridMethod("createRigidBody", &BulletWrapper::createRigidBody);
proto.registerHybridMethod("createBoxShape", &BulletWrapper::createBoxShape);
proto.registerHybridMethod("createCylinderShape", &BulletWrapper::createCylinderShape);
proto.registerHybridMethod("createCylinderShapeX", &BulletWrapper::createCylinderShapeX);
proto.registerHybridMethod("createCylinderShapeZ", &BulletWrapper::createCylinderShapeZ);
proto.registerHybridMethod("createStaticPlaneShape", &BulletWrapper::createStaticPlaneShape);
proto.registerHybridMethod("createRigidBodyFromTransform", &BulletWrapper::createRigidBodyFromTransform);
proto.registerHybridMethod("createSphereShape", &BulletWrapper::createSphereShape);
proto.registerHybridMethod("createDiscreteDynamicWorld", &BulletWrapper::createDiscreteDynamicWorld);
proto.registerHybridMethod("createRigidBody", &BulletWrapper::createRigidBody);
proto.registerHybridMethod("createBoxShape", &BulletWrapper::createBoxShape);
proto.registerHybridMethod("createCylinderShape", &BulletWrapper::createCylinderShape);
proto.registerHybridMethod("createCylinderShapeX", &BulletWrapper::createCylinderShapeX);
proto.registerHybridMethod("createCylinderShapeZ", &BulletWrapper::createCylinderShapeZ);
proto.registerHybridMethod("createStaticPlaneShape", &BulletWrapper::createStaticPlaneShape);
proto.registerHybridMethod("createRigidBodyFromTransform", &BulletWrapper::createRigidBodyFromTransform);
proto.registerHybridMethod("createSphereShape", &BulletWrapper::createSphereShape);
});
}

Expand All @@ -37,7 +37,8 @@ std::shared_ptr<RigidBodyWrapper> BulletWrapper::createRigidBody(double mass, do
return RigidBodyWrapper::create(mass, x, y, z, shapePtr, id, collisionCallback);
}

std::shared_ptr<RigidBodyWrapper> BulletWrapper::createRigidBodyFromTransform(double mass, const std::shared_ptr<TMat44Wrapper>& entityTransform,
std::shared_ptr<RigidBodyWrapper> BulletWrapper::createRigidBodyFromTransform(double mass,
const std::shared_ptr<TMat44Wrapper>& entityTransform,
const std::shared_ptr<ShapeWrapper>& shape, std::string id,
const std::optional<CollisionCallback>& collisionCallback) {
const auto& shapePtr = shape->getShape();
Expand Down
3 changes: 1 addition & 2 deletions package/cpp/core/RNFEngineImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ class EngineImpl : public std::enable_shared_from_this<EngineImpl> {
std::shared_ptr<NameComponentManagerWrapper> createNameComponentManager();
std::shared_ptr<MaterialWrapper> createMaterial(std::shared_ptr<FilamentBuffer> materialBuffer);
void createAndSetSkybox(std::string hexColor, std::optional<bool> showSun, std::optional<float> envIntensity);
void createAndSetSkybox(std::shared_ptr<FilamentBuffer> textureBuffer, std::optional<bool> showSun,
std::optional<float> envIntensity);
void createAndSetSkybox(std::shared_ptr<FilamentBuffer> textureBuffer, std::optional<bool> showSun, std::optional<float> envIntensity);
void clearSkybox();
void setAutomaticInstancingEnabled(bool enabled);

Expand Down
2 changes: 1 addition & 1 deletion package/cpp/core/RNFLightManagerWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
namespace margelo {

void LightManagerWrapper::loadHybridMethods() {
PointerHolder::loadHybridMethods();
PointerHolder::loadHybridMethods();
registerHybrids(this, [](nitro::Prototype& proto) {
proto.registerHybridMethod("createLightEntity", &LightManagerWrapper::createLightEntity);
proto.registerHybridMethod("destroy", &LightManagerWrapper::destroy);
Expand Down
2 changes: 1 addition & 1 deletion package/cpp/core/RNFMaterialWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace margelo {
void MaterialWrapper::loadHybridMethods() {
PointerHolder::loadHybridMethods();
PointerHolder::loadHybridMethods();
registerHybrids(this, [](nitro::Prototype& proto) {
proto.registerHybridMethod("createInstance", &MaterialWrapper::createInstance);
proto.registerHybridMethod("setDefaultFloatParameter", &MaterialWrapper::setDefaultFloatParameter);
Expand Down
48 changes: 23 additions & 25 deletions package/cpp/core/RNFNameComponentManagerWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,30 @@

namespace margelo {

void NameComponentManagerWrapper::loadHybridMethods() {
PointerHolder::loadHybridMethods();
registerHybrids(this, [](nitro::Prototype& proto) {
proto.registerHybridMethod("getEntityName", &NameComponentManagerWrapper::getEntityName);
});
}
void NameComponentManagerWrapper::loadHybridMethods() {
PointerHolder::loadHybridMethods();
registerHybrids(
this, [](nitro::Prototype& proto) { proto.registerHybridMethod("getEntityName", &NameComponentManagerWrapper::getEntityName); });
}

// TODO: This code is similar to EntityNameMap AnimatorWrapper::createEntityNameMap, consider refactoring
std::optional<std::string>
NameComponentManagerWrapper::getEntityName(std::shared_ptr<EntityWrapper> entityWrapper) {
if (!entityWrapper) {
throw std::invalid_argument("EntityWrapper is null");
}
// TODO: This code is similar to EntityNameMap AnimatorWrapper::createEntityNameMap, consider refactoring
std::optional<std::string> NameComponentManagerWrapper::getEntityName(std::shared_ptr<EntityWrapper> entityWrapper) {
if (!entityWrapper) {
throw std::invalid_argument("EntityWrapper is null");
}

Entity entity = entityWrapper->getEntity();
bool hasEntity = pointee()->hasComponent(entity);
if (!hasEntity) {
Logger::log(TAG, "Entity wasn't found in NameComponentManager");
return std::nullopt;
}
Entity entity = entityWrapper->getEntity();
bool hasEntity = pointee()->hasComponent(entity);
if (!hasEntity) {
Logger::log(TAG, "Entity wasn't found in NameComponentManager");
return std::nullopt;
}

NameComponentManager::Instance instance = pointee()->getInstance(entity);
if (!instance || !instance.isValid()) {
Logger::log(TAG, "Instance wasn't found in NameComponentManager");
return std::nullopt;
}
return pointee()->getName(instance);
}
NameComponentManager::Instance instance = pointee()->getInstance(entity);
if (!instance || !instance.isValid()) {
Logger::log(TAG, "Instance wasn't found in NameComponentManager");
return std::nullopt;
}
return pointee()->getName(instance);
}
} // namespace margelo
4 changes: 2 additions & 2 deletions package/cpp/core/RNFNameComponentManagerWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

#pragma once

#include "jsi/RNFPointerHolder.h"
#include "core/utils/RNFEntityWrapper.h"
#include "jsi/RNFPointerHolder.h"
#include <utils/NameComponentManager.h>

namespace margelo {
Expand All @@ -27,7 +27,7 @@ class NameComponentManagerWrapper : public PointerHolder<NameComponentManager> {
static auto constexpr TAG = "NameComponentManagerWrapper";

private: // Exposed JS method
std::optional<std::string> getEntityName(std::shared_ptr<EntityWrapper> entityWrapper);
std::optional<std::string> getEntityName(std::shared_ptr<EntityWrapper> entityWrapper);
};

} // namespace margelo
2 changes: 1 addition & 1 deletion package/cpp/core/RNFRenderableManagerWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace margelo {
void RenderableManagerWrapper::loadHybridMethods() {
PointerHolder::loadHybridMethods();
PointerHolder::loadHybridMethods();
registerHybrids(this, [](nitro::Prototype& proto) {
proto.registerHybridMethod("getPrimitiveCount", &RenderableManagerWrapper::getPrimitiveCount);
proto.registerHybridMethod("getMaterialInstanceAt", &RenderableManagerWrapper::getMaterialInstanceAt);
Expand Down
2 changes: 1 addition & 1 deletion package/cpp/core/RNFSceneWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace margelo {

void margelo::SceneWrapper::loadHybridMethods() {
PointerHolder::loadHybridMethods();
PointerHolder::loadHybridMethods();
registerHybrids(this, [](nitro::Prototype& proto) {
proto.registerHybridMethod("addEntity", &SceneWrapper::addEntity);
proto.registerHybridMethod("addEntities", &SceneWrapper::addEntities);
Expand Down
2 changes: 1 addition & 1 deletion package/cpp/core/RNFSwapChainWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class SwapChainWrapper : public PointerHolder<SwapChain> {
explicit SwapChainWrapper(std::shared_ptr<SwapChain> swapChain) : PointerHolder("SwapChainWrapper", swapChain) {}

void loadHybridMethods() override {
PointerHolder::loadHybridMethods();
PointerHolder::loadHybridMethods();
}

std::shared_ptr<SwapChain> getSwapChain() {
Expand Down
2 changes: 1 addition & 1 deletion package/cpp/core/RNFTransformManagerWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace margelo {

void TransformManagerWrapper::loadHybridMethods() {
PointerHolder::loadHybridMethods();
PointerHolder::loadHybridMethods();
registerHybrids(this, [](nitro::Prototype& proto) {
proto.registerHybridMethod("getTransform", &TransformManagerWrapper::getTransform);
proto.registerHybridMethod("getWorldTransform", &TransformManagerWrapper::getWorldTransform);
Expand Down
2 changes: 1 addition & 1 deletion package/cpp/core/RNFViewWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace margelo {

void ViewWrapper::loadHybridMethods() {
PointerHolder::loadHybridMethods();
PointerHolder::loadHybridMethods();
registerHybrids(this, [](nitro::Prototype& proto) {
proto.registerHybridMethod("getAspectRatio", &ViewWrapper::getAspectRatio);
proto.registerHybridMethod("createAmbientOcclusionOptions", &ViewWrapper::createAmbientOcclusionOptions);
Expand Down
4 changes: 1 addition & 3 deletions package/cpp/core/utils/RNFEntityWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

void margelo::EntityWrapper::loadHybridMethods() {
HybridObject::loadHybridMethods();
registerHybrids(this, [](nitro::Prototype& proto) {
proto.registerHybridGetter("id", &EntityWrapper::getId);
});
registerHybrids(this, [](nitro::Prototype& proto) { proto.registerHybridGetter("id", &EntityWrapper::getId); });
}

int margelo::EntityWrapper::getId() {
Expand Down
2 changes: 1 addition & 1 deletion package/cpp/core/utils/RNFManipulatorWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace margelo {
void ManipulatorWrapper::loadHybridMethods() {
PointerHolder::loadHybridMethods();
PointerHolder::loadHybridMethods();
registerHybrids(this, [](nitro::Prototype& proto) {
proto.registerHybridMethod("grabBegin", &ManipulatorWrapper::grabBegin);
proto.registerHybridMethod("grabUpdate", &ManipulatorWrapper::grabUpdate);
Expand Down
16 changes: 8 additions & 8 deletions package/cpp/jsi/RNFPointerHolder.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ template <typename T> class PointerHolder : public nitro::HybridObject {
Logger::log(TAG, "Automatically releasing %s... (~PointerHolder())", _name.c_str());
}
}
void loadHybridMethods() override {
HybridObject::loadHybridMethods();
registerHybrids(this, [](nitro::Prototype& proto) {
proto.registerHybridMethod("release", &PointerHolder<T>::release);
proto.registerHybridGetter("isValid", &PointerHolder<T>::getIsValid);
});
}

void loadHybridMethods() override {
HybridObject::loadHybridMethods();
registerHybrids(this, [](nitro::Prototype& proto) {
proto.registerHybridMethod("release", &PointerHolder<T>::release);
proto.registerHybridGetter("isValid", &PointerHolder<T>::getIsValid);
});
}

protected:
/**
Expand Down
2 changes: 1 addition & 1 deletion package/ios/src/RNFAppleFilamentRecorder.mm
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Created by Marc Rousavy on 02.05.24.
//

#include "RNFLogger.h"
#include "RNFAppleFilamentRecorder.h"
#include "RNFLogger.h"
#include <CoreFoundation/CoreFoundation.h>
#include <CoreVideo/CoreVideo.h>
#include <VideoToolbox/VTCompressionProperties.h>
Expand Down
2 changes: 1 addition & 1 deletion package/ios/src/RNFFilamentInstaller.mm
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ + (BOOL)installToBridge:(jsi::Runtime*)runtime
#else
auto filamentProxy = std::make_shared<margelo::AppleFilamentProxy>(runtime, jsDispatcher);
#endif
runtime->global().setProperty(*runtime, "FilamentProxy", filamentProxy->toObject(*runtime));
runtime->global().setProperty(*runtime, "FilamentProxy", filamentProxy->toObject(*runtime));

return YES;
}
Expand Down

0 comments on commit 4c7f90f

Please sign in to comment.