Skip to content

Commit

Permalink
mrb: add Table#locked?
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Dec 28, 2014
1 parent aeefd6c commit d95a886
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/mrb/mrb_table.c
Expand Up @@ -21,9 +21,23 @@
#ifdef GRN_WITH_MRUBY
#include <mruby.h>
#include <mruby/class.h>
#include <mruby/data.h>

#include "mrb_ctx.h"
#include "mrb_table.h"

static mrb_value
mrb_grn_table_is_locked(mrb_state *mrb, mrb_value self)
{
grn_ctx *ctx = (grn_ctx *)mrb->ud;
unsigned int is_locked;

is_locked = grn_obj_is_locked(ctx, DATA_PTR(self));
grn_mrb_ctx_check(mrb);

return mrb_bool_value(is_locked != 0);
}

void
grn_mrb_table_init(grn_ctx *ctx)
{
Expand All @@ -35,5 +49,8 @@ grn_mrb_table_init(grn_ctx *ctx)

klass = mrb_define_class_under(mrb, module, "Table", object_class);
MRB_SET_INSTANCE_TT(klass, MRB_TT_DATA);

mrb_define_method(mrb, klass, "locked?",
mrb_grn_table_is_locked, MRB_ARGS_NONE());
}
#endif

0 comments on commit d95a886

Please sign in to comment.