diff --git a/ReactCommon/fabric/debug/DebugStringConvertible.cpp b/ReactCommon/fabric/debug/DebugStringConvertible.cpp index eab3557a072..59ce2e6c02f 100644 --- a/ReactCommon/fabric/debug/DebugStringConvertible.cpp +++ b/ReactCommon/fabric/debug/DebugStringConvertible.cpp @@ -7,6 +7,9 @@ #include "DebugStringConvertible.h" +#include +#include + namespace facebook { namespace react { @@ -107,6 +110,28 @@ SharedDebugStringConvertibleList DebugStringConvertible::getDebugProps() const { return SharedDebugStringConvertibleList(); } +/* + * `toString`-family implementation. + */ +std::string toString(std::string const &value) { + return value; +} +std::string toString(int const &value) { + return folly::to(value); +} +std::string toString(bool const &value) { + return folly::to(value); +} +std::string toString(float const &value) { + return folly::to(value); +} +std::string toString(double const &value) { + return folly::to(value); +} +std::string toString(void const *value) { + return folly::sformat("0x{0:016x}", reinterpret_cast(value)); +} + #endif } // namespace react diff --git a/ReactCommon/fabric/debug/DebugStringConvertible.h b/ReactCommon/fabric/debug/DebugStringConvertible.h index e03ec6f60f0..f1892605791 100644 --- a/ReactCommon/fabric/debug/DebugStringConvertible.h +++ b/ReactCommon/fabric/debug/DebugStringConvertible.h @@ -80,5 +80,19 @@ class DebugStringConvertible {}; #endif +#if RN_DEBUG_STRING_CONVERTIBLE + +/* + * Set of particular-format-opinionated functions that convert base types to `std::string`; practically incapsulate `folly:to<>` and `folly::format`. + */ +std::string toString(std::string const &value); +std::string toString(int const &value); +std::string toString(bool const &value); +std::string toString(float const &value); +std::string toString(double const &value); +std::string toString(void const *value); + +#endif + } // namespace react } // namespace facebook diff --git a/ReactCommon/fabric/debug/debugStringConvertibleUtils.h b/ReactCommon/fabric/debug/debugStringConvertibleUtils.h index 51bf698b4be..cf5fb18cb01 100644 --- a/ReactCommon/fabric/debug/debugStringConvertibleUtils.h +++ b/ReactCommon/fabric/debug/debugStringConvertibleUtils.h @@ -12,8 +12,6 @@ #include #include -#include -#include #include #include @@ -22,22 +20,6 @@ namespace react { #if RN_DEBUG_STRING_CONVERTIBLE -inline std::string toString(const std::string &value) { - return value; -} -inline std::string toString(const int &value) { - return folly::to(value); -} -inline std::string toString(const bool &value) { - return folly::to(value); -} -inline std::string toString(const float &value) { - return folly::to(value); -} -inline std::string toString(const double &value) { - return folly::to(value); -} - template inline SharedDebugStringConvertible debugStringConvertibleItem(std::string name, T value, T defaultValue = {}) {