| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "bin/dbg_connection.h" | 5 #include "bin/dbg_connection.h" |
| 6 #include "bin/dbg_message.h" | 6 #include "bin/dbg_message.h" |
| 7 #include "bin/dartutils.h" | 7 #include "bin/dartutils.h" |
| 8 #include "bin/lockers.h" | 8 #include "bin/lockers.h" |
| 9 #include "bin/thread.h" | 9 #include "bin/thread.h" |
| 10 #include "bin/utils.h" | 10 #include "bin/utils.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 } | 125 } |
| 126 | 126 |
| 127 | 127 |
| 128 static void FormatEncodedCharsTrunc(dart::TextBuffer* buf, | 128 static void FormatEncodedCharsTrunc(dart::TextBuffer* buf, |
| 129 Dart_Handle str, | 129 Dart_Handle str, |
| 130 intptr_t max_chars) { | 130 intptr_t max_chars) { |
| 131 intptr_t str_len = 0; | 131 intptr_t str_len = 0; |
| 132 Dart_Handle res = Dart_StringLength(str, &str_len); | 132 Dart_Handle res = Dart_StringLength(str, &str_len); |
| 133 ASSERT_NOT_ERROR(res); | 133 ASSERT_NOT_ERROR(res); |
| 134 intptr_t num_chars = (str_len > max_chars) ? max_chars : str_len; | 134 intptr_t num_chars = (str_len > max_chars) ? max_chars : str_len; |
| 135 uint16_t* codepoints = | 135 uint16_t* codeunits = |
| 136 reinterpret_cast<uint16_t*>(malloc(num_chars * sizeof(uint16_t))); | 136 reinterpret_cast<uint16_t*>(malloc(num_chars * sizeof(uint16_t))); |
| 137 ASSERT(codepoints != NULL); | 137 ASSERT(codeunits != NULL); |
| 138 intptr_t actual_len = num_chars; | 138 intptr_t actual_len = num_chars; |
| 139 res = Dart_StringToUTF16(str, codepoints, &actual_len); | 139 res = Dart_StringToUTF16(str, codeunits, &actual_len); |
| 140 ASSERT_NOT_ERROR(res); | 140 ASSERT_NOT_ERROR(res); |
| 141 ASSERT(num_chars == actual_len); | 141 ASSERT(num_chars == actual_len); |
| 142 for (int i = 0; i < num_chars; i++) { | 142 for (int i = 0; i < num_chars; i++) { |
| 143 buf->AddEscapedChar(codepoints[i]); | 143 buf->EscapeAndAddCodeUnit(codeunits[i]); |
| 144 } | 144 } |
| 145 if (str_len > max_chars) { | 145 if (str_len > max_chars) { |
| 146 buf->Printf("..."); | 146 buf->Printf("..."); |
| 147 } | 147 } |
| 148 free(codepoints); | 148 free(codeunits); |
| 149 } | 149 } |
| 150 | 150 |
| 151 | 151 |
| 152 static void FormatEncodedChars(dart::TextBuffer* buf, Dart_Handle str) { | 152 static void FormatEncodedChars(dart::TextBuffer* buf, Dart_Handle str) { |
| 153 intptr_t str_len = 0; | 153 intptr_t str_len = 0; |
| 154 Dart_Handle res = Dart_StringLength(str, &str_len); | 154 Dart_Handle res = Dart_StringLength(str, &str_len); |
| 155 ASSERT_NOT_ERROR(res); | 155 ASSERT_NOT_ERROR(res); |
| 156 uint16_t* codepoints = | 156 uint16_t* codeunits = |
| 157 reinterpret_cast<uint16_t*>(malloc(str_len * sizeof(uint16_t))); | 157 reinterpret_cast<uint16_t*>(malloc(str_len * sizeof(uint16_t))); |
| 158 ASSERT(codepoints != NULL); | 158 ASSERT(codeunits != NULL); |
| 159 intptr_t actual_len = str_len; | 159 intptr_t actual_len = str_len; |
| 160 res = Dart_StringToUTF16(str, codepoints, &actual_len); | 160 res = Dart_StringToUTF16(str, codeunits, &actual_len); |
| 161 ASSERT_NOT_ERROR(res); | 161 ASSERT_NOT_ERROR(res); |
| 162 ASSERT(str_len == actual_len); | 162 ASSERT(str_len == actual_len); |
| 163 for (int i = 0; i < str_len; i++) { | 163 for (int i = 0; i < str_len; i++) { |
| 164 buf->AddEscapedChar(codepoints[i]); | 164 buf->EscapeAndAddCodeUnit(codeunits[i]); |
| 165 } | 165 } |
| 166 free(codepoints); | 166 free(codeunits); |
| 167 } | 167 } |
| 168 | 168 |
| 169 | 169 |
| 170 static void FormatEncodedString(dart::TextBuffer* buf, Dart_Handle str) { | 170 static void FormatEncodedString(dart::TextBuffer* buf, Dart_Handle str) { |
| 171 buf->AddChar('\"'); | 171 buf->AddChar('\"'); |
| 172 FormatEncodedChars(buf, str); | 172 FormatEncodedChars(buf, str); |
| 173 buf->AddChar('\"'); | 173 buf->AddChar('\"'); |
| 174 } | 174 } |
| 175 | 175 |
| 176 | 176 |
| (...skipping 1234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1411 } else { | 1411 } else { |
| 1412 ASSERT(kind == kShutdown); | 1412 ASSERT(kind == kShutdown); |
| 1413 RemoveIsolateMsgQueue(isolate_id); | 1413 RemoveIsolateMsgQueue(isolate_id); |
| 1414 } | 1414 } |
| 1415 } | 1415 } |
| 1416 Dart_ExitScope(); | 1416 Dart_ExitScope(); |
| 1417 } | 1417 } |
| 1418 | 1418 |
| 1419 } // namespace bin | 1419 } // namespace bin |
| 1420 } // namespace dart | 1420 } // namespace dart |
| OLD | NEW |