Skip to content

Commit

Permalink
Rename to .hpp
Browse files Browse the repository at this point in the history
  • Loading branch information
mrousavy committed Jun 20, 2024
1 parent 18dac23 commit 84b995e
Show file tree
Hide file tree
Showing 19 changed files with 61 additions and 27 deletions.
2 changes: 2 additions & 0 deletions example/ios/NitroExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@
);
REACT_NATIVE_PATH = "${PODS_ROOT}/../../../node_modules/react-native";
SDKROOT = iphoneos;
SWIFT_OBJC_INTEROP_MODE = objcxx;
USE_HERMES = true;
};
name = Debug;
Expand Down Expand Up @@ -683,6 +684,7 @@
);
REACT_NATIVE_PATH = "${PODS_ROOT}/../../../node_modules/react-native";
SDKROOT = iphoneos;
SWIFT_OBJC_INTEROP_MODE = objcxx;
USE_HERMES = true;
VALIDATE_PRODUCT = YES;
};
Expand Down
2 changes: 1 addition & 1 deletion example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1440,7 +1440,7 @@ SPEC CHECKSUMS:
React-jsitracing: 0fa7f78d8fdda794667cb2e6f19c874c1cf31d7e
React-logger: 29fa3e048f5f67fe396bc08af7606426d9bd7b5d
React-Mapbuffer: bf56147c9775491e53122a94c423ac201417e326
react-native-nitro-modules: 7ce374898fa9867e18014b6960457c9da17096d2
react-native-nitro-modules: 9f30e849db461f046b881701efcebd3c2d44f6aa
React-nativeconfig: 9f223cd321823afdecf59ed00861ab2d69ee0fc1
React-NativeModulesApple: ff7efaff7098639db5631236cfd91d60abff04c0
React-perflogger: 32ed45d9cee02cf6639acae34251590dccd30994
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <jni.h>
#include "react-native-nitro.h"
#include "react-native-nitro.hpp"

extern "C"
JNIEXPORT jdouble JNICALL
Expand Down
6 changes: 3 additions & 3 deletions packages/react-native-nitro-modules/cpp/core/HybridObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Created by Marc Rousavy on 21.02.24.
//

#include "HybridObject.h"
#include "JSIConverter.h"
#include "Logger.h"
#include "HybridObject.hpp"
#include "JSIConverter.hpp"
#include "Logger.hpp"

namespace margelo {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

#pragma once

#include "JSIConverter.h"
#include "Logger.h"
#include "JSIConverter.hpp"
#include "NitroLogger.hpp"
#include <functional>
#include <jsi/jsi.h>
#include <memory>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@

#pragma once

#include "EnumMapper.h"
#include "HybridObject.h"
#include "Promise.h"
#include "PromiseFactory.h"
#include "WorkletRuntimeRegistry.h"
#include "threading/Dispatcher.h"
#include "EnumMapper.hpp"
#include "HybridObject.hpp"
#include "Promise.hpp"
#include "PromiseFactory.hpp"
#include "Dispatcher.hpp"
#include <array>
#include <future>
#include <jsi/jsi.h>
Expand Down Expand Up @@ -201,7 +200,8 @@ template <typename ReturnType, typename... Args> struct JSIConverter<std::functi
static std::function<ReturnType(Args...)> fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
jsi::Function function = arg.getObject(runtime).getFunction(runtime);

std::shared_ptr<jsi::Function> sharedFunction = JSIHelper::createSharedJsiFunction(runtime, std::move(function));
// TODO: Weakify this using a RuntimeWatch so it is safely managed by the Runtime, not by us.
auto sharedFunction = std::make_shared<jsi::Function>(std::move(function));
return [&runtime, sharedFunction](Args... args) -> ReturnType {
jsi::Value result = sharedFunction->call(runtime, JSIConverter<std::decay_t<Args>>::toJSI(runtime, args)...);
if constexpr (std::is_same_v<ReturnType, void>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

#pragma once

#include "HybridObject.h"
#include "Logger.h"
#include "HybridObject.hpp"
#include "NitroLogger.hpp"
#include <memory>
#include <mutex>

Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-nitro-modules/cpp/core/Promise.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "Promise.h"
#include "Promise.hpp"
#include <future>
#include <jsi/jsi.h>
#include <utility>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
// Created by Marc Rousavy on 11.03.24.
//

#include "PromiseFactory.h"
#include "Logger.h"
#include "threading/Dispatcher.h"
#include "PromiseFactory.hpp"
#include "Logger.hpp"
#include "threading/Dispatcher.hpp"

namespace margelo {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

#pragma once

#include "Promise.h"
#include "threading/Dispatcher.h"
#include "Promise.hpp"
#include "Dispatcher.hpp"
#include <jsi/jsi.h>
#include <memory>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#include "react-native-nitro.h"
#include "react-native-nitro.hpp"

#include <react-native-nitro-modules/react-native-nitro-modules-umbrella.h>

namespace nitro {
double multiply(double a, double b) {

return a * b;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#pragma once

#include "Dispatcher.h"
#include "Dispatcher.hpp"
#include <ReactCommon/CallInvoker.h>

namespace margelo {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "Dispatcher.h"
#include "Logger.h"
#include "Dispatcher.hpp"
#include "Logger.hpp"

namespace margelo {

Expand Down
28 changes: 28 additions & 0 deletions packages/react-native-nitro-modules/cpp/utils/NitroLogger.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// Created by Marc Rousavy on 05.03.24.
//

#pragma once

#include <iostream>
#include <string>
#include <format>

namespace margelo {

class Logger {
private:
Logger() = delete;

public:
template <typename... Args> inline static void log(const std::string& tag, const std::string& message, Args&&... args) {
try {
std::string formattedMessage = std::format(message, std::forward<decltype(args)>(args)...);
std::cout << "[" << tag << "] " << formattedMessage << std::endl;
} catch (const std::format_error& e) {
std::cerr << "Formatting error: " << e.what() << std::endl;
}
}
};

} // namespace margelo
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ Pod::Spec.new do |s|
s.subspec 'C++-Bindings' do |ss|
# VisionCamera Core C++ bindings
ss.source_files = [
"cpp/**/*.{h,c,cpp}"
"cpp/**/*.{h,c}",
"cpp/**/*.{hpp,cpp}"
]
ss.public_header_files = [
"cpp/**/*.h"
Expand Down

0 comments on commit 84b995e

Please sign in to comment.