| 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/eventhandler.h" | 5 #include "bin/eventhandler.h" |
| 6 #include "bin/dartutils.h" | 6 #include "bin/dartutils.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 | 13 |
| 14 /* | 14 /* |
| 15 * Returns the reference of the EventHandler stored in the native field. | 15 * Returns the reference of the EventHandler stored in the native field. |
| 16 */ | 16 */ |
| 17 static EventHandler* GetEventHandler(Dart_Handle handle) { | 17 static EventHandler* GetEventHandler(Dart_Handle handle) { |
| 18 Dart_Result result = Dart_GetNativeInstanceField( | 18 Dart_Result result = Dart_GetNativeInstanceField( |
| 19 handle, kNativeEventHandlerFieldIndex); | 19 handle, kNativeEventHandlerFieldIndex); |
| 20 assert(Dart_IsValidResult(result)); | 20 ASSERT(Dart_IsValidResult(result)); |
| 21 EventHandler* event_handler = | 21 EventHandler* event_handler = |
| 22 reinterpret_cast<EventHandler*>(Dart_GetResultAsCIntptr(result)); | 22 reinterpret_cast<EventHandler*>(Dart_GetResultAsCIntptr(result)); |
| 23 assert(event_handler != NULL); | 23 ASSERT(event_handler != NULL); |
| 24 return event_handler; | 24 return event_handler; |
| 25 } | 25 } |
| 26 | 26 |
| 27 | 27 |
| 28 /* | 28 /* |
| 29 * Sets the reference of the EventHandler in the native field. | 29 * Sets the reference of the EventHandler in the native field. |
| 30 */ | 30 */ |
| 31 static void SetEventHandler(Dart_Handle handle, EventHandler* event_handler) { | 31 static void SetEventHandler(Dart_Handle handle, EventHandler* event_handler) { |
| 32 Dart_SetNativeInstanceField(handle, | 32 Dart_SetNativeInstanceField(handle, |
| 33 kNativeEventHandlerFieldIndex, | 33 kNativeEventHandlerFieldIndex, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 59 Dart_Handle handle = Dart_GetNativeArgument(args, 0); | 59 Dart_Handle handle = Dart_GetNativeArgument(args, 0); |
| 60 EventHandler* event_handler = GetEventHandler(handle); | 60 EventHandler* event_handler = GetEventHandler(handle); |
| 61 intptr_t id = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 1)); | 61 intptr_t id = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 1)); |
| 62 handle = Dart_GetNativeArgument(args, 2); | 62 handle = Dart_GetNativeArgument(args, 2); |
| 63 Dart_Port dart_port = | 63 Dart_Port dart_port = |
| 64 DartUtils::GetIntegerInstanceField(handle, DartUtils::kIdFieldName); | 64 DartUtils::GetIntegerInstanceField(handle, DartUtils::kIdFieldName); |
| 65 intptr_t data = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 3)); | 65 intptr_t data = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 3)); |
| 66 event_handler->SendData(id, dart_port, data); | 66 event_handler->SendData(id, dart_port, data); |
| 67 Dart_ExitScope(); | 67 Dart_ExitScope(); |
| 68 } | 68 } |
| OLD | NEW |