| 1 | /* |
| 2 | Copyright(C) 2019 Yasuhiro Horimoto <[email protected]> |
| 3 | |
| 4 | This library is free software; you can redistribute it and/or |
| 5 | modify it under the terms of the GNU Lesser General Public |
| 6 | License as published by the Free Software Foundation; either |
| 7 | version 2.1 of the License, or (at your option) any later version. |
| 8 | |
| 9 | This library is distributed in the hope that it will be useful, |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | Lesser General Public License for more details. |
| 13 | |
| 14 | You should have received a copy of the GNU Lesser General Public |
| 15 | License along with this library; if not, write to the Free Software |
| 16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 17 | */ |
| 18 | |
| 19 | #include "grn_ctx_impl.h"cxx . . $ `<file>/lib/grn_ctx_impl.h`/ |
| 20 | #include "grn_ctx_impl_lua.h"cxx . . $ `<file>/lib/grn_ctx_impl_lua.h`/ |
| 21 | |
| 22 | #ifdef GRN_WITH_LUAJIT |
| 23 | static void |
| 24 | grn_ctx_impl_lua_init_real(grn_ctx *ctx) |
| 25 | { |
| 26 | lua_State *lua; |
| 27 | |
| 28 | lua = lua_open(); |
| 29 | luaL_openlibs(lua); |
| 30 | ctx->impl->lua.state = lua; |
| 31 | } |
| 32 | |
| 33 | static void |
| 34 | grn_ctx_impl_lua_fin_real(grn_ctx * ctx) |
| 35 | { |
| 36 | if (ctx->impl->lua.state) { |
| 37 | lua_close(ctx->impl->lua.state); |
| 38 | ctx->impl->lua.state = NULL; |
| 39 | } |
| 40 | } |
| 41 | #else /* GRN_WITH_LUAJIT */ |
| 42 | static void |
| 43 | grn_ctx_impl_lua_init_realcxx . . $ grn_ctx_impl_lua_init_real(b578cd6e53d5fe91).(grn_ctxcxx . . $ grn_ctx# *ctx) |
| 44 | { |
| 45 | } |
| 46 | |
| 47 | static void |
| 48 | grn_ctx_impl_lua_fin_realcxx . . $ grn_ctx_impl_lua_fin_real(b578cd6e53d5fe91).(grn_ctxcxx . . $ grn_ctx# *ctx) |
| 49 | { |
| 50 | } |
| 51 | #endif /* GRN_WITH_LUAJIT */ |
| 52 | |
| 53 | void |
| 54 | grn_ctx_impl_lua_initcxx . . $ grn_ctx_impl_lua_init(b578cd6e53d5fe91).(grn_ctxcxx . . $ grn_ctx# *ctx) |
| 55 | { |
| 56 | ctx->implcxx . . $ _grn_ctx#impl.->luacxx . . $ _grn_ctx_impl#lua..initializedcxx . . $ _grn_lua_data#initialized. = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!; |
| 57 | grn_ctx_impl_lua_init_realcxx . . $ grn_ctx_impl_lua_init_real(b578cd6e53d5fe91).(ctx); |
| 58 | } |
| 59 | |
| 60 | void |
| 61 | grn_ctx_impl_lua_fincxx . . $ grn_ctx_impl_lua_fin(b578cd6e53d5fe91).(grn_ctxcxx . . $ grn_ctx# *ctx) |
| 62 | { |
| 63 | if (!ctx->implcxx . . $ _grn_ctx#impl.->luacxx . . $ _grn_ctx_impl#lua..initializedcxx . . $ _grn_lua_data#initialized.) { |
| 64 | return; |
| 65 | } |
| 66 | |
| 67 | ctx->implcxx . . $ _grn_ctx#impl.->luacxx . . $ _grn_ctx_impl#lua..initializedcxx . . $ _grn_lua_data#initialized. = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!; |
| 68 | grn_ctx_impl_lua_fin_realcxx . . $ grn_ctx_impl_lua_fin_real(b578cd6e53d5fe91).(ctx); |
| 69 | } |