Kouhei Sutou
null+****@clear*****
Wed Jan 16 16:47:14 JST 2013
Kouhei Sutou 2013-01-16 16:47:14 +0900 (Wed, 16 Jan 2013) New Revision: 14c95993b8fed43b4b8cc2bb39bcad7111cd2705 https://github.com/groonga/groonga/commit/14c95993b8fed43b4b8cc2bb39bcad7111cd2705 Merged 78e354e: Merge pull request #50 from groonga/mruby Log: mruby: extract mruby related code to another file Added files: lib/mrb.c lib/mrb.h Modified files: lib/ctx.c lib/ctx_impl.h lib/sources.am Modified: lib/ctx.c (+3 -6) =================================================================== --- lib/ctx.c 2013-01-15 14:13:16 +0900 (332f95b) +++ lib/ctx.c 2013-01-16 16:47:14 +0900 (29e2c09) @@ -25,6 +25,7 @@ #include "snip.h" #include "output.h" #include "normalizer_in.h" +#include "mrb.h" #include <stdio.h> #include <stdarg.h> #include <time.h> @@ -508,9 +509,7 @@ grn_ctx_impl_init(grn_ctx *ctx) msgpack_packer_init(&ctx->impl->msgpacker, ctx, grn_msgpack_buffer_write); #endif -#ifdef WITH_MRUBY - ctx->impl->mrb = mrb_open(); -#endif + grn_ctx_impl_mrb_init(ctx); } void @@ -596,9 +595,7 @@ grn_ctx_fin(grn_ctx *ctx) if (ctx->impl->finalizer) { ctx->impl->finalizer(ctx, 0, NULL, &(ctx->user_data)); } -#ifdef WITH_MRUBY - mrb_close(ctx->impl->mrb); -#endif + grn_ctx_impl_mrb_fin(ctx); grn_ctx_loader_clear(ctx); if (ctx->impl->parser) { grn_expr_parser_close(ctx); Modified: lib/ctx_impl.h (+0 -2) =================================================================== --- lib/ctx_impl.h 2013-01-15 14:13:16 +0900 (d1e9292) +++ lib/ctx_impl.h 2013-01-16 16:47:14 +0900 (e63ac38) @@ -32,8 +32,6 @@ #ifdef WITH_MRUBY # include <mruby.h> -# include <mruby/proc.h> -# include <mruby/compile.h> #endif #ifdef __cplusplus Added: lib/mrb.c (+49 -0) 100644 =================================================================== --- /dev/null +++ lib/mrb.c 2013-01-16 16:47:14 +0900 (0b3655b) @@ -0,0 +1,49 @@ +/* -*- c-basic-offset: 2 -*- */ +/* + Copyright(C) 2013 Brazil + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License version 2.1 as published by the Free Software Foundation. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "mrb.h" +#include "ctx_impl.h" + +#ifdef WITH_MRUBY +# include <mruby/proc.h> +# include <mruby/compile.h> +#endif + +#ifdef WITH_MRUBY +void +grn_ctx_impl_mrb_init(grn_ctx *ctx) +{ + ctx->impl->mrb = mrb_open(); +} + +void +grn_ctx_impl_mrb_fin(grn_ctx *ctx) +{ + mrb_close(ctx->impl->mrb); +} +#else +void +grn_ctx_impl_mrb_init(grn_ctx *ctx) +{ +} + +void +grn_ctx_impl_mrb_fin(grn_ctx *ctx) +{ +} +#endif Added: lib/mrb.h (+36 -0) 100644 =================================================================== --- /dev/null +++ lib/mrb.h 2013-01-16 16:47:14 +0900 (800aab6) @@ -0,0 +1,36 @@ +/* -*- c-basic-offset: 2 -*- */ +/* + Copyright(C) 2013 Brazil + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License version 2.1 as published by the Free Software Foundation. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef GRN_MRB_H +#define GRN_MRB_H + +#include "groonga_in.h" +#include "ctx.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void grn_ctx_impl_mrb_init(grn_ctx *ctx); +void grn_ctx_impl_mrb_fin(grn_ctx *ctx); + +#ifdef __cplusplus +} +#endif + +#endif /* GRN_MRB_H */ Modified: lib/sources.am (+2 -0) =================================================================== --- lib/sources.am 2013-01-15 14:13:16 +0900 (b1db3ab) +++ lib/sources.am 2013-01-16 16:47:14 +0900 (f1b6ceb) @@ -18,6 +18,8 @@ libgroonga_la_SOURCES = \ ii.h \ io.c \ io.h \ + mrb.c \ + mrb.h \ nfkc.c \ nfkc.h \ normalizer.c \ -------------- next part -------------- HTML����������������������������...다운로드