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_native_api.h" | 5 #include "include/dart_native_api.h" |
6 | 6 |
7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
8 #include "vm/dart_api_impl.h" | 8 #include "vm/dart_api_impl.h" |
9 #include "vm/dart_api_message.h" | 9 #include "vm/dart_api_message.h" |
10 #include "vm/dart_api_state.h" | 10 #include "vm/dart_api_state.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 bool success = writer.WriteCMessage(message); | 49 bool success = writer.WriteCMessage(message); |
50 | 50 |
51 if (!success) return success; | 51 if (!success) return success; |
52 | 52 |
53 // Post the message at the given port. | 53 // Post the message at the given port. |
54 return PortMap::PostMessage(new Message( | 54 return PortMap::PostMessage(new Message( |
55 port_id, buffer, writer.BytesWritten(), Message::kNormalPriority)); | 55 port_id, buffer, writer.BytesWritten(), Message::kNormalPriority)); |
56 } | 56 } |
57 | 57 |
58 | 58 |
| 59 DART_EXPORT bool Dart_PostInteger(Dart_Port port_id, intptr_t message) { |
| 60 if (!Smi::IsValid(message)) { |
| 61 return false; |
| 62 } |
| 63 Message* msg = new Message( |
| 64 port_id, Smi::New(message), Message::kNormalPriority); |
| 65 |
| 66 // Post the message at the given port. |
| 67 return PortMap::PostMessage(msg); |
| 68 } |
| 69 |
| 70 |
| 71 DART_EXPORT bool Dart_PostSimpleObject(Dart_Port port_id, Dart_Handle message) { |
| 72 RawObject* raw_obj = Api::UnwrapHandle(message); |
| 73 if (raw_obj->IsHeapObject() && !raw_obj->IsVMHeapObject()) { |
| 74 return false; |
| 75 } |
| 76 Message* msg = new Message(port_id, raw_obj, Message::kNormalPriority); |
| 77 |
| 78 // Post the message at the given port. |
| 79 return PortMap::PostMessage(msg); |
| 80 } |
| 81 |
| 82 |
59 DART_EXPORT Dart_Port Dart_NewNativePort(const char* name, | 83 DART_EXPORT Dart_Port Dart_NewNativePort(const char* name, |
60 Dart_NativeMessageHandler handler, | 84 Dart_NativeMessageHandler handler, |
61 bool handle_concurrently) { | 85 bool handle_concurrently) { |
62 if (name == NULL) { | 86 if (name == NULL) { |
63 name = "<UnnamedNativePort>"; | 87 name = "<UnnamedNativePort>"; |
64 } | 88 } |
65 if (handler == NULL) { | 89 if (handler == NULL) { |
66 OS::PrintErr("%s expects argument 'handler' to be non-null.\n", | 90 OS::PrintErr("%s expects argument 'handler' to be non-null.\n", |
67 CURRENT_FUNC); | 91 CURRENT_FUNC); |
68 return ILLEGAL_PORT; | 92 return ILLEGAL_PORT; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 Dart_Handle result = Api::CheckAndFinalizePendingClasses(T); | 128 Dart_Handle result = Api::CheckAndFinalizePendingClasses(T); |
105 if (::Dart_IsError(result)) { | 129 if (::Dart_IsError(result)) { |
106 return result; | 130 return result; |
107 } | 131 } |
108 CHECK_CALLBACK_STATE(T); | 132 CHECK_CALLBACK_STATE(T); |
109 CompileAll(T, &result); | 133 CompileAll(T, &result); |
110 return result; | 134 return result; |
111 } | 135 } |
112 | 136 |
113 } // namespace dart | 137 } // namespace dart |
OLD | NEW |