Index: sky/tools/packager/logging.cc |
diff --git a/sky/engine/tonic/dart_error.cc b/sky/tools/packager/logging.cc |
similarity index 58% |
copy from sky/engine/tonic/dart_error.cc |
copy to sky/tools/packager/logging.cc |
index d733c3328a60131644add913abcf50de8fb96190..e61820cb9725165ae14f6576eeca615fc75142e8 100644 |
--- a/sky/engine/tonic/dart_error.cc |
+++ b/sky/tools/packager/logging.cc |
@@ -2,19 +2,10 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "sky/engine/config.h" |
-#include "sky/engine/tonic/dart_error.h" |
+#include "sky/tools/packager/logging.h" |
#include "base/logging.h" |
-namespace blink { |
- |
-namespace DartError { |
- |
-const char kInvalidArgument[] = "Invalid argument."; |
- |
-} // namespace DartError |
- |
bool LogIfError(Dart_Handle handle) { |
if (Dart_IsError(handle)) { |
LOG(ERROR) << Dart_GetError(handle); |
@@ -32,4 +23,15 @@ bool LogIfError(Dart_Handle handle) { |
return false; |
} |
-} // namespace blink |
+std::string StringFromDart(Dart_Handle string) { |
+ CHECK(Dart_IsString(string)); |
+ uint8_t* utf8_array; |
+ intptr_t length; |
+ Dart_StringToUTF8(string, &utf8_array, &length); |
+ return std::string(reinterpret_cast<const char*>(utf8_array), length); |
+} |
+ |
+Dart_Handle StringToDart(const std::string& string) { |
+ return Dart_NewStringFromUTF8(reinterpret_cast<const uint8_t*>(string.data()), |
+ string.length()); |
+} |