| 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 "include/dart_api.h" | 5 #include "include/dart_api.h" |
| 6 #include "include/dart_mirrors_api.h" | 6 #include "include/dart_mirrors_api.h" |
| 7 #include "include/dart_native_api.h" | 7 #include "include/dart_native_api.h" |
| 8 | 8 |
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
| 10 #include "vm/bigint_operations.h" | 10 #include "vm/bigint_operations.h" |
| (...skipping 1164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1175 DART_EXPORT Dart_Handle Dart_PostMessage(Dart_Handle send_port, | 1175 DART_EXPORT Dart_Handle Dart_PostMessage(Dart_Handle send_port, |
| 1176 Dart_Handle object) { | 1176 Dart_Handle object) { |
| 1177 Isolate* isolate = Isolate::Current(); | 1177 Isolate* isolate = Isolate::Current(); |
| 1178 DARTSCOPE(isolate); | 1178 DARTSCOPE(isolate); |
| 1179 Instance& port_instance = Instance::Handle(); | 1179 Instance& port_instance = Instance::Handle(); |
| 1180 port_instance ^= Api::UnwrapHandle(send_port); | 1180 port_instance ^= Api::UnwrapHandle(send_port); |
| 1181 if (!DartLibraryCalls::IsSendPort(port_instance)) { | 1181 if (!DartLibraryCalls::IsSendPort(port_instance)) { |
| 1182 return Api::NewError("send_port is not a SendPort."); | 1182 return Api::NewError("send_port is not a SendPort."); |
| 1183 } | 1183 } |
| 1184 const Object& idObj = Object::Handle( | 1184 const Object& idObj = Object::Handle( |
| 1185 DartLibraryCalls::PortGetId(port_instance)); | 1185 DartLibraryCalls::PortGetId(port_instance)); |
| 1186 ASSERT(!idObj.IsError()); | 1186 ASSERT(!idObj.IsError()); |
| 1187 Integer& id = Integer::Handle(); | 1187 Integer& id = Integer::Handle(); |
| 1188 id ^= idObj.raw(); | 1188 id ^= idObj.raw(); |
| 1189 Dart_Port port = static_cast<Dart_Port>(id.AsInt64Value()); | 1189 Dart_Port port = static_cast<Dart_Port>(id.AsInt64Value()); |
| 1190 if (Dart_Post(port, object)) { | 1190 uint8_t* data = NULL; |
| 1191 MessageWriter writer(&data, &allocator); |
| 1192 Object& msg_object = Object::Handle(Api::UnwrapHandle(object)); |
| 1193 writer.WriteMessage(msg_object); |
| 1194 intptr_t len = writer.BytesWritten(); |
| 1195 bool r = PortMap::PostMessage( |
| 1196 new Message(port, data, len, Message::kNormalPriority)); |
| 1197 if (r) { |
| 1191 return Api::Success(); | 1198 return Api::Success(); |
| 1192 } | 1199 } |
| 1193 return Api::NewError("Dart_Post failed."); | 1200 return Api::NewError("Dart_PostMessage failed."); |
| 1194 } | 1201 } |
| 1195 | 1202 |
| 1196 // --- Scopes ---- | 1203 // --- Scopes ---- |
| 1197 | 1204 |
| 1198 DART_EXPORT void Dart_EnterScope() { | 1205 DART_EXPORT void Dart_EnterScope() { |
| 1199 Isolate* isolate = Isolate::Current(); | 1206 Isolate* isolate = Isolate::Current(); |
| 1200 CHECK_ISOLATE(isolate); | 1207 CHECK_ISOLATE(isolate); |
| 1201 ApiState* state = isolate->api_state(); | 1208 ApiState* state = isolate->api_state(); |
| 1202 ASSERT(state != NULL); | 1209 ASSERT(state != NULL); |
| 1203 ApiLocalScope* new_scope = state->reusable_scope(); | 1210 ApiLocalScope* new_scope = state->reusable_scope(); |
| (...skipping 3316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4520 } | 4527 } |
| 4521 | 4528 |
| 4522 | 4529 |
| 4523 // --- Service support --- | 4530 // --- Service support --- |
| 4524 | 4531 |
| 4525 DART_EXPORT Dart_Isolate Dart_GetServiceIsolate(void* callback_data) { | 4532 DART_EXPORT Dart_Isolate Dart_GetServiceIsolate(void* callback_data) { |
| 4526 return Api::CastIsolate(Service::GetServiceIsolate(callback_data)); | 4533 return Api::CastIsolate(Service::GetServiceIsolate(callback_data)); |
| 4527 } | 4534 } |
| 4528 | 4535 |
| 4529 } // namespace dart | 4536 } // namespace dart |
| OLD | NEW |