Convert most Fabric Cxx code to use react_native_assert instead of assert
Summary: See react_native_assert.{h,cpp}. Because of the BUCK+Android issue where NDEBUG is always defined, we use react_native_assert instead of assert to enable xplat asserts in debug/dev mode. This migrates most of the codebase, but probably not 100%. The goal is to increase assertion coverage on Android, not to get to 100% (yet). Changelog: [Internal] Reviewed By: RSNara Differential Revision: D26562866 fbshipit-source-id: a7bf2055b973e1d3650ed8d68a6d02d556604af9
This commit is contained in:
Родитель
2d51f4b499
Коммит
b3930f935f
|
@ -43,6 +43,8 @@ void react_native_assert_fail(
|
|||
|
||||
#else // __ANDROID__
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#define react_native_assert(e) assert(e)
|
||||
|
||||
#endif // platforms besides __ANDROID__
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <react/renderer/mounting/ShadowViewMutation.h>
|
||||
|
||||
#include <glog/logging.h>
|
||||
#include <react/debug/react_native_assert.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
@ -79,8 +80,8 @@ void LayoutAnimationDriver::animationMutationsForFrame(
|
|||
// All generated Update mutations must have an "old" and "new"
|
||||
// ShadowView. Checking for nonzero tag doesn't guarantee that the views
|
||||
// are valid/correct, just that something is there.
|
||||
assert(updateMutation.oldChildShadowView.tag > 0);
|
||||
assert(updateMutation.newChildShadowView.tag > 0);
|
||||
react_native_assert(updateMutation.oldChildShadowView.tag > 0);
|
||||
react_native_assert(updateMutation.newChildShadowView.tag > 0);
|
||||
|
||||
mutationsList.push_back(updateMutation);
|
||||
PrintMutationInstruction("Animation Progress:", updateMutation);
|
||||
|
@ -125,8 +126,8 @@ void LayoutAnimationDriver::animationMutationsForFrame(
|
|||
keyframe.viewPrev,
|
||||
finalMutationForKeyFrame.newChildShadowView,
|
||||
finalMutationForKeyFrame.index};
|
||||
assert(mutation.oldChildShadowView.tag > 0);
|
||||
assert(
|
||||
react_native_assert(mutation.oldChildShadowView.tag > 0);
|
||||
react_native_assert(
|
||||
mutation.newChildShadowView.tag > 0 ||
|
||||
finalMutationForKeyFrame.type == ShadowViewMutation::Remove ||
|
||||
finalMutationForKeyFrame.type == ShadowViewMutation::Delete);
|
||||
|
@ -142,8 +143,8 @@ void LayoutAnimationDriver::animationMutationsForFrame(
|
|||
keyframe.viewPrev,
|
||||
keyframe.viewEnd,
|
||||
-1};
|
||||
assert(mutation.oldChildShadowView.tag > 0);
|
||||
assert(mutation.newChildShadowView.tag > 0);
|
||||
react_native_assert(mutation.oldChildShadowView.tag > 0);
|
||||
react_native_assert(mutation.newChildShadowView.tag > 0);
|
||||
mutationsList.push_back(mutation);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
#include "AttributedStringBox.h"
|
||||
|
||||
#include <react/debug/react_native_assert.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
|
@ -37,14 +39,14 @@ AttributedStringBox::Mode AttributedStringBox::getMode() const {
|
|||
}
|
||||
|
||||
AttributedString const &AttributedStringBox::getValue() const {
|
||||
assert(mode_ == AttributedStringBox::Mode::Value);
|
||||
assert(value_);
|
||||
react_native_assert(mode_ == AttributedStringBox::Mode::Value);
|
||||
react_native_assert(value_);
|
||||
return *value_;
|
||||
}
|
||||
|
||||
std::shared_ptr<void> AttributedStringBox::getOpaquePointer() const {
|
||||
assert(mode_ == AttributedStringBox::Mode::OpaquePointer);
|
||||
assert(opaquePointer_);
|
||||
react_native_assert(mode_ == AttributedStringBox::Mode::OpaquePointer);
|
||||
react_native_assert(opaquePointer_);
|
||||
return opaquePointer_;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,11 +55,12 @@ rn_xplat_cxx_library(
|
|||
"//xplat/folly:headers_only",
|
||||
"//xplat/folly:memory",
|
||||
"//xplat/folly:molly",
|
||||
react_native_xplat_target("react/utils:utils"),
|
||||
react_native_xplat_target("react/debug:debug"),
|
||||
react_native_xplat_target("react/renderer/debug:debug"),
|
||||
react_native_xplat_target("react/renderer/core:core"),
|
||||
react_native_xplat_target("react/renderer/graphics:graphics"),
|
||||
react_native_xplat_target("react/renderer/mounting:mounting"),
|
||||
react_native_xplat_target("react/utils:utils"),
|
||||
],
|
||||
)
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include <folly/Conv.h>
|
||||
#include <folly/dynamic.h>
|
||||
#include <react/debug/react_native_assert.h>
|
||||
#include <react/renderer/attributedstring/AttributedString.h>
|
||||
#include <react/renderer/attributedstring/ParagraphAttributes.h>
|
||||
#include <react/renderer/attributedstring/TextAttributes.h>
|
||||
|
@ -175,7 +176,7 @@ inline std::string toString(const FontStyle &fontStyle) {
|
|||
}
|
||||
|
||||
inline void fromRawValue(const RawValue &value, FontVariant &result) {
|
||||
assert(value.hasType<std::vector<std::string>>());
|
||||
react_native_assert(value.hasType<std::vector<std::string>>());
|
||||
result = FontVariant::Default;
|
||||
auto items = std::vector<std::string>{value};
|
||||
for (const auto &item : items) {
|
||||
|
|
|
@ -55,6 +55,7 @@ rn_xplat_cxx_library(
|
|||
"//xplat/folly:molly",
|
||||
"//xplat/jsi:JSIDynamic",
|
||||
"//xplat/jsi:jsi",
|
||||
react_native_xplat_target("react/debug:debug"),
|
||||
react_native_xplat_target("react/renderer/core:core"),
|
||||
react_native_xplat_target("react/renderer/debug:debug"),
|
||||
react_native_xplat_target("react/utils:utils"),
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "ComponentDescriptorRegistry.h"
|
||||
|
||||
#include <react/debug/react_native_assert.h>
|
||||
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
|
||||
#include <react/renderer/core/ShadowNodeFragment.h>
|
||||
|
||||
|
@ -26,10 +27,10 @@ void ComponentDescriptorRegistry::add(
|
|||
{parameters_.eventDispatcher,
|
||||
parameters_.contextContainer,
|
||||
componentDescriptorProvider.flavor});
|
||||
assert(
|
||||
react_native_assert(
|
||||
componentDescriptor->getComponentHandle() ==
|
||||
componentDescriptorProvider.handle);
|
||||
assert(
|
||||
react_native_assert(
|
||||
componentDescriptor->getComponentName() ==
|
||||
componentDescriptorProvider.name);
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ rn_xplat_cxx_library(
|
|||
],
|
||||
visibility = ["PUBLIC"],
|
||||
deps = [
|
||||
react_native_xplat_target("react/debug:debug"),
|
||||
react_native_xplat_target("react/renderer/core:core"),
|
||||
"//xplat/js/react-native-github:generated_components-rncore",
|
||||
],
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <react/debug/react_native_assert.h>
|
||||
#include <react/renderer/components/inputaccessory/InputAccessoryShadowNode.h>
|
||||
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
||||
|
||||
|
@ -22,11 +23,12 @@ class InputAccessoryComponentDescriptor final
|
|||
using ConcreteComponentDescriptor::ConcreteComponentDescriptor;
|
||||
|
||||
void adopt(UnsharedShadowNode shadowNode) const override {
|
||||
assert(std::dynamic_pointer_cast<InputAccessoryShadowNode>(shadowNode));
|
||||
react_native_assert(
|
||||
std::dynamic_pointer_cast<InputAccessoryShadowNode>(shadowNode));
|
||||
auto concreteShadowNode =
|
||||
std::static_pointer_cast<InputAccessoryShadowNode>(shadowNode);
|
||||
|
||||
assert(std::dynamic_pointer_cast<YogaLayoutableShadowNode>(
|
||||
react_native_assert(std::dynamic_pointer_cast<YogaLayoutableShadowNode>(
|
||||
concreteShadowNode));
|
||||
auto layoutableShadowNode =
|
||||
std::static_pointer_cast<YogaLayoutableShadowNode>(concreteShadowNode);
|
||||
|
|
|
@ -85,6 +85,7 @@ rn_xplat_cxx_library(
|
|||
"//xplat/folly:memory",
|
||||
"//xplat/folly:molly",
|
||||
YOGA_CXX_TARGET,
|
||||
react_native_xplat_target("react/debug:debug"),
|
||||
react_native_xplat_target("react/renderer/debug:debug"),
|
||||
react_native_xplat_target("react/renderer/core:core"),
|
||||
react_native_xplat_target("react/renderer/components/image:image"),
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <react/debug/react_native_assert.h>
|
||||
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
||||
#include "AndroidProgressBarMeasurementsManager.h"
|
||||
#include "AndroidProgressBarShadowNode.h"
|
||||
|
@ -30,7 +31,8 @@ class AndroidProgressBarComponentDescriptor final
|
|||
void adopt(UnsharedShadowNode shadowNode) const override {
|
||||
ConcreteComponentDescriptor::adopt(shadowNode);
|
||||
|
||||
assert(std::dynamic_pointer_cast<AndroidProgressBarShadowNode>(shadowNode));
|
||||
react_native_assert(
|
||||
std::dynamic_pointer_cast<AndroidProgressBarShadowNode>(shadowNode));
|
||||
auto androidProgressBarShadowNode =
|
||||
std::static_pointer_cast<AndroidProgressBarShadowNode>(shadowNode);
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ rn_xplat_cxx_library(
|
|||
],
|
||||
visibility = ["PUBLIC"],
|
||||
deps = [
|
||||
react_native_xplat_target("react/debug:debug"),
|
||||
react_native_xplat_target("react/renderer/core:core"),
|
||||
"//xplat/js/react-native-github:generated_components-rncore",
|
||||
],
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <react/debug/react_native_assert.h>
|
||||
#include <react/renderer/components/safeareaview/SafeAreaViewShadowNode.h>
|
||||
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
||||
|
||||
|
@ -20,11 +21,12 @@ class SafeAreaViewComponentDescriptor final
|
|||
: public ConcreteComponentDescriptor<SafeAreaViewShadowNode> {
|
||||
using ConcreteComponentDescriptor::ConcreteComponentDescriptor;
|
||||
void adopt(UnsharedShadowNode shadowNode) const override {
|
||||
assert(std::dynamic_pointer_cast<SafeAreaViewShadowNode>(shadowNode));
|
||||
react_native_assert(
|
||||
std::dynamic_pointer_cast<SafeAreaViewShadowNode>(shadowNode));
|
||||
auto safeAreaViewShadowNode =
|
||||
std::static_pointer_cast<SafeAreaViewShadowNode>(shadowNode);
|
||||
|
||||
assert(std::dynamic_pointer_cast<YogaLayoutableShadowNode>(
|
||||
react_native_assert(std::dynamic_pointer_cast<YogaLayoutableShadowNode>(
|
||||
safeAreaViewShadowNode));
|
||||
auto layoutableShadowNode =
|
||||
std::static_pointer_cast<YogaLayoutableShadowNode>(
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "AndroidSwitchMeasurementsManager.h"
|
||||
#include "AndroidSwitchShadowNode.h"
|
||||
|
||||
#include <react/debug/react_native_assert.h>
|
||||
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
||||
|
||||
namespace facebook {
|
||||
|
@ -30,7 +31,8 @@ class AndroidSwitchComponentDescriptor final
|
|||
void adopt(UnsharedShadowNode shadowNode) const override {
|
||||
ConcreteComponentDescriptor::adopt(shadowNode);
|
||||
|
||||
assert(std::dynamic_pointer_cast<AndroidSwitchShadowNode>(shadowNode));
|
||||
react_native_assert(
|
||||
std::dynamic_pointer_cast<AndroidSwitchShadowNode>(shadowNode));
|
||||
auto androidSwitchShadowNode =
|
||||
std::static_pointer_cast<AndroidSwitchShadowNode>(shadowNode);
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ rn_xplat_cxx_library(
|
|||
"//xplat/folly:memory",
|
||||
"//xplat/folly:molly",
|
||||
YOGA_CXX_TARGET,
|
||||
react_native_xplat_target("react/utils:utils"),
|
||||
react_native_xplat_target("react/debug:debug"),
|
||||
react_native_xplat_target("react/renderer/attributedstring:attributedstring"),
|
||||
react_native_xplat_target("react/renderer/core:core"),
|
||||
react_native_xplat_target("react/renderer/debug:debug"),
|
||||
|
@ -71,6 +71,7 @@ rn_xplat_cxx_library(
|
|||
react_native_xplat_target("react/renderer/uimanager:uimanager"),
|
||||
react_native_xplat_target("react/renderer/mounting:mounting"),
|
||||
react_native_xplat_target("react/renderer/componentregistry:componentregistry"),
|
||||
react_native_xplat_target("react/utils:utils"),
|
||||
],
|
||||
)
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "ParagraphShadowNode.h"
|
||||
|
||||
#include <react/config/ReactNativeConfig.h>
|
||||
#include <react/debug/react_native_assert.h>
|
||||
#include <react/renderer/components/view/ViewPropsInterpolation.h>
|
||||
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
||||
#include <react/renderer/textlayoutmanager/TextLayoutManager.h>
|
||||
|
@ -47,7 +48,8 @@ class ParagraphComponentDescriptor final
|
|||
void adopt(UnsharedShadowNode shadowNode) const override {
|
||||
ConcreteComponentDescriptor::adopt(shadowNode);
|
||||
|
||||
assert(std::dynamic_pointer_cast<ParagraphShadowNode>(shadowNode));
|
||||
react_native_assert(
|
||||
std::dynamic_pointer_cast<ParagraphShadowNode>(shadowNode));
|
||||
auto paragraphShadowNode =
|
||||
std::static_pointer_cast<ParagraphShadowNode>(shadowNode);
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include <cmath>
|
||||
|
||||
#include <react/debug/react_native_assert.h>
|
||||
#include <react/renderer/attributedstring/AttributedStringBox.h>
|
||||
#include <react/renderer/components/view/ViewShadowNode.h>
|
||||
#include <react/renderer/components/view/conversions.h>
|
||||
|
@ -102,8 +103,8 @@ void ParagraphShadowNode::updateStateIfNeeded(Content const &content) {
|
|||
|
||||
auto &state = getStateData();
|
||||
|
||||
assert(textLayoutManager_);
|
||||
assert(
|
||||
react_native_assert(textLayoutManager_);
|
||||
react_native_assert(
|
||||
(!state.layoutManager || state.layoutManager == textLayoutManager_) &&
|
||||
"`StateData` refers to a different `TextLayoutManager`");
|
||||
|
||||
|
@ -191,7 +192,8 @@ void ParagraphShadowNode::layout(LayoutContext layoutContext) {
|
|||
// only to keep it in memory for a while.
|
||||
auto paragraphOwningShadowNode = ShadowNode::Unshared{};
|
||||
|
||||
assert(content.attachments.size() == measurement.attachments.size());
|
||||
react_native_assert(
|
||||
content.attachments.size() == measurement.attachments.size());
|
||||
|
||||
for (auto i = 0; i < content.attachments.size(); i++) {
|
||||
auto &attachment = content.attachments.at(i);
|
||||
|
|
|
@ -58,7 +58,7 @@ rn_xplat_cxx_library(
|
|||
"//xplat/folly:memory",
|
||||
"//xplat/folly:molly",
|
||||
YOGA_CXX_TARGET,
|
||||
react_native_xplat_target("react/utils:utils"),
|
||||
react_native_xplat_target("react/debug:debug"),
|
||||
react_native_xplat_target("react/renderer/attributedstring:attributedstring"),
|
||||
react_native_xplat_target("react/renderer/core:core"),
|
||||
react_native_xplat_target("react/renderer/debug:debug"),
|
||||
|
@ -70,6 +70,7 @@ rn_xplat_cxx_library(
|
|||
react_native_xplat_target("react/renderer/uimanager:uimanager"),
|
||||
react_native_xplat_target("react/renderer/componentregistry:componentregistry"),
|
||||
react_native_xplat_target("react/renderer/imagemanager:imagemanager"),
|
||||
react_native_xplat_target("react/utils:utils"),
|
||||
],
|
||||
)
|
||||
|
||||
|
|
|
@ -7,14 +7,17 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <fbjni/fbjni.h>
|
||||
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
||||
#include "AndroidTextInputShadowNode.h"
|
||||
|
||||
#include <fbjni/fbjni.h>
|
||||
|
||||
#include <yoga/CompactValue.h>
|
||||
#include <yoga/YGEnums.h>
|
||||
#include <yoga/YGValue.h>
|
||||
|
||||
#include <react/debug/react_native_assert.h>
|
||||
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
|
@ -86,7 +89,8 @@ class AndroidTextInputComponentDescriptor final
|
|||
|
||||
protected:
|
||||
void adopt(UnsharedShadowNode shadowNode) const override {
|
||||
assert(std::dynamic_pointer_cast<AndroidTextInputShadowNode>(shadowNode));
|
||||
react_native_assert(
|
||||
std::dynamic_pointer_cast<AndroidTextInputShadowNode>(shadowNode));
|
||||
auto textInputShadowNode =
|
||||
std::static_pointer_cast<AndroidTextInputShadowNode>(shadowNode);
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "AndroidTextInputShadowNode.h"
|
||||
|
||||
#include <fbjni/fbjni.h>
|
||||
#include <react/debug/react_native_assert.h>
|
||||
#include <react/jni/ReadableNativeMap.h>
|
||||
#include <react/renderer/attributedstring/AttributedStringBox.h>
|
||||
#include <react/renderer/attributedstring/TextAttributes.h>
|
||||
|
@ -118,8 +119,8 @@ void AndroidTextInputShadowNode::updateStateIfNeeded() {
|
|||
auto reactTreeAttributedString = getAttributedString();
|
||||
auto const &state = getStateData();
|
||||
|
||||
assert(textLayoutManager_);
|
||||
assert(
|
||||
react_native_assert(textLayoutManager_);
|
||||
react_native_assert(
|
||||
(!state.layoutManager || state.layoutManager == textLayoutManager_) &&
|
||||
"`StateData` refers to a different `TextLayoutManager`");
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ rn_xplat_cxx_library(
|
|||
"//xplat/folly:memory",
|
||||
"//xplat/folly:molly",
|
||||
YOGA_CXX_TARGET,
|
||||
react_native_xplat_target("react/utils:utils"),
|
||||
react_native_xplat_target("react/debug:debug"),
|
||||
react_native_xplat_target("react/renderer/attributedstring:attributedstring"),
|
||||
react_native_xplat_target("react/renderer/core:core"),
|
||||
react_native_xplat_target("react/renderer/debug:debug"),
|
||||
|
@ -70,6 +70,7 @@ rn_xplat_cxx_library(
|
|||
react_native_xplat_target("react/renderer/uimanager:uimanager"),
|
||||
react_native_xplat_target("react/renderer/componentregistry:componentregistry"),
|
||||
react_native_xplat_target("react/renderer/imagemanager:imagemanager"),
|
||||
react_native_xplat_target("react/utils:utils"),
|
||||
],
|
||||
)
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <react/debug/react_native_assert.h>
|
||||
#include <react/renderer/components/iostextinput/TextInputShadowNode.h>
|
||||
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
||||
|
||||
|
@ -29,7 +30,8 @@ class TextInputComponentDescriptor final
|
|||
void adopt(UnsharedShadowNode shadowNode) const override {
|
||||
ConcreteComponentDescriptor::adopt(shadowNode);
|
||||
|
||||
assert(std::dynamic_pointer_cast<TextInputShadowNode>(shadowNode));
|
||||
react_native_assert(
|
||||
std::dynamic_pointer_cast<TextInputShadowNode>(shadowNode));
|
||||
auto concreteShadowNode =
|
||||
std::static_pointer_cast<TextInputShadowNode>(shadowNode);
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@ rn_xplat_cxx_library(
|
|||
"//xplat/folly:memory",
|
||||
"//xplat/folly:molly",
|
||||
YOGA_CXX_TARGET,
|
||||
react_native_xplat_target("react/debug:debug"),
|
||||
react_native_xplat_target("react/renderer/core:core"),
|
||||
react_native_xplat_target("react/renderer/debug:debug"),
|
||||
react_native_xplat_target("react/renderer/graphics:graphics"),
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
#include "ViewProps.h"
|
||||
|
||||
#include <react/debug/react_native_assert.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
|
@ -29,7 +31,7 @@ static inline void interpolateViewProps(
|
|||
ViewProps *interpolatedProps = const_cast<ViewProps *>(
|
||||
dynamic_cast<ViewProps const *>(interpolatedPropsShared.get()));
|
||||
|
||||
assert(
|
||||
react_native_assert(
|
||||
oldViewProps != nullptr && newViewProps != nullptr &&
|
||||
interpolatedProps != nullptr);
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
#include "YogaLayoutableShadowNode.h"
|
||||
#include <react/debug/react_native_assert.h>
|
||||
#include <react/renderer/components/view/ViewProps.h>
|
||||
#include <react/renderer/components/view/conversions.h>
|
||||
#include <react/renderer/core/LayoutConstraints.h>
|
||||
|
@ -42,7 +43,8 @@ YogaLayoutableShadowNode::YogaLayoutableShadowNode(
|
|||
yogaNode_.setDirty(true);
|
||||
|
||||
if (getTraits().check(ShadowNodeTraits::Trait::MeasurableYogaNode)) {
|
||||
assert(getTraits().check(ShadowNodeTraits::Trait::LeafYogaNode));
|
||||
react_native_assert(
|
||||
getTraits().check(ShadowNodeTraits::Trait::LeafYogaNode));
|
||||
|
||||
yogaNode_.setMeasureFunc(
|
||||
YogaLayoutableShadowNode::yogaNodeMeasureCallbackConnector);
|
||||
|
@ -67,7 +69,7 @@ YogaLayoutableShadowNode::YogaLayoutableShadowNode(
|
|||
// dirty flag, measure function, and other properties being set originally in
|
||||
// the `YogaLayoutableShadowNode` constructor above.
|
||||
|
||||
assert(
|
||||
react_native_assert(
|
||||
static_cast<YogaLayoutableShadowNode const &>(sourceShadowNode)
|
||||
.yogaNode_.isDirty() == yogaNode_.isDirty() &&
|
||||
"Yoga node must inherit dirty flag.");
|
||||
|
@ -118,7 +120,8 @@ void YogaLayoutableShadowNode::enableMeasurement() {
|
|||
|
||||
void YogaLayoutableShadowNode::appendYogaChild(ShadowNode const &childNode) {
|
||||
// The caller must check this before calling this method.
|
||||
assert(!getTraits().check(ShadowNodeTraits::Trait::LeafYogaNode));
|
||||
react_native_assert(
|
||||
!getTraits().check(ShadowNodeTraits::Trait::LeafYogaNode));
|
||||
|
||||
ensureYogaChildrenLookFine();
|
||||
|
||||
|
@ -135,13 +138,14 @@ void YogaLayoutableShadowNode::adoptYogaChild(size_t index) {
|
|||
ensureYogaChildrenLookFine();
|
||||
|
||||
// The caller must check this before calling this method.
|
||||
assert(!getTraits().check(ShadowNodeTraits::Trait::LeafYogaNode));
|
||||
react_native_assert(
|
||||
!getTraits().check(ShadowNodeTraits::Trait::LeafYogaNode));
|
||||
|
||||
auto &children = getChildren();
|
||||
|
||||
// Overflow checks.
|
||||
assert(children.size() > index);
|
||||
assert(children.size() >= yogaNode_.getChildren().size());
|
||||
react_native_assert(children.size() > index);
|
||||
react_native_assert(children.size() >= yogaNode_.getChildren().size());
|
||||
|
||||
auto &childNode = *children.at(index);
|
||||
|
||||
|
@ -151,13 +155,14 @@ void YogaLayoutableShadowNode::adoptYogaChild(size_t index) {
|
|||
// Note, the following (commented out) assert is conceptually valid but still
|
||||
// might produce false-positive signals because of the ABA problem (different
|
||||
// objects with non-interleaving life-times being allocated on the same
|
||||
// address). assert(layoutableChildNode.yogaNode_.getOwner() != &yogaNode_);
|
||||
// address). react_native_assert(layoutableChildNode.yogaNode_.getOwner() !=
|
||||
// &yogaNode_);
|
||||
|
||||
if (layoutableChildNode.yogaNode_.getOwner() == nullptr) {
|
||||
// The child node is not owned.
|
||||
layoutableChildNode.yogaNode_.setOwner(&yogaNode_);
|
||||
// At this point the child yoga node must be already inserted by the caller.
|
||||
// assert(layoutableChildNode.yogaNode_.isDirty());
|
||||
// react_native_assert(layoutableChildNode.yogaNode_.isDirty());
|
||||
} else {
|
||||
// The child is owned by some other node, we need to clone that.
|
||||
auto clonedChildNode = childNode.clone({});
|
||||
|
@ -165,7 +170,8 @@ void YogaLayoutableShadowNode::adoptYogaChild(size_t index) {
|
|||
traitCast<YogaLayoutableShadowNode const &>(*clonedChildNode);
|
||||
|
||||
// The owner must be nullptr for a newly cloned node.
|
||||
assert(layoutableClonedChildNode.yogaNode_.getOwner() == nullptr);
|
||||
react_native_assert(
|
||||
layoutableClonedChildNode.yogaNode_.getOwner() == nullptr);
|
||||
|
||||
// Establishing ownership.
|
||||
layoutableClonedChildNode.yogaNode_.setOwner(&yogaNode_);
|
||||
|
@ -201,7 +207,8 @@ void YogaLayoutableShadowNode::appendChild(
|
|||
|
||||
// All children of a non-leaf `YogaLayoutableShadowNode` must be a
|
||||
// `YogaLayoutableShadowNode`s.
|
||||
assert(traitCast<YogaLayoutableShadowNode const *>(childNode.get()));
|
||||
react_native_assert(
|
||||
traitCast<YogaLayoutableShadowNode const *>(childNode.get()));
|
||||
|
||||
// Appending the Yoga node.
|
||||
appendYogaChild(*childNode);
|
||||
|
@ -256,7 +263,7 @@ void YogaLayoutableShadowNode::updateYogaChildren() {
|
|||
}
|
||||
}
|
||||
|
||||
assert(getChildren().size() == yogaNode_.getChildren().size());
|
||||
react_native_assert(getChildren().size() == yogaNode_.getChildren().size());
|
||||
|
||||
yogaNode_.setDirty(!isClean);
|
||||
}
|
||||
|
@ -338,18 +345,18 @@ void YogaLayoutableShadowNode::layoutTree(
|
|||
|
||||
// The caller must ensure that layout constraints make sense.
|
||||
// Values cannot be NaN.
|
||||
assert(!std::isnan(minimumSize.width));
|
||||
assert(!std::isnan(minimumSize.height));
|
||||
assert(!std::isnan(maximumSize.width));
|
||||
assert(!std::isnan(maximumSize.height));
|
||||
react_native_assert(!std::isnan(minimumSize.width));
|
||||
react_native_assert(!std::isnan(minimumSize.height));
|
||||
react_native_assert(!std::isnan(maximumSize.width));
|
||||
react_native_assert(!std::isnan(maximumSize.height));
|
||||
// Values cannot be negative.
|
||||
assert(minimumSize.width >= 0);
|
||||
assert(minimumSize.height >= 0);
|
||||
assert(maximumSize.width >= 0);
|
||||
assert(maximumSize.height >= 0);
|
||||
react_native_assert(minimumSize.width >= 0);
|
||||
react_native_assert(minimumSize.height >= 0);
|
||||
react_native_assert(maximumSize.width >= 0);
|
||||
react_native_assert(maximumSize.height >= 0);
|
||||
// Mimimum size cannot be infinity.
|
||||
assert(!std::isinf(minimumSize.width));
|
||||
assert(!std::isinf(minimumSize.height));
|
||||
react_native_assert(!std::isinf(minimumSize.width));
|
||||
react_native_assert(!std::isinf(minimumSize.height));
|
||||
|
||||
// Internally Yoga uses three different measurement modes controlling layout
|
||||
// constraints: `Undefined`, `Exactly`, and `AtMost`. These modes are an
|
||||
|
@ -440,7 +447,7 @@ static EdgeInsets calculateOverflowInset(
|
|||
|
||||
void YogaLayoutableShadowNode::layout(LayoutContext layoutContext) {
|
||||
// Reading data from a dirtied node does not make sense.
|
||||
assert(!yogaNode_.isDirty());
|
||||
react_native_assert(!yogaNode_.isDirty());
|
||||
|
||||
auto contentFrame = Rect{};
|
||||
|
||||
|
@ -449,17 +456,17 @@ void YogaLayoutableShadowNode::layout(LayoutContext layoutContext) {
|
|||
*static_cast<YogaLayoutableShadowNode *>(childYogaNode->getContext());
|
||||
|
||||
// Verifying that the Yoga node belongs to the ShadowNode.
|
||||
assert(&childNode.yogaNode_ == childYogaNode);
|
||||
react_native_assert(&childNode.yogaNode_ == childYogaNode);
|
||||
|
||||
if (childYogaNode->getHasNewLayout()) {
|
||||
childYogaNode->setHasNewLayout(false);
|
||||
|
||||
// Reading data from a dirtied node does not make sense.
|
||||
assert(!childYogaNode->isDirty());
|
||||
react_native_assert(!childYogaNode->isDirty());
|
||||
|
||||
// We must copy layout metrics from Yoga node only once (when the parent
|
||||
// node exclusively ownes the child node).
|
||||
assert(childYogaNode->getOwner() == &yogaNode_);
|
||||
react_native_assert(childYogaNode->getOwner() == &yogaNode_);
|
||||
|
||||
// We are about to mutate layout metrics of the node.
|
||||
childNode.ensureUnsealed();
|
||||
|
@ -731,7 +738,7 @@ void YogaLayoutableShadowNode::ensureYogaChildrenOwnersConsistency() const {
|
|||
if (!yogaChildren.empty()) {
|
||||
auto owner = yogaChildren.at(0)->getOwner();
|
||||
for (auto const &child : yogaChildren) {
|
||||
assert(child->getOwner() == owner);
|
||||
react_native_assert(child->getOwner() == owner);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -746,10 +753,10 @@ void YogaLayoutableShadowNode::ensureYogaChildrenLookFine() const {
|
|||
auto &yogaChildren = yogaNode_.getChildren();
|
||||
|
||||
for (auto const &yogaChild : yogaChildren) {
|
||||
assert(yogaChild->getContext());
|
||||
assert(yogaChild->getChildren().size() < 16384);
|
||||
react_native_assert(yogaChild->getContext());
|
||||
react_native_assert(yogaChild->getChildren().size() < 16384);
|
||||
if (!yogaChild->getChildren().empty()) {
|
||||
assert(!yogaChild->hasMeasureFunc());
|
||||
react_native_assert(!yogaChild->hasMeasureFunc());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -766,16 +773,16 @@ void YogaLayoutableShadowNode::ensureYogaChildrenAlighment() const {
|
|||
auto &children = getChildren();
|
||||
|
||||
if (getTraits().check(ShadowNodeTraits::Trait::LeafYogaNode)) {
|
||||
assert(yogaChildren.empty());
|
||||
react_native_assert(yogaChildren.empty());
|
||||
return;
|
||||
}
|
||||
|
||||
assert(yogaChildren.size() == children.size());
|
||||
react_native_assert(yogaChildren.size() == children.size());
|
||||
|
||||
for (size_t i = 0; i < children.size(); i++) {
|
||||
auto &yogaChild = yogaChildren.at(i);
|
||||
auto &child = children.at(i);
|
||||
assert(
|
||||
react_native_assert(
|
||||
yogaChild->getContext() ==
|
||||
traitCast<YogaLayoutableShadowNode const *>(child.get()));
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
#include <yoga/YGNode.h>
|
||||
|
||||
#include <react/debug/react_native_assert.h>
|
||||
#include <react/renderer/components/view/YogaStylableProps.h>
|
||||
#include <react/renderer/core/LayoutableShadowNode.h>
|
||||
#include <react/renderer/core/Sealable.h>
|
||||
|
@ -185,10 +186,10 @@ inline YogaLayoutableShadowNode const &
|
|||
traitCast<YogaLayoutableShadowNode const &>(ShadowNode const &shadowNode) {
|
||||
bool castable =
|
||||
shadowNode.getTraits().check(ShadowNodeTraits::Trait::YogaLayoutableKind);
|
||||
assert(
|
||||
react_native_assert(
|
||||
castable ==
|
||||
(dynamic_cast<YogaLayoutableShadowNode const *>(&shadowNode) != nullptr));
|
||||
assert(castable);
|
||||
react_native_assert(castable);
|
||||
(void)castable;
|
||||
return static_cast<YogaLayoutableShadowNode const &>(shadowNode);
|
||||
}
|
||||
|
@ -201,7 +202,7 @@ traitCast<YogaLayoutableShadowNode const *>(ShadowNode const *shadowNode) {
|
|||
}
|
||||
bool castable = shadowNode->getTraits().check(
|
||||
ShadowNodeTraits::Trait::YogaLayoutableKind);
|
||||
assert(
|
||||
react_native_assert(
|
||||
castable ==
|
||||
(dynamic_cast<YogaLayoutableShadowNode const *>(shadowNode) != nullptr));
|
||||
if (!castable) {
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <folly/Conv.h>
|
||||
#include <folly/dynamic.h>
|
||||
#include <glog/logging.h>
|
||||
#include <react/debug/react_native_assert.h>
|
||||
#include <react/renderer/components/view/primitives.h>
|
||||
#include <react/renderer/core/LayoutMetrics.h>
|
||||
#include <react/renderer/graphics/Geometry.h>
|
||||
|
@ -165,7 +166,7 @@ inline YGDirection yogaDirectionFromLayoutDirection(LayoutDirection direction) {
|
|||
}
|
||||
|
||||
inline void fromRawValue(const RawValue &value, YGDirection &result) {
|
||||
assert(value.hasType<std::string>());
|
||||
react_native_assert(value.hasType<std::string>());
|
||||
auto stringValue = (std::string)value;
|
||||
if (stringValue == "inherit") {
|
||||
result = YGDirectionInherit;
|
||||
|
@ -180,11 +181,11 @@ inline void fromRawValue(const RawValue &value, YGDirection &result) {
|
|||
return;
|
||||
}
|
||||
LOG(FATAL) << "Could not parse YGDirection:" << stringValue;
|
||||
assert(false);
|
||||
react_native_assert(false);
|
||||
}
|
||||
|
||||
inline void fromRawValue(const RawValue &value, YGFlexDirection &result) {
|
||||
assert(value.hasType<std::string>());
|
||||
react_native_assert(value.hasType<std::string>());
|
||||
auto stringValue = (std::string)value;
|
||||
if (stringValue == "row") {
|
||||
result = YGFlexDirectionRow;
|
||||
|
@ -203,11 +204,11 @@ inline void fromRawValue(const RawValue &value, YGFlexDirection &result) {
|
|||
return;
|
||||
}
|
||||
LOG(FATAL) << "Could not parse YGFlexDirection:" << stringValue;
|
||||
assert(false);
|
||||
react_native_assert(false);
|
||||
}
|
||||
|
||||
inline void fromRawValue(const RawValue &value, YGJustify &result) {
|
||||
assert(value.hasType<std::string>());
|
||||
react_native_assert(value.hasType<std::string>());
|
||||
auto stringValue = (std::string)value;
|
||||
if (stringValue == "flex-start") {
|
||||
result = YGJustifyFlexStart;
|
||||
|
@ -234,11 +235,11 @@ inline void fromRawValue(const RawValue &value, YGJustify &result) {
|
|||
return;
|
||||
}
|
||||
LOG(FATAL) << "Could not parse YGJustify:" << stringValue;
|
||||
assert(false);
|
||||
react_native_assert(false);
|
||||
}
|
||||
|
||||
inline void fromRawValue(const RawValue &value, YGAlign &result) {
|
||||
assert(value.hasType<std::string>());
|
||||
react_native_assert(value.hasType<std::string>());
|
||||
auto stringValue = (std::string)value;
|
||||
if (stringValue == "auto") {
|
||||
result = YGAlignAuto;
|
||||
|
@ -273,11 +274,11 @@ inline void fromRawValue(const RawValue &value, YGAlign &result) {
|
|||
return;
|
||||
}
|
||||
LOG(FATAL) << "Could not parse YGAlign:" << stringValue;
|
||||
assert(false);
|
||||
react_native_assert(false);
|
||||
}
|
||||
|
||||
inline void fromRawValue(const RawValue &value, YGPositionType &result) {
|
||||
assert(value.hasType<std::string>());
|
||||
react_native_assert(value.hasType<std::string>());
|
||||
auto stringValue = (std::string)value;
|
||||
if (stringValue == "static") {
|
||||
result = YGPositionTypeStatic;
|
||||
|
@ -292,11 +293,11 @@ inline void fromRawValue(const RawValue &value, YGPositionType &result) {
|
|||
return;
|
||||
}
|
||||
LOG(FATAL) << "Could not parse YGPositionType:" << stringValue;
|
||||
assert(false);
|
||||
react_native_assert(false);
|
||||
}
|
||||
|
||||
inline void fromRawValue(const RawValue &value, YGWrap &result) {
|
||||
assert(value.hasType<std::string>());
|
||||
react_native_assert(value.hasType<std::string>());
|
||||
auto stringValue = (std::string)value;
|
||||
if (stringValue == "nowrap") {
|
||||
result = YGWrapNoWrap;
|
||||
|
@ -311,11 +312,11 @@ inline void fromRawValue(const RawValue &value, YGWrap &result) {
|
|||
return;
|
||||
}
|
||||
LOG(FATAL) << "Could not parse YGWrap:" << stringValue;
|
||||
assert(false);
|
||||
react_native_assert(false);
|
||||
}
|
||||
|
||||
inline void fromRawValue(const RawValue &value, YGOverflow &result) {
|
||||
assert(value.hasType<std::string>());
|
||||
react_native_assert(value.hasType<std::string>());
|
||||
auto stringValue = (std::string)value;
|
||||
if (stringValue == "visible") {
|
||||
result = YGOverflowVisible;
|
||||
|
@ -330,11 +331,11 @@ inline void fromRawValue(const RawValue &value, YGOverflow &result) {
|
|||
return;
|
||||
}
|
||||
LOG(FATAL) << "Could not parse YGOverflow:" << stringValue;
|
||||
assert(false);
|
||||
react_native_assert(false);
|
||||
}
|
||||
|
||||
inline void fromRawValue(const RawValue &value, YGDisplay &result) {
|
||||
assert(value.hasType<std::string>());
|
||||
react_native_assert(value.hasType<std::string>());
|
||||
auto stringValue = (std::string)value;
|
||||
if (stringValue == "flex") {
|
||||
result = YGDisplayFlex;
|
||||
|
@ -345,7 +346,7 @@ inline void fromRawValue(const RawValue &value, YGDisplay &result) {
|
|||
return;
|
||||
}
|
||||
LOG(FATAL) << "Could not parse YGDisplay:" << stringValue;
|
||||
assert(false);
|
||||
react_native_assert(false);
|
||||
}
|
||||
|
||||
inline void fromRawValue(const RawValue &value, YGStyle::ValueRepr &result) {
|
||||
|
@ -384,14 +385,14 @@ inline void fromRawValue(const RawValue &value, YGFloatOptional &result) {
|
|||
}
|
||||
}
|
||||
LOG(FATAL) << "Could not parse YGFloatOptional";
|
||||
assert(false);
|
||||
react_native_assert(false);
|
||||
}
|
||||
|
||||
inline Float toRadians(const RawValue &value) {
|
||||
if (value.hasType<Float>()) {
|
||||
return (Float)value;
|
||||
}
|
||||
assert(value.hasType<std::string>());
|
||||
react_native_assert(value.hasType<std::string>());
|
||||
auto stringValue = (std::string)value;
|
||||
char *suffixStart;
|
||||
double num = strtod(
|
||||
|
@ -404,7 +405,7 @@ inline Float toRadians(const RawValue &value) {
|
|||
}
|
||||
|
||||
inline void fromRawValue(const RawValue &value, Transform &result) {
|
||||
assert(value.hasType<std::vector<RawValue>>());
|
||||
react_native_assert(value.hasType<std::vector<RawValue>>());
|
||||
auto transformMatrix = Transform{};
|
||||
auto configurations = static_cast<std::vector<RawValue>>(value);
|
||||
|
||||
|
@ -422,9 +423,9 @@ inline void fromRawValue(const RawValue &value, Transform &result) {
|
|||
auto ¶meters = pair->second;
|
||||
|
||||
if (operation == "matrix") {
|
||||
assert(parameters.hasType<std::vector<Float>>());
|
||||
react_native_assert(parameters.hasType<std::vector<Float>>());
|
||||
auto numbers = (std::vector<Float>)parameters;
|
||||
assert(numbers.size() == transformMatrix.matrix.size());
|
||||
react_native_assert(numbers.size() == transformMatrix.matrix.size());
|
||||
auto i = 0;
|
||||
for (auto number : numbers) {
|
||||
transformMatrix.matrix[i++] = number;
|
||||
|
@ -479,7 +480,7 @@ inline void fromRawValue(const RawValue &value, Transform &result) {
|
|||
}
|
||||
|
||||
inline void fromRawValue(const RawValue &value, PointerEventsMode &result) {
|
||||
assert(value.hasType<std::string>());
|
||||
react_native_assert(value.hasType<std::string>());
|
||||
auto stringValue = (std::string)value;
|
||||
if (stringValue == "auto") {
|
||||
result = PointerEventsMode::Auto;
|
||||
|
@ -498,11 +499,11 @@ inline void fromRawValue(const RawValue &value, PointerEventsMode &result) {
|
|||
return;
|
||||
}
|
||||
LOG(FATAL) << "Could not parse PointerEventsMode:" << stringValue;
|
||||
assert(false);
|
||||
react_native_assert(false);
|
||||
}
|
||||
|
||||
inline void fromRawValue(const RawValue &value, BackfaceVisibility &result) {
|
||||
assert(value.hasType<std::string>());
|
||||
react_native_assert(value.hasType<std::string>());
|
||||
auto stringValue = (std::string)value;
|
||||
if (stringValue == "auto") {
|
||||
result = BackfaceVisibility::Auto;
|
||||
|
@ -517,11 +518,11 @@ inline void fromRawValue(const RawValue &value, BackfaceVisibility &result) {
|
|||
return;
|
||||
}
|
||||
LOG(FATAL) << "Could not parse BackfaceVisibility:" << stringValue;
|
||||
assert(false);
|
||||
react_native_assert(false);
|
||||
}
|
||||
|
||||
inline void fromRawValue(const RawValue &value, BorderStyle &result) {
|
||||
assert(value.hasType<std::string>());
|
||||
react_native_assert(value.hasType<std::string>());
|
||||
auto stringValue = (std::string)value;
|
||||
if (stringValue == "solid") {
|
||||
result = BorderStyle::Solid;
|
||||
|
@ -536,7 +537,7 @@ inline void fromRawValue(const RawValue &value, BorderStyle &result) {
|
|||
return;
|
||||
}
|
||||
LOG(FATAL) << "Could not parse BorderStyle:" << stringValue;
|
||||
assert(false);
|
||||
react_native_assert(false);
|
||||
}
|
||||
|
||||
inline std::string toString(
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
#include <react/debug/react_native_assert.h>
|
||||
#include <react/renderer/core/ComponentDescriptor.h>
|
||||
#include <react/renderer/core/EventDispatcher.h>
|
||||
#include <react/renderer/core/Props.h>
|
||||
|
@ -63,7 +64,8 @@ class ConcreteComponentDescriptor : public ComponentDescriptor {
|
|||
ShadowNode::Shared createShadowNode(
|
||||
const ShadowNodeFragment &fragment,
|
||||
ShadowNodeFamily::Shared const &family) const override {
|
||||
assert(std::dynamic_pointer_cast<const ConcreteProps>(fragment.props));
|
||||
react_native_assert(
|
||||
std::dynamic_pointer_cast<const ConcreteProps>(fragment.props));
|
||||
|
||||
auto shadowNode =
|
||||
std::make_shared<ShadowNodeT>(fragment, family, getTraits());
|
||||
|
@ -76,7 +78,7 @@ class ConcreteComponentDescriptor : public ComponentDescriptor {
|
|||
UnsharedShadowNode cloneShadowNode(
|
||||
const ShadowNode &sourceShadowNode,
|
||||
const ShadowNodeFragment &fragment) const override {
|
||||
assert(
|
||||
react_native_assert(
|
||||
dynamic_cast<ConcreteShadowNode const *>(&sourceShadowNode) &&
|
||||
"Provided `sourceShadowNode` has an incompatible type.");
|
||||
|
||||
|
@ -89,7 +91,7 @@ class ConcreteComponentDescriptor : public ComponentDescriptor {
|
|||
void appendChild(
|
||||
const ShadowNode::Shared &parentShadowNode,
|
||||
const ShadowNode::Shared &childShadowNode) const override {
|
||||
assert(
|
||||
react_native_assert(
|
||||
dynamic_cast<ConcreteShadowNode const *>(parentShadowNode.get()) &&
|
||||
"Provided `parentShadowNode` has an incompatible type.");
|
||||
|
||||
|
@ -103,7 +105,7 @@ class ConcreteComponentDescriptor : public ComponentDescriptor {
|
|||
virtual SharedProps cloneProps(
|
||||
const SharedProps &props,
|
||||
const RawProps &rawProps) const override {
|
||||
assert(
|
||||
react_native_assert(
|
||||
!props ||
|
||||
dynamic_cast<ConcreteProps const *>(props.get()) &&
|
||||
"Provided `props` has an incompatible type.");
|
||||
|
@ -161,7 +163,7 @@ class ConcreteComponentDescriptor : public ComponentDescriptor {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
assert(data && "Provided `data` is nullptr.");
|
||||
react_native_assert(data && "Provided `data` is nullptr.");
|
||||
|
||||
return std::make_shared<ConcreteState const>(
|
||||
std::static_pointer_cast<ConcreteStateData const>(data),
|
||||
|
@ -183,7 +185,8 @@ class ConcreteComponentDescriptor : public ComponentDescriptor {
|
|||
protected:
|
||||
virtual void adopt(UnsharedShadowNode shadowNode) const {
|
||||
// Default implementation does nothing.
|
||||
assert(shadowNode->getComponentHandle() == getComponentHandle());
|
||||
react_native_assert(
|
||||
shadowNode->getComponentHandle() == getComponentHandle());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <react/debug/react_native_assert.h>
|
||||
#include <react/renderer/core/ConcreteState.h>
|
||||
#include <react/renderer/core/Props.h>
|
||||
#include <react/renderer/core/ShadowNode.h>
|
||||
|
@ -92,8 +93,9 @@ class ConcreteShadowNode : public BaseShadowNodeT {
|
|||
* Thread-safe after the node is sealed.
|
||||
*/
|
||||
ConcreteProps const &getConcreteProps() const {
|
||||
assert(BaseShadowNodeT::props_ && "Props must not be `nullptr`.");
|
||||
assert(
|
||||
react_native_assert(
|
||||
BaseShadowNodeT::props_ && "Props must not be `nullptr`.");
|
||||
react_native_assert(
|
||||
std::dynamic_pointer_cast<ConcreteProps const>(props_) &&
|
||||
"Props must be an instance of ConcreteProps class.");
|
||||
return static_cast<ConcreteProps const &>(*props_);
|
||||
|
@ -104,7 +106,7 @@ class ConcreteShadowNode : public BaseShadowNodeT {
|
|||
* Thread-safe after the node is sealed.
|
||||
*/
|
||||
ConcreteEventEmitter const &getConcreteEventEmitter() const {
|
||||
assert(
|
||||
react_native_assert(
|
||||
std::dynamic_pointer_cast<ConcreteEventEmitter const>(
|
||||
BaseShadowNodeT::getEventEmitter()) &&
|
||||
"EventEmitter must be an instance of ConcreteEventEmitter class.");
|
||||
|
@ -117,8 +119,8 @@ class ConcreteShadowNode : public BaseShadowNodeT {
|
|||
* Thread-safe after the node is sealed.
|
||||
*/
|
||||
ConcreteStateData const &getStateData() const {
|
||||
assert(state_ && "State must not be `nullptr`.");
|
||||
assert(
|
||||
react_native_assert(state_ && "State must not be `nullptr`.");
|
||||
react_native_assert(
|
||||
std::dynamic_pointer_cast<ConcreteState const>(state_) &&
|
||||
"State must be an instance of ConcreteState class.");
|
||||
return static_cast<ConcreteState const *>(state_.get())->getData();
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
#include <react/debug/react_native_assert.h>
|
||||
#include <react/renderer/core/State.h>
|
||||
|
||||
namespace facebook {
|
||||
|
@ -89,7 +90,7 @@ class ConcreteState : public State {
|
|||
|
||||
auto stateUpdate = StateUpdate{
|
||||
family, [=](StateData::Shared const &oldData) -> StateData::Shared {
|
||||
assert(oldData);
|
||||
react_native_assert(oldData);
|
||||
return callback(*std::static_pointer_cast<Data const>(oldData));
|
||||
}};
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
#include "EventTarget.h"
|
||||
|
||||
#include <react/debug/react_native_assert.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
|
@ -38,8 +40,8 @@ void EventTarget::retain(jsi::Runtime &runtime) const {
|
|||
// particular implementation of JSI was able to detect this inconsistency and
|
||||
// dealt with it, but some JSI implementation may not support this feature and
|
||||
// that case will lead to a crash in those environments.
|
||||
assert(!strongInstanceHandle_.isNull());
|
||||
assert(!strongInstanceHandle_.isUndefined());
|
||||
react_native_assert(!strongInstanceHandle_.isNull());
|
||||
react_native_assert(!strongInstanceHandle_.isUndefined());
|
||||
}
|
||||
|
||||
void EventTarget::release(jsi::Runtime &runtime) const {
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <vector>
|
||||
|
||||
#include <better/small_vector.h>
|
||||
#include <react/debug/react_native_assert.h>
|
||||
#include <react/renderer/core/LayoutMetrics.h>
|
||||
#include <react/renderer/core/ShadowNode.h>
|
||||
#include <react/renderer/core/ShadowNodeFragment.h>
|
||||
|
@ -169,10 +170,10 @@ inline LayoutableShadowNode const &traitCast<LayoutableShadowNode const &>(
|
|||
ShadowNode const &shadowNode) {
|
||||
bool castable =
|
||||
shadowNode.getTraits().check(ShadowNodeTraits::Trait::LayoutableKind);
|
||||
assert(
|
||||
react_native_assert(
|
||||
castable ==
|
||||
(dynamic_cast<LayoutableShadowNode const *>(&shadowNode) != nullptr));
|
||||
assert(castable);
|
||||
react_native_assert(castable);
|
||||
(void)castable;
|
||||
return static_cast<LayoutableShadowNode const &>(shadowNode);
|
||||
}
|
||||
|
@ -185,7 +186,7 @@ inline LayoutableShadowNode const *traitCast<LayoutableShadowNode const *>(
|
|||
}
|
||||
bool castable =
|
||||
shadowNode->getTraits().check(ShadowNodeTraits::Trait::LayoutableKind);
|
||||
assert(
|
||||
react_native_assert(
|
||||
castable ==
|
||||
(dynamic_cast<LayoutableShadowNode const *>(shadowNode) != nullptr));
|
||||
if (!castable) {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "RawProps.h"
|
||||
|
||||
#include <react/debug/react_native_assert.h>
|
||||
#include <react/renderer/core/RawPropsParser.h>
|
||||
|
||||
namespace facebook {
|
||||
|
@ -47,7 +48,7 @@ RawProps::RawProps(folly::dynamic const &dynamic) noexcept {
|
|||
}
|
||||
|
||||
void RawProps::parse(RawPropsParser const &parser) const noexcept {
|
||||
assert(parser_ == nullptr && "A parser was already assigned.");
|
||||
react_native_assert(parser_ == nullptr && "A parser was already assigned.");
|
||||
parser_ = &parser;
|
||||
parser.preparse(*this);
|
||||
}
|
||||
|
@ -84,7 +85,7 @@ const RawValue *RawProps::at(
|
|||
char const *name,
|
||||
char const *prefix,
|
||||
char const *suffix) const noexcept {
|
||||
assert(
|
||||
react_native_assert(
|
||||
parser_ &&
|
||||
"The object is not parsed. `parse` must be called before `at`.");
|
||||
return parser_->at(*this, RawPropsKey{prefix, name, suffix});
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
||||
#include <react/debug/react_native_assert.h>
|
||||
#include <react/renderer/core/RawPropsPrimitives.h>
|
||||
|
||||
namespace facebook {
|
||||
|
@ -37,14 +38,14 @@ void RawPropsKey::render(char *buffer, RawPropsPropNameLength *length)
|
|||
std::memcpy(buffer + *length, suffix, suffixLength);
|
||||
*length += suffixLength;
|
||||
}
|
||||
assert(*length < kPropNameLengthHardCap);
|
||||
react_native_assert(*length < kPropNameLengthHardCap);
|
||||
}
|
||||
|
||||
RawPropsKey::operator std::string() const noexcept {
|
||||
char buffer[kPropNameLengthHardCap];
|
||||
RawPropsPropNameLength length = 0;
|
||||
render(buffer, &length);
|
||||
assert(length < kPropNameLengthHardCap);
|
||||
react_native_assert(length < kPropNameLengthHardCap);
|
||||
return std::string{buffer, length};
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
#include "RawPropsKeyMap.h"
|
||||
|
||||
#include <react/debug/react_native_assert.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstdlib>
|
||||
|
@ -79,12 +81,12 @@ void RawPropsKeyMap::reindex() noexcept {
|
|||
RawPropsValueIndex RawPropsKeyMap::at(
|
||||
char const *name,
|
||||
RawPropsPropNameLength length) noexcept {
|
||||
assert(length > 0);
|
||||
assert(length < kPropNameLengthHardCap);
|
||||
react_native_assert(length > 0);
|
||||
react_native_assert(length < kPropNameLengthHardCap);
|
||||
// 1. Find the bucket.
|
||||
auto lower = int{buckets_[length - 1]};
|
||||
auto upper = int{buckets_[length]} - 1;
|
||||
assert(lower - 1 <= upper);
|
||||
react_native_assert(lower - 1 <= upper);
|
||||
|
||||
// 2. Binary search in the bucket.
|
||||
while (lower <= upper) {
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
#include <jsi/JSIDynamic.h>
|
||||
#include <jsi/jsi.h>
|
||||
|
||||
#include <react/debug/react_native_assert.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
|
@ -189,7 +191,7 @@ class RawValue {
|
|||
}
|
||||
|
||||
for (const auto &item : dynamic.items()) {
|
||||
assert(item.first.isString());
|
||||
react_native_assert(item.first.isString());
|
||||
if (!checkValueType(item.second, (T *)nullptr)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -242,7 +244,7 @@ class RawValue {
|
|||
static std::vector<T> castValue(
|
||||
const folly::dynamic &dynamic,
|
||||
std::vector<T> *type) noexcept {
|
||||
assert(dynamic.isArray());
|
||||
react_native_assert(dynamic.isArray());
|
||||
auto result = std::vector<T>{};
|
||||
result.reserve(dynamic.size());
|
||||
for (const auto &item : dynamic) {
|
||||
|
@ -255,7 +257,7 @@ class RawValue {
|
|||
static std::vector<std::vector<T>> castValue(
|
||||
const folly::dynamic &dynamic,
|
||||
std::vector<std::vector<T>> *type) noexcept {
|
||||
assert(dynamic.isArray());
|
||||
react_native_assert(dynamic.isArray());
|
||||
auto result = std::vector<std::vector<T>>{};
|
||||
result.reserve(dynamic.size());
|
||||
for (const auto &item : dynamic) {
|
||||
|
@ -268,10 +270,10 @@ class RawValue {
|
|||
static better::map<std::string, T> castValue(
|
||||
const folly::dynamic &dynamic,
|
||||
better::map<std::string, T> *type) noexcept {
|
||||
assert(dynamic.isObject());
|
||||
react_native_assert(dynamic.isObject());
|
||||
auto result = better::map<std::string, T>{};
|
||||
for (const auto &item : dynamic.items()) {
|
||||
assert(item.first.isString());
|
||||
react_native_assert(item.first.isString());
|
||||
result[item.first.getString()] = castValue(item.second, (T *)nullptr);
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include "Sealable.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <react/debug/react_native_assert.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
@ -56,7 +56,7 @@ bool Sealable::getSealed() const {
|
|||
}
|
||||
|
||||
void Sealable::ensureUnsealed() const {
|
||||
assert(!sealed_ && "Attempt to mutate a sealed object.");
|
||||
react_native_assert(!sealed_ && "Attempt to mutate a sealed object.");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include <better/small_vector.h>
|
||||
|
||||
#include <react/debug/react_native_assert.h>
|
||||
#include <react/renderer/core/ComponentDescriptor.h>
|
||||
#include <react/renderer/core/ShadowNodeFragment.h>
|
||||
#include <react/renderer/debug/DebugStringConvertible.h>
|
||||
|
@ -74,8 +75,8 @@ ShadowNode::ShadowNode(
|
|||
orderIndex_(0),
|
||||
family_(family),
|
||||
traits_(traits) {
|
||||
assert(props_);
|
||||
assert(children_);
|
||||
react_native_assert(props_);
|
||||
react_native_assert(children_);
|
||||
|
||||
traits_.set(ShadowNodeTraits::Trait::ChildrenAreShared);
|
||||
|
||||
|
@ -104,8 +105,8 @@ ShadowNode::ShadowNode(
|
|||
family_(sourceShadowNode.family_),
|
||||
traits_(sourceShadowNode.traits_) {
|
||||
|
||||
assert(props_);
|
||||
assert(children_);
|
||||
react_native_assert(props_);
|
||||
react_native_assert(children_);
|
||||
|
||||
traits_.set(ShadowNodeTraits::Trait::ChildrenAreShared);
|
||||
|
||||
|
@ -227,7 +228,7 @@ void ShadowNode::replaceChild(
|
|||
}
|
||||
}
|
||||
|
||||
assert(false && "Child to replace was not found.");
|
||||
react_native_assert(false && "Child to replace was not found.");
|
||||
}
|
||||
|
||||
void ShadowNode::cloneChildrenIfShared() {
|
||||
|
@ -267,7 +268,7 @@ ShadowNode::Unshared ShadowNode::cloneTree(
|
|||
|
||||
auto newShadowNode = callback(*oldShadowNode);
|
||||
|
||||
assert(
|
||||
react_native_assert(
|
||||
newShadowNode &&
|
||||
"`callback` returned `nullptr` which is not allowed value.");
|
||||
|
||||
|
@ -278,7 +279,8 @@ ShadowNode::Unshared ShadowNode::cloneTree(
|
|||
auto childIndex = it->second;
|
||||
|
||||
auto children = parentNode.getChildren();
|
||||
assert(ShadowNode::sameFamily(*children.at(childIndex), *childNode));
|
||||
react_native_assert(
|
||||
ShadowNode::sameFamily(*children.at(childIndex), *childNode));
|
||||
children[childIndex] = childNode;
|
||||
|
||||
childNode = parentNode.clone({
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "ShadowNodeFamily.h"
|
||||
#include "ShadowNode.h"
|
||||
|
||||
#include <react/debug/react_native_assert.h>
|
||||
#include <react/renderer/core/ComponentDescriptor.h>
|
||||
#include <react/renderer/core/State.h>
|
||||
|
||||
|
@ -29,7 +30,7 @@ ShadowNodeFamily::ShadowNodeFamily(
|
|||
componentName_(componentDescriptor.getComponentName()) {}
|
||||
|
||||
void ShadowNodeFamily::setParent(ShadowNodeFamily::Shared const &parent) const {
|
||||
assert(parent_.lock() == nullptr || parent_.lock() == parent);
|
||||
react_native_assert(parent_.lock() == nullptr || parent_.lock() == parent);
|
||||
if (hasParent_) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -96,6 +96,7 @@ rn_xplat_cxx_library(
|
|||
tests = [":tests"],
|
||||
visibility = ["PUBLIC"],
|
||||
deps = [
|
||||
react_native_xplat_target("react/debug:debug"),
|
||||
react_native_xplat_target("better:better"),
|
||||
"//third-party/glog:glog",
|
||||
"//xplat/fbsystrace:fbsystrace",
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <cmath>
|
||||
|
||||
#include <glog/logging.h>
|
||||
#include <react/debug/react_native_assert.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
@ -226,8 +227,8 @@ Transform Transform::Interpolate(
|
|||
(haveRHS && rhs.operations[j].type == type
|
||||
? rhs.operations[j++]
|
||||
: Transform::DefaultTransformOperation(type));
|
||||
assert(type == lhsOp.type);
|
||||
assert(type == rhsOp.type);
|
||||
react_native_assert(type == lhsOp.type);
|
||||
react_native_assert(type == rhsOp.type);
|
||||
|
||||
result = result *
|
||||
Transform::FromTransformOperation(TransformOperation{
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include <better/map.h>
|
||||
#include <folly/dynamic.h>
|
||||
#include <react/debug/react_native_assert.h>
|
||||
#include <react/renderer/core/RawProps.h>
|
||||
#include <react/renderer/graphics/Color.h>
|
||||
#include <react/renderer/graphics/Geometry.h>
|
||||
|
@ -34,7 +35,7 @@ inline void fromRawValue(const RawValue &value, SharedColor &result) {
|
|||
} else if (value.hasType<std::vector<float>>()) {
|
||||
auto items = (std::vector<float>)value;
|
||||
auto length = items.size();
|
||||
assert(length == 3 || length == 4);
|
||||
react_native_assert(length == 3 || length == 4);
|
||||
red = items.at(0);
|
||||
green = items.at(1);
|
||||
blue = items.at(2);
|
||||
|
@ -85,7 +86,7 @@ inline void fromRawValue(const RawValue &value, Point &result) {
|
|||
|
||||
if (value.hasType<std::vector<Float>>()) {
|
||||
auto array = (std::vector<Float>)value;
|
||||
assert(array.size() == 2);
|
||||
react_native_assert(array.size() == 2);
|
||||
result = {array.at(0), array.at(1)};
|
||||
return;
|
||||
}
|
||||
|
@ -108,7 +109,7 @@ inline void fromRawValue(const RawValue &value, Size &result) {
|
|||
|
||||
if (value.hasType<std::vector<Float>>()) {
|
||||
auto array = (std::vector<Float>)value;
|
||||
assert(array.size() == 2);
|
||||
react_native_assert(array.size() == 2);
|
||||
result = {array.at(0), array.at(1)};
|
||||
return;
|
||||
}
|
||||
|
@ -140,7 +141,7 @@ inline void fromRawValue(const RawValue &value, EdgeInsets &result) {
|
|||
|
||||
if (value.hasType<std::vector<Float>>()) {
|
||||
auto array = (std::vector<Float>)value;
|
||||
assert(array.size() == 4);
|
||||
react_native_assert(array.size() == 4);
|
||||
result = {array.at(0), array.at(1), array.at(2), array.at(3)};
|
||||
return;
|
||||
}
|
||||
|
@ -172,7 +173,7 @@ inline void fromRawValue(const RawValue &value, CornerInsets &result) {
|
|||
|
||||
if (value.hasType<std::vector<Float>>()) {
|
||||
auto array = (std::vector<Float>)value;
|
||||
assert(array.size() == 4);
|
||||
react_native_assert(array.size() == 4);
|
||||
result = {array.at(0), array.at(1), array.at(2), array.at(3)};
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -105,6 +105,7 @@ rn_xplat_cxx_library(
|
|||
"//xplat/folly:headers_only",
|
||||
"//xplat/folly:molly",
|
||||
YOGA_CXX_TARGET,
|
||||
react_native_xplat_target("react/debug:debug"),
|
||||
react_native_xplat_target("react/renderer/core:core"),
|
||||
react_native_xplat_target("react/renderer/mounting:mounting"),
|
||||
react_native_xplat_target("react/renderer/debug:debug"),
|
||||
|
|
|
@ -8,7 +8,8 @@
|
|||
#include "ImageResponseObserverCoordinator.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#include <react/debug/react_native_assert.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
@ -52,7 +53,7 @@ void ImageResponseObserverCoordinator::nativeImageResponseProgress(
|
|||
float progress) const {
|
||||
mutex_.lock();
|
||||
auto observers = observers_;
|
||||
assert(status_ == ImageResponse::Status::Loading);
|
||||
react_native_assert(status_ == ImageResponse::Status::Loading);
|
||||
mutex_.unlock();
|
||||
|
||||
for (auto observer : observers) {
|
||||
|
@ -65,7 +66,7 @@ void ImageResponseObserverCoordinator::nativeImageResponseComplete(
|
|||
mutex_.lock();
|
||||
imageData_ = imageResponse.getImage();
|
||||
imageMetadata_ = imageResponse.getMetadata();
|
||||
assert(status_ == ImageResponse::Status::Loading);
|
||||
react_native_assert(status_ == ImageResponse::Status::Loading);
|
||||
status_ = ImageResponse::Status::Completed;
|
||||
auto observers = observers_;
|
||||
mutex_.unlock();
|
||||
|
@ -77,7 +78,7 @@ void ImageResponseObserverCoordinator::nativeImageResponseComplete(
|
|||
|
||||
void ImageResponseObserverCoordinator::nativeImageResponseFailed() const {
|
||||
mutex_.lock();
|
||||
assert(status_ == ImageResponse::Status::Loading);
|
||||
react_native_assert(status_ == ImageResponse::Status::Loading);
|
||||
status_ = ImageResponse::Status::Failed;
|
||||
auto observers = observers_;
|
||||
mutex_.unlock();
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include <condition_variable>
|
||||
|
||||
#include <react/debug/react_native_assert.h>
|
||||
#include <react/renderer/mounting/ShadowViewMutation.h>
|
||||
|
||||
namespace facebook {
|
||||
|
@ -37,7 +38,7 @@ void MountingCoordinator::push(ShadowTreeRevision const &revision) const {
|
|||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
|
||||
assert(
|
||||
react_native_assert(
|
||||
!lastRevision_.has_value() || revision.number != lastRevision_->number);
|
||||
|
||||
if (!lastRevision_.has_value() || lastRevision_->number < revision.number) {
|
||||
|
@ -162,7 +163,8 @@ better::optional<MountingTransaction> MountingCoordinator::pullTransaction()
|
|||
}
|
||||
}
|
||||
|
||||
assert((treesEqual) && "Incorrect set of mutations detected.");
|
||||
react_native_assert(
|
||||
(treesEqual) && "Incorrect set of mutations detected.");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "ShadowTree.h"
|
||||
|
||||
#include <react/debug/react_native_assert.h>
|
||||
#include <react/renderer/components/root/RootComponentDescriptor.h>
|
||||
#include <react/renderer/components/view/ViewShadowNode.h>
|
||||
#include <react/renderer/core/LayoutContext.h>
|
||||
|
@ -305,7 +306,7 @@ CommitStatus ShadowTree::commit(
|
|||
|
||||
// After multiple attempts, we failed to commit the transaction.
|
||||
// Something internally went terribly wrong.
|
||||
assert(attempts < 1024);
|
||||
react_native_assert(attempts < 1024);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,11 +7,13 @@
|
|||
|
||||
#include "ShadowTreeRegistry.h"
|
||||
|
||||
#include <react/debug/react_native_assert.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
ShadowTreeRegistry::~ShadowTreeRegistry() {
|
||||
assert(
|
||||
react_native_assert(
|
||||
registry_.empty() && "Deallocation of non-empty `ShadowTreeRegistry`.");
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "StubViewTree.h"
|
||||
|
||||
#include <glog/logging.h>
|
||||
#include <react/debug/react_native_assert.h>
|
||||
|
||||
// For iOS especially: flush logs because some might be lost on iOS if an
|
||||
// assert is hit right after this.
|
||||
|
@ -16,7 +17,7 @@
|
|||
LOG(ERROR) << "ASSERT FAILURE: " << #cond; \
|
||||
google::FlushLogFiles(google::INFO); \
|
||||
} \
|
||||
assert(cond);
|
||||
react_native_assert(cond);
|
||||
|
||||
#ifdef STUB_VIEW_TREE_VERBOSE
|
||||
#define STUB_VIEW_LOG(code) code
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include "TransactionTelemetry.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <react/debug/react_native_assert.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
@ -27,32 +27,32 @@ void TransactionTelemetry::unsetAsThreadLocal() {
|
|||
}
|
||||
|
||||
void TransactionTelemetry::willCommit() {
|
||||
assert(commitStartTime_ == kTelemetryUndefinedTimePoint);
|
||||
assert(commitEndTime_ == kTelemetryUndefinedTimePoint);
|
||||
react_native_assert(commitStartTime_ == kTelemetryUndefinedTimePoint);
|
||||
react_native_assert(commitEndTime_ == kTelemetryUndefinedTimePoint);
|
||||
commitStartTime_ = telemetryTimePointNow();
|
||||
}
|
||||
|
||||
void TransactionTelemetry::didCommit() {
|
||||
assert(commitStartTime_ != kTelemetryUndefinedTimePoint);
|
||||
assert(commitEndTime_ == kTelemetryUndefinedTimePoint);
|
||||
react_native_assert(commitStartTime_ != kTelemetryUndefinedTimePoint);
|
||||
react_native_assert(commitEndTime_ == kTelemetryUndefinedTimePoint);
|
||||
commitEndTime_ = telemetryTimePointNow();
|
||||
}
|
||||
|
||||
void TransactionTelemetry::willDiff() {
|
||||
assert(diffStartTime_ == kTelemetryUndefinedTimePoint);
|
||||
assert(diffEndTime_ == kTelemetryUndefinedTimePoint);
|
||||
react_native_assert(diffStartTime_ == kTelemetryUndefinedTimePoint);
|
||||
react_native_assert(diffEndTime_ == kTelemetryUndefinedTimePoint);
|
||||
diffStartTime_ = telemetryTimePointNow();
|
||||
}
|
||||
|
||||
void TransactionTelemetry::didDiff() {
|
||||
assert(diffStartTime_ != kTelemetryUndefinedTimePoint);
|
||||
assert(diffEndTime_ == kTelemetryUndefinedTimePoint);
|
||||
react_native_assert(diffStartTime_ != kTelemetryUndefinedTimePoint);
|
||||
react_native_assert(diffEndTime_ == kTelemetryUndefinedTimePoint);
|
||||
diffEndTime_ = telemetryTimePointNow();
|
||||
}
|
||||
|
||||
void TransactionTelemetry::willLayout() {
|
||||
assert(layoutStartTime_ == kTelemetryUndefinedTimePoint);
|
||||
assert(layoutEndTime_ == kTelemetryUndefinedTimePoint);
|
||||
react_native_assert(layoutStartTime_ == kTelemetryUndefinedTimePoint);
|
||||
react_native_assert(layoutEndTime_ == kTelemetryUndefinedTimePoint);
|
||||
layoutStartTime_ = telemetryTimePointNow();
|
||||
}
|
||||
|
||||
|
@ -61,20 +61,20 @@ void TransactionTelemetry::didMeasureText() {
|
|||
}
|
||||
|
||||
void TransactionTelemetry::didLayout() {
|
||||
assert(layoutStartTime_ != kTelemetryUndefinedTimePoint);
|
||||
assert(layoutEndTime_ == kTelemetryUndefinedTimePoint);
|
||||
react_native_assert(layoutStartTime_ != kTelemetryUndefinedTimePoint);
|
||||
react_native_assert(layoutEndTime_ == kTelemetryUndefinedTimePoint);
|
||||
layoutEndTime_ = telemetryTimePointNow();
|
||||
}
|
||||
|
||||
void TransactionTelemetry::willMount() {
|
||||
assert(mountStartTime_ == kTelemetryUndefinedTimePoint);
|
||||
assert(mountEndTime_ == kTelemetryUndefinedTimePoint);
|
||||
react_native_assert(mountStartTime_ == kTelemetryUndefinedTimePoint);
|
||||
react_native_assert(mountEndTime_ == kTelemetryUndefinedTimePoint);
|
||||
mountStartTime_ = telemetryTimePointNow();
|
||||
}
|
||||
|
||||
void TransactionTelemetry::didMount() {
|
||||
assert(mountStartTime_ != kTelemetryUndefinedTimePoint);
|
||||
assert(mountEndTime_ == kTelemetryUndefinedTimePoint);
|
||||
react_native_assert(mountStartTime_ != kTelemetryUndefinedTimePoint);
|
||||
react_native_assert(mountEndTime_ == kTelemetryUndefinedTimePoint);
|
||||
mountEndTime_ = telemetryTimePointNow();
|
||||
}
|
||||
|
||||
|
@ -83,50 +83,50 @@ void TransactionTelemetry::setRevisionNumber(int revisionNumber) {
|
|||
}
|
||||
|
||||
TelemetryTimePoint TransactionTelemetry::getDiffStartTime() const {
|
||||
assert(diffStartTime_ != kTelemetryUndefinedTimePoint);
|
||||
assert(diffEndTime_ != kTelemetryUndefinedTimePoint);
|
||||
react_native_assert(diffStartTime_ != kTelemetryUndefinedTimePoint);
|
||||
react_native_assert(diffEndTime_ != kTelemetryUndefinedTimePoint);
|
||||
return diffStartTime_;
|
||||
}
|
||||
|
||||
TelemetryTimePoint TransactionTelemetry::getDiffEndTime() const {
|
||||
assert(diffStartTime_ != kTelemetryUndefinedTimePoint);
|
||||
assert(diffEndTime_ != kTelemetryUndefinedTimePoint);
|
||||
react_native_assert(diffStartTime_ != kTelemetryUndefinedTimePoint);
|
||||
react_native_assert(diffEndTime_ != kTelemetryUndefinedTimePoint);
|
||||
return diffEndTime_;
|
||||
}
|
||||
|
||||
TelemetryTimePoint TransactionTelemetry::getCommitStartTime() const {
|
||||
assert(commitStartTime_ != kTelemetryUndefinedTimePoint);
|
||||
assert(commitEndTime_ != kTelemetryUndefinedTimePoint);
|
||||
react_native_assert(commitStartTime_ != kTelemetryUndefinedTimePoint);
|
||||
react_native_assert(commitEndTime_ != kTelemetryUndefinedTimePoint);
|
||||
return commitStartTime_;
|
||||
}
|
||||
|
||||
TelemetryTimePoint TransactionTelemetry::getCommitEndTime() const {
|
||||
assert(commitStartTime_ != kTelemetryUndefinedTimePoint);
|
||||
assert(commitEndTime_ != kTelemetryUndefinedTimePoint);
|
||||
react_native_assert(commitStartTime_ != kTelemetryUndefinedTimePoint);
|
||||
react_native_assert(commitEndTime_ != kTelemetryUndefinedTimePoint);
|
||||
return commitEndTime_;
|
||||
}
|
||||
|
||||
TelemetryTimePoint TransactionTelemetry::getLayoutStartTime() const {
|
||||
assert(layoutStartTime_ != kTelemetryUndefinedTimePoint);
|
||||
assert(layoutEndTime_ != kTelemetryUndefinedTimePoint);
|
||||
react_native_assert(layoutStartTime_ != kTelemetryUndefinedTimePoint);
|
||||
react_native_assert(layoutEndTime_ != kTelemetryUndefinedTimePoint);
|
||||
return layoutStartTime_;
|
||||
}
|
||||
|
||||
TelemetryTimePoint TransactionTelemetry::getLayoutEndTime() const {
|
||||
assert(layoutStartTime_ != kTelemetryUndefinedTimePoint);
|
||||
assert(layoutEndTime_ != kTelemetryUndefinedTimePoint);
|
||||
react_native_assert(layoutStartTime_ != kTelemetryUndefinedTimePoint);
|
||||
react_native_assert(layoutEndTime_ != kTelemetryUndefinedTimePoint);
|
||||
return layoutEndTime_;
|
||||
}
|
||||
|
||||
TelemetryTimePoint TransactionTelemetry::getMountStartTime() const {
|
||||
assert(mountStartTime_ != kTelemetryUndefinedTimePoint);
|
||||
assert(mountEndTime_ != kTelemetryUndefinedTimePoint);
|
||||
react_native_assert(mountStartTime_ != kTelemetryUndefinedTimePoint);
|
||||
react_native_assert(mountEndTime_ != kTelemetryUndefinedTimePoint);
|
||||
return mountStartTime_;
|
||||
}
|
||||
|
||||
TelemetryTimePoint TransactionTelemetry::getMountEndTime() const {
|
||||
assert(mountStartTime_ != kTelemetryUndefinedTimePoint);
|
||||
assert(mountEndTime_ != kTelemetryUndefinedTimePoint);
|
||||
react_native_assert(mountStartTime_ != kTelemetryUndefinedTimePoint);
|
||||
react_native_assert(mountEndTime_ != kTelemetryUndefinedTimePoint);
|
||||
return mountEndTime_;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,11 +55,12 @@ rn_xplat_cxx_library(
|
|||
"//xplat/folly:molly",
|
||||
"//xplat/jsi:JSIDynamic",
|
||||
"//xplat/jsi:jsi",
|
||||
react_native_xplat_target("react/config:config"),
|
||||
react_native_xplat_target("react/debug:debug"),
|
||||
react_native_xplat_target("react/renderer/core:core"),
|
||||
react_native_xplat_target("react/renderer/mounting:mounting"),
|
||||
react_native_xplat_target("react/renderer/uimanager:uimanager"),
|
||||
react_native_xplat_target("react/renderer/templateprocessor:templateprocessor"),
|
||||
react_native_xplat_target("react/config:config"),
|
||||
react_native_xplat_target("react/renderer/componentregistry:componentregistry"),
|
||||
react_native_xplat_target("react/renderer/debug:debug"),
|
||||
react_native_xplat_target("react/renderer/components/root:root"),
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <glog/logging.h>
|
||||
#include <jsi/jsi.h>
|
||||
|
||||
#include <react/debug/react_native_assert.h>
|
||||
#include <react/renderer/componentregistry/ComponentDescriptorRegistry.h>
|
||||
#include <react/renderer/core/Constants.h>
|
||||
#include <react/renderer/core/LayoutContext.h>
|
||||
|
@ -153,7 +154,7 @@ Scheduler::~Scheduler() {
|
|||
surfaceIds.push_back(shadowTree.getSurfaceId());
|
||||
});
|
||||
|
||||
assert(
|
||||
react_native_assert(
|
||||
surfaceIds.empty() &&
|
||||
"Scheduler was destroyed with outstanding Surfaces.");
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "SurfaceHandler.h"
|
||||
|
||||
#include <react/debug/react_native_assert.h>
|
||||
#include <react/renderer/scheduler/Scheduler.h>
|
||||
#include <react/renderer/uimanager/UIManager.h>
|
||||
|
||||
|
@ -55,7 +56,8 @@ Status SurfaceHandler::getStatus() const noexcept {
|
|||
void SurfaceHandler::start() const noexcept {
|
||||
{
|
||||
std::unique_lock<better::shared_mutex> lock(linkMutex_);
|
||||
assert(link_.status == Status::Registered && "Surface must be registered.");
|
||||
react_native_assert(
|
||||
link_.status == Status::Registered && "Surface must be registered.");
|
||||
|
||||
auto parameters = Parameters{};
|
||||
{
|
||||
|
@ -78,7 +80,8 @@ void SurfaceHandler::start() const noexcept {
|
|||
|
||||
void SurfaceHandler::stop() const noexcept {
|
||||
std::unique_lock<better::shared_mutex> lock(linkMutex_);
|
||||
assert(link_.status == Status::Running && "Surface must be running.");
|
||||
react_native_assert(
|
||||
link_.status == Status::Running && "Surface must be running.");
|
||||
|
||||
link_.status = Status::Registered;
|
||||
link_.shadowTree = nullptr;
|
||||
|
@ -136,8 +139,10 @@ folly::dynamic SurfaceHandler::getProps() const noexcept {
|
|||
std::shared_ptr<MountingCoordinator const>
|
||||
SurfaceHandler::getMountingCoordinator() const noexcept {
|
||||
std::shared_lock<better::shared_mutex> lock(linkMutex_);
|
||||
assert(link_.status != Status::Unregistered && "Surface must be registered.");
|
||||
assert(link_.shadowTree && "`link_.shadowTree` must not be null.");
|
||||
react_native_assert(
|
||||
link_.status != Status::Unregistered && "Surface must be registered.");
|
||||
react_native_assert(
|
||||
link_.shadowTree && "`link_.shadowTree` must not be null.");
|
||||
return link_.shadowTree->getMountingCoordinator();
|
||||
}
|
||||
|
||||
|
@ -152,7 +157,8 @@ Size SurfaceHandler::measure(
|
|||
return layoutConstraints.clamp({0, 0});
|
||||
}
|
||||
|
||||
assert(link_.shadowTree && "`link_.shadowTree` must not be null.");
|
||||
react_native_assert(
|
||||
link_.shadowTree && "`link_.shadowTree` must not be null.");
|
||||
|
||||
auto currentRootShadowNode =
|
||||
link_.shadowTree->getCurrentRevision().rootShadowNode;
|
||||
|
@ -185,7 +191,8 @@ void SurfaceHandler::constraintLayout(
|
|||
return;
|
||||
}
|
||||
|
||||
assert(link_.shadowTree && "`link_.shadowTree` must not be null.");
|
||||
react_native_assert(
|
||||
link_.shadowTree && "`link_.shadowTree` must not be null.");
|
||||
link_.shadowTree->commit([&](RootShadowNode const &oldRootShadowNode) {
|
||||
return oldRootShadowNode.clone(layoutConstraints, layoutContext);
|
||||
});
|
||||
|
@ -205,8 +212,10 @@ LayoutContext SurfaceHandler::getLayoutContext() const noexcept {
|
|||
#pragma mark - Private
|
||||
|
||||
void SurfaceHandler::applyDisplayMode(DisplayMode displayMode) const noexcept {
|
||||
assert(link_.status == Status::Running && "Surface must be running.");
|
||||
assert(link_.shadowTree && "`link_.shadowTree` must not be null.");
|
||||
react_native_assert(
|
||||
link_.status == Status::Running && "Surface must be running.");
|
||||
react_native_assert(
|
||||
link_.shadowTree && "`link_.shadowTree` must not be null.");
|
||||
|
||||
switch (displayMode) {
|
||||
case DisplayMode::Visible:
|
||||
|
@ -236,7 +245,8 @@ void SurfaceHandler::applyDisplayMode(DisplayMode displayMode) const noexcept {
|
|||
void SurfaceHandler::setUIManager(UIManager const *uiManager) const noexcept {
|
||||
std::unique_lock<better::shared_mutex> lock(linkMutex_);
|
||||
|
||||
assert(link_.status != Status::Running && "Surface must not be running.");
|
||||
react_native_assert(
|
||||
link_.status != Status::Running && "Surface must not be running.");
|
||||
|
||||
if (link_.uiManager == uiManager) {
|
||||
return;
|
||||
|
@ -247,7 +257,7 @@ void SurfaceHandler::setUIManager(UIManager const *uiManager) const noexcept {
|
|||
}
|
||||
|
||||
SurfaceHandler::~SurfaceHandler() noexcept {
|
||||
assert(
|
||||
react_native_assert(
|
||||
link_.status == Status::Unregistered &&
|
||||
"`SurfaceHandler` must be unregistered (or moved-from) before deallocation.");
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
#include "SynchronousEventBeat.h"
|
||||
|
||||
#include <react/debug/react_native_assert.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
|
@ -23,7 +25,7 @@ SynchronousEventBeat::SynchronousEventBeat(
|
|||
void SynchronousEventBeat::activityDidChange(
|
||||
RunLoopObserver::Delegate const *delegate,
|
||||
RunLoopObserver::Activity activity) const noexcept {
|
||||
assert(delegate == this);
|
||||
react_native_assert(delegate == this);
|
||||
lockExecutorAndBeat();
|
||||
}
|
||||
|
||||
|
|
|
@ -58,6 +58,7 @@ rn_xplat_cxx_library(
|
|||
"//xplat/jsi:JSIDynamic",
|
||||
"//xplat/jsi:jsi",
|
||||
react_native_xplat_target("react/config:config"),
|
||||
react_native_xplat_target("react/debug:debug"),
|
||||
react_native_xplat_target("react/renderer/components/view:view"),
|
||||
react_native_xplat_target("react/renderer/mounting:mounting"),
|
||||
react_native_xplat_target("react/renderer/core:core"),
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "UIManager.h"
|
||||
|
||||
#include <react/debug/react_native_assert.h>
|
||||
#include <react/renderer/core/ShadowNodeFragment.h>
|
||||
#include <react/renderer/debug/SystraceSection.h>
|
||||
#include <react/renderer/graphics/Geometry.h>
|
||||
|
@ -357,7 +358,7 @@ ShadowTreeRegistry const &UIManager::getShadowTreeRegistry() const {
|
|||
void UIManager::registerCommitHook(
|
||||
UIManagerCommitHook const &commitHook) const {
|
||||
std::unique_lock<better::shared_mutex> lock(commitHookMutex_);
|
||||
assert(
|
||||
react_native_assert(
|
||||
std::find(commitHooks_.begin(), commitHooks_.end(), &commitHook) ==
|
||||
commitHooks_.end());
|
||||
commitHook.commitHookWasRegistered(*this);
|
||||
|
@ -369,7 +370,7 @@ void UIManager::unregisterCommitHook(
|
|||
std::unique_lock<better::shared_mutex> lock(commitHookMutex_);
|
||||
auto iterator =
|
||||
std::find(commitHooks_.begin(), commitHooks_.end(), &commitHook);
|
||||
assert(iterator != commitHooks_.end());
|
||||
react_native_assert(iterator != commitHooks_.end());
|
||||
commitHooks_.erase(iterator);
|
||||
commitHook.commitHookWasUnregistered(*this);
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include <glog/logging.h>
|
||||
#include <jsi/JSIDynamic.h>
|
||||
#include <react/debug/react_native_assert.h>
|
||||
#include <react/renderer/core/LayoutableShadowNode.h>
|
||||
#include <react/renderer/debug/SystraceSection.h>
|
||||
|
||||
|
@ -29,7 +30,7 @@ static jsi::Object getModule(
|
|||
if (!moduleAsValue.isObject()) {
|
||||
LOG(ERROR) << "getModule of " << moduleName << " is not an object";
|
||||
}
|
||||
assert(moduleAsValue.isObject());
|
||||
react_native_assert(moduleAsValue.isObject());
|
||||
return moduleAsValue.asObject(runtime);
|
||||
}
|
||||
|
||||
|
@ -170,7 +171,7 @@ void UIManagerBinding::dispatchEvent(
|
|||
if (!payload.isObject()) {
|
||||
LOG(ERROR) << "payload for dispatchEvent is not an object: " << eventTarget->getTag();
|
||||
}
|
||||
assert(payload.isObject());
|
||||
react_native_assert(payload.isObject());
|
||||
payload.asObject(runtime).setProperty(runtime, "target", eventTarget->getTag());
|
||||
return instanceHandle;
|
||||
}()
|
||||
|
|
Загрузка…
Ссылка в новой задаче