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 "vm/native_message_handler.h" | 5 #include "vm/native_message_handler.h" |
6 | 6 |
7 #include "vm/dart_api_message.h" | 7 #include "vm/dart_api_message.h" |
8 #include "vm/isolate.h" | 8 #include "vm/isolate.h" |
9 #include "vm/message.h" | 9 #include "vm/message.h" |
10 #include "vm/snapshot.h" | 10 #include "vm/snapshot.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 } | 31 } |
32 #endif | 32 #endif |
33 | 33 |
34 | 34 |
35 MessageHandler::MessageStatus NativeMessageHandler::HandleMessage( | 35 MessageHandler::MessageStatus NativeMessageHandler::HandleMessage( |
36 Message* message) { | 36 Message* message) { |
37 if (message->IsOOB()) { | 37 if (message->IsOOB()) { |
38 // We currently do not use OOB messages for native ports. | 38 // We currently do not use OOB messages for native ports. |
39 UNREACHABLE(); | 39 UNREACHABLE(); |
40 } | 40 } |
41 // We create a native scope for handling the message. | 41 if (message->type() == Message::kDataType) { |
42 // All allocation of objects for decoding the message is done in the | 42 // We create a native scope for handling the message. |
43 // zone associated with this scope. | 43 // All allocation of objects for decoding the message is done in the |
44 ApiNativeScope scope; | 44 // zone associated with this scope. |
45 ApiMessageReader reader(message->data(), message->len()); | 45 ApiNativeScope scope; |
46 Dart_CObject* object = reader.ReadMessage(); | 46 ApiMessageReader reader(message->data(), message->len()); |
47 (*func())(message->dest_port(), object); | 47 Dart_CObject* object = reader.ReadMessage(); |
| 48 (*func())(message->dest_port(), object); |
| 49 } else { |
| 50 ASSERT(message->type() == Message::kIntegerType); |
| 51 Dart_CObject integer; |
| 52 integer.type = Dart_CObject_kInt64; |
| 53 integer.value.as_int64 = message->integer(); |
| 54 (*func())(message->dest_port(), &integer); |
| 55 } |
48 delete message; | 56 delete message; |
49 return kOK; | 57 return kOK; |
50 } | 58 } |
51 | 59 |
52 } // namespace dart | 60 } // namespace dart |
OLD | NEW |