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

Side by Side Diff: runtime/bin/dbg_message.cc

Issue 11318018: - Represent strings internally in UTF-16 format, this makes it (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/thread.h" 8 #include "bin/thread.h"
9 #include "bin/utils.h" 9 #include "bin/utils.h"
10 10
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 pr.GetValueChars(param_chars, buflen); 102 pr.GetValueChars(param_chars, buflen);
103 // TODO(hausner): Decode escape sequences. 103 // TODO(hausner): Decode escape sequences.
104 return param_chars; 104 return param_chars;
105 } 105 }
106 106
107 107
108 static void FormatEncodedString(dart::TextBuffer* buf, Dart_Handle str) { 108 static void FormatEncodedString(dart::TextBuffer* buf, Dart_Handle str) {
109 intptr_t str_len = 0; 109 intptr_t str_len = 0;
110 Dart_Handle res = Dart_StringLength(str, &str_len); 110 Dart_Handle res = Dart_StringLength(str, &str_len);
111 ASSERT_NOT_ERROR(res); 111 ASSERT_NOT_ERROR(res);
112 uint32_t* codepoints = 112 uint16_t* codepoints =
113 reinterpret_cast<uint32_t*>(malloc(str_len * sizeof(uint32_t))); 113 reinterpret_cast<uint16_t*>(malloc(str_len * sizeof(uint16_t)));
114 ASSERT(codepoints != NULL); 114 ASSERT(codepoints != NULL);
115 intptr_t actual_len = str_len; 115 intptr_t actual_len = str_len;
116 res = Dart_StringGet32(str, codepoints, &actual_len); 116 res = Dart_StringToUTF16(str, codepoints, &actual_len);
117 ASSERT_NOT_ERROR(res); 117 ASSERT_NOT_ERROR(res);
118 ASSERT(str_len == actual_len); 118 ASSERT(str_len == actual_len);
119 buf->AddChar('\"'); 119 buf->AddChar('\"');
120 for (int i = 0; i < str_len; i++) { 120 for (int i = 0; i < str_len; i++) {
121 buf->AddEscapedChar(codepoints[i]); 121 buf->AddEscapedChar(codepoints[i]);
122 } 122 }
123 buf->AddChar('\"'); 123 buf->AddChar('\"');
124 free(codepoints); 124 free(codepoints);
125 } 125 }
126 126
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 685
686 686
687 bool DbgMessage::HandleGetSourceCmd(DbgMessage* in_msg) { 687 bool DbgMessage::HandleGetSourceCmd(DbgMessage* in_msg) {
688 ASSERT(in_msg != NULL); 688 ASSERT(in_msg != NULL);
689 MessageParser msg_parser(in_msg->buffer(), in_msg->buffer_len()); 689 MessageParser msg_parser(in_msg->buffer(), in_msg->buffer_len());
690 int msg_id = msg_parser.MessageId(); 690 int msg_id = msg_parser.MessageId();
691 dart::TextBuffer msg(64); 691 dart::TextBuffer msg(64);
692 intptr_t lib_id = msg_parser.GetIntParam("libraryId"); 692 intptr_t lib_id = msg_parser.GetIntParam("libraryId");
693 char* url_chars = msg_parser.GetStringParam("url"); 693 char* url_chars = msg_parser.GetStringParam("url");
694 ASSERT(url_chars != NULL); 694 ASSERT(url_chars != NULL);
695 Dart_Handle url = Dart_NewString(url_chars); 695 Dart_Handle url = DartUtils::NewString(url_chars);
696 ASSERT_NOT_ERROR(url); 696 ASSERT_NOT_ERROR(url);
697 free(url_chars); 697 free(url_chars);
698 url_chars = NULL; 698 url_chars = NULL;
699 Dart_Handle source = Dart_ScriptGetSource(lib_id, url); 699 Dart_Handle source = Dart_ScriptGetSource(lib_id, url);
700 if (Dart_IsError(source)) { 700 if (Dart_IsError(source)) {
701 in_msg->SendErrorReply(msg_id, Dart_GetError(source)); 701 in_msg->SendErrorReply(msg_id, Dart_GetError(source));
702 return false; 702 return false;
703 } 703 }
704 msg.Printf("{ \"id\": %d, ", msg_id); 704 msg.Printf("{ \"id\": %d, ", msg_id);
705 msg.Printf("\"result\": { \"text\": "); 705 msg.Printf("\"result\": { \"text\": ");
(...skipping 19 matching lines...) Expand all
725 return false; 725 return false;
726 } 726 }
727 727
728 728
729 bool DbgMessage::HandleSetBpCmd(DbgMessage* in_msg) { 729 bool DbgMessage::HandleSetBpCmd(DbgMessage* in_msg) {
730 ASSERT(in_msg != NULL); 730 ASSERT(in_msg != NULL);
731 MessageParser msg_parser(in_msg->buffer(), in_msg->buffer_len()); 731 MessageParser msg_parser(in_msg->buffer(), in_msg->buffer_len());
732 int msg_id = msg_parser.MessageId(); 732 int msg_id = msg_parser.MessageId();
733 char* url_chars = msg_parser.GetStringParam("url"); 733 char* url_chars = msg_parser.GetStringParam("url");
734 ASSERT(url_chars != NULL); 734 ASSERT(url_chars != NULL);
735 Dart_Handle url = Dart_NewString(url_chars); 735 Dart_Handle url = DartUtils::NewString(url_chars);
736 ASSERT_NOT_ERROR(url); 736 ASSERT_NOT_ERROR(url);
737 free(url_chars); 737 free(url_chars);
738 url_chars = NULL; 738 url_chars = NULL;
739 intptr_t line_number = msg_parser.GetIntParam("line"); 739 intptr_t line_number = msg_parser.GetIntParam("line");
740 Dart_Handle bp_id = Dart_SetBreakpoint(url, line_number); 740 Dart_Handle bp_id = Dart_SetBreakpoint(url, line_number);
741 if (Dart_IsError(bp_id)) { 741 if (Dart_IsError(bp_id)) {
742 in_msg->SendErrorReply(msg_id, Dart_GetError(bp_id)); 742 in_msg->SendErrorReply(msg_id, Dart_GetError(bp_id));
743 return false; 743 return false;
744 } 744 }
745 ASSERT(Dart_IsInteger(bp_id)); 745 ASSERT(Dart_IsInteger(bp_id));
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
1092 msg_queue->SendIsolateEvent(isolate_id, kind); 1092 msg_queue->SendIsolateEvent(isolate_id, kind);
1093 if (kind == kInterrupted) { 1093 if (kind == kInterrupted) {
1094 msg_queue->HandleMessages(); 1094 msg_queue->HandleMessages();
1095 } else { 1095 } else {
1096 ASSERT(kind == kShutdown); 1096 ASSERT(kind == kShutdown);
1097 RemoveIsolateMsgQueue(isolate_id); 1097 RemoveIsolateMsgQueue(isolate_id);
1098 } 1098 }
1099 } 1099 }
1100 Dart_ExitScope(); 1100 Dart_ExitScope();
1101 } 1101 }
OLDNEW
« no previous file with comments | « runtime/bin/dartutils.cc ('k') | runtime/bin/directory.cc » ('j') | runtime/vm/dart_api_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698