Fabric: folly::dynamic was replaced with RawValue in prop-parsing infra

Summary:
Our long-term plan is to completely illuminate `jsi::Value`-to-`folly::dynamic` serialization step in prop parsing process improving performance and memory pressure. At the same time, we don't want to introduce a hard dependency in application code to JSI because it exposes direct access to VM and prevents parsing some data that come *NOT* from JSVM.
RawValue is an extremely light-weight (hopefully fully optimized-out) abstraction that provides limited JSON-like and C++-idiomatic interface.

The current particular implementation is still using `folly::dynamic` inside, but I have fully JSI-powered one which will replace the current one right after we figure out how to deal with folly::dynamic-specific callsites. Or we can implement RawValue in a hybrid manner if a code-size implication of that will be minimal.

Reviewed By: JoshuaGross, mdvacca

Differential Revision: D13962466

fbshipit-source-id: e848522fd242f21e9e771773f2103f1c1d9d7f21
This commit is contained in:
Valentin Shergin
2019-02-06 16:34:46 -08:00
committed by Facebook Github Bot
parent b0c8275369
commit 9842e39019
26 changed files with 660 additions and 319 deletions
+2 -2
View File
@@ -56,8 +56,8 @@ class ::_CLASSNAME_:: final::_EXTEND_CLASSES_:: {
const enumTemplate = `
enum class ::_ENUM_NAME_:: { ::_VALUES_:: };
static inline void fromDynamic(const folly::dynamic &value, ::_ENUM_NAME_:: &result) {
auto string = value.asString();
static inline void fromRawValue(const RawValue &value, ::_ENUM_NAME_:: &result) {
auto string = (std::string)value;
::_FROM_CASES_::
abort();
}
@@ -80,8 +80,8 @@ namespace react {
enum class EnumPropsNativeComponentAlignment { Top, Center, Bottom };
static inline void fromDynamic(const folly::dynamic &value, EnumPropsNativeComponentAlignment &result) {
auto string = value.asString();
static inline void fromRawValue(const RawValue &value, EnumPropsNativeComponentAlignment &result) {
auto string = (std::string)value;
if (string == \\"top\\") { result = EnumPropsNativeComponentAlignment::Top; return; }
if (string == \\"center\\") { result = EnumPropsNativeComponentAlignment::Center; return; }
if (string == \\"bottom\\") { result = EnumPropsNativeComponentAlignment::Bottom; return; }