1/* -*- c-basic-offset: 2 -*- */
2/*
3 Copyright(C) 2014 Brazil
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License version 2.1 as published by the Free Software Foundation.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this library; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17*/
18
19#include "../grn_ctx_impl.h"
20
21#ifdef GRN_WITH_MRUBY
22#include <mruby.h>
23#include <mruby/class.h>
24#include <mruby/variable.h>
25#include <mruby/data.h>
26
27#include "../grn_db.h"
28#include "mrb_void.h"
29
30static struct mrb_data_type mrb_grn_void_type = {
31 "Groonga::Void",
32 NULL
33};
34
35static mrb_value
36mrb_grn_void_initialize(mrb_state *mrb, mrb_value self)
37{
38 mrb_value mrb_void_ptr;
39
40 mrb_get_args(mrb, "o", &mrb_void_ptr);
41 DATA_TYPE(self) = &mrb_grn_void_type;
42 DATA_PTR(self) = mrb_cptr(mrb_void_ptr);
43 return self;
44}
45
46void
47grn_mrb_void_init(grn_ctx *ctx)
48{
49 grn_mrb_data *data = &(ctx->impl->mrb);
50 mrb_state *mrb = data->state;
51 struct RClass *module = data->module;
52 struct RClass *klass;
53
54 klass = mrb_define_class_under(mrb, module, "Void", mrb->object_class);
55 MRB_SET_INSTANCE_TT(klass, MRB_TT_DATA);
56 mrb_define_method(mrb, klass, "initialize",
57 mrb_grn_void_initialize, MRB_ARGS_REQ(1));
58}
59#endif
60