Kouhei Sutou
null+****@clear*****
Wed Dec 17 11:22:09 JST 2014
Kouhei Sutou 2014-12-17 11:22:09 +0900 (Wed, 17 Dec 2014) New Revision: d2caaa9a1148b5e98210d7f0afb701e538897034 https://github.com/groonga/groonga/commit/d2caaa9a1148b5e98210d7f0afb701e538897034 Message: mrb: bind grn_db Added files: lib/mrb/mrb_database.c lib/mrb/mrb_database.h Modified files: lib/ctx_impl_mrb.c lib/mrb/sources.am Modified: lib/ctx_impl_mrb.c (+2 -0) =================================================================== --- lib/ctx_impl_mrb.c 2014-12-17 11:08:40 +0900 (e13223f) +++ lib/ctx_impl_mrb.c 2014-12-17 11:22:09 +0900 (253989d) @@ -30,6 +30,7 @@ #include "mrb/mrb_void.h" #include "mrb/mrb_bulk.h" #include "mrb/mrb_obj.h" +#include "mrb/mrb_database.h" #include "mrb/mrb_column.h" #include "mrb/mrb_fixed_size_column.h" #include "mrb/mrb_variable_size_column.h" @@ -75,6 +76,7 @@ grn_ctx_impl_mrb_init_bindings(grn_ctx *ctx) grn_mrb_void_init(ctx); grn_mrb_bulk_init(ctx); grn_mrb_obj_init(ctx); + grn_mrb_database_init(ctx); grn_mrb_column_init(ctx); grn_mrb_fixed_size_column_init(ctx); grn_mrb_variable_size_column_init(ctx); Added: lib/mrb/mrb_database.c (+58 -0) 100644 =================================================================== --- /dev/null +++ lib/mrb/mrb_database.c 2014-12-17 11:22:09 +0900 (f027e05) @@ -0,0 +1,58 @@ +/* -*- c-basic-offset: 2 -*- */ +/* + Copyright(C) 2014 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 "../grn_ctx_impl.h" + +#ifdef GRN_WITH_MRUBY +#include <mruby.h> +#include <mruby/class.h> +#include <mruby/data.h> + +#include "mrb_database.h" + +static struct mrb_data_type mrb_grn_database_type = { + "Groonga::Database", + NULL +}; + +static mrb_value +mrb_grn_database_initialize(mrb_state *mrb, mrb_value self) +{ + mrb_value mrb_database_ptr; + + mrb_get_args(mrb, "o", &mrb_database_ptr); + DATA_TYPE(self) = &mrb_grn_database_type; + DATA_PTR(self) = mrb_cptr(mrb_database_ptr); + return self; +} + +void +grn_mrb_database_init(grn_ctx *ctx) +{ + grn_mrb_data *data = &(ctx->impl->mrb); + mrb_state *mrb = data->state; + struct RClass *module = data->module; + struct RClass *object_class = data->object_class; + struct RClass *klass; + + klass = mrb_define_class_under(mrb, module, "Database", object_class); + MRB_SET_INSTANCE_TT(klass, MRB_TT_DATA); + mrb_define_method(mrb, klass, "initialize", + mrb_grn_database_initialize, MRB_ARGS_REQ(1)); +} +#endif Added: lib/mrb/mrb_database.h (+34 -0) 100644 =================================================================== --- /dev/null +++ lib/mrb/mrb_database.h 2014-12-17 11:22:09 +0900 (fd319c5) @@ -0,0 +1,34 @@ +/* -*- c-basic-offset: 2 -*- */ +/* + Copyright(C) 2014 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_DATABASE_H +#define GRN_MRB_DATABASE_H + +#include "../grn_ctx.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void grn_mrb_database_init(grn_ctx *ctx); + +#ifdef __cplusplus +} +#endif + +#endif /* GRN_MRB_DATABASE_H */ Modified: lib/mrb/sources.am (+2 -0) =================================================================== --- lib/mrb/sources.am 2014-12-17 11:08:40 +0900 (947607c) +++ lib/mrb/sources.am 2014-12-17 11:22:09 +0900 (10f0ba7) @@ -9,6 +9,8 @@ libgrnmrb_la_SOURCES = \ mrb_converter.h \ mrb_ctx.c \ mrb_ctx.h \ + mrb_database.c \ + mrb_database.h \ mrb_error.c \ mrb_error.h \ mrb_expr.c \ -------------- next part -------------- HTML����������������������������... 다운로드