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/data.h>
25
26#include "mrb_patricia_trie.h"
27
28static struct mrb_data_type mrb_grn_patricia_trie_type = {
29 "Groonga::PatriciaTrie",
30 NULL
31};
32
33static mrb_value
34mrb_grn_patricia_trie_initialize(mrb_state *mrb, mrb_value self)
35{
36 mrb_value mrb_patricia_trie_ptr;
37
38 mrb_get_args(mrb, "o", &mrb_patricia_trie_ptr);
39 DATA_TYPE(self) = &mrb_grn_patricia_trie_type;
40 DATA_PTR(self) = mrb_cptr(mrb_patricia_trie_ptr);
41 return self;
42}
43
44void
45grn_mrb_patricia_trie_init(grn_ctx *ctx)
46{
47 grn_mrb_data *data = &(ctx->impl->mrb);
48 mrb_state *mrb = data->state;
49 struct RClass *module = data->module;
50 struct RClass *table_class;
51 struct RClass *klass;
52
53 table_class = mrb_class_get_under(mrb, module, "Table");
54 klass = mrb_define_class_under(mrb, module, "PatriciaTrie", table_class);
55 MRB_SET_INSTANCE_TT(klass, MRB_TT_DATA);
56 mrb_define_method(mrb, klass, "initialize",
57 mrb_grn_patricia_trie_initialize, MRB_ARGS_REQ(1));
58}
59#endif
60