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_IMPL_H 17#define JERRYX_AUTORELEASE_IMPL_H 18 19#include "jerryscript.h" 20 21#ifdef __GNUC__ 22/* 23 * Calls jerry_release_value (*value). 24 * The GCC __cleanup__ function must take a pointer to the variable to clean up. 25 * 26 * @return void 27 */ 28static inline void 29jerryx_autorelease_cleanup (const jerry_value_t *value) /**< jerry value */ 30{ 31 jerry_release_value (*value); 32} /* jerryx_autorelease_cleanup */ 33 34#define __JERRYX_AR_VALUE_T_IMPL const jerry_value_t __attribute__ ((__cleanup__(jerryx_autorelease_cleanup))) 35#else /* !__GNUC__ */ 36/* TODO: for other compilers */ 37#error "No autorelease implementation for your compiler!" 38#endif /* __GNUC__ */ 39 40#endif /* !JERRYX_AUTORELEASE_IMPL_H */ 41