[Groonga-commit] groonga/groonga at 4fc8145 [master] mrb: add Table#size

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Feb 3 13:05:51 JST 2015


Kouhei Sutou	2015-02-03 13:05:51 +0900 (Tue, 03 Feb 2015)

  New Revision: 4fc814518a70e9419a279d4b960aa9ef33a9b909
  https://github.com/groonga/groonga/commit/4fc814518a70e9419a279d4b960aa9ef33a9b909

  Message:
    mrb: add Table#size

  Modified files:
    lib/mrb/mrb_table.c

  Modified: lib/mrb/mrb_table.c (+15 -0)
===================================================================
--- lib/mrb/mrb_table.c    2015-02-03 12:51:54 +0900 (939ac6a)
+++ lib/mrb/mrb_table.c    2015-02-03 13:05:51 +0900 (d18298e)
@@ -38,6 +38,18 @@ mrb_grn_table_is_locked(mrb_state *mrb, mrb_value self)
   return mrb_bool_value(is_locked != 0);
 }
 
+static mrb_value
+mrb_grn_table_get_size(mrb_state *mrb, mrb_value self)
+{
+  grn_ctx *ctx = (grn_ctx *)mrb->ud;
+  unsigned int size;
+
+  size = grn_table_size(ctx, DATA_PTR(self));
+  grn_mrb_ctx_check(mrb);
+
+  return mrb_fixnum_value(size);
+}
+
 void
 grn_mrb_table_init(grn_ctx *ctx)
 {
@@ -52,5 +64,8 @@ grn_mrb_table_init(grn_ctx *ctx)
 
   mrb_define_method(mrb, klass, "locked?",
                     mrb_grn_table_is_locked, MRB_ARGS_NONE());
+
+  mrb_define_method(mrb, klass, "size",
+                    mrb_grn_table_get_size, MRB_ARGS_NONE());
 }
 #endif
-------------- next part --------------
HTML����������������������������...
다운로드 



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