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/dartutils.h" | 5 #include "bin/dartutils.h" |
6 #include "bin/eventhandler.h" | 6 #include "bin/eventhandler.h" |
7 #include "bin/socket.h" | 7 #include "bin/socket.h" |
8 #include "bin/thread.h" | 8 #include "bin/thread.h" |
9 | 9 |
10 #include "include/dart_api.h" | 10 #include "include/dart_api.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 * args[0] a ReceivePort args[1] with a notification event args[2]. | 85 * args[0] a ReceivePort args[1] with a notification event args[2]. |
86 */ | 86 */ |
87 void FUNCTION_NAME(EventHandler_SendData)(Dart_NativeArguments args) { | 87 void FUNCTION_NAME(EventHandler_SendData)(Dart_NativeArguments args) { |
88 Dart_Handle sender = Dart_GetNativeArgument(args, 0); | 88 Dart_Handle sender = Dart_GetNativeArgument(args, 0); |
89 intptr_t id = kInvalidId; | 89 intptr_t id = kInvalidId; |
90 if (Dart_IsNull(sender)) { | 90 if (Dart_IsNull(sender)) { |
91 id = kTimerId; | 91 id = kTimerId; |
92 } else { | 92 } else { |
93 id = Socket::GetSocketIdNativeField(sender); | 93 id = Socket::GetSocketIdNativeField(sender); |
94 } | 94 } |
95 // Get the _id field out of the port. | 95 // Get the id out of the receive port. If the handle is not a receive port |
| 96 // we will get an error and propagate that out. |
96 Dart_Handle handle = Dart_GetNativeArgument(args, 1); | 97 Dart_Handle handle = Dart_GetNativeArgument(args, 1); |
97 handle = Dart_GetField(handle, DartUtils::NewString(DartUtils::kIdFieldName)); | 98 Dart_Port dart_port; |
| 99 handle = Dart_ReceivePortGetId(handle, &dart_port); |
98 if (Dart_IsError(handle)) { | 100 if (Dart_IsError(handle)) { |
99 Dart_PropagateError(handle); | 101 Dart_PropagateError(handle); |
100 UNREACHABLE(); | 102 UNREACHABLE(); |
101 } | |
102 Dart_Port dart_port; | |
103 handle = Dart_IntegerToInt64(handle, &dart_port); | |
104 if (Dart_IsError(handle)) { | |
105 Dart_PropagateError(handle); | |
106 UNREACHABLE(); | |
107 } | 103 } |
108 int64_t data = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 2)); | 104 int64_t data = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 2)); |
109 event_handler->SendData(id, dart_port, data); | 105 event_handler->SendData(id, dart_port, data); |
110 } | 106 } |
111 | 107 |
112 } // namespace bin | 108 } // namespace bin |
113 } // namespace dart | 109 } // namespace dart |
OLD | NEW |