1 | /* Copyright JS Foundation and other contributors, http://js.foundation |
2 | * |
3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
4 | * you may not use this file except in compliance with the License. |
5 | * You may obtain a copy of the License at |
6 | * |
7 | * http://www.apache.org/licenses/LICENSE-2.0 |
8 | * |
9 | * Unless required by applicable law or agreed to in writing, software |
10 | * distributed under the License is distributed on an "AS IS" BASIS |
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | * See the License for the specific language governing permissions and |
13 | * limitations under the License. |
14 | */ |
15 | |
16 | #ifndef JERRYX_HANDLE_SCOPE_INTERNAL_H |
17 | #define JERRYX_HANDLE_SCOPE_INTERNAL_H |
18 | |
19 | #include "jerryscript.h" |
20 | #include "jerryscript-port.h" |
21 | #include "jerryscript-ext/handle-scope.h" |
22 | |
23 | #ifdef __cplusplus |
24 | extern "C" |
25 | { |
26 | #endif /* __cplusplus */ |
27 | |
28 | /** MARK: - handle-scope-allocator.c */ |
29 | typedef struct jerryx_handle_scope_pool_s jerryx_handle_scope_pool_t; |
30 | /** |
31 | * A linear allocating memory pool for type jerryx_handle_scope_t, |
32 | * in which allocated item shall be released in reversed order of allocation |
33 | */ |
34 | struct jerryx_handle_scope_pool_s |
35 | { |
36 | jerryx_handle_scope_t prelist[JERRYX_SCOPE_PRELIST_SIZE]; /**< inlined handle scopes in the pool */ |
37 | size_t count; /**< number of handle scopes in the pool */ |
38 | jerryx_handle_scope_dynamic_t *start; /**< start address of dynamically allocated handle scope list */ |
39 | }; |
40 | |
41 | jerryx_handle_scope_t * |
42 | jerryx_handle_scope_get_parent (jerryx_handle_scope_t *scope); |
43 | |
44 | jerryx_handle_scope_t * |
45 | jerryx_handle_scope_get_child (jerryx_handle_scope_t *scope); |
46 | |
47 | jerryx_handle_scope_t * |
48 | jerryx_handle_scope_alloc (void); |
49 | |
50 | void |
51 | jerryx_handle_scope_free (jerryx_handle_scope_t *scope); |
52 | /** MARK: - END handle-scope-allocator.c */ |
53 | |
54 | /** MARK: - handle-scope.c */ |
55 | void |
56 | jerryx_handle_scope_release_handles (jerryx_handle_scope scope); |
57 | |
58 | jerry_value_t |
59 | jerryx_hand_scope_escape_handle_from_prelist (jerryx_handle_scope scope, size_t idx); |
60 | |
61 | jerry_value_t |
62 | jerryx_handle_scope_add_handle_to (jerryx_handle_t *handle, jerryx_handle_scope scope); |
63 | |
64 | jerryx_handle_scope_status |
65 | jerryx_escape_handle_internal (jerryx_escapable_handle_scope scope, |
66 | jerry_value_t escapee, |
67 | jerry_value_t *result, |
68 | bool should_promote); |
69 | /** MARK: - END handle-scope.c */ |
70 | |
71 | #ifdef __cplusplus |
72 | } |
73 | #endif /* __cplusplus */ |
74 | #endif /* !JERRYX_HANDLE_SCOPE_INTERNAL_H */ |
75 | |