1425bb815Sopenharmony_ci/* Copyright JS Foundation and other contributors, http://js.foundation 2425bb815Sopenharmony_ci * 3425bb815Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4425bb815Sopenharmony_ci * you may not use this file except in compliance with the License. 5425bb815Sopenharmony_ci * You may obtain a copy of the License at 6425bb815Sopenharmony_ci * 7425bb815Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8425bb815Sopenharmony_ci * 9425bb815Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10425bb815Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS 11425bb815Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12425bb815Sopenharmony_ci * See the License for the specific language governing permissions and 13425bb815Sopenharmony_ci * limitations under the License. 14425bb815Sopenharmony_ci */ 15425bb815Sopenharmony_ci 16425bb815Sopenharmony_ci#ifndef JERRYX_HANDLE_SCOPE_INTERNAL_H 17425bb815Sopenharmony_ci#define JERRYX_HANDLE_SCOPE_INTERNAL_H 18425bb815Sopenharmony_ci 19425bb815Sopenharmony_ci#include "jerryscript.h" 20425bb815Sopenharmony_ci#include "jerryscript-port.h" 21425bb815Sopenharmony_ci#include "jerryscript-ext/handle-scope.h" 22425bb815Sopenharmony_ci 23425bb815Sopenharmony_ci#ifdef __cplusplus 24425bb815Sopenharmony_ciextern "C" 25425bb815Sopenharmony_ci{ 26425bb815Sopenharmony_ci#endif /* __cplusplus */ 27425bb815Sopenharmony_ci 28425bb815Sopenharmony_ci#define JERRYX_HANDLE_SCOPE_ASSERT(x) \ 29425bb815Sopenharmony_ci do \ 30425bb815Sopenharmony_ci { \ 31425bb815Sopenharmony_ci if (!(x)) \ 32425bb815Sopenharmony_ci { \ 33425bb815Sopenharmony_ci jerry_port_log (JERRY_LOG_LEVEL_ERROR, \ 34425bb815Sopenharmony_ci "JerryXHandleScope: Assertion '%s' failed at %s(%s):%lu.\n", \ 35425bb815Sopenharmony_ci #x, \ 36425bb815Sopenharmony_ci __FILE__, \ 37425bb815Sopenharmony_ci __func__, \ 38425bb815Sopenharmony_ci (unsigned long) __LINE__); \ 39425bb815Sopenharmony_ci jerry_port_fatal (ERR_FAILED_INTERNAL_ASSERTION); \ 40425bb815Sopenharmony_ci } \ 41425bb815Sopenharmony_ci } while (0) 42425bb815Sopenharmony_ci 43425bb815Sopenharmony_ci/** MARK: - handle-scope-allocator.c */ 44425bb815Sopenharmony_citypedef struct jerryx_handle_scope_pool_s jerryx_handle_scope_pool_t; 45425bb815Sopenharmony_ci/** 46425bb815Sopenharmony_ci * A linear allocating memory pool for type jerryx_handle_scope_t, 47425bb815Sopenharmony_ci * in which allocated item shall be released in reversed order of allocation 48425bb815Sopenharmony_ci */ 49425bb815Sopenharmony_cistruct jerryx_handle_scope_pool_s 50425bb815Sopenharmony_ci{ 51425bb815Sopenharmony_ci jerryx_handle_scope_t prelist[JERRYX_SCOPE_PRELIST_SIZE]; /**< inlined handle scopes in the pool */ 52425bb815Sopenharmony_ci size_t count; /**< number of handle scopes in the pool */ 53425bb815Sopenharmony_ci jerryx_handle_scope_dynamic_t *start; /**< start address of dynamically allocated handle scope list */ 54425bb815Sopenharmony_ci}; 55425bb815Sopenharmony_ci 56425bb815Sopenharmony_cijerryx_handle_scope_t * 57425bb815Sopenharmony_cijerryx_handle_scope_get_parent (jerryx_handle_scope_t *scope); 58425bb815Sopenharmony_ci 59425bb815Sopenharmony_cijerryx_handle_scope_t * 60425bb815Sopenharmony_cijerryx_handle_scope_get_child (jerryx_handle_scope_t *scope); 61425bb815Sopenharmony_ci 62425bb815Sopenharmony_cijerryx_handle_scope_t * 63425bb815Sopenharmony_cijerryx_handle_scope_alloc (void); 64425bb815Sopenharmony_ci 65425bb815Sopenharmony_civoid 66425bb815Sopenharmony_cijerryx_handle_scope_free (jerryx_handle_scope_t *scope); 67425bb815Sopenharmony_ci/** MARK: - END handle-scope-allocator.c */ 68425bb815Sopenharmony_ci 69425bb815Sopenharmony_ci/** MARK: - handle-scope.c */ 70425bb815Sopenharmony_civoid 71425bb815Sopenharmony_cijerryx_handle_scope_release_handles (jerryx_handle_scope scope); 72425bb815Sopenharmony_ci 73425bb815Sopenharmony_cijerry_value_t 74425bb815Sopenharmony_cijerryx_hand_scope_escape_handle_from_prelist (jerryx_handle_scope scope, size_t idx); 75425bb815Sopenharmony_ci 76425bb815Sopenharmony_cijerry_value_t 77425bb815Sopenharmony_cijerryx_handle_scope_add_handle_to (jerryx_handle_t *handle, jerryx_handle_scope scope); 78425bb815Sopenharmony_ci 79425bb815Sopenharmony_cijerryx_handle_scope_status 80425bb815Sopenharmony_cijerryx_escape_handle_internal (jerryx_escapable_handle_scope scope, 81425bb815Sopenharmony_ci jerry_value_t escapee, 82425bb815Sopenharmony_ci jerry_value_t *result, 83425bb815Sopenharmony_ci bool should_promote); 84425bb815Sopenharmony_ci/** MARK: - END handle-scope.c */ 85425bb815Sopenharmony_ci 86425bb815Sopenharmony_ci#ifdef __cplusplus 87425bb815Sopenharmony_ci} 88425bb815Sopenharmony_ci#endif /* __cplusplus */ 89425bb815Sopenharmony_ci#endif /* !JERRYX_HANDLE_SCOPE_INTERNAL_H */ 90