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 RUNTIME_VM_DART_API_IMPL_H_ | 5 #ifndef RUNTIME_VM_DART_API_IMPL_H_ |
6 #define RUNTIME_VM_DART_API_IMPL_H_ | 6 #define RUNTIME_VM_DART_API_IMPL_H_ |
7 | 7 |
8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
9 #include "vm/native_arguments.h" | 9 #include "vm/native_arguments.h" |
10 #include "vm/object.h" | 10 #include "vm/object.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 } else if (tmp.IsError()) { \ | 78 } else if (tmp.IsError()) { \ |
79 return dart_handle; \ | 79 return dart_handle; \ |
80 } \ | 80 } \ |
81 return Api::NewError("%s expects argument '%s' to be of type %s.", \ | 81 return Api::NewError("%s expects argument '%s' to be of type %s.", \ |
82 CURRENT_FUNC, #dart_handle, #type); \ | 82 CURRENT_FUNC, #dart_handle, #type); \ |
83 } while (0) | 83 } while (0) |
84 | 84 |
85 | 85 |
86 #define RETURN_NULL_ERROR(parameter) \ | 86 #define RETURN_NULL_ERROR(parameter) \ |
87 return Api::NewError("%s expects argument '%s' to be non-null.", \ | 87 return Api::NewError("%s expects argument '%s' to be non-null.", \ |
88 CURRENT_FUNC, #parameter); | 88 CURRENT_FUNC, #parameter) |
89 | 89 |
| 90 #define CHECK_NULL(parameter) \ |
| 91 if (parameter == NULL) { \ |
| 92 RETURN_NULL_ERROR(parameter); \ |
| 93 } |
90 | 94 |
91 #define CHECK_LENGTH(length, max_elements) \ | 95 #define CHECK_LENGTH(length, max_elements) \ |
92 do { \ | 96 do { \ |
93 intptr_t len = (length); \ | 97 intptr_t len = (length); \ |
94 intptr_t max = (max_elements); \ | 98 intptr_t max = (max_elements); \ |
95 if (len < 0 || len > max) { \ | 99 if (len < 0 || len > max) { \ |
96 return Api::NewError( \ | 100 return Api::NewError( \ |
97 "%s expects argument '%s' to be in the range [0..%" Pd "].", \ | 101 "%s expects argument '%s' to be in the range [0..%" Pd "].", \ |
98 CURRENT_FUNC, #length, max); \ | 102 CURRENT_FUNC, #length, max); \ |
99 } \ | 103 } \ |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 return Api::NewError("%s: Cannot load after Dart_Precompile", \ | 300 return Api::NewError("%s: Cannot load after Dart_Precompile", \ |
297 CURRENT_FUNC); \ | 301 CURRENT_FUNC); \ |
298 } | 302 } |
299 | 303 |
300 #define ASSERT_CALLBACK_STATE(thread) \ | 304 #define ASSERT_CALLBACK_STATE(thread) \ |
301 ASSERT(thread->no_callback_scope_depth() == 0) | 305 ASSERT(thread->no_callback_scope_depth() == 0) |
302 | 306 |
303 } // namespace dart. | 307 } // namespace dart. |
304 | 308 |
305 #endif // RUNTIME_VM_DART_API_IMPL_H_ | 309 #endif // RUNTIME_VM_DART_API_IMPL_H_ |
OLD | NEW |