mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fix regression when setting shadow node properties in D38272966 (github PR merge)
Summary: Changelog: [Android][Fixed] - Fix regression when setting shadow node properties. Also simplified the corresponding macros to avoid using lambdas altogether, as they are not required. Note that this **does not** modify any constexpr-related semantics of the existing code, as the main constexpr macro, `CONSTEXPR_RAW_PROPS_KEY_HASH` evaluation result is still contstexpr value, and the other ones already involved non-const parts (see my comments). Reviewed By: NickGerleman Differential Revision: D38356411 fbshipit-source-id: 22c330d3425c8aed36693f4652f1b257d2dc96be
This commit is contained in:
committed by
Facebook GitHub Bot
parent
c7c263dda8
commit
a142a78473
@@ -12,20 +12,17 @@
|
||||
#include <react/renderer/debug/DebugStringConvertibleItem.h>
|
||||
#include <react/renderer/graphics/conversions.h>
|
||||
|
||||
#define GET_FIELD_VALUE(field, fieldName, defaultValue, rawValue) \
|
||||
(rawValue.hasValue() ? ([&rawValue, &context] { \
|
||||
decltype(defaultValue) res; \
|
||||
fromRawValue(context, rawValue, res); \
|
||||
return res; \
|
||||
}()) \
|
||||
: defaultValue);
|
||||
|
||||
#define REBUILD_FIELD_SWITCH_CASE( \
|
||||
defaults, rawValue, property, field, fieldName) \
|
||||
case CONSTEXPR_RAW_PROPS_KEY_HASH(fieldName): { \
|
||||
property.field = \
|
||||
GET_FIELD_VALUE(field, fieldName, defaults.field, rawValue); \
|
||||
return; \
|
||||
#define REBUILD_FIELD_SWITCH_CASE( \
|
||||
defaults, rawValue, property, field, fieldName) \
|
||||
case CONSTEXPR_RAW_PROPS_KEY_HASH(fieldName): { \
|
||||
if (rawValue.hasValue()) { \
|
||||
decltype(defaults.field) res; \
|
||||
fromRawValue(context, rawValue, res); \
|
||||
property.field = res; \
|
||||
} else { \
|
||||
property.field = defaults.field; \
|
||||
} \
|
||||
return; \
|
||||
}
|
||||
|
||||
namespace facebook {
|
||||
|
||||
@@ -258,18 +258,15 @@ ViewProps::ViewProps(
|
||||
#endif
|
||||
{};
|
||||
|
||||
#define VIEW_EVENT_CASE(eventType, eventString) \
|
||||
case CONSTEXPR_RAW_PROPS_KEY_HASH(eventString): { \
|
||||
ViewEvents defaultViewEvents{}; \
|
||||
events[eventType] = [ defaultViewEvents, &value, &context ]() constexpr { \
|
||||
bool res = defaultViewEvents[eventType]; \
|
||||
if (value.hasValue()) { \
|
||||
fromRawValue(context, value, res); \
|
||||
} \
|
||||
return res; \
|
||||
} \
|
||||
(); \
|
||||
return; \
|
||||
#define VIEW_EVENT_CASE(eventType, eventString) \
|
||||
case CONSTEXPR_RAW_PROPS_KEY_HASH(eventString): { \
|
||||
ViewEvents defaultViewEvents{}; \
|
||||
bool res = defaultViewEvents[eventType]; \
|
||||
if (value.hasValue()) { \
|
||||
fromRawValue(context, value, res); \
|
||||
} \
|
||||
events[eventType] = res; \
|
||||
return; \
|
||||
}
|
||||
|
||||
void ViewProps::setProp(
|
||||
|
||||
@@ -119,7 +119,7 @@ class ConcreteComponentDescriptor : public ComponentDescriptor {
|
||||
rawProps.iterateOverValues([&](RawPropsPropNameHash hash,
|
||||
const char *propName,
|
||||
RawValue const &fn) {
|
||||
shadowNodeProps.get()->Props::setProp(context, hash, propName, fn);
|
||||
shadowNodeProps.get()->setProp(context, hash, propName, fn);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
// Get hash at compile-time. sizeof(str) - 1 == strlen
|
||||
#define CONSTEXPR_RAW_PROPS_KEY_HASH(s) \
|
||||
([]() constexpr { \
|
||||
([]() constexpr->RawPropsPropNameHash { \
|
||||
CLANG_PRAGMA("clang diagnostic push") \
|
||||
CLANG_PRAGMA("clang diagnostic ignored \"-Wshadow\"") \
|
||||
return folly::hash::fnv32_buf(s, sizeof(s) - 1); \
|
||||
|
||||
Reference in New Issue
Block a user