| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 | 7 |
| 8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
| 9 | 9 |
| 10 | 10 |
| 11 static const intptr_t kNativeEventHandlerFieldIndex = 0; | 11 static const intptr_t kNativeEventHandlerFieldIndex = 0; |
| 12 | 12 |
| 13 ThreadPool* EventHandler::thread_pool_ = NULL; | 13 ThreadPool* EventHandler::thread_pool_ = NULL; |
| 14 | 14 |
| 15 /* | 15 /* |
| 16 * Returns the reference of the EventHandler stored in the native field. | 16 * Returns the reference of the EventHandler stored in the native field. |
| 17 */ | 17 */ |
| 18 static EventHandler* GetEventHandler(Dart_Handle handle) { | 18 static EventHandler* GetEventHandler(Dart_Handle handle) { |
| 19 intptr_t value = 0; | 19 intptr_t value = 0; |
| 20 Dart_Handle result = Dart_GetNativeInstanceField( | 20 Dart_Handle result = Dart_GetNativeInstanceField( |
| 21 handle, kNativeEventHandlerFieldIndex, &value); | 21 handle, kNativeEventHandlerFieldIndex, &value); |
| 22 ASSERT(!Dart_IsError(result)); | 22 if (Dart_IsError(result)) { |
| 23 Dart_PropagateError(result); |
| 24 } |
| 23 EventHandler* event_handler = reinterpret_cast<EventHandler*>(value); | 25 EventHandler* event_handler = reinterpret_cast<EventHandler*>(value); |
| 24 ASSERT(event_handler != NULL); | 26 ASSERT(event_handler != NULL); |
| 25 return event_handler; | 27 return event_handler; |
| 26 } | 28 } |
| 27 | 29 |
| 28 | 30 |
| 29 /* | 31 /* |
| 30 * Sets the reference of the EventHandler in the native field. | 32 * Sets the reference of the EventHandler in the native field. |
| 31 */ | 33 */ |
| 32 static void SetEventHandler(Dart_Handle handle, EventHandler* event_handler) { | 34 static void SetEventHandler(Dart_Handle handle, EventHandler* event_handler) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 60 Dart_Handle handle = Dart_GetNativeArgument(args, 0); | 62 Dart_Handle handle = Dart_GetNativeArgument(args, 0); |
| 61 EventHandler* event_handler = GetEventHandler(handle); | 63 EventHandler* event_handler = GetEventHandler(handle); |
| 62 intptr_t id = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 1)); | 64 intptr_t id = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 1)); |
| 63 handle = Dart_GetNativeArgument(args, 2); | 65 handle = Dart_GetNativeArgument(args, 2); |
| 64 Dart_Port dart_port = | 66 Dart_Port dart_port = |
| 65 DartUtils::GetIntegerField(handle, DartUtils::kIdFieldName); | 67 DartUtils::GetIntegerField(handle, DartUtils::kIdFieldName); |
| 66 intptr_t data = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 3)); | 68 intptr_t data = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 3)); |
| 67 event_handler->SendData(id, dart_port, data); | 69 event_handler->SendData(id, dart_port, data); |
| 68 Dart_ExitScope(); | 70 Dart_ExitScope(); |
| 69 } | 71 } |
| OLD | NEW |