Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: vm/native_entry.h

Issue 11639007: Cleanup the exceptions create code to use Arrays instead GrowableArrays so (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « vm/isolate.cc ('k') | vm/object_store.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 static RawObject* DN_Helper##name(Isolate* isolate, \ 50 static RawObject* DN_Helper##name(Isolate* isolate, \
51 NativeArguments* arguments) 51 NativeArguments* arguments)
52 52
53 53
54 // Natives should throw an exception if an illegal argument or null is passed. 54 // Natives should throw an exception if an illegal argument or null is passed.
55 // type name = value. 55 // type name = value.
56 #define GET_NON_NULL_NATIVE_ARGUMENT(type, name, value) \ 56 #define GET_NON_NULL_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 const Array& __args__ = Array::Handle(Array::New(1)); \
61 __args__.Add(&__##name##_instance__); \ 61 __args__.SetAt(0, __##name##_instance__); \
62 Exceptions::ThrowByType(Exceptions::kArgument, __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 // Natives should throw an exception if an illegal argument is passed. 67 // Natives should throw an exception if an illegal argument is passed.
68 // type name = value. 68 // type name = value.
69 #define GET_NATIVE_ARGUMENT(type, name, value) \ 69 #define GET_NATIVE_ARGUMENT(type, name, value) \
70 const Instance& __##name##_instance__ = \ 70 const Instance& __##name##_instance__ = \
71 Instance::CheckedHandle(isolate, value); \ 71 Instance::CheckedHandle(isolate, value); \
72 type& name = type::Handle(isolate); \ 72 type& name = type::Handle(isolate); \
73 if (!__##name##_instance__.IsNull()) { \ 73 if (!__##name##_instance__.IsNull()) { \
74 if (!__##name##_instance__.Is##type()) { \ 74 if (!__##name##_instance__.Is##type()) { \
75 GrowableArray<const Object*> __args__; \ 75 const Array& __args__ = Array::Handle(Array::New(1)); \
76 __args__.Add(&__##name##_instance__); \ 76 __args__.SetAt(0, __##name##_instance__); \
77 Exceptions::ThrowByType(Exceptions::kArgument, __args__); \ 77 Exceptions::ThrowByType(Exceptions::kArgument, __args__); \
78 } \ 78 } \
79 } \ 79 } \
80 name ^= value; 80 name ^= value;
81 81
82 82
83 // Helper class for resolving and handling native functions. 83 // Helper class for resolving and handling native functions.
84 class NativeEntry : public AllStatic { 84 class NativeEntry : public AllStatic {
85 public: 85 public:
86 // Resolve specified dart native function to the actual native entrypoint. 86 // Resolve specified dart native function to the actual native entrypoint.
87 static NativeFunction ResolveNative(const Class& cls, 87 static NativeFunction ResolveNative(const Class& cls,
88 const String& function_name, 88 const String& function_name,
89 int number_of_arguments); 89 int number_of_arguments);
90 }; 90 };
91 91
92 } // namespace dart 92 } // namespace dart
93 93
94 #endif // VM_NATIVE_ENTRY_H_ 94 #endif // VM_NATIVE_ENTRY_H_
OLDNEW
« no previous file with comments | « vm/isolate.cc ('k') | vm/object_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698