Kouhei Sutou
null+****@clear*****
Tue Jun 10 22:42:19 JST 2014
Kouhei Sutou 2014-06-10 22:42:19 +0900 (Tue, 10 Jun 2014) New Revision: 5f42e2d6b59202eb2252b354af6b1a7ec8cbf66d https://github.com/groonga/groonga/commit/5f42e2d6b59202eb2252b354af6b1a7ec8cbf66d Message: mrb: bind ExpressionCode#value Modified files: lib/mrb/mrb_expr.c lib/mrb/scripts/scan_info.rb Modified: lib/mrb/mrb_expr.c (+13 -6) =================================================================== --- lib/mrb/mrb_expr.c 2014-06-10 22:39:02 +0900 (1e9bde1) +++ lib/mrb/mrb_expr.c 2014-06-10 22:42:19 +0900 (d06f838) @@ -187,26 +187,22 @@ scan_info_build(grn_ctx *ctx, grn_obj *expr, int *n, switch (ec->value->header.type) { case GRN_ACCESSOR : { - mrb_value mrb_accessor; mrb_value mrb_ec; - mrb_accessor = grn_mrb_value_from_grn_obj(mrb, ec->value); mrb_ec = mrb_grn_expr_code_new(mrb, ec); mrb_funcall(mrb, mrb_si, "match_expr_resolve_index_accessor", - 2, mrb_accessor, mrb_ec); + 1, mrb_ec); } break; case GRN_COLUMN_FIX_SIZE : case GRN_COLUMN_VAR_SIZE : { - mrb_value mrb_column; mrb_value mrb_ec; - mrb_column = grn_mrb_value_from_grn_obj(mrb, ec->value); mrb_ec = mrb_grn_expr_code_new(mrb, ec); mrb_funcall(mrb, mrb_si, "match_expr_resolve_index_data_column", - 2, mrb_column, mrb_ec); + 1, mrb_ec); } break; case GRN_COLUMN_INDEX : @@ -514,6 +510,15 @@ mrb_grn_expr_code_get_weight(mrb_state *mrb, mrb_value self) } static mrb_value +mrb_grn_expr_code_get_value(mrb_state *mrb, mrb_value self) +{ + grn_expr_code *expr_code; + + expr_code = DATA_PTR(self); + return grn_mrb_value_from_grn_obj(mrb, expr_code->value); +} + +static mrb_value mrb_grn_expression_initialize(mrb_state *mrb, mrb_value self) { mrb_value mrb_expression_ptr; @@ -580,6 +585,8 @@ grn_mrb_expr_init(grn_ctx *ctx) mrb_grn_expr_code_initialize, MRB_ARGS_REQ(1)); mrb_define_method(mrb, klass, "weight", mrb_grn_expr_code_get_weight, MRB_ARGS_NONE()); + mrb_define_method(mrb, klass, "value", + mrb_grn_expr_code_get_value, MRB_ARGS_NONE()); klass = mrb_define_class_under(mrb, module, "Expression", object_class); MRB_SET_INSTANCE_TT(klass, MRB_TT_DATA); Modified: lib/mrb/scripts/scan_info.rb (+4 -2) =================================================================== --- lib/mrb/scripts/scan_info.rb 2014-06-10 22:39:02 +0900 (44c6e19) +++ lib/mrb/scripts/scan_info.rb 2014-06-10 22:42:19 +0900 (f9edae1) @@ -18,7 +18,8 @@ module Groonga nil end - def match_expr_resolve_index_accessor(accessor, expr_code) + def match_expr_resolve_index_accessor(expr_code) + accessor = expr_code.value self.flags |= Flags::ACCESSOR index_info = accessor.find_index(op) return if index_info.nil? @@ -29,7 +30,8 @@ module Groonga end end - def match_expr_resolve_index_data_column(column, expr_code) + def match_expr_resolve_index_data_column(expr_code) + column = expr_code.value index_info = column.find_index(op) return if index_info.nil? put_index(index_info.index, index_info.section_id, expr_code.weight) -------------- next part -------------- HTML����������������������������...Download