Remove layoutContext Drilling (#1376)

Summary:
X-link: https://github.com/facebook/react-native/pull/39401

Pull Request resolved: https://github.com/facebook/yoga/pull/1376

kill_with_fire_flamethrower

Reviewed By: rshest

Differential Revision: D49179244

fbshipit-source-id: 9a827e1bd29205254fee5725449191726d6bcf5a
This commit is contained in:
Nick Gerleman
2023-09-12 19:08:55 -07:00
committed by Facebook GitHub Bot
parent b1e0140aaa
commit 0a90b16ac6
17 changed files with 83 additions and 370 deletions

View File

@@ -22,7 +22,7 @@ namespace facebook::yoga {
void assertFatal(const bool condition, const char* message) {
if (!condition) {
yoga::log(YGLogLevelFatal, nullptr, "%s\n", message);
yoga::log(YGLogLevelFatal, "%s\n", message);
fatalWithMessage(message);
}
}
@@ -32,7 +32,7 @@ void assertFatalWithNode(
const bool condition,
const char* message) {
if (!condition) {
yoga::log(node, YGLogLevelFatal, nullptr, "%s\n", message);
yoga::log(node, YGLogLevelFatal, "%s\n", message);
fatalWithMessage(message);
}
}
@@ -42,7 +42,7 @@ void assertFatalWithConfig(
const bool condition,
const char* message) {
if (!condition) {
yoga::log(config, YGLogLevelFatal, nullptr, "%s\n", message);
yoga::log(config, YGLogLevelFatal, "%s\n", message);
fatalWithMessage(message);
}
}

View File

@@ -19,51 +19,43 @@ void vlog(
const yoga::Config* config,
const yoga::Node* node,
YGLogLevel level,
void* context,
const char* format,
va_list args) {
if (config == nullptr) {
getDefaultLogger()(nullptr, node, level, format, args);
} else {
config->log(node, level, context, format, args);
config->log(node, level, format, args);
}
}
} // namespace
void log(YGLogLevel level, void* context, const char* format, ...) noexcept {
void log(YGLogLevel level, const char* format, ...) noexcept {
va_list args;
va_start(args, format);
vlog(nullptr, nullptr, level, context, format, args);
vlog(nullptr, nullptr, level, format, args);
va_end(args);
}
void log(
const yoga::Node* node,
YGLogLevel level,
void* context,
const char* format,
...) noexcept {
va_list args;
va_start(args, format);
vlog(
node == nullptr ? nullptr : node->getConfig(),
node,
level,
context,
format,
args);
node == nullptr ? nullptr : node->getConfig(), node, level, format, args);
va_end(args);
}
void log(
const yoga::Config* config,
YGLogLevel level,
void* context,
const char* format,
...) noexcept {
va_list args;
va_start(args, format);
vlog(config, nullptr, level, context, format, args);
vlog(config, nullptr, level, format, args);
va_end(args);
}

View File

@@ -15,19 +15,17 @@
namespace facebook::yoga {
void log(YGLogLevel level, void*, const char* format, ...) noexcept;
void log(YGLogLevel level, const char* format, ...) noexcept;
void log(
const yoga::Node* node,
YGLogLevel level,
void*,
const char* message,
...) noexcept;
void log(
const yoga::Config* config,
YGLogLevel level,
void*,
const char* format,
...) noexcept;