| 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 |
| 3 | // BSD-style license that can be found in the LICENSE file. |
| 4 | |
| 5 | #ifndef RUNTIME_VM_NATIVE_FUNCTION_H_ |
| 6 | #define RUNTIME_VM_NATIVE_FUNCTION_H_ |
| 7 | |
| 8 | #include "vm/allocation.h" |
| 9 | |
| 10 | #include "include/dart_api.h" |
| 11 | |
| 12 | namespace dart { |
| 13 | |
| 14 | // Forward declarations. |
| 15 | class NativeArguments; |
| 16 | |
| 17 | // We have three variants of native functions: |
| 18 | // - bootstrap natives, which are called directly from stub code. The callee is |
| 19 | // responsible for safepoint transitions and setting up handle scopes as |
| 20 | // needed. Only VM-defined natives are bootstrap natives; they cannot be |
| 21 | // defined by embedders or native extensions. |
| 22 | // - no scope natives, which are called through a wrapper function. The wrapper |
| 23 | // function handles the safepoint transition. The callee is responsible for |
| 24 | // setting up API scopes as needed. |
| 25 | // - auto scope natives, which are called through a wrapper function. The |
| 26 | // wrapper function handles the safepoint transition and sets up an API |
| 27 | // scope. |
| 28 | |
| 29 | typedef void (*NativeFunction)(NativeArguments* arguments); |
| 30 | typedef void (*NativeFunctionWrapper)(Dart_NativeArguments args, |
| 31 | Dart_NativeFunction func); |
| 32 | |
| 33 | } // namespace dart |
| 34 | |
| 35 | #endif // RUNTIME_VM_NATIVE_FUNCTION_H_ |
| 36 | |