[Groonga-commit] groonga/groonga at fb320f2 [master] mrb: add Object#check_corrupt and Object#corrupt?

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Jun 14 16:39:14 JST 2017


Kouhei Sutou	2017-06-14 16:39:14 +0900 (Wed, 14 Jun 2017)

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

  Message:
    mrb: add Object#check_corrupt and Object#corrupt?

  Modified files:
    lib/mrb/mrb_object.c
    lib/mrb/scripts/object.rb

  Modified: lib/mrb/mrb_object.c (+16 -0)
===================================================================
--- lib/mrb/mrb_object.c    2017-06-14 16:38:59 +0900 (af18261)
+++ lib/mrb/mrb_object.c    2017-06-14 16:39:14 +0900 (ffa2c55)
@@ -280,6 +280,19 @@ object_is_true(mrb_state *mrb, mrb_value self)
   return mrb_bool_value(grn_obj_is_true(ctx, object));
 }
 
+static mrb_value
+object_check_corrupt(mrb_state *mrb, mrb_value self)
+{
+  grn_ctx *ctx = (grn_ctx *)mrb->ud;
+  grn_obj *object;
+  grn_bool is_corrupt;
+
+  object = DATA_PTR(self);
+  is_corrupt = grn_obj_is_corrupt(ctx, object);
+  grn_mrb_ctx_check(mrb);
+  return mrb_bool_value(is_corrupt);
+}
+
 void
 grn_mrb_object_init(grn_ctx *ctx)
 {
@@ -325,6 +338,9 @@ grn_mrb_object_init(grn_ctx *ctx)
 
   mrb_define_method(mrb, klass, "true?", object_is_true, MRB_ARGS_NONE());
 
+  mrb_define_method(mrb, klass, "check_corrupt", object_check_corrupt,
+                    MRB_ARGS_NONE());
+
   grn_mrb_load(ctx, "index_info.rb");
 }
 #endif

  Modified: lib/mrb/scripts/object.rb (+7 -0)
===================================================================
--- lib/mrb/scripts/object.rb    2017-06-14 16:38:59 +0900 (d98b506)
+++ lib/mrb/scripts/object.rb    2017-06-14 16:39:14 +0900 (aa8e9e6)
@@ -7,5 +7,12 @@ module Groonga
     def range
       Context.instance[range_id]
     end
+
+    def corrupt?
+      check_corrupt
+      false
+    rescue
+      true
+    end
   end
 end
-------------- next part --------------
HTML����������������������������...
Download 



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