| 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 #ifndef VM_NATIVE_ENTRY_H_ | 5 #ifndef VM_NATIVE_ENTRY_H_ |
| 6 #define VM_NATIVE_ENTRY_H_ | 6 #define VM_NATIVE_ENTRY_H_ |
| 7 | 7 |
| 8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
| 10 #include "vm/native_arguments.h" | 10 #include "vm/native_arguments.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 DN_Helper##name(arguments); \ | 45 DN_Helper##name(arguments); \ |
| 46 } \ | 46 } \ |
| 47 VERIFY_ON_TRANSITION; \ | 47 VERIFY_ON_TRANSITION; \ |
| 48 } \ | 48 } \ |
| 49 static void DN_Helper##name(NativeArguments* arguments) | 49 static void DN_Helper##name(NativeArguments* arguments) |
| 50 | 50 |
| 51 | 51 |
| 52 #define DECLARE_NATIVE_ENTRY(name, argument_count) \ | 52 #define DECLARE_NATIVE_ENTRY(name, argument_count) \ |
| 53 extern void NATIVE_ENTRY_FUNCTION(name)(Dart_NativeArguments arguments); | 53 extern void NATIVE_ENTRY_FUNCTION(name)(Dart_NativeArguments arguments); |
| 54 | 54 |
| 55 // Natives should throw an exception if an illegal argument is passed. |
| 56 // type name = value. |
| 57 #define GET_NATIVE_ARGUMENT(type, name, value) \ |
| 58 type& name = type::Handle(); \ |
| 59 { \ |
| 60 const Instance& __instance__ = Instance::CheckedHandle(value); \ |
| 61 if (!__instance__.Is##type()) { \ |
| 62 GrowableArray<const Object*> __args__; \ |
| 63 __args__.Add(&__instance__); \ |
| 64 Exceptions::ThrowByType(Exceptions::kIllegalArgument, __args__); \ |
| 65 } \ |
| 66 name ^= __instance__.raw(); \ |
| 67 } |
| 68 |
| 69 |
| 55 | 70 |
| 56 // Helper class for resolving and handling native functions. | 71 // Helper class for resolving and handling native functions. |
| 57 class NativeEntry : public AllStatic { | 72 class NativeEntry : public AllStatic { |
| 58 public: | 73 public: |
| 59 // Resolve specified dart native function to the actual native entrypoint. | 74 // Resolve specified dart native function to the actual native entrypoint. |
| 60 static NativeFunction ResolveNative(const Class& cls, | 75 static NativeFunction ResolveNative(const Class& cls, |
| 61 const String& function_name, | 76 const String& function_name, |
| 62 int number_of_arguments); | 77 int number_of_arguments); |
| 63 }; | 78 }; |
| 64 | 79 |
| 65 } // namespace dart | 80 } // namespace dart |
| 66 | 81 |
| 67 #endif // VM_NATIVE_ENTRY_H_ | 82 #endif // VM_NATIVE_ENTRY_H_ |
| OLD | NEW |