[Groonga-commit] ranguba/rroonga at 56eb328 [master] Use meaningful name

Back to archive index

Kouhei Sutou null+****@clear*****
Sun Apr 12 00:23:55 JST 2015


Kouhei Sutou	2015-04-12 00:23:55 +0900 (Sun, 12 Apr 2015)

  New Revision: 56eb328f7cacaf1ca27a8fa9b5322585d33ad8a2
  https://github.com/ranguba/rroonga/commit/56eb328f7cacaf1ca27a8fa9b5322585d33ad8a2

  Message:
    Use meaningful name

  Modified files:
    ext/groonga/extconf.rb
    ext/groonga/rb-grn-context.c
    ext/groonga/rb-grn-expression.c
    ext/groonga/rb-grn-index-column.c
    ext/groonga/rb-grn-patricia-trie.c
    ext/groonga/rb-grn-table-key-support.c
    ext/groonga/rb-grn-table.c
    ext/groonga/rb-grn.h
    ext/groonga/rb-groonga.c

  Modified: ext/groonga/extconf.rb (+1 -0)
===================================================================
--- ext/groonga/extconf.rb    2015-04-12 00:12:38 +0900 (fbfac57)
+++ ext/groonga/extconf.rb    2015-04-12 00:23:55 +0900 (ecc840f)
@@ -282,6 +282,7 @@ have_header("ruby/st.h") unless have_macro("HAVE_RUBY_ST_H", "ruby.h")
 have_func("rb_errinfo", "ruby.h")
 have_func("rb_sym2str", "ruby.h")
 have_func("rb_to_symbol", "ruby.h")
+have_func("rb_ary_new_from_args", "ruby.h")
 have_func("rb_ary_new_from_values", "ruby.h")
 have_type("enum ruby_value_type", "ruby.h")
 

  Modified: ext/groonga/rb-grn-context.c (+1 -1)
===================================================================
--- ext/groonga/rb-grn-context.c    2015-04-12 00:12:38 +0900 (5ab0a3d)
+++ ext/groonga/rb-grn-context.c    2015-04-12 00:23:55 +0900 (9c2019c)
@@ -817,7 +817,7 @@ rb_grn_context_receive (VALUE self)
     }
     rb_grn_context_check(context, self);
 
-    return rb_ary_new3(2, UINT2NUM(query_id), rb_result);
+    return rb_ary_new_from_args(2, UINT2NUM(query_id), rb_result);
 }
 
 static const char *

  Modified: ext/groonga/rb-grn-expression.c (+7 -3)
===================================================================
--- ext/groonga/rb-grn-expression.c    2015-04-12 00:12:38 +0900 (df8fcfc)
+++ ext/groonga/rb-grn-expression.c    2015-04-12 00:23:55 +0900 (bab6a76)
@@ -475,7 +475,10 @@ rb_grn_expression_parse (int argc, VALUE *argv, VALUE self)
     if (rc != GRN_SUCCESS) {
         VALUE related_object;
 
-        related_object = rb_ary_new3(2, self, rb_ary_new_from_values(argc, argv));
+        related_object =
+            rb_ary_new_from_args(2,
+                                 self,
+                                 rb_ary_new_from_values(argc, argv));
         exception = rb_grn_context_to_exception(context, related_object);
     }
     if (default_column_is_created)
@@ -694,7 +697,7 @@ rb_grn_expression_snippet (int argc, VALUE *argv, VALUE self)
     }
 
     if (TYPE(RARRAY_PTR(rb_tags)[0]) == T_STRING) {
-        rb_tags = rb_ary_new3(1, rb_tags);
+        rb_tags = rb_ary_new_from_args(1, rb_tags);
     }
 
     rb_tag_values = RARRAY_PTR(rb_tags);
@@ -740,7 +743,8 @@ rb_grn_expression_snippet (int argc, VALUE *argv, VALUE self)
                             (const char **)open_tags, open_tag_lengths,
                             (const char **)close_tags, close_tag_lengths,
                             mapping);
-    related_object = rb_ary_new3(2, self, rb_ary_new_from_values(argc, argv));
+    related_object =
+        rb_ary_new_from_args(2, self, rb_ary_new_from_values(argc, argv));
     rb_grn_context_check(context, related_object);
 
     return GRNOBJECT2RVAL(Qnil, context, snippet, GRN_TRUE);

  Modified: ext/groonga/rb-grn-index-column.c (+1 -1)
===================================================================
--- ext/groonga/rb-grn-index-column.c    2015-04-12 00:12:38 +0900 (59e07bd)
+++ ext/groonga/rb-grn-index-column.c    2015-04-12 00:23:55 +0900 (5e011ed)
@@ -709,7 +709,7 @@ static VALUE
 rb_grn_index_column_set_source (VALUE self, VALUE rb_source)
 {
     if (!RVAL2CBOOL(rb_obj_is_kind_of(rb_source, rb_cArray)))
-        rb_source = rb_ary_new3(1, rb_source);
+        rb_source = rb_ary_new_from_args(1, rb_source);
 
     return rb_grn_index_column_set_sources(self, rb_source);
 }

  Modified: ext/groonga/rb-grn-patricia-trie.c (+5 -5)
===================================================================
--- ext/groonga/rb-grn-patricia-trie.c    2015-04-12 00:12:38 +0900 (b3bf6ed)
+++ ext/groonga/rb-grn-patricia-trie.c    2015-04-12 00:23:55 +0900 (c219c61)
@@ -424,11 +424,11 @@ rb_grn_patricia_trie_scan (VALUE self, VALUE rb_string)
             term = rb_grn_context_rb_string_new(context,
                                                 string + hits[i].offset,
                                                 hits[i].length);
-            matched_info = rb_ary_new3(4,
-                                       record,
-                                       term,
-                                       UINT2NUM(hits[i].offset),
-                                       UINT2NUM(hits[i].length));
+            matched_info = rb_ary_new_from_args(4,
+                                                record,
+                                                term,
+                                                UINT2NUM(hits[i].offset),
+                                                UINT2NUM(hits[i].length));
             if (block_given) {
                 rb_yield(matched_info);
             } else {

  Modified: ext/groonga/rb-grn-table-key-support.c (+8 -4)
===================================================================
--- ext/groonga/rb-grn-table-key-support.c    2015-04-12 00:12:38 +0900 (c7ba3a3)
+++ ext/groonga/rb-grn-table-key-support.c    2015-04-12 00:23:55 +0900 (c17b30c)
@@ -525,7 +525,9 @@ rb_grn_table_key_support_array_set (VALUE self, VALUE rb_key, VALUE rb_values)
     if (id == GRN_ID_NIL) {
         rb_raise(rb_eGrnError,
                  "failed to add record: %s",
-                 rb_grn_inspect(rb_ary_new3(3, self, rb_key, rb_values)));
+                 rb_grn_inspect(rb_ary_new_from_args(3,
+                                                     self,
+                                                     rb_key, rb_values)));
     }
 
     data.self = self;
@@ -568,9 +570,11 @@ rb_grn_table_key_support_set_column_value (int argc, VALUE *argv, VALUE self)
     if (id == GRN_ID_NIL) {
         rb_raise(rb_eGrnError,
                  "failed to add record: %s",
-                 rb_grn_inspect(rb_ary_new3(4,
-                                            self, rb_key,
-                                            rb_name, rb_value)));
+                 rb_grn_inspect(rb_ary_new_from_args(4,
+                                                     self,
+                                                     rb_key,
+                                                     rb_name,
+                                                     rb_value)));
     }
 
     return rb_grn_table_set_column_value_raw(self, id, rb_name, rb_value);

  Modified: ext/groonga/rb-grn-table.c (+34 -15)
===================================================================
--- ext/groonga/rb-grn-table.c    2015-04-12 00:12:38 +0900 (3848717)
+++ ext/groonga/rb-grn-table.c    2015-04-12 00:23:55 +0900 (4f44287)
@@ -328,9 +328,12 @@ rb_grn_table_define_column (int argc, VALUE *argv, VALUE self)
     column = grn_column_create(context, table, name, name_size,
                                path, flags, value_type);
     if (context->rc) {
-        rb_grn_context_check(context,
-                             rb_ary_new3(2, self,
-                                         rb_ary_new_from_values(argc, argv)));
+        VALUE rb_related_object;
+        rb_related_object =
+            rb_ary_new_from_args(2,
+                                 self,
+                                 rb_ary_new_from_values(argc, argv));
+        rb_grn_context_check(context, rb_related_object);
     }
 
     rb_column = GRNCOLUMN2RVAL(Qnil, context, column, GRN_TRUE);
@@ -452,8 +455,10 @@ rb_grn_table_define_index_column (int argc, VALUE *argv, VALUE self)
     column = grn_column_create(context, table, name, name_size,
                                path, flags, value_type);
     if (context->rc) {
-        rb_grn_context_check(context,
-                             rb_ary_new3(2, self, rb_ary_new_from_values(argc, argv)));
+        VALUE rb_related_object;
+        rb_related_object =
+            rb_ary_new_from_args(2, self, rb_ary_new_from_values(argc, argv));
+        rb_grn_context_check(context, rb_related_object);
     }
 
     rb_column = GRNCOLUMN2RVAL(Qnil, context, column, GRN_TRUE);
@@ -1585,10 +1590,14 @@ rb_grn_table_get_value_convenience (int argc, VALUE *argv, VALUE self)
                             "id", &rb_option_id,
                             NULL);
         if (!(NIL_P(rb_option_id) || RVAL2CBOOL(rb_option_id))) {
+            VALUE rb_related_object;
+            rb_related_object =
+                rb_ary_new_from_args(2,
+                                     self,
+                                     rb_ary_new_from_values(argc, argv));
             rb_raise(rb_eArgError, ":id options must be true or nil: %s: %s",
                      rb_grn_inspect(rb_option_id),
-                     rb_grn_inspect(rb_ary_new3(2,
-                                                self, rb_ary_new_from_values(argc, argv))));
+                     rb_grn_inspect(rb_related_object));
         }
     }
 
@@ -1643,10 +1652,14 @@ rb_grn_table_set_value_convenience (int argc, VALUE *argv, VALUE self)
                             "id", &rb_option_id,
                             NULL);
         if (!(NIL_P(rb_option_id) || RVAL2CBOOL(rb_option_id))) {
+            VALUE rb_related_object;
+            rb_related_object =
+                rb_ary_new_from_args(2,
+                                     self,
+                                     rb_ary_new_from_values(argc, argv));
             rb_raise(rb_eArgError, ":id options must be true or nil: %s: %s",
                      rb_grn_inspect(rb_option_id),
-                     rb_grn_inspect(rb_ary_new3(2,
-                                                self, rb_ary_new_from_values(argc, argv))));
+                     rb_grn_inspect(rb_related_object));
         }
     }
 
@@ -1694,11 +1707,14 @@ rb_grn_table_get_column_value_convenience (int argc, VALUE *argv, VALUE self)
                             "id", &rb_option_id,
                             NULL);
         if (!(NIL_P(rb_option_id) || RVAL2CBOOL(rb_option_id))) {
+            VALUE rb_related_object;
+            rb_related_object =
+                rb_ary_new_from_args(2,
+                                     self,
+                                     rb_ary_new_from_values(argc, argv));
             rb_raise(rb_eArgError, ":id options must be true or nil: %s: %s",
                      rb_grn_inspect(rb_option_id),
-                     rb_grn_inspect(rb_ary_new3(2,
-                                                self,
-                                                rb_ary_new_from_values(argc, argv))));
+                     rb_grn_inspect(rb_related_object));
         }
     }
 
@@ -1895,11 +1911,14 @@ rb_grn_table_set_column_value_convenience (int argc, VALUE *argv, VALUE self)
                             "id", &rb_option_id,
                             NULL);
         if (!(NIL_P(rb_option_id) || RVAL2CBOOL(rb_option_id))) {
+            VALUE rb_related_object;
+            rb_related_object =
+                rb_ary_new_from_args(2,
+                                     self,
+                                     rb_ary_new_from_values(argc, argv));
             rb_raise(rb_eArgError, ":id options must be true or nil: %s: %s",
                      rb_grn_inspect(rb_option_id),
-                     rb_grn_inspect(rb_ary_new3(2,
-                                                self,
-                                                rb_ary_new_from_values(argc, argv))));
+                     rb_grn_inspect(rb_related_object));
         }
     }
 

  Modified: ext/groonga/rb-grn.h (+4 -0)
===================================================================
--- ext/groonga/rb-grn.h    2015-04-12 00:12:38 +0900 (4d6be24)
+++ ext/groonga/rb-grn.h    2015-04-12 00:23:55 +0900 (f1f54cd)
@@ -49,6 +49,10 @@
 #  define rb_to_symbol(rb_string) (rb_str_intern(rb_string))
 #endif
 
+#ifndef HAVE_RB_ARY_NEW_FROM_ARGS
+#  define rb_ary_new_from_args(n, ...) rb_ary_new3((n), __VA_ARGS__)
+#endif
+
 #ifndef HAVE_RB_ARY_NEW_FROM_VALUES
 #  define rb_ary_new_from_values(n, values) rb_ary_new4((n), (values))
 #endif

  Modified: ext/groonga/rb-groonga.c (+8 -8)
===================================================================
--- ext/groonga/rb-groonga.c    2015-04-12 00:12:38 +0900 (f800e2c)
+++ ext/groonga/rb-groonga.c    2015-04-12 00:23:55 +0900 (37cfee2)
@@ -84,10 +84,10 @@ rb_grn_init_version (VALUE mGrn)
 
     rb_grn_init_runtime_version(mGrn);
 
-    build_version = rb_ary_new3(3,
-                                INT2NUM(GRN_MAJOR_VERSION),
-                                INT2NUM(GRN_MINOR_VERSION),
-                                INT2NUM(GRN_MICRO_VERSION));
+    build_version = rb_ary_new_from_args(3,
+                                         INT2NUM(GRN_MAJOR_VERSION),
+                                         INT2NUM(GRN_MINOR_VERSION),
+                                         INT2NUM(GRN_MICRO_VERSION));
     rb_obj_freeze(build_version);
     /*
      * ビルドしたgroongaのバージョン。 @[メジャーバージョン,
@@ -95,10 +95,10 @@ rb_grn_init_version (VALUE mGrn)
      */
     rb_define_const(mGrn, "BUILD_VERSION", build_version);
 
-    bindings_version = rb_ary_new3(3,
-                                   INT2NUM(RB_GRN_MAJOR_VERSION),
-                                   INT2NUM(RB_GRN_MINOR_VERSION),
-                                   INT2NUM(RB_GRN_MICRO_VERSION));
+    bindings_version = rb_ary_new_from_args(3,
+                                            INT2NUM(RB_GRN_MAJOR_VERSION),
+                                            INT2NUM(RB_GRN_MINOR_VERSION),
+                                            INT2NUM(RB_GRN_MICRO_VERSION));
     rb_obj_freeze(bindings_version);
     /*
      * rroongaのバージョン。 @[メジャーバージョン, マ
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index