Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions .github/workflows/validate-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,7 @@ jobs:
- name: Run cpplint
run: |
scripts/cpplint.sh

- name: Disallow DEBUG macros
run: |
! egrep -r '(#if DEBUG|#ifdef DEBUG)' Common/cpp apple android/src/main/cpp
10 changes: 5 additions & 5 deletions Common/cpp/LayoutAnimations/LayoutAnimationsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "CollectionUtils.h"
#include "Shareables.h"

#ifdef DEBUG
#ifndef NDEBUG
#include <utility>
#include "JSLogger.h"
#endif
Expand Down Expand Up @@ -59,11 +59,11 @@ void LayoutAnimationsManager::clearLayoutAnimationConfig(int tag) {
exitingAnimations_.erase(tag);
layoutAnimations_.erase(tag);
shouldAnimateExitingForTag_.erase(tag);
#ifdef DEBUG
#ifndef NDEBUG
const auto &pair = viewsScreenSharedTagMap_[tag];
screenSharedTagSet_.erase(pair);
viewsScreenSharedTagMap_.erase(tag);
#endif // DEBUG
#endif // NDEBUG

sharedTransitionAnimations_.erase(tag);
auto const &groupName = viewTagToSharedTag_[tag];
Expand Down Expand Up @@ -136,7 +136,7 @@ int LayoutAnimationsManager::findPrecedingViewTagForTransition(int tag) {
return -1;
}

#ifdef DEBUG
#ifndef NDEBUG
std::string LayoutAnimationsManager::getScreenSharedTagPairString(
const int screenTag,
const std::string &sharedTag) const {
Expand All @@ -160,7 +160,7 @@ void LayoutAnimationsManager::checkDuplicateSharedTag(
viewsScreenSharedTagMap_[viewTag] = pair;
screenSharedTagSet_.insert(pair);
}
#endif // DEBUG
#endif // NDEBUG

std::unordered_map<int, std::shared_ptr<Shareable>>
&LayoutAnimationsManager::getConfigsForType(LayoutAnimationType type) {
Expand Down
8 changes: 4 additions & 4 deletions Common/cpp/LayoutAnimations/LayoutAnimationsManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "LayoutAnimationType.h"
#include "Shareables.h"

#ifdef DEBUG
#ifndef NDEBUG
#include "JSLogger.h"
#endif

Expand All @@ -23,7 +23,7 @@ using namespace facebook;

class LayoutAnimationsManager {
public:
#ifdef DEBUG
#ifndef NDEBUG
explicit LayoutAnimationsManager(const std::shared_ptr<JSLogger> &jsLogger)
: jsLogger_(jsLogger) {}
#endif
Expand All @@ -43,7 +43,7 @@ class LayoutAnimationsManager {
void clearLayoutAnimationConfig(int tag);
void cancelLayoutAnimation(jsi::Runtime &rt, int tag);
int findPrecedingViewTagForTransition(int tag);
#ifdef DEBUG
#ifndef NDEBUG
std::string getScreenSharedTagPairString(
const int screenTag,
const std::string &sharedTag) const;
Expand All @@ -54,7 +54,7 @@ class LayoutAnimationsManager {
std::unordered_map<int, std::shared_ptr<Shareable>> &getConfigsForType(
LayoutAnimationType type);

#ifdef DEBUG
#ifndef NDEBUG
std::shared_ptr<JSLogger> jsLogger_;
// This set's function is to detect duplicate sharedTags on a single screen
// it contains strings in form: "reactScreenTag:sharedTag"
Expand Down
4 changes: 2 additions & 2 deletions Common/cpp/NativeModules/NativeReanimatedModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include <fbjni/fbjni.h>
#endif

#ifdef DEBUG
#ifndef NDEBUG
#include "JSLogger.h"
#endif

Expand Down Expand Up @@ -61,7 +61,7 @@ NativeReanimatedModule::NativeReanimatedModule(
onRender(timestampMs);
}),
animatedSensorModule_(platformDepMethodsHolder),
#ifdef DEBUG
#ifndef NDEBUG
layoutAnimationsManager_(std::make_shared<JSLogger>(jsScheduler_)),
#endif
#ifdef RCT_NEW_ARCH_ENABLED
Expand Down
2 changes: 1 addition & 1 deletion Common/cpp/NativeModules/NativeReanimatedModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class NativeReanimatedModule : public NativeReanimatedModuleSpec {
const KeyboardEventSubscribeFunction subscribeForKeyboardEventsFunction_;
const KeyboardEventUnsubscribeFunction unsubscribeFromKeyboardEventsFunction_;

#ifdef DEBUG
#ifndef NDEBUG
SingleInstanceChecker<NativeReanimatedModule> singleInstanceChecker_;
#endif
};
Expand Down
8 changes: 4 additions & 4 deletions Common/cpp/ReanimatedRuntime/RNRuntimeDecorator.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "RNRuntimeDecorator.h"
#ifdef DEBUG
#ifndef NDEBUG
#include "ReanimatedVersion.h"
#endif // DEBUG
#endif // NDEBUG

namespace reanimated {

Expand Down Expand Up @@ -31,9 +31,9 @@ void RNRuntimeDecorator::decorate(
#endif // RCT_NEW_ARCH_ENABLED
rnRuntime.global().setProperty(rnRuntime, "_IS_FABRIC", isFabric);

#ifdef DEBUG
#ifndef NDEBUG
checkJSVersion(rnRuntime);
#endif // DEBUG
#endif // NDEBUG

rnRuntime.global().setProperty(
rnRuntime, "_REANIMATED_IS_REDUCED_MOTION", isReducedMotion);
Expand Down
4 changes: 2 additions & 2 deletions Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ ReanimatedHermesRuntime::ReanimatedHermesRuntime(
jsQueue->quitSynchronous();
#endif // HERMES_ENABLE_DEBUGGER

#ifdef DEBUG
#ifndef NDEBUG
facebook::hermes::HermesRuntime *wrappedRuntime = runtime_.get();
jsi::Value evalWithSourceMap = jsi::Function::createFromHostFunction(
*runtime_,
Expand All @@ -120,7 +120,7 @@ ReanimatedHermesRuntime::ReanimatedHermesRuntime(
});
runtime_->global().setProperty(
*runtime_, "evalWithSourceMap", evalWithSourceMap);
#endif // DEBUG
#endif // NDEBUG
}

ReanimatedHermesRuntime::~ReanimatedHermesRuntime() {
Expand Down
2 changes: 1 addition & 1 deletion Common/cpp/ReanimatedRuntime/WorkletRuntimeDecorator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void WorkletRuntimeDecorator::decorate(
#endif // RCT_NEW_ARCH_ENABLED
rt.global().setProperty(rt, "_IS_FABRIC", isFabric);

#ifdef DEBUG
#ifndef NDEBUG
auto evalWithSourceUrl = [](jsi::Runtime &rt,
const jsi::Value &thisValue,
const jsi::Value *args,
Expand Down
6 changes: 3 additions & 3 deletions Common/cpp/SharedItems/Shareables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jsi::Function getValueUnpacker(jsi::Runtime &rt) {
return valueUnpacker.asObject(rt).asFunction(rt);
}

#ifdef DEBUG
#ifndef NDEBUG

static const auto callGuardLambda = [](facebook::jsi::Runtime &rt,
const facebook::jsi::Value &thisVal,
Expand All @@ -36,7 +36,7 @@ jsi::Function getCallGuard(jsi::Runtime &rt) {
rt, jsi::PropNameID::forAscii(rt, "callGuard"), 1, callGuardLambda);
}

#endif // DEBUG
#endif // NDEBUG

jsi::Value makeShareableClone(
jsi::Runtime &rt,
Expand Down Expand Up @@ -224,7 +224,7 @@ jsi::Value ShareableRemoteFunction::toJSValue(jsi::Runtime &rt) {
if (&rt == runtime_) {
return jsi::Value(rt, *function_);
} else {
#ifdef DEBUG
#ifndef NDEBUG
return getValueUnpacker(rt).call(
rt,
ShareableJSRef::newHostObject(rt, shared_from_this()),
Expand Down
6 changes: 3 additions & 3 deletions Common/cpp/SharedItems/Shareables.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ namespace reanimated {

jsi::Function getValueUnpacker(jsi::Runtime &rt);

#ifdef DEBUG
#ifndef NDEBUG
jsi::Function getCallGuard(jsi::Runtime &rt);
#endif // DEBUG
#endif // NDEBUG

// If possible, please use `WorkletRuntime::runGuarded` instead.
template <typename... Args>
Expand All @@ -28,7 +28,7 @@ inline void runOnRuntimeGuarded(
// function directly. CallGuard provides a way of capturing exceptions in
// JavaScript and propagating them to the main React Native thread such that
// they can be presented using RN's LogBox.
#ifdef DEBUG
#ifndef NDEBUG
getCallGuard(rt).call(rt, function, args...);
#else
function.asObject(rt).asFunction(rt).call(rt, args...);
Expand Down
4 changes: 2 additions & 2 deletions Common/cpp/Tools/JSLogger.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifdef DEBUG
#ifndef NDEBUG

#include "JSLogger.h"
#include <memory>
Expand All @@ -15,4 +15,4 @@ void JSLogger::warnOnJS(const std::string &warning) const {

} // namespace reanimated

#endif // DEBUG
#endif // NDEBUG
4 changes: 2 additions & 2 deletions Common/cpp/Tools/JSLogger.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifdef DEBUG
#ifndef NDEBUG

#pragma once

Expand All @@ -21,4 +21,4 @@ class JSLogger {

} // namespace reanimated

#endif // DEBUG
#endif // NDEBUG
4 changes: 2 additions & 2 deletions Common/cpp/Tools/ReanimatedVersion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ std::string getReanimatedCppVersion() {

// This function is pretty much a copy of
// `src/reanimated2/platform-specific/checkVersion.ts`.
#ifdef DEBUG
#ifndef NDEBUG
bool matchVersion(const std::string &version1, const std::string &version2) {
std::regex pattern("^\\d+\\.\\d+\\.\\d+$");
if (std::regex_match(version1, pattern) &&
Expand Down Expand Up @@ -68,6 +68,6 @@ void checkJSVersion(jsi::Runtime &rnRuntime) {
"_REANIMATED_VERSION_CPP",
jsi::String::createFromUtf8(rnRuntime, cppVersion));
}
#endif // DEBUG
#endif // NDEBUG

}; // namespace reanimated
4 changes: 2 additions & 2 deletions Common/cpp/Tools/ReanimatedVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ namespace reanimated {

std::string getReanimatedCppVersion();

#ifdef DEBUG
#ifndef NDEBUG
bool matchVersion(const std::string &, const std::string &);
void checkJSVersion(jsi::Runtime &);
#endif // DEBUG
#endif // NDEBUG

}; // namespace reanimated
4 changes: 2 additions & 2 deletions Common/cpp/Tools/SingleInstanceChecker.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#ifdef DEBUG
#ifndef NDEBUG

#include <cxxabi.h>

Expand Down Expand Up @@ -67,4 +67,4 @@ SingleInstanceChecker<T>::~SingleInstanceChecker() {

} // namespace reanimated

#endif // DEBUG
#endif // NDEBUG
2 changes: 0 additions & 2 deletions Example/ios/ReanimatedExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,6 @@
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
INFOPLIST_FILE = ReanimatedExampleTests/Info.plist;
Expand Down Expand Up @@ -624,7 +623,6 @@
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
Expand Down
2 changes: 1 addition & 1 deletion Example/ios/ReanimatedExample/AppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
#ifndef NDEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
#else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
Expand Down
4 changes: 2 additions & 2 deletions Example/ios/ReanimatedExampleTests/ReanimatedExampleTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ - (void)testRendersWelcomeScreen
BOOL foundElement = NO;

__block NSString *redboxError = nil;
#ifdef DEBUG
#ifndef NDEBUG
RCTSetLogFunction(
^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) {
if (level >= RCTLogLevelError) {
Expand All @@ -55,7 +55,7 @@ - (void)testRendersWelcomeScreen
}];
}

#ifdef DEBUG
#ifndef NDEBUG
RCTSetLogFunction(RCTDefaultLogFunction);
#endif

Expand Down
2 changes: 0 additions & 2 deletions FabricExample/ios/FabricExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,6 @@
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
INFOPLIST_FILE = FabricExampleTests/Info.plist;
Expand Down Expand Up @@ -619,7 +618,6 @@
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
Expand Down
2 changes: 1 addition & 1 deletion FabricExample/ios/FabricExample/AppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
#ifndef NDEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
#else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
Expand Down
4 changes: 2 additions & 2 deletions FabricExample/ios/FabricExampleTests/FabricExampleTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ - (void)testRendersWelcomeScreen
BOOL foundElement = NO;

__block NSString *redboxError = nil;
#ifdef DEBUG
#ifndef NDEBUG
RCTSetLogFunction(
^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) {
if (level >= RCTLogLevelError) {
Expand All @@ -55,7 +55,7 @@ - (void)testRendersWelcomeScreen
}];
}

#ifdef DEBUG
#ifndef NDEBUG
RCTSetLogFunction(RCTDefaultLogFunction);
#endif

Expand Down
2 changes: 0 additions & 2 deletions MacOSExample/ios/MacOSExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,6 @@
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
INFOPLIST_FILE = MacOSExampleTests/Info.plist;
Expand Down Expand Up @@ -570,7 +569,6 @@
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
Expand Down
2 changes: 1 addition & 1 deletion MacOSExample/ios/MacOSExample/AppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
#ifndef NDEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
#else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
Expand Down
Loading