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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 void FUNCTION_NAME(Socket_GetRemotePeer)(Dart_NativeArguments args) { | 179 void FUNCTION_NAME(Socket_GetRemotePeer)(Dart_NativeArguments args) { |
180 Dart_EnterScope(); | 180 Dart_EnterScope(); |
181 Dart_Handle socket_obj = Dart_GetNativeArgument(args, 0); | 181 Dart_Handle socket_obj = Dart_GetNativeArgument(args, 0); |
182 intptr_t socket = 0; | 182 intptr_t socket = 0; |
183 Socket::GetSocketIdNativeField(socket_obj, &socket); | 183 Socket::GetSocketIdNativeField(socket_obj, &socket); |
184 OSError os_error; | 184 OSError os_error; |
185 intptr_t port = 0; | 185 intptr_t port = 0; |
186 char host[INET_ADDRSTRLEN]; | 186 char host[INET_ADDRSTRLEN]; |
187 if (Socket::GetRemotePeer(socket, host, &port)) { | 187 if (Socket::GetRemotePeer(socket, host, &port)) { |
188 Dart_Handle list = Dart_NewList(2); | 188 Dart_Handle list = Dart_NewList(2); |
189 Dart_ListSetAt(list, 0, Dart_NewString(host)); | 189 Dart_ListSetAt(list, 0, Dart_NewStringFromCString(host)); |
190 Dart_ListSetAt(list, 1, Dart_NewInteger(port)); | 190 Dart_ListSetAt(list, 1, Dart_NewInteger(port)); |
191 Dart_SetReturnValue(args, list); | 191 Dart_SetReturnValue(args, list); |
192 } else { | 192 } else { |
193 Dart_SetReturnValue(args, DartUtils::NewDartOSError()); | 193 Dart_SetReturnValue(args, DartUtils::NewDartOSError()); |
194 } | 194 } |
195 Dart_ExitScope(); | 195 Dart_ExitScope(); |
196 } | 196 } |
197 | 197 |
198 | 198 |
199 void FUNCTION_NAME(Socket_GetError)(Dart_NativeArguments args) { | 199 void FUNCTION_NAME(Socket_GetError)(Dart_NativeArguments args) { |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 | 356 |
357 | 357 |
358 Dart_Handle Socket::SetSocketIdNativeField(Dart_Handle socket, intptr_t id) { | 358 Dart_Handle Socket::SetSocketIdNativeField(Dart_Handle socket, intptr_t id) { |
359 return Dart_SetNativeInstanceField(socket, kSocketIdNativeField, id); | 359 return Dart_SetNativeInstanceField(socket, kSocketIdNativeField, id); |
360 } | 360 } |
361 | 361 |
362 | 362 |
363 Dart_Handle Socket::GetSocketIdNativeField(Dart_Handle socket, intptr_t* id) { | 363 Dart_Handle Socket::GetSocketIdNativeField(Dart_Handle socket, intptr_t* id) { |
364 return Dart_GetNativeInstanceField(socket, kSocketIdNativeField, id); | 364 return Dart_GetNativeInstanceField(socket, kSocketIdNativeField, id); |
365 } | 365 } |
OLD | NEW |