Kouhei Sutou
null+****@clear*****
Sun Dec 28 23:41:08 JST 2014
Kouhei Sutou 2014-12-28 23:41:08 +0900 (Sun, 28 Dec 2014) New Revision: a10a76c57d4c8b727c0abe5787c047a3baeb00e2 https://github.com/groonga/groonga/commit/a10a76c57d4c8b727c0abe5787c047a3baeb00e2 Message: mrb: add Groonga::Array Added files: lib/mrb/mrb_array.c lib/mrb/mrb_array.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 23:35:38 +0900 (6a06b61) +++ lib/ctx_impl_mrb.c 2014-12-28 23:41:08 +0900 (1f6b60e) @@ -32,6 +32,7 @@ #include "mrb/mrb_object.h" #include "mrb/mrb_database.h" #include "mrb/mrb_table.h" +#include "mrb/mrb_array.h" #include "mrb/mrb_hash_table.h" #include "mrb/mrb_patricia_trie.h" #include "mrb/mrb_column.h" @@ -105,6 +106,7 @@ grn_ctx_impl_mrb_init_bindings(grn_ctx *ctx) grn_mrb_object_init(ctx); grn_mrb_database_init(ctx); grn_mrb_table_init(ctx); + grn_mrb_array_init(ctx); grn_mrb_hash_table_init(ctx); grn_mrb_patricia_trie_init(ctx); grn_mrb_column_init(ctx); Added: lib/mrb/mrb_array.c (+60 -0) 100644 =================================================================== --- /dev/null +++ lib/mrb/mrb_array.c 2014-12-28 23:41:08 +0900 (f19bcfa) @@ -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_array.h" + +static struct mrb_data_type mrb_grn_array_type = { + "Groonga::Array", + NULL +}; + +static mrb_value +mrb_grn_array_initialize(mrb_state *mrb, mrb_value self) +{ + mrb_value mrb_array_ptr; + + mrb_get_args(mrb, "o", &mrb_array_ptr); + DATA_TYPE(self) = &mrb_grn_array_type; + DATA_PTR(self) = mrb_cptr(mrb_array_ptr); + return self; +} + +void +grn_mrb_array_init(grn_ctx *ctx) +{ + grn_mrb_data *data = &(ctx->impl->mrb); + mrb_state *mrb = data->state; + struct RClass *module = data->module; + struct RClass *table_class; + struct RClass *klass; + + table_class = mrb_class_get_under(mrb, module, "Table"); + klass = mrb_define_class_under(mrb, module, "Array", table_class); + MRB_SET_INSTANCE_TT(klass, MRB_TT_DATA); + + mrb_define_method(mrb, klass, "initialize", + mrb_grn_array_initialize, MRB_ARGS_REQ(1)); +} +#endif Added: lib/mrb/mrb_array.h (+34 -0) 100644 =================================================================== --- /dev/null +++ lib/mrb/mrb_array.h 2014-12-28 23:41:08 +0900 (0622816) @@ -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_ARRAY_H +#define GRN_MRB_ARRAY_H + +#include "../grn_ctx.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void grn_mrb_array_init(grn_ctx *ctx); + +#ifdef __cplusplus +} +#endif + +#endif /* GRN_MRB_ARRAY_H */ Modified: lib/mrb/mrb_converter.c (+3 -0) =================================================================== --- lib/mrb/mrb_converter.c 2014-12-28 23:35:38 +0900 (6ecfabf) +++ lib/mrb/mrb_converter.c 2014-12-28 23:41:08 +0900 (6612ea2) @@ -58,6 +58,9 @@ grn_mrb_class_from_grn_obj(mrb_state *mrb, grn_obj *object) case GRN_EXPR : klass = mrb_class_get_under(mrb, data->module, "Expression"); break; + case GRN_TABLE_NO_KEY : + klass = mrb_class_get_under(mrb, data->module, "Array"); + break; case GRN_TABLE_HASH_KEY : klass = mrb_class_get_under(mrb, data->module, "HashTable"); break; Modified: lib/mrb/sources.am (+2 -0) =================================================================== --- lib/mrb/sources.am 2014-12-28 23:35:38 +0900 (4b67805) +++ lib/mrb/sources.am 2014-12-28 23:41:08 +0900 (5e8384a) @@ -1,6 +1,8 @@ libgrnmrb_la_SOURCES = \ mrb_accessor.c \ mrb_accessor.h \ + mrb_array.c \ + mrb_array.h \ mrb_bulk.c \ mrb_bulk.h \ mrb_column.c \ -------------- next part -------------- HTML����������������������������... Télécharger