[Groonga-commit] groonga/groonga at a5dbb5b [master] mrb: bind grn_table_sort_key

Back to archive index

Kouhei Sutou null+****@clear*****
Sun Jun 28 23:18:44 JST 2015


Kouhei Sutou	2015-06-28 23:18:44 +0900 (Sun, 28 Jun 2015)

  New Revision: a5dbb5be74fcf2bc0b53194618d514b6d4234d55
  https://github.com/groonga/groonga/commit/a5dbb5be74fcf2bc0b53194618d514b6d4234d55

  Message:
    mrb: bind grn_table_sort_key
    
    It's not useful yet because there are no accessors.
    
    TODO:
    
      * Use it in Groonga::Table#sort

  Added files:
    lib/mrb/mrb_table_sort_key.c
    lib/mrb/mrb_table_sort_key.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    2015-06-28 23:03:35 +0900 (ef3e78e)
+++ lib/ctx_impl_mrb.c    2015-06-28 23:18:44 +0900 (9a357f4)
@@ -41,6 +41,7 @@
 # include "mrb/mrb_patricia_trie.h"
 # include "mrb/mrb_double_array_trie.h"
 # include "mrb/mrb_table_group_result.h"
+# include "mrb/mrb_table_sort_key.h"
 # include "mrb/mrb_column.h"
 # include "mrb/mrb_fixed_size_column.h"
 # include "mrb/mrb_variable_size_column.h"
@@ -144,6 +145,7 @@ grn_ctx_impl_mrb_init_bindings(grn_ctx *ctx)
   grn_mrb_patricia_trie_init(ctx);
   grn_mrb_double_array_trie_init(ctx);
   grn_mrb_table_group_result_init(ctx);
+  grn_mrb_table_sort_key_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_table_sort_key.c (+83 -0) 100644
===================================================================
--- /dev/null
+++ lib/mrb/mrb_table_sort_key.c    2015-06-28 23:18:44 +0900 (87966db)
@@ -0,0 +1,83 @@
+/* -*- c-basic-offset: 2 -*- */
+/*
+  Copyright(C) 2015 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 <mruby/hash.h>
+#include <mruby/array.h>
+#include <mruby/string.h>
+
+#include "mrb_ctx.h"
+#include "mrb_table_sort_key.h"
+
+static struct mrb_data_type mrb_grn_table_sort_key_type = {
+  "Groonga::TableSortKey",
+  mrb_free
+};
+
+static mrb_value
+mrb_grn_table_sort_key_initialize(mrb_state *mrb, mrb_value self)
+{
+  grn_table_sort_key *result;
+
+  DATA_TYPE(self) = &mrb_grn_table_sort_key_type;
+
+  result = mrb_calloc(mrb, 1, sizeof(grn_table_sort_key));
+  DATA_PTR(self) = result;
+
+  return self;
+}
+
+
+static mrb_value
+mrb_grn_table_sort_key_close(mrb_state *mrb, mrb_value self)
+{
+  grn_table_sort_key *result;
+
+  result = DATA_PTR(self);
+  if (result) {
+    mrb_free(mrb, result);
+    DATA_PTR(self) = NULL;
+  }
+
+  return mrb_nil_value();
+}
+
+void
+grn_mrb_table_sort_key_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, "TableSortKey",
+                                 mrb->object_class);
+  MRB_SET_INSTANCE_TT(klass, MRB_TT_DATA);
+
+  mrb_define_method(mrb, klass, "initialize",
+                    mrb_grn_table_sort_key_initialize, MRB_ARGS_NONE());
+
+  mrb_define_method(mrb, klass, "close",
+                    mrb_grn_table_sort_key_close, MRB_ARGS_NONE());
+}
+#endif

  Added: lib/mrb/mrb_table_sort_key.h (+34 -0) 100644
===================================================================
--- /dev/null
+++ lib/mrb/mrb_table_sort_key.h    2015-06-28 23:18:44 +0900 (1d56bcd)
@@ -0,0 +1,34 @@
+/* -*- c-basic-offset: 2 -*- */
+/*
+  Copyright(C) 2015 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_TABLE_SORT_KEY_H
+#define GRN_MRB_TABLE_SORT_KEY_H
+
+#include "../grn_ctx.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void grn_mrb_table_sort_key_init(grn_ctx *ctx);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GRN_MRB_TABLE_SORT_KEY_H */

  Modified: lib/mrb/sources.am (+2 -0)
===================================================================
--- lib/mrb/sources.am    2015-06-28 23:03:35 +0900 (bb74203)
+++ lib/mrb/sources.am    2015-06-28 23:18:44 +0900 (1b9860c)
@@ -57,6 +57,8 @@ libgrnmrb_la_SOURCES =				\
 	mrb_table_cursor_flags.h		\
 	mrb_table_group_result.c		\
 	mrb_table_group_result.h		\
+	mrb_table_sort_key.c			\
+	mrb_table_sort_key.h			\
 	mrb_type.c				\
 	mrb_type.h				\
 	mrb_variable_size_column.c		\
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index