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

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

Issue 8575004: Test for immutable Lists in ListSet API methods. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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/socket.h" 5 #include "bin/socket.h"
6 #include "bin/dartutils.h" 6 #include "bin/dartutils.h"
7 7
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 9
10 10
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 51
52 if (Dart_IsVMFlagSet("short_socket_read")) { 52 if (Dart_IsVMFlagSet("short_socket_read")) {
53 length = (length + 1) / 2; 53 length = (length + 1) / 2;
54 } 54 }
55 55
56 uint8_t* buffer = new uint8_t[length]; 56 uint8_t* buffer = new uint8_t[length];
57 intptr_t bytes_read = Socket::Read(socket, buffer, length); 57 intptr_t bytes_read = Socket::Read(socket, buffer, length);
58 if (bytes_read > 0) { 58 if (bytes_read > 0) {
59 Dart_Handle result = 59 Dart_Handle result =
60 Dart_ListSetAsBytes(buffer_obj, offset, buffer, bytes_read); 60 Dart_ListSetAsBytes(buffer_obj, offset, buffer, bytes_read);
61 ASSERT(!Dart_IsError(result)); 61 if (Dart_IsError(result)) {
turnidge 2011/11/16 18:50:18 Diito previous comment.
62 bytes_read = -1;
63 }
62 } else if (bytes_read < 0) { 64 } else if (bytes_read < 0) {
63 bytes_read = 0; 65 bytes_read = 0;
64 } 66 }
65 delete[] buffer; 67 delete[] buffer;
66 Dart_SetReturnValue(args, Dart_NewInteger(bytes_read)); 68 Dart_SetReturnValue(args, Dart_NewInteger(bytes_read));
67 Dart_ExitScope(); 69 Dart_ExitScope();
68 } 70 }
69 71
70 72
71 void FUNCTION_NAME(Socket_WriteList)(Dart_NativeArguments args) { 73 void FUNCTION_NAME(Socket_WriteList)(Dart_NativeArguments args) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 DartUtils::kIdFieldName); 153 DartUtils::kIdFieldName);
152 Dart_Handle socketobj = Dart_GetNativeArgument(args, 1); 154 Dart_Handle socketobj = Dart_GetNativeArgument(args, 1);
153 intptr_t newSocket = ServerSocket::Accept(socket); 155 intptr_t newSocket = ServerSocket::Accept(socket);
154 if (newSocket >= 0) { 156 if (newSocket >= 0) {
155 DartUtils::SetIntegerInstanceField( 157 DartUtils::SetIntegerInstanceField(
156 socketobj, DartUtils::kIdFieldName, newSocket); 158 socketobj, DartUtils::kIdFieldName, newSocket);
157 } 159 }
158 Dart_SetReturnValue(args, Dart_NewBoolean(newSocket >= 0)); 160 Dart_SetReturnValue(args, Dart_NewBoolean(newSocket >= 0));
159 Dart_ExitScope(); 161 Dart_ExitScope();
160 } 162 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698