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_AUTORELEASE_H 17#define JERRYX_AUTORELEASE_H 18 19#ifdef __cplusplus 20extern "C" 21{ 22#endif /* __cplusplus */ 23 24#include "autorelease.impl.h" 25 26/* 27 * Macro for `const jerry_value_t` for which jerry_release_value () is 28 * automatically called when the variable goes out of scope. 29 * 30 * Example usage: 31 * static void foo (bool enable) 32 * { 33 * JERRYX_AR_VALUE_T bar = jerry_create_string (...); 34 * 35 * if (enable) { 36 * JERRYX_AR_VALUE_T baz = jerry_get_global_object (); 37 * 38 * // ... 39 * 40 * // jerry_release_value (baz) and jerry_release_value (bar) is called automatically before 41 * // returning, because `baz` and `bar` go out of scope. 42 * return; 43 * } 44 * 45 * // jerry_release_value (bar) is called automatically when the function returns, 46 * // because `bar` goes out of scope. 47 * } 48 */ 49#define JERRYX_AR_VALUE_T __JERRYX_AR_VALUE_T_IMPL 50 51#ifdef __cplusplus 52} 53#endif /* __cplusplus */ 54#endif /* !JERRYX_AUTORELEASE_H */ 55