| 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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 OSError* os_error = NULL; | 420 OSError* os_error = NULL; |
| 421 AddressList<InterfaceSocketAddress>* addresses = Socket::ListInterfaces( | 421 AddressList<InterfaceSocketAddress>* addresses = Socket::ListInterfaces( |
| 422 type.Value(), &os_error); | 422 type.Value(), &os_error); |
| 423 if (addresses != NULL) { | 423 if (addresses != NULL) { |
| 424 CObjectArray* array = new CObjectArray( | 424 CObjectArray* array = new CObjectArray( |
| 425 CObject::NewArray(addresses->count() + 1)); | 425 CObject::NewArray(addresses->count() + 1)); |
| 426 array->SetAt(0, new CObjectInt32(CObject::NewInt32(0))); | 426 array->SetAt(0, new CObjectInt32(CObject::NewInt32(0))); |
| 427 for (intptr_t i = 0; i < addresses->count(); i++) { | 427 for (intptr_t i = 0; i < addresses->count(); i++) { |
| 428 InterfaceSocketAddress* interface = addresses->GetAt(i); | 428 InterfaceSocketAddress* interface = addresses->GetAt(i); |
| 429 SocketAddress* addr = interface->socket_address(); | 429 SocketAddress* addr = interface->socket_address(); |
| 430 CObjectArray* entry = new CObjectArray(CObject::NewArray(4)); | 430 CObjectArray* entry = new CObjectArray(CObject::NewArray(5)); |
| 431 | 431 |
| 432 CObjectInt32* type = new CObjectInt32( | 432 CObjectInt32* type = new CObjectInt32( |
| 433 CObject::NewInt32(addr->GetType())); | 433 CObject::NewInt32(addr->GetType())); |
| 434 entry->SetAt(0, type); | 434 entry->SetAt(0, type); |
| 435 | 435 |
| 436 CObjectString* as_string = new CObjectString(CObject::NewString( | 436 CObjectString* as_string = new CObjectString(CObject::NewString( |
| 437 addr->as_string())); | 437 addr->as_string())); |
| 438 entry->SetAt(1, as_string); | 438 entry->SetAt(1, as_string); |
| 439 | 439 |
| 440 RawAddr raw = addr->addr(); | 440 RawAddr raw = addr->addr(); |
| 441 CObjectUint8Array* data = new CObjectUint8Array(CObject::NewUint8Array( | 441 CObjectUint8Array* data = new CObjectUint8Array(CObject::NewUint8Array( |
| 442 SocketAddress::GetAddrLength(&raw))); | 442 SocketAddress::GetAddrLength(&raw))); |
| 443 memmove(data->Buffer(), | 443 memmove(data->Buffer(), |
| 444 reinterpret_cast<void *>(&raw), | 444 reinterpret_cast<void *>(&raw), |
| 445 SocketAddress::GetAddrLength(&raw)); | 445 SocketAddress::GetAddrLength(&raw)); |
| 446 entry->SetAt(2, data); | 446 entry->SetAt(2, data); |
| 447 | 447 |
| 448 CObjectString* interface_name = new CObjectString(CObject::NewString( | 448 CObjectString* interface_name = new CObjectString(CObject::NewString( |
| 449 interface->interface_name())); | 449 interface->interface_name())); |
| 450 entry->SetAt(3, interface_name); | 450 entry->SetAt(3, interface_name); |
| 451 | 451 |
| 452 CObjectInt64* interface_index = new CObjectInt64(CObject::NewInt64( |
| 453 interface->interface_index())); |
| 454 entry->SetAt(4, interface_index); |
| 455 |
| 452 array->SetAt(i + 1, entry); | 456 array->SetAt(i + 1, entry); |
| 453 } | 457 } |
| 454 result = array; | 458 result = array; |
| 455 delete addresses; | 459 delete addresses; |
| 456 } else { | 460 } else { |
| 457 result = CObject::NewOSError(os_error); | 461 result = CObject::NewOSError(os_error); |
| 458 delete os_error; | 462 delete os_error; |
| 459 } | 463 } |
| 460 return result; | 464 return result; |
| 461 } | 465 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 intptr_t Socket::GetSocketIdNativeField(Dart_Handle socket_obj) { | 500 intptr_t Socket::GetSocketIdNativeField(Dart_Handle socket_obj) { |
| 497 intptr_t socket = 0; | 501 intptr_t socket = 0; |
| 498 Dart_Handle err = | 502 Dart_Handle err = |
| 499 Dart_GetNativeInstanceField(socket_obj, kSocketIdNativeField, &socket); | 503 Dart_GetNativeInstanceField(socket_obj, kSocketIdNativeField, &socket); |
| 500 if (Dart_IsError(err)) Dart_PropagateError(err); | 504 if (Dart_IsError(err)) Dart_PropagateError(err); |
| 501 return socket; | 505 return socket; |
| 502 } | 506 } |
| 503 | 507 |
| 504 } // namespace bin | 508 } // namespace bin |
| 505 } // namespace dart | 509 } // namespace dart |
| OLD | NEW |