[Groonga-commit] groonga/groonga at 8e5dbc7 [master] mrb: add Groonga::IndexInfo

アーカイブの一覧に戻る

Kouhei Sutou null+****@clear*****
Tue May 27 23:57:25 JST 2014


Kouhei Sutou	2014-05-27 23:57:25 +0900 (Tue, 27 May 2014)

  New Revision: 8e5dbc75d2eaae2d1d06705fb5c40a0e46d2e524
  https://github.com/groonga/groonga/commit/8e5dbc75d2eaae2d1d06705fb5c40a0e46d2e524

  Message:
    mrb: add Groonga::IndexInfo

  Added files:
    lib/mrb/mrb_index_info.c
    lib/mrb/mrb_index_info.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-05-27 23:03:57 +0900 (e617225)
+++ lib/ctx_impl_mrb.c    2014-05-27 23:57:25 +0900 (0c7371b)
@@ -26,6 +26,7 @@
 #include "mrb/mrb_fixed_size_column.h"
 #include "mrb/mrb_expr.h"
 #include "mrb/mrb_accessor.h"
+#include "mrb/mrb_index_info.h"
 
 #ifdef GRN_WITH_MRUBY
 static void
@@ -42,6 +43,7 @@ grn_ctx_impl_mrb_init_bindings(grn_ctx *ctx)
   grn_mrb_fixed_size_column_init(ctx);
   grn_mrb_expr_init(ctx);
   grn_mrb_accessor_init(ctx);
+  grn_mrb_index_info_init(ctx);
 }
 
 static void

  Added: lib/mrb/mrb_index_info.c (+84 -0) 100644
===================================================================
--- /dev/null
+++ lib/mrb/mrb_index_info.c    2014-05-27 23:57:25 +0900 (1620fa5)
@@ -0,0 +1,84 @@
+/* -*- 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 "../ctx_impl.h"
+
+#ifdef GRN_WITH_MRUBY
+#include <mruby.h>
+#include <mruby/class.h>
+#include <mruby/variable.h>
+
+#include "../db.h"
+#include "mrb_index_info.h"
+
+mrb_value
+mrb_grn_index_info_new(mrb_state *mrb, grn_obj *index, int section_id)
+{
+  grn_ctx *ctx = (grn_ctx *)mrb->ud;
+  struct RClass *module = ctx->impl->mrb.module;
+  struct RClass *klass;
+  mrb_value args[2];
+
+  args[0] = mrb_cptr_value(mrb, index);
+  args[1] = mrb_fixnum_value(section_id);
+  klass = mrb_class_ptr(mrb_const_get(mrb, mrb_obj_value(module),
+                                      mrb_intern(mrb, "IndexInfo")));
+  return mrb_obj_new(mrb, klass, 2, args);
+}
+
+static mrb_value
+mrb_grn_index_info_initialize(mrb_state *mrb, mrb_value self)
+{
+  mrb_value index;
+  mrb_value section_id;
+
+  mrb_get_args(mrb, "oo", &index, &section_id);
+  mrb_iv_set(mrb, self, mrb_intern_cstr(mrb, "index"), index);
+  mrb_iv_set(mrb, self, mrb_intern_cstr(mrb, "section_id"), section_id);
+  return self;
+}
+
+static mrb_value
+mrb_grn_index_info_get_index(mrb_state *mrb, mrb_value self)
+{
+  return mrb_iv_get(mrb, self, mrb_intern_cstr(mrb, "index"));
+}
+
+static mrb_value
+mrb_grn_index_info_get_section_id(mrb_state *mrb, mrb_value self)
+{
+  return mrb_iv_get(mrb, self, mrb_intern_cstr(mrb, "section_id"));
+}
+
+void
+grn_mrb_index_info_init(grn_ctx *ctx)
+{
+  grn_mrb_data *data = &(ctx->impl->mrb);
+  mrb_state *mrb = data->state;
+  struct RClass *module = data->module;
+  struct RClass *klass;
+
+  klass = mrb_define_class_under(mrb, module, "IndexInfo", data->object_class);
+  mrb_define_method(mrb, klass, "initialize",
+                    mrb_grn_index_info_initialize, MRB_ARGS_REQ(2));
+  mrb_define_method(mrb, klass, "index",
+                    mrb_grn_index_info_get_index, MRB_ARGS_NONE());
+  mrb_define_method(mrb, klass, "section_id",
+                    mrb_grn_index_info_get_section_id, MRB_ARGS_NONE());
+}
+#endif

  Added: lib/mrb/mrb_index_info.h (+38 -0) 100644
===================================================================
--- /dev/null
+++ lib/mrb/mrb_index_info.h    2014-05-27 23:57:25 +0900 (9337c7f)
@@ -0,0 +1,38 @@
+/* -*- 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_INDEX_INFO_H
+#define GRN_MRB_INDEX_INFO_H
+
+#include "../ctx.h"
+#include "../db.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void grn_mrb_index_info_init(grn_ctx *ctx);
+#ifdef GRN_WITH_MRUBY
+mrb_value mrb_grn_index_info_new(mrb_state *mrb, grn_obj *index, int section_id);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GRN_MRB_INDEX_INFO_H */

  Modified: lib/mrb/sources.am (+2 -0)
===================================================================
--- lib/mrb/sources.am    2014-05-27 23:03:57 +0900 (aed8b94)
+++ lib/mrb/sources.am    2014-05-27 23:57:25 +0900 (7be8f72)
@@ -11,5 +11,7 @@ libgrnmrb_la_SOURCES =				\
 	mrb_expr.h				\
 	mrb_fixed_size_column.c			\
 	mrb_fixed_size_column.h			\
+	mrb_index_info.c			\
+	mrb_index_info.h			\
 	mrb_obj.c				\
 	mrb_obj.h
-------------- next part --------------
HTML����������������������������...
ダウンロード 



More information about the Groonga-commit mailing list
アーカイブの一覧に戻る