| OLD | NEW |
| 1 // Copyright (c) 2012, 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 |
| 11 #include "platform/globals.h" | 11 #include "platform/globals.h" |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 Dart_Handle socket_obj = Dart_GetNativeArgument(args, 0); | 260 Dart_Handle socket_obj = Dart_GetNativeArgument(args, 0); |
| 261 intptr_t socket = 0; | 261 intptr_t socket = 0; |
| 262 Socket::GetSocketIdNativeField(socket_obj, &socket); | 262 Socket::GetSocketIdNativeField(socket_obj, &socket); |
| 263 OSError os_error; | 263 OSError os_error; |
| 264 Socket::GetError(socket, &os_error); | 264 Socket::GetError(socket, &os_error); |
| 265 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&os_error)); | 265 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&os_error)); |
| 266 Dart_ExitScope(); | 266 Dart_ExitScope(); |
| 267 } | 267 } |
| 268 | 268 |
| 269 | 269 |
| 270 void FUNCTION_NAME(Socket_GetType)(Dart_NativeArguments args) { |
| 271 Dart_EnterScope(); |
| 272 Dart_Handle socket_obj = Dart_GetNativeArgument(args, 0); |
| 273 intptr_t socket = 0; |
| 274 Socket::GetSocketIdNativeField(socket_obj, &socket); |
| 275 OSError os_error; |
| 276 intptr_t type = Socket::GetType(socket); |
| 277 if (type >= 0) { |
| 278 Dart_SetReturnValue(args, Dart_NewInteger(type)); |
| 279 } else { |
| 280 Dart_SetReturnValue(args, DartUtils::NewDartOSError()); |
| 281 } |
| 282 Dart_ExitScope(); |
| 283 } |
| 284 |
| 285 |
| 270 void FUNCTION_NAME(Socket_GetStdioHandle)(Dart_NativeArguments args) { | 286 void FUNCTION_NAME(Socket_GetStdioHandle)(Dart_NativeArguments args) { |
| 271 Dart_EnterScope(); | 287 Dart_EnterScope(); |
| 272 Dart_Handle socket_obj = Dart_GetNativeArgument(args, 0); | 288 Dart_Handle socket_obj = Dart_GetNativeArgument(args, 0); |
| 273 intptr_t num = | 289 intptr_t num = |
| 274 DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 1)); | 290 DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 1)); |
| 275 ASSERT(num == 0 || num == 1 || num == 2); | 291 ASSERT(num == 0 || num == 1 || num == 2); |
| 276 intptr_t socket = Socket::GetStdioHandle(num); | 292 intptr_t socket = Socket::GetStdioHandle(num); |
| 277 Socket::SetSocketIdNativeField(socket_obj, socket); | 293 Socket::SetSocketIdNativeField(socket_obj, socket); |
| 278 Dart_SetReturnValue(args, Dart_NewBoolean(socket >= 0)); | 294 Dart_SetReturnValue(args, Dart_NewBoolean(socket >= 0)); |
| 279 Dart_ExitScope(); | 295 Dart_ExitScope(); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 | 431 |
| 416 | 432 |
| 417 Dart_Handle Socket::SetSocketIdNativeField(Dart_Handle socket, intptr_t id) { | 433 Dart_Handle Socket::SetSocketIdNativeField(Dart_Handle socket, intptr_t id) { |
| 418 return Dart_SetNativeInstanceField(socket, kSocketIdNativeField, id); | 434 return Dart_SetNativeInstanceField(socket, kSocketIdNativeField, id); |
| 419 } | 435 } |
| 420 | 436 |
| 421 | 437 |
| 422 Dart_Handle Socket::GetSocketIdNativeField(Dart_Handle socket, intptr_t* id) { | 438 Dart_Handle Socket::GetSocketIdNativeField(Dart_Handle socket, intptr_t* id) { |
| 423 return Dart_GetNativeInstanceField(socket, kSocketIdNativeField, id); | 439 return Dart_GetNativeInstanceField(socket, kSocketIdNativeField, id); |
| 424 } | 440 } |
| OLD | NEW |