Navigation Menu

Skip to content

Commit

Permalink
mrb: bind bulk
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Jun 8, 2014
1 parent 12a6b93 commit 2e6e3ae
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/ctx_impl_mrb.c
@@ -1,6 +1,6 @@
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2013 Brazil
Copyright(C) 2013-2014 Brazil
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
Expand All @@ -21,6 +21,7 @@

#include "mrb.h"
#include "mrb/mrb_ctx.h"
#include "mrb/mrb_bulk.h"
#include "mrb/mrb_obj.h"
#include "mrb/mrb_column.h"
#include "mrb/mrb_fixed_size_column.h"
Expand All @@ -40,6 +41,7 @@ grn_ctx_impl_mrb_init_bindings(grn_ctx *ctx)
ctx->impl->mrb.module = mrb_define_module(mrb, "Groonga");

grn_mrb_ctx_init(ctx);
grn_mrb_bulk_init(ctx);
grn_mrb_obj_init(ctx);
grn_mrb_column_init(ctx);
grn_mrb_fixed_size_column_init(ctx);
Expand Down
59 changes: 59 additions & 0 deletions lib/mrb/mrb_bulk.c
@@ -0,0 +1,59 @@
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2014 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 "../ctx_impl.h"

#ifdef GRN_WITH_MRUBY
#include <mruby.h>
#include <mruby/class.h>
#include <mruby/variable.h>
#include <mruby/data.h>

#include "../db.h"
#include "mrb_bulk.h"

static struct mrb_data_type mrb_grn_bulk_type = {
"Groonga::Bulk",
NULL
};

static mrb_value
mrb_grn_bulk_initialize(mrb_state *mrb, mrb_value self)
{
mrb_value mrb_bulk_ptr;

mrb_get_args(mrb, "o", &mrb_bulk_ptr);
DATA_TYPE(self) = &mrb_grn_bulk_type;
DATA_PTR(self) = mrb_cptr(mrb_bulk_ptr);
return self;
}

void
grn_mrb_bulk_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, "Bulk", mrb->object_class);
MRB_SET_INSTANCE_TT(klass, MRB_TT_DATA);
mrb_define_method(mrb, klass, "initialize",
mrb_grn_bulk_initialize, MRB_ARGS_REQ(1));
}
#endif
35 changes: 35 additions & 0 deletions lib/mrb/mrb_bulk.h
@@ -0,0 +1,35 @@
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2014 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_BULK_H
#define GRN_MRB_BULK_H

#include "../ctx.h"
#include "../db.h"

#ifdef __cplusplus
extern "C" {
#endif

void grn_mrb_bulk_init(grn_ctx *ctx);

#ifdef __cplusplus
}
#endif

#endif /* GRN_MRB_BULK_H */
2 changes: 2 additions & 0 deletions lib/mrb/sources.am
@@ -1,6 +1,8 @@
libgrnmrb_la_SOURCES = \
mrb_accessor.c \
mrb_accessor.h \
mrb_bulk.c \
mrb_bulk.h \
mrb_column.c \
mrb_column.h \
mrb_converter.c \
Expand Down

0 comments on commit 2e6e3ae

Please sign in to comment.