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