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

Side by Side Diff: runtime/vm/native_entry.h

Issue 10693071: Use VM type cast and save handles. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 5 months 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 | « runtime/vm/isolate.cc ('k') | runtime/vm/object.h » ('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/exceptions.h" 10 #include "vm/exceptions.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 type& name = type::Handle(); \ 59 const Instance& __##name##_instance__ = Instance::CheckedHandle(value); \
60 { \ 60 if (!__##name##_instance__.Is##type()) { \
61 const Instance& __instance__ = Instance::CheckedHandle(value); \ 61 GrowableArray<const Object*> __args__; \
62 if (!__instance__.Is##type()) { \ 62 __args__.Add(&__##name##_instance__); \
63 GrowableArray<const Object*> __args__; \ 63 Exceptions::ThrowByType(Exceptions::kIllegalArgument, __args__); \
64 __args__.Add(&__instance__); \ 64 } \
65 Exceptions::ThrowByType(Exceptions::kIllegalArgument, __args__); \ 65 const type& name = type::Cast(__##name##_instance__);
66 } \
67 name ^= __instance__.raw(); \
68 }
69 66
70 67
71 68
72 // Helper class for resolving and handling native functions. 69 // Helper class for resolving and handling native functions.
73 class NativeEntry : public AllStatic { 70 class NativeEntry : public AllStatic {
74 public: 71 public:
75 // Resolve specified dart native function to the actual native entrypoint. 72 // Resolve specified dart native function to the actual native entrypoint.
76 static NativeFunction ResolveNative(const Class& cls, 73 static NativeFunction ResolveNative(const Class& cls,
77 const String& function_name, 74 const String& function_name,
78 int number_of_arguments); 75 int number_of_arguments);
79 }; 76 };
80 77
81 } // namespace dart 78 } // namespace dart
82 79
83 #endif // VM_NATIVE_ENTRY_H_ 80 #endif // VM_NATIVE_ENTRY_H_
OLDNEW
« no previous file with comments | « runtime/vm/isolate.cc ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698