Kouhei Sutou
null+****@clear*****
Tue Feb 10 00:02:36 JST 2015
Kouhei Sutou 2015-02-10 00:02:36 +0900 (Tue, 10 Feb 2015) New Revision: 6986097a21631f828350d4f9f87215616ff5c887 https://github.com/groonga/groonga/commit/6986097a21631f828350d4f9f87215616ff5c887 Message: mrb: add Object#temporary? and #persistent? Modified files: lib/mrb/mrb_object.c Modified: lib/mrb/mrb_object.c (+27 -0) =================================================================== --- lib/mrb/mrb_object.c 2015-02-09 22:55:48 +0900 (2bbf60d) +++ lib/mrb/mrb_object.c 2015-02-10 00:02:36 +0900 (60398b9) @@ -139,6 +139,28 @@ object_close(mrb_state *mrb, mrb_value self) return mrb_nil_value(); } +static mrb_value +object_is_temporary(mrb_state *mrb, mrb_value self) +{ + grn_obj *object; + grn_obj_flags flags; + + object = DATA_PTR(self); + flags = object->header.flags; + return mrb_bool_value((flags & GRN_OBJ_PERSISTENT) != GRN_OBJ_PERSISTENT); +} + +static mrb_value +object_is_persistent(mrb_state *mrb, mrb_value self) +{ + grn_obj *object; + grn_obj_flags flags; + + object = DATA_PTR(self); + flags = object->header.flags; + return mrb_bool_value((flags & GRN_OBJ_PERSISTENT) == GRN_OBJ_PERSISTENT); +} + void grn_mrb_object_init(grn_ctx *ctx) { @@ -160,6 +182,11 @@ grn_mrb_object_init(grn_ctx *ctx) mrb_define_method(mrb, klass, "==", object_equal, MRB_ARGS_REQ(1)); mrb_define_method(mrb, klass, "close", object_close, MRB_ARGS_NONE()); + mrb_define_method(mrb, klass, "temporary?", object_is_temporary, + MRB_ARGS_NONE()); + mrb_define_method(mrb, klass, "persistent?", object_is_persistent, + MRB_ARGS_NONE()); + grn_mrb_load(ctx, "index_info.rb"); } #endif -------------- next part -------------- HTML����������������������������... Download