| 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 "include/dart_native_api.h" | 5 #include "include/dart_native_api.h" |
| 6 #include "platform/assert.h" | 6 #include "platform/assert.h" |
| 7 #include "vm/bootstrap_natives.h" | 7 #include "vm/bootstrap_natives.h" |
| 8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
| 9 #include "vm/dart.h" | 9 #include "vm/dart.h" |
| 10 #include "vm/dart_api_impl.h" | 10 #include "vm/dart_api_impl.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 } | 63 } |
| 64 | 64 |
| 65 DEFINE_NATIVE_ENTRY(RawReceivePortImpl_factory, 1) { | 65 DEFINE_NATIVE_ENTRY(RawReceivePortImpl_factory, 1) { |
| 66 ASSERT(TypeArguments::CheckedHandle(arguments->NativeArgAt(0)).IsNull()); | 66 ASSERT(TypeArguments::CheckedHandle(arguments->NativeArgAt(0)).IsNull()); |
| 67 Dart_Port port_id = PortMap::CreatePort(isolate->message_handler()); | 67 Dart_Port port_id = PortMap::CreatePort(isolate->message_handler()); |
| 68 return ReceivePort::New(port_id, false /* not control port */); | 68 return ReceivePort::New(port_id, false /* not control port */); |
| 69 } | 69 } |
| 70 | 70 |
| 71 DEFINE_NATIVE_ENTRY(RawReceivePortImpl_get_id, 1) { | 71 DEFINE_NATIVE_ENTRY(RawReceivePortImpl_get_id, 1) { |
| 72 GET_NON_NULL_NATIVE_ARGUMENT(ReceivePort, port, arguments->NativeArgAt(0)); | 72 GET_NON_NULL_NATIVE_ARGUMENT(ReceivePort, port, arguments->NativeArgAt(0)); |
| 73 return Integer::New(port.Id()); | 73 return Integer::NewFromUint64(port.Id()); |
| 74 } | 74 } |
| 75 | 75 |
| 76 DEFINE_NATIVE_ENTRY(RawReceivePortImpl_get_sendport, 1) { | 76 DEFINE_NATIVE_ENTRY(RawReceivePortImpl_get_sendport, 1) { |
| 77 GET_NON_NULL_NATIVE_ARGUMENT(ReceivePort, port, arguments->NativeArgAt(0)); | 77 GET_NON_NULL_NATIVE_ARGUMENT(ReceivePort, port, arguments->NativeArgAt(0)); |
| 78 return port.send_port(); | 78 return port.send_port(); |
| 79 } | 79 } |
| 80 | 80 |
| 81 DEFINE_NATIVE_ENTRY(RawReceivePortImpl_closeInternal, 1) { | 81 DEFINE_NATIVE_ENTRY(RawReceivePortImpl_closeInternal, 1) { |
| 82 GET_NON_NULL_NATIVE_ARGUMENT(ReceivePort, port, arguments->NativeArgAt(0)); | 82 GET_NON_NULL_NATIVE_ARGUMENT(ReceivePort, port, arguments->NativeArgAt(0)); |
| 83 Dart_Port id = port.Id(); | 83 Dart_Port id = port.Id(); |
| 84 PortMap::ClosePort(id); | 84 PortMap::ClosePort(id); |
| 85 return Integer::New(id); | 85 return Integer::NewFromUint64(id); |
| 86 } | 86 } |
| 87 | 87 |
| 88 DEFINE_NATIVE_ENTRY(SendPortImpl_get_id, 1) { | 88 DEFINE_NATIVE_ENTRY(SendPortImpl_get_id, 1) { |
| 89 GET_NON_NULL_NATIVE_ARGUMENT(SendPort, port, arguments->NativeArgAt(0)); | 89 GET_NON_NULL_NATIVE_ARGUMENT(SendPort, port, arguments->NativeArgAt(0)); |
| 90 return Integer::New(port.Id()); | 90 return Integer::NewFromUint64(port.Id()); |
| 91 } | 91 } |
| 92 | 92 |
| 93 DEFINE_NATIVE_ENTRY(SendPortImpl_get_hashcode, 1) { | 93 DEFINE_NATIVE_ENTRY(SendPortImpl_get_hashcode, 1) { |
| 94 GET_NON_NULL_NATIVE_ARGUMENT(SendPort, port, arguments->NativeArgAt(0)); | 94 GET_NON_NULL_NATIVE_ARGUMENT(SendPort, port, arguments->NativeArgAt(0)); |
| 95 int64_t id = port.Id(); | 95 int64_t id = port.Id(); |
| 96 int32_t hi = static_cast<int32_t>(id >> 32); | 96 int32_t hi = static_cast<int32_t>(id >> 32); |
| 97 int32_t lo = static_cast<int32_t>(id); | 97 int32_t lo = static_cast<int32_t>(id); |
| 98 int32_t hash = (hi ^ lo) & kSmiMax; | 98 int32_t hash = (hi ^ lo) & kSmiMax; |
| 99 return Smi::New(hash); | 99 return Smi::New(hash); |
| 100 } | 100 } |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 uint8_t* data = NULL; | 444 uint8_t* data = NULL; |
| 445 MessageWriter writer(&data, &malloc_allocator, &malloc_deallocator, false); | 445 MessageWriter writer(&data, &malloc_allocator, &malloc_deallocator, false); |
| 446 writer.WriteMessage(msg); | 446 writer.WriteMessage(msg); |
| 447 | 447 |
| 448 PortMap::PostMessage(new Message(port.Id(), data, writer.BytesWritten(), | 448 PortMap::PostMessage(new Message(port.Id(), data, writer.BytesWritten(), |
| 449 Message::kOOBPriority)); | 449 Message::kOOBPriority)); |
| 450 return Object::null(); | 450 return Object::null(); |
| 451 } | 451 } |
| 452 | 452 |
| 453 } // namespace dart | 453 } // namespace dart |
| OLD | NEW |