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

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

Issue 8372094: Renaming Array -> List in the VM API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix test 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 21 matching lines...) Expand all
32 Dart_ExitScope(); 32 Dart_ExitScope();
33 } 33 }
34 34
35 35
36 void FUNCTION_NAME(Socket_ReadList)(Dart_NativeArguments args) { 36 void FUNCTION_NAME(Socket_ReadList)(Dart_NativeArguments args) {
37 Dart_EnterScope(); 37 Dart_EnterScope();
38 intptr_t socket = 38 intptr_t socket =
39 DartUtils::GetIntegerInstanceField(Dart_GetNativeArgument(args, 0), 39 DartUtils::GetIntegerInstanceField(Dart_GetNativeArgument(args, 0),
40 DartUtils::kIdFieldName); 40 DartUtils::kIdFieldName);
41 Dart_Handle buffer_obj = Dart_GetNativeArgument(args, 1); 41 Dart_Handle buffer_obj = Dart_GetNativeArgument(args, 1);
42 ASSERT(Dart_IsArray(buffer_obj)); 42 ASSERT(Dart_IsList(buffer_obj));
43 intptr_t offset = 43 intptr_t offset =
44 DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 2)); 44 DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 2));
45 intptr_t length = 45 intptr_t length =
46 DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 3)); 46 DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 3));
47 intptr_t buffer_len = 0; 47 intptr_t buffer_len = 0;
48 Dart_Handle result = Dart_GetLength(buffer_obj, &buffer_len); 48 Dart_Handle result = Dart_ListLength(buffer_obj, &buffer_len);
49 ASSERT(Dart_IsValid(result)); 49 ASSERT(Dart_IsValid(result));
50 ASSERT((offset + length) <= buffer_len); 50 ASSERT((offset + length) <= buffer_len);
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 = Dart_ArraySet(buffer_obj, offset, buffer, bytes_read); 59 Dart_Handle result = Dart_ListSet(buffer_obj, offset, buffer, bytes_read);
60 ASSERT(Dart_IsValid(result)); 60 ASSERT(Dart_IsValid(result));
61 } else if (bytes_read < 0) { 61 } else if (bytes_read < 0) {
62 bytes_read = 0; 62 bytes_read = 0;
63 } 63 }
64 delete[] buffer; 64 delete[] buffer;
65 Dart_SetReturnValue(args, Dart_NewInteger(bytes_read)); 65 Dart_SetReturnValue(args, Dart_NewInteger(bytes_read));
66 Dart_ExitScope(); 66 Dart_ExitScope();
67 } 67 }
68 68
69 69
70 void FUNCTION_NAME(Socket_WriteList)(Dart_NativeArguments args) { 70 void FUNCTION_NAME(Socket_WriteList)(Dart_NativeArguments args) {
71 Dart_EnterScope(); 71 Dart_EnterScope();
72 intptr_t socket = 72 intptr_t socket =
73 DartUtils::GetIntegerInstanceField(Dart_GetNativeArgument(args, 0), 73 DartUtils::GetIntegerInstanceField(Dart_GetNativeArgument(args, 0),
74 DartUtils::kIdFieldName); 74 DartUtils::kIdFieldName);
75 Dart_Handle buffer_obj = Dart_GetNativeArgument(args, 1); 75 Dart_Handle buffer_obj = Dart_GetNativeArgument(args, 1);
76 ASSERT(Dart_IsArray(buffer_obj)); 76 ASSERT(Dart_IsList(buffer_obj));
77 intptr_t offset = 77 intptr_t offset =
78 DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 2)); 78 DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 2));
79 intptr_t length = 79 intptr_t length =
80 DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 3)); 80 DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 3));
81 intptr_t buffer_len = 0; 81 intptr_t buffer_len = 0;
82 Dart_Handle result = Dart_GetLength(buffer_obj, &buffer_len); 82 Dart_Handle result = Dart_ListLength(buffer_obj, &buffer_len);
83 ASSERT(Dart_IsValid(result)); 83 ASSERT(Dart_IsValid(result));
84 ASSERT((offset + length) <= buffer_len); 84 ASSERT((offset + length) <= buffer_len);
85 85
86 if (Dart_IsVMFlagSet("short_socket_write")) { 86 if (Dart_IsVMFlagSet("short_socket_write")) {
87 length = (length + 1) / 2; 87 length = (length + 1) / 2;
88 } 88 }
89 89
90 uint8_t* buffer = new uint8_t[length]; 90 uint8_t* buffer = new uint8_t[length];
91 result = Dart_ArrayGet(buffer_obj, offset, buffer, length); 91 result = Dart_ListGet(buffer_obj, offset, buffer, length);
92 ASSERT(Dart_IsValid(result)); 92 ASSERT(Dart_IsValid(result));
93 intptr_t total_bytes_written = 93 intptr_t total_bytes_written =
94 Socket::Write(socket, reinterpret_cast<void*>(buffer), length); 94 Socket::Write(socket, reinterpret_cast<void*>(buffer), length);
95 delete[] buffer; 95 delete[] buffer;
96 if (total_bytes_written < 0) { 96 if (total_bytes_written < 0) {
97 total_bytes_written = 0; 97 total_bytes_written = 0;
98 } 98 }
99 Dart_SetReturnValue(args, Dart_NewInteger(total_bytes_written)); 99 Dart_SetReturnValue(args, Dart_NewInteger(total_bytes_written));
100 Dart_ExitScope(); 100 Dart_ExitScope();
101 } 101 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 DartUtils::kIdFieldName); 136 DartUtils::kIdFieldName);
137 Dart_Handle socketobj = Dart_GetNativeArgument(args, 1); 137 Dart_Handle socketobj = Dart_GetNativeArgument(args, 1);
138 intptr_t newSocket = ServerSocket::Accept(socket); 138 intptr_t newSocket = ServerSocket::Accept(socket);
139 if (newSocket >= 0) { 139 if (newSocket >= 0) {
140 DartUtils::SetIntegerInstanceField( 140 DartUtils::SetIntegerInstanceField(
141 socketobj, DartUtils::kIdFieldName, newSocket); 141 socketobj, DartUtils::kIdFieldName, newSocket);
142 } 142 }
143 Dart_SetReturnValue(args, Dart_NewBoolean(newSocket >= 0)); 143 Dart_SetReturnValue(args, Dart_NewBoolean(newSocket >= 0));
144 Dart_ExitScope(); 144 Dart_ExitScope();
145 } 145 }
OLDNEW
« no previous file with comments | « runtime/bin/process.cc ('k') | runtime/include/dart_api.h » ('j') | runtime/include/dart_api.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698