| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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/io_buffer.h" | 5 #include "bin/io_buffer.h" |
| 6 #include "bin/socket.h" | 6 #include "bin/socket.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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 | 179 |
| 180 void FUNCTION_NAME(Socket_WriteList)(Dart_NativeArguments args) { | 180 void FUNCTION_NAME(Socket_WriteList)(Dart_NativeArguments args) { |
| 181 static bool short_socket_writes = Dart_IsVMFlagSet("short_socket_write"); | 181 static bool short_socket_writes = Dart_IsVMFlagSet("short_socket_write"); |
| 182 Dart_Handle socket_obj = Dart_GetNativeArgument(args, 0); | 182 Dart_Handle socket_obj = Dart_GetNativeArgument(args, 0); |
| 183 intptr_t socket = 0; | 183 intptr_t socket = 0; |
| 184 Dart_Handle err = Socket::GetSocketIdNativeField(socket_obj, &socket); | 184 Dart_Handle err = Socket::GetSocketIdNativeField(socket_obj, &socket); |
| 185 if (Dart_IsError(err)) Dart_PropagateError(err); | 185 if (Dart_IsError(err)) Dart_PropagateError(err); |
| 186 Dart_Handle buffer_obj = Dart_GetNativeArgument(args, 1); | 186 Dart_Handle buffer_obj = Dart_GetNativeArgument(args, 1); |
| 187 ASSERT(Dart_IsList(buffer_obj)); | 187 ASSERT(Dart_IsList(buffer_obj)); |
| 188 intptr_t offset = | 188 intptr_t offset = |
| 189 DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 2)); | 189 DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 2)); |
| 190 intptr_t length = | 190 intptr_t length = |
| 191 DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 3)); | 191 DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 3)); |
| 192 if (short_socket_writes) { | 192 if (short_socket_writes) { |
| 193 length = (length + 1) / 2; | 193 length = (length + 1) / 2; |
| 194 } | 194 } |
| 195 Dart_TypedData_Type type; | 195 Dart_TypedData_Type type; |
| 196 uint8_t* buffer = NULL; | 196 uint8_t* buffer = NULL; |
| 197 intptr_t len; | 197 intptr_t len; |
| 198 Dart_Handle result = Dart_TypedDataAcquireData( | 198 Dart_Handle result = Dart_TypedDataAcquireData( |
| 199 buffer_obj, &type, reinterpret_cast<void**>(&buffer), &len); | 199 buffer_obj, &type, reinterpret_cast<void**>(&buffer), &len); |
| 200 if (Dart_IsError(result)) Dart_PropagateError(result); | 200 if (Dart_IsError(result)) Dart_PropagateError(result); |
| 201 ASSERT((offset + length) <= len); | 201 ASSERT((offset + length) <= len); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 Dart_SetReturnValue(args, Dart_NewInteger(type)); | 269 Dart_SetReturnValue(args, Dart_NewInteger(type)); |
| 270 } else { | 270 } else { |
| 271 Dart_SetReturnValue(args, DartUtils::NewDartOSError()); | 271 Dart_SetReturnValue(args, DartUtils::NewDartOSError()); |
| 272 } | 272 } |
| 273 } | 273 } |
| 274 | 274 |
| 275 | 275 |
| 276 void FUNCTION_NAME(Socket_GetStdioHandle)(Dart_NativeArguments args) { | 276 void FUNCTION_NAME(Socket_GetStdioHandle)(Dart_NativeArguments args) { |
| 277 Dart_Handle socket_obj = Dart_GetNativeArgument(args, 0); | 277 Dart_Handle socket_obj = Dart_GetNativeArgument(args, 0); |
| 278 intptr_t num = | 278 intptr_t num = |
| 279 DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 1)); | 279 DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 1)); |
| 280 ASSERT(num == 0 || num == 1 || num == 2); | 280 ASSERT(num == 0 || num == 1 || num == 2); |
| 281 intptr_t socket = Socket::GetStdioHandle(num); | 281 intptr_t socket = Socket::GetStdioHandle(num); |
| 282 Dart_Handle err = Socket::SetSocketIdNativeField(socket_obj, socket); | 282 Dart_Handle err = Socket::SetSocketIdNativeField(socket_obj, socket); |
| 283 if (Dart_IsError(err)) Dart_PropagateError(err); | 283 if (Dart_IsError(err)) Dart_PropagateError(err); |
| 284 Dart_SetReturnValue(args, Dart_NewBoolean(socket >= 0)); | 284 Dart_SetReturnValue(args, Dart_NewBoolean(socket >= 0)); |
| 285 } | 285 } |
| 286 | 286 |
| 287 | 287 |
| 288 void FUNCTION_NAME(ServerSocket_CreateBindListen)(Dart_NativeArguments args) { | 288 void FUNCTION_NAME(ServerSocket_CreateBindListen)(Dart_NativeArguments args) { |
| 289 Dart_Handle socket_obj = Dart_GetNativeArgument(args, 0); | 289 Dart_Handle socket_obj = Dart_GetNativeArgument(args, 0); |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 return Dart_SetNativeInstanceField(socket, kSocketIdNativeField, id); | 560 return Dart_SetNativeInstanceField(socket, kSocketIdNativeField, id); |
| 561 } | 561 } |
| 562 | 562 |
| 563 | 563 |
| 564 Dart_Handle Socket::GetSocketIdNativeField(Dart_Handle socket, intptr_t* id) { | 564 Dart_Handle Socket::GetSocketIdNativeField(Dart_Handle socket, intptr_t* id) { |
| 565 return Dart_GetNativeInstanceField(socket, kSocketIdNativeField, id); | 565 return Dart_GetNativeInstanceField(socket, kSocketIdNativeField, id); |
| 566 } | 566 } |
| 567 | 567 |
| 568 } // namespace bin | 568 } // namespace bin |
| 569 } // namespace dart | 569 } // namespace dart |
| OLD | NEW |