| 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/socket.h" | 5 #include "bin/socket.h" |
| 6 #include "bin/dartutils.h" | 6 #include "bin/dartutils.h" |
| 7 #include "bin/thread.h" | 7 #include "bin/thread.h" |
| 8 #include "bin/utils.h" | 8 #include "bin/utils.h" |
| 9 | 9 |
| 10 #include "platform/globals.h" | 10 #include "platform/globals.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 } | 32 } |
| 33 Dart_ExitScope(); | 33 Dart_ExitScope(); |
| 34 } | 34 } |
| 35 | 35 |
| 36 | 36 |
| 37 void FUNCTION_NAME(Socket_Available)(Dart_NativeArguments args) { | 37 void FUNCTION_NAME(Socket_Available)(Dart_NativeArguments args) { |
| 38 Dart_EnterScope(); | 38 Dart_EnterScope(); |
| 39 int64_t socket = DartUtils::GetIntegerField(Dart_GetNativeArgument(args, 0), | 39 int64_t socket = DartUtils::GetIntegerField(Dart_GetNativeArgument(args, 0), |
| 40 DartUtils::kIdFieldName); | 40 DartUtils::kIdFieldName); |
| 41 intptr_t available = Socket::Available(socket); | 41 intptr_t available = Socket::Available(socket); |
| 42 Dart_SetReturnValue(args, Dart_NewInteger(available)); | 42 if (available >= 0) { |
| 43 Dart_SetReturnValue(args, Dart_NewInteger(available)); |
| 44 } else { |
| 45 Dart_SetReturnValue(args, DartUtils::NewDartOSError()); |
| 46 } |
| 43 Dart_ExitScope(); | 47 Dart_ExitScope(); |
| 44 } | 48 } |
| 45 | 49 |
| 46 | 50 |
| 47 void FUNCTION_NAME(Socket_ReadList)(Dart_NativeArguments args) { | 51 void FUNCTION_NAME(Socket_ReadList)(Dart_NativeArguments args) { |
| 48 Dart_EnterScope(); | 52 Dart_EnterScope(); |
| 49 intptr_t socket = | 53 intptr_t socket = |
| 50 DartUtils::GetIntegerField(Dart_GetNativeArgument(args, 0), | 54 DartUtils::GetIntegerField(Dart_GetNativeArgument(args, 0), |
| 51 DartUtils::kIdFieldName); | 55 DartUtils::kIdFieldName); |
| 52 Dart_Handle buffer_obj = Dart_GetNativeArgument(args, 1); | 56 Dart_Handle buffer_obj = Dart_GetNativeArgument(args, 1); |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 Dart_EnterScope(); | 317 Dart_EnterScope(); |
| 314 Dart_SetReturnValue(args, Dart_Null()); | 318 Dart_SetReturnValue(args, Dart_Null()); |
| 315 Dart_Port service_port = Socket::GetServicePort(); | 319 Dart_Port service_port = Socket::GetServicePort(); |
| 316 if (service_port != kIllegalPort) { | 320 if (service_port != kIllegalPort) { |
| 317 // Return a send port for the service port. | 321 // Return a send port for the service port. |
| 318 Dart_Handle send_port = Dart_NewSendPort(service_port); | 322 Dart_Handle send_port = Dart_NewSendPort(service_port); |
| 319 Dart_SetReturnValue(args, send_port); | 323 Dart_SetReturnValue(args, send_port); |
| 320 } | 324 } |
| 321 Dart_ExitScope(); | 325 Dart_ExitScope(); |
| 322 } | 326 } |
| OLD | NEW |