OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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_ARGUMENTS_H_ | 5 #ifndef VM_NATIVE_ARGUMENTS_H_ |
6 #define VM_NATIVE_ARGUMENTS_H_ | 6 #define VM_NATIVE_ARGUMENTS_H_ |
7 | 7 |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "vm/globals.h" | 9 #include "vm/globals.h" |
10 | 10 |
11 namespace dart { | 11 namespace dart { |
12 | 12 |
13 // Forward declarations. | 13 // Forward declarations. |
14 class Isolate; | 14 class Isolate; |
15 class Object; | 15 class Object; |
16 class RawObject; | 16 class RawObject; |
17 | 17 |
18 | 18 |
19 // Class NativeArguments is used to access arguments passed in from | 19 // Class NativeArguments is used to access arguments passed in from |
20 // generated dart code to a runtime function or a dart library native | 20 // generated dart code to a runtime function or a dart library native |
21 // function. It is also used to set the return value if any at the slot | 21 // function. It is also used to set the return value if any at the slot |
22 // reserved for return values. | 22 // reserved for return values. |
23 // All runtime function/dart library native functions have the | 23 // All runtime function/dart library native functions have the |
24 // following signature: | 24 // following signature: |
25 // void function_name(NativeArguments arguments); | 25 // void function_name(NativeArguments arguments); |
26 // Inside the function, arguments are accessed as follows: | 26 // Inside the function, arguments are accessed as follows: |
27 // const Type& arg1 = Type::CheckedHandle(arguments.GetArgument(0)); | 27 // const Type& arg1 = Type::CheckedHandle(arguments.GetArgument(0)); |
28 // const Type& arg2 = Type::CheckedHandle(arguments.GetArgument(1)); | 28 // const Type& arg2 = Type::CheckedHandle(arguments.GetArgument(1)); |
29 // The return value is set as follows: | 29 // The return value is set as follows: |
30 // arguments.SetReturnValue(result); | 30 // arguments.SetReturn(result); |
31 // NOTE: Since we pass this as a pass by value argument in the stubs we don't | 31 // NOTE: Since we pass this as a pass by value argument in the stubs we don't |
32 // have DISALLOW_COPY_AND_ASSIGN in the class definition and do not make it a | 32 // have DISALLOW_COPY_AND_ASSIGN in the class definition and do not make it a |
33 // subclass of ValueObject. | 33 // subclass of ValueObject. |
34 class NativeArguments { | 34 class NativeArguments { |
35 public: | 35 public: |
36 Isolate* isolate() const { return isolate_; } | 36 Isolate* isolate() const { return isolate_; } |
37 int Count() const { return argc_; } | 37 int Count() const { return argc_; } |
38 | 38 |
39 RawObject* At(int index) const { | 39 RawObject* At(int index) const { |
40 ASSERT(index >=0 && index < argc_); | 40 ASSERT(index >=0 && index < argc_); |
(...skipping 14 matching lines...) Expand all Loading... |
55 private: | 55 private: |
56 Isolate* isolate_; // Current isolate pointer. | 56 Isolate* isolate_; // Current isolate pointer. |
57 int argc_; // Number of arguments passed to the runtime call. | 57 int argc_; // Number of arguments passed to the runtime call. |
58 RawObject*(*argv_)[]; // Pointer to an array of arguments to runtime call. | 58 RawObject*(*argv_)[]; // Pointer to an array of arguments to runtime call. |
59 RawObject** retval_; // Pointer to the return value area. | 59 RawObject** retval_; // Pointer to the return value area. |
60 }; | 60 }; |
61 | 61 |
62 } // namespace dart | 62 } // namespace dart |
63 | 63 |
64 #endif // VM_NATIVE_ARGUMENTS_H_ | 64 #endif // VM_NATIVE_ARGUMENTS_H_ |
OLD | NEW |