Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Unified Diff: runtime/bin/builtin_natives.cc

Issue 10306002: Do not externalize Dart strings as C strings for "print()". (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address review comments Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/include/dart_api.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/builtin_natives.cc
diff --git a/runtime/bin/builtin_natives.cc b/runtime/bin/builtin_natives.cc
index 4cfed77da297c7a92999e7dfcd0a5ca9c789e67b..214bd28db1c0de5430f0cc57d3c215b24a517675 100644
--- a/runtime/bin/builtin_natives.cc
+++ b/runtime/bin/builtin_natives.cc
@@ -104,16 +104,19 @@ Dart_NativeFunction Builtin::NativeLookup(Dart_Handle name,
// test/debug functionality in standalone dart mode.
void Builtin::PrintString(FILE* out, Dart_Handle str) {
- const char* cstring = NULL;
- Dart_Handle result = Dart_StringToCString(str, &cstring);
+ const uint8_t* characters = NULL;
+ intptr_t length;
+ Dart_Handle result = Dart_StringToBytes(str, &characters, &length);
if (Dart_IsError(result)) {
// TODO(turnidge): Consider propagating some errors here. What if
// an isolate gets interrupted by the embedder in the middle of
- // Dart_StringToCString? We need to make sure not to swallow the
+ // Dart_StringToBytes? We need to make sure not to swallow the
// interrupt.
- cstring = Dart_GetError(result);
+ fputs(Dart_GetError(result));
+ } else {
+ fwrite(characters, sizeof(*characters), length, out);
}
- fprintf(out, "%s\n", cstring);
+ fputc('\n', out);
fflush(out);
}
« no previous file with comments | « no previous file | runtime/include/dart_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698