Kouhei Sutou
null+****@clear*****
Sun Dec 28 21:17:33 JST 2014
Kouhei Sutou 2014-12-28 21:17:33 +0900 (Sun, 28 Dec 2014) New Revision: 196e10ad4b4b24e12c346842dc4cc80fb3415b1c https://github.com/groonga/groonga/commit/196e10ad4b4b24e12c346842dc4cc80fb3415b1c Message: mrb: bind Groonga::Type Added files: lib/mrb/mrb_type.c lib/mrb/mrb_type.h Modified files: lib/ctx_impl_mrb.c lib/mrb/mrb_converter.c lib/mrb/sources.am Modified: lib/ctx_impl_mrb.c (+2 -0) =================================================================== --- lib/ctx_impl_mrb.c 2014-12-28 21:12:31 +0900 (5e048f8) +++ lib/ctx_impl_mrb.c 2014-12-28 21:17:33 +0900 (0f9ef2a) @@ -37,6 +37,7 @@ #include "mrb/mrb_fixed_size_column.h" #include "mrb/mrb_variable_size_column.h" #include "mrb/mrb_index_column.h" +#include "mrb/mrb_type.h" #include "mrb/mrb_expr.h" #include "mrb/mrb_accessor.h" #include "mrb/mrb_procedure.h" @@ -107,6 +108,7 @@ grn_ctx_impl_mrb_init_bindings(grn_ctx *ctx) grn_mrb_fixed_size_column_init(ctx); grn_mrb_variable_size_column_init(ctx); grn_mrb_index_column_init(ctx); + grn_mrb_type_init(ctx); grn_mrb_expr_init(ctx); grn_mrb_accessor_init(ctx); grn_mrb_procedure_init(ctx); Modified: lib/mrb/mrb_converter.c (+3 -0) =================================================================== --- lib/mrb/mrb_converter.c 2014-12-28 21:12:31 +0900 (5ec439b) +++ lib/mrb/mrb_converter.c 2014-12-28 21:17:33 +0900 (48cd507) @@ -49,6 +49,9 @@ grn_mrb_class_from_grn_obj(mrb_state *mrb, grn_obj *object) case GRN_COLUMN_INDEX : klass = mrb_class_get_under(mrb, data->module, "IndexColumn"); break; + case GRN_TYPE : + klass = mrb_class_get_under(mrb, data->module, "Type"); + break; case GRN_EXPR : klass = mrb_class_get_under(mrb, data->module, "Expression"); break; Added: lib/mrb/mrb_type.c (+60 -0) 100644 =================================================================== --- /dev/null +++ lib/mrb/mrb_type.c 2014-12-28 21:17:33 +0900 (9fe602e) @@ -0,0 +1,60 @@ +/* -*- 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_ctx.h" +#include "mrb_type.h" + +static struct mrb_data_type mrb_grn_type_type = { + "Groonga::Type", + NULL +}; + +static mrb_value +mrb_grn_type_initialize(mrb_state *mrb, mrb_value self) +{ + mrb_value mrb_type_ptr; + + mrb_get_args(mrb, "o", &mrb_type_ptr); + DATA_TYPE(self) = &mrb_grn_type_type; + DATA_PTR(self) = mrb_cptr(mrb_type_ptr); + return self; +} + +void +grn_mrb_type_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, "Type", object_class); + MRB_SET_INSTANCE_TT(klass, MRB_TT_DATA); + + mrb_define_method(mrb, klass, "initialize", + mrb_grn_type_initialize, MRB_ARGS_REQ(1)); +} +#endif Added: lib/mrb/mrb_type.h (+34 -0) 100644 =================================================================== --- /dev/null +++ lib/mrb/mrb_type.h 2014-12-28 21:17:33 +0900 (f861674) @@ -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_TYPE_H +#define GRN_MRB_TYPE_H + +#include "../grn_ctx.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void grn_mrb_type_init(grn_ctx *ctx); + +#ifdef __cplusplus +} +#endif + +#endif /* GRN_MRB_TYPE_H */ Modified: lib/mrb/sources.am (+2 -0) =================================================================== --- lib/mrb/sources.am 2014-12-28 21:12:31 +0900 (9b8d18b) +++ lib/mrb/sources.am 2014-12-28 21:17:33 +0900 (34d9763) @@ -35,6 +35,8 @@ libgrnmrb_la_SOURCES = \ mrb_table.h \ mrb_table_cursor.c \ mrb_table_cursor.h \ + mrb_type.c \ + mrb_type.h \ mrb_variable_size_column.c \ mrb_variable_size_column.h \ mrb_void.c \ -------------- next part -------------- HTML����������������������������... Download