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