forked from facebook/yoga
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Temporary commit at 9/4/2023, 2:51:36 AM
Differential Revision: https://www.internalfb.com/diff/D48769809?entry_point=27 fbshipit-source-id: 91b0312a1e15eba4a77d849c5d4bb63b187fae88
- Loading branch information
1 parent
0828d42
commit 79fe987
Showing
6 changed files
with
117 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#include <stdexcept> | ||
|
||
#include <yoga/debug/Assert.h> | ||
#include <yoga/debug/Log.h> | ||
|
||
namespace facebook::yoga { | ||
|
||
[[noreturn]] void fatalWithMessage(const char* message) { | ||
#if defined(__cpp_exceptions) | ||
throw std::logic_error(message); | ||
#else | ||
std::terminate(); | ||
#endif | ||
} | ||
|
||
void assertFatal(const bool condition, const char* message) { | ||
if (!condition) { | ||
yoga::log( | ||
static_cast<yoga::Node*>(nullptr), | ||
YGLogLevelFatal, | ||
nullptr, | ||
"%s\n", | ||
message); | ||
fatalWithMessage(message); | ||
} | ||
} | ||
|
||
void assertFatalWithNode( | ||
const YGNodeRef node, | ||
const bool condition, | ||
const char* message) { | ||
if (!condition) { | ||
yoga::log( | ||
static_cast<yoga::Node*>(node), | ||
YGLogLevelFatal, | ||
nullptr, | ||
"%s\n", | ||
message); | ||
fatalWithMessage(message); | ||
} | ||
} | ||
|
||
void assertFatalWithConfig( | ||
const YGConfigRef config, | ||
const bool condition, | ||
const char* message) { | ||
if (!condition) { | ||
yoga::log( | ||
static_cast<yoga::Config*>(config), | ||
YGLogLevelFatal, | ||
nullptr, | ||
"%s\n", | ||
message); | ||
fatalWithMessage(message); | ||
} | ||
} | ||
|
||
} // namespace facebook::yoga |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <yoga/Yoga.h> | ||
#include <yoga/node/Node.h> | ||
#include <yoga/config/Config.h> | ||
|
||
namespace facebook::yoga { | ||
|
||
[[noreturn]] void fatalWithMessage(const char* message); | ||
|
||
void assertFatal(bool condition, const char* message); | ||
void assertFatalWithNode(YGNodeRef node, bool condition, const char* message); | ||
void assertFatalWithConfig( | ||
YGConfigRef config, | ||
bool condition, | ||
const char* message); | ||
|
||
} // namespace facebook::yoga |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters