Kouhei Sutou
null+****@clear*****
Wed Feb 25 14:07:22 JST 2015
Kouhei Sutou 2015-02-25 14:07:22 +0900 (Wed, 25 Feb 2015) New Revision: 946f2b6bc365762fd64b6b0ea0aa926a44c46e9c https://github.com/groonga/groonga/commit/946f2b6bc365762fd64b6b0ea0aa926a44c46e9c Message: mrb: add ObjectFlags Added files: lib/mrb/mrb_object_flags.c lib/mrb/mrb_object_flags.h Modified files: lib/mrb/sources.am Added: lib/mrb/mrb_object_flags.c (+95 -0) 100644 =================================================================== --- /dev/null +++ lib/mrb/mrb_object_flags.c 2015-02-25 14:07:22 +0900 (c8accad) @@ -0,0 +1,95 @@ +/* -*- c-basic-offset: 2 -*- */ +/* + Copyright(C) 2015 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 "../grn_ctx_impl.h" + +#ifdef GRN_WITH_MRUBY +# include <mruby.h> +# include <mruby/string.h> +# include <mruby/class.h> +# include <mruby/data.h> + +# include "../grn_mrb.h" +# include "mrb_object.h" +# include "mrb_operator.h" +# include "mrb_converter.h" + +void +grn_mrb_object_flags_init(grn_ctx *ctx) +{ + grn_mrb_data *data = &(ctx->impl->mrb); + mrb_state *mrb = data->state; + struct RClass *module = data->module; + struct RClass *flags_module; + + flags_module = mrb_define_module_under(mrb, module, "ObjectFlags"); + +#define MRB_DEFINE_FLAG(name) \ + mrb_define_const(mrb, flags_module, #name, \ + mrb_fixnum_value(GRN_OBJ_ ## name)) + + MRB_DEFINE_FLAG(TABLE_TYPE_MASK); + MRB_DEFINE_FLAG(TABLE_HASH_KEY); + MRB_DEFINE_FLAG(TABLE_PAT_KEY); + MRB_DEFINE_FLAG(TABLE_DAT_KEY); + MRB_DEFINE_FLAG(TABLE_NO_KEY); + + MRB_DEFINE_FLAG(KEY_MASK); + MRB_DEFINE_FLAG(KEY_UINT); + MRB_DEFINE_FLAG(KEY_INT); + MRB_DEFINE_FLAG(KEY_FLOAT); + MRB_DEFINE_FLAG(KEY_GEO_POINT); + + MRB_DEFINE_FLAG(KEY_WITH_SIS); + MRB_DEFINE_FLAG(KEY_NORMALIZE); + + MRB_DEFINE_FLAG(COLUMN_TYPE_MASK); + MRB_DEFINE_FLAG(COLUMN_SCALAR); + MRB_DEFINE_FLAG(COLUMN_VECTOR); + MRB_DEFINE_FLAG(COLUMN_INDEX); + + MRB_DEFINE_FLAG(COMPRESS_MASK); + MRB_DEFINE_FLAG(COMPRESS_NONE); + MRB_DEFINE_FLAG(COMPRESS_ZLIB); + MRB_DEFINE_FLAG(COMPRESS_LZ4); + + MRB_DEFINE_FLAG(WITH_SECTION); + MRB_DEFINE_FLAG(WITH_WEIGHT); + MRB_DEFINE_FLAG(WITH_POSITION); + MRB_DEFINE_FLAG(RING_BUFFER); + + MRB_DEFINE_FLAG(UNIT_MASK); + MRB_DEFINE_FLAG(UNIT_DOCUMENT_NONE); + MRB_DEFINE_FLAG(UNIT_DOCUMENT_SECTION); + MRB_DEFINE_FLAG(UNIT_DOCUMENT_POSITION); + MRB_DEFINE_FLAG(UNIT_SECTION_NONE); + MRB_DEFINE_FLAG(UNIT_SECTION_POSITION); + MRB_DEFINE_FLAG(UNIT_POSITION_NONE); + MRB_DEFINE_FLAG(UNIT_USERDEF_DOCUMENT); + MRB_DEFINE_FLAG(UNIT_USERDEF_SECTION); + MRB_DEFINE_FLAG(UNIT_USERDEF_POSITION); + + MRB_DEFINE_FLAG(NO_SUBREC); + MRB_DEFINE_FLAG(WITH_SUBREC); + + MRB_DEFINE_FLAG(KEY_VAR_SIZE); + + MRB_DEFINE_FLAG(TEMPORARY); + MRB_DEFINE_FLAG(PERSISTENT); +} +#endif /* GRN_WITH_MRUBY */ Added: lib/mrb/mrb_object_flags.h (+34 -0) 100644 =================================================================== --- /dev/null +++ lib/mrb/mrb_object_flags.h 2015-02-25 14:07:22 +0900 (60c8222) @@ -0,0 +1,34 @@ +/* -*- c-basic-offset: 2 -*- */ +/* + Copyright(C) 2015 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_OBJECT_FLAGS_H +#define GRN_MRB_OBJECT_FLAGS_H + +#include "../grn_ctx.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void grn_mrb_object_flags_init(grn_ctx *ctx); + +#ifdef __cplusplus +} +#endif + +#endif /* GRN_MRB_OBJECT_FLAGS_H */ Modified: lib/mrb/sources.am (+2 -0) =================================================================== --- lib/mrb/sources.am 2015-02-24 21:21:09 +0900 (0613360) +++ lib/mrb/sources.am 2015-02-25 14:07:22 +0900 (5cda570) @@ -39,6 +39,8 @@ libgrnmrb_la_SOURCES = \ mrb_logger.h \ mrb_object.c \ mrb_object.h \ + mrb_object_flags.c \ + mrb_object_flags.h \ mrb_operator.c \ mrb_operator.h \ mrb_options.c \ -------------- next part -------------- HTML����������������������������...Download