Fabric: New nice way to deal with DebugStringConvertible items

Summary:
No macros in product code.
(Not all callsites are converted yet.)

Reviewed By: mdvacca

Differential Revision: D7797561

fbshipit-source-id: da899421bf99669a0e0a2b83df6004daf14355c2
This commit is contained in:
Valentin Shergin
2018-05-08 22:56:02 -07:00
committed by Facebook Github Bot
parent d9ff1769aa
commit 6e537b000b
11 changed files with 198 additions and 60 deletions

View File

@@ -10,27 +10,21 @@
#include <fabric/attributedstring/textValuesConversions.h>
#include <fabric/debug/DebugStringConvertibleItem.h>
#include "debugStringConvertibleUtils.h"
namespace facebook {
namespace react {
#pragma mark - DebugStringConvertible
SharedDebugStringConvertibleList ParagraphAttributes::getDebugProps() const {
ParagraphAttributes defaultParagraphAttributes = {};
SharedDebugStringConvertibleList list = {};
#define PARAGRAPH_ATTRIBUTE(stringName, propertyName, accessor, convertor) \
if (propertyName != defaultParagraphAttributes.propertyName) { \
list.push_back(std::make_shared<DebugStringConvertibleItem>(#stringName, convertor(propertyName accessor))); \
}
PARAGRAPH_ATTRIBUTE(maximumNumberOfLines, maximumNumberOfLines, , std::to_string)
PARAGRAPH_ATTRIBUTE(ellipsizeMode, ellipsizeMode, , stringFromEllipsizeMode)
PARAGRAPH_ATTRIBUTE(adjustsFontSizeToFit, adjustsFontSizeToFit, , std::to_string)
PARAGRAPH_ATTRIBUTE(minimumFontSize, minimumFontSize, , std::to_string)
PARAGRAPH_ATTRIBUTE(maximumFontSize, maximumFontSize, , std::to_string)
return list;
return {
debugStringConvertibleItem("maximumNumberOfLines", maximumNumberOfLines),
debugStringConvertibleItem("ellipsizeMode", ellipsizeMode),
debugStringConvertibleItem("adjustsFontSizeToFit", adjustsFontSizeToFit),
debugStringConvertibleItem("minimumFontSize", minimumFontSize),
debugStringConvertibleItem("maximumFontSize", maximumFontSize)
};
}
} // namespace react