[Groonga-commit] groonga/groonga at 9b9fc4e [master] mrb: use "class method" instead of "singleton method"

Back to archive index

Kouhei Sutou null+****@clear*****
Thu Jul 16 17:29:08 JST 2015


Kouhei Sutou	2015-07-16 17:29:08 +0900 (Thu, 16 Jul 2015)

  New Revision: 9b9fc4efd765092fda0f437ac733bc983bef076e
  https://github.com/groonga/groonga/commit/9b9fc4efd765092fda0f437ac733bc983bef076e

  Message:
    mrb: use "class method" instead of "singleton method"

  Modified files:
    lib/mrb/mrb_array.c
    lib/mrb/mrb_command.c
    lib/mrb/mrb_converter.c
    lib/mrb/mrb_database.c
    lib/mrb/mrb_expr.c
    lib/mrb/mrb_hash_table.c
    lib/mrb/mrb_index_cursor.c
    lib/mrb/mrb_table_cursor.c

  Modified: lib/mrb/mrb_array.c (+5 -5)
===================================================================
--- lib/mrb/mrb_array.c    2015-07-16 17:22:21 +0900 (f90a7c6)
+++ lib/mrb/mrb_array.c    2015-07-16 17:29:08 +0900 (ab0b3e5)
@@ -1,6 +1,6 @@
 /* -*- c-basic-offset: 2 -*- */
 /*
-  Copyright(C) 2014 Brazil
+  Copyright(C) 2014-2015 Brazil
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -32,7 +32,7 @@ static struct mrb_data_type mrb_grn_array_type = {
 };
 
 static mrb_value
-mrb_grn_array_singleton_create(mrb_state *mrb, mrb_value klass)
+mrb_grn_array_class_create(mrb_state *mrb, mrb_value klass)
 {
   grn_ctx *ctx = (grn_ctx *)mrb->ud;
   char *name;
@@ -82,9 +82,9 @@ grn_mrb_array_init(grn_ctx *ctx)
   klass = mrb_define_class_under(mrb, module, "Array", table_class);
   MRB_SET_INSTANCE_TT(klass, MRB_TT_DATA);
 
-  mrb_define_singleton_method(mrb, (struct RObject *)klass, "create",
-                              mrb_grn_array_singleton_create,
-                              MRB_ARGS_REQ(2));
+  mrb_define_class_method(mrb, klass, "create",
+                          mrb_grn_array_class_create,
+                          MRB_ARGS_REQ(2));
 
   mrb_define_method(mrb, klass, "initialize",
                     mrb_grn_array_initialize, MRB_ARGS_REQ(1));

  Modified: lib/mrb/mrb_command.c (+4 -4)
===================================================================
--- lib/mrb/mrb_command.c    2015-07-16 17:22:21 +0900 (0ff3a0d)
+++ lib/mrb/mrb_command.c    2015-07-16 17:29:08 +0900 (e0cef6f)
@@ -91,7 +91,7 @@ mrb_grn_command_run_wrapper(grn_ctx *ctx,
 }
 
 static mrb_value
-mrb_grn_command_singleton_register(mrb_state *mrb, mrb_value klass)
+mrb_grn_command_class_register(mrb_state *mrb, mrb_value klass)
 {
   grn_ctx *ctx = (grn_ctx *)mrb->ud;
   mrb_value mrb_name;
@@ -170,9 +170,9 @@ grn_mrb_command_init(grn_ctx *ctx)
   klass = mrb_define_class_under(mrb, module, "Command", procedure_class);
   MRB_SET_INSTANCE_TT(klass, MRB_TT_DATA);
 
-  mrb_define_singleton_method(mrb, (struct RObject *)klass, "register",
-                              mrb_grn_command_singleton_register,
-                              MRB_ARGS_REQ(2));
+  mrb_define_class_method(mrb, klass, "register",
+                          mrb_grn_command_class_register,
+                          MRB_ARGS_REQ(2));
 
   mrb_define_method(mrb, klass, "initialize",
                     mrb_grn_command_initialize, MRB_ARGS_REQ(1));

  Modified: lib/mrb/mrb_converter.c (+4 -4)
===================================================================
--- lib/mrb/mrb_converter.c    2015-07-16 17:22:21 +0900 (387d921)
+++ lib/mrb/mrb_converter.c    2015-07-16 17:29:08 +0900 (21a6bc5)
@@ -250,7 +250,7 @@ grn_mrb_class_to_type(mrb_state *mrb, struct RClass *klass)
 }
 
 static mrb_value
-mrb_grn_converter_singleton_convert(mrb_state *mrb, mrb_value klass)
+mrb_grn_converter_class_convert(mrb_state *mrb, mrb_value klass)
 {
   grn_ctx *ctx = (grn_ctx *)mrb->ud;
   grn_obj *from = &(ctx->impl->mrb.buffer.from);
@@ -282,8 +282,8 @@ grn_mrb_converter_init(grn_ctx *ctx)
 
   module = mrb_define_module_under(mrb, data->module, "Converter");
 
-  mrb_define_singleton_method(mrb, (struct RObject *)module, "convert",
-                              mrb_grn_converter_singleton_convert,
-                              MRB_ARGS_REQ(2));
+  mrb_define_class_method(mrb, module, "convert",
+                          mrb_grn_converter_class_convert,
+                          MRB_ARGS_REQ(2));
 }
 #endif

  Modified: lib/mrb/mrb_database.c (+9 -9)
===================================================================
--- lib/mrb/mrb_database.c    2015-07-16 17:22:21 +0900 (2299410)
+++ lib/mrb/mrb_database.c    2015-07-16 17:29:08 +0900 (84599d0)
@@ -1,6 +1,6 @@
 /* -*- c-basic-offset: 2 -*- */
 /*
-  Copyright(C) 2014 Brazil
+  Copyright(C) 2014-2015 Brazil
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -43,7 +43,7 @@ mrb_grn_database_initialize(mrb_state *mrb, mrb_value self)
 }
 
 static mrb_value
-mrb_grn_database_singleton_open(mrb_state *mrb, mrb_value klass)
+mrb_grn_database_class_open(mrb_state *mrb, mrb_value klass)
 {
   grn_ctx *ctx = (grn_ctx *)mrb->ud;
   grn_obj *database;
@@ -58,7 +58,7 @@ mrb_grn_database_singleton_open(mrb_state *mrb, mrb_value klass)
 }
 
 static mrb_value
-mrb_grn_database_singleton_create(mrb_state *mrb, mrb_value klass)
+mrb_grn_database_class_create(mrb_state *mrb, mrb_value klass)
 {
   grn_ctx *ctx = (grn_ctx *)mrb->ud;
   grn_obj *database;
@@ -107,12 +107,12 @@ grn_mrb_database_init(grn_ctx *ctx)
   klass = mrb_define_class_under(mrb, module, "Database", object_class);
   MRB_SET_INSTANCE_TT(klass, MRB_TT_DATA);
 
-  mrb_define_singleton_method(mrb, (struct RObject *)klass, "open",
-                              mrb_grn_database_singleton_open,
-                              MRB_ARGS_REQ(1));
-  mrb_define_singleton_method(mrb, (struct RObject *)klass, "create",
-                              mrb_grn_database_singleton_create,
-                              MRB_ARGS_REQ(1));
+  mrb_define_class_method(mrb, klass, "open",
+                          mrb_grn_database_class_open,
+                          MRB_ARGS_REQ(1));
+  mrb_define_class_method(mrb, klass, "create",
+                          mrb_grn_database_class_create,
+                          MRB_ARGS_REQ(1));
 
   mrb_define_method(mrb, klass, "initialize",
                     mrb_grn_database_initialize, MRB_ARGS_REQ(1));

  Modified: lib/mrb/mrb_expr.c (+4 -4)
===================================================================
--- lib/mrb/mrb_expr.c    2015-07-16 17:22:21 +0900 (dcae12a)
+++ lib/mrb/mrb_expr.c    2015-07-16 17:29:08 +0900 (822e465)
@@ -422,7 +422,7 @@ mrb_grn_expr_code_get_flags(mrb_state *mrb, mrb_value self)
 }
 
 static mrb_value
-mrb_grn_expression_singleton_create(mrb_state *mrb, mrb_value klass)
+mrb_grn_expression_class_create(mrb_state *mrb, mrb_value klass)
 {
   grn_ctx *ctx = (grn_ctx *)mrb->ud;
   mrb_value mrb_expr;
@@ -783,9 +783,9 @@ grn_mrb_expr_init(grn_ctx *ctx)
   klass = mrb_define_class_under(mrb, module, "Expression", object_class);
   MRB_SET_INSTANCE_TT(klass, MRB_TT_DATA);
 
-  mrb_define_singleton_method(mrb, (struct RObject *)klass, "create",
-                              mrb_grn_expression_singleton_create,
-                              MRB_ARGS_REQ(1));
+  mrb_define_class_method(mrb, klass, "create",
+                          mrb_grn_expression_class_create,
+                          MRB_ARGS_REQ(1));
 
   mrb_define_method(mrb, klass, "initialize",
                     mrb_grn_expression_initialize, MRB_ARGS_REQ(1));

  Modified: lib/mrb/mrb_hash_table.c (+4 -4)
===================================================================
--- lib/mrb/mrb_hash_table.c    2015-07-16 17:22:21 +0900 (31d0095)
+++ lib/mrb/mrb_hash_table.c    2015-07-16 17:29:08 +0900 (ee71987)
@@ -34,7 +34,7 @@ static struct mrb_data_type mrb_grn_hash_table_type = {
 };
 
 static mrb_value
-mrb_grn_hash_table_singleton_create(mrb_state *mrb, mrb_value klass)
+mrb_grn_hash_table_class_create(mrb_state *mrb, mrb_value klass)
 {
   grn_ctx *ctx = (grn_ctx *)mrb->ud;
   mrb_value mrb_options = mrb_nil_value();
@@ -107,9 +107,9 @@ grn_mrb_hash_table_init(grn_ctx *ctx)
   klass = mrb_define_class_under(mrb, module, "HashTable", table_class);
   MRB_SET_INSTANCE_TT(klass, MRB_TT_DATA);
 
-  mrb_define_singleton_method(mrb, (struct RObject *)klass, "create",
-                              mrb_grn_hash_table_singleton_create,
-                              MRB_ARGS_OPT(1));
+  mrb_define_class_method(mrb, klass, "create",
+                          mrb_grn_hash_table_class_create,
+                          MRB_ARGS_OPT(1));
 
   mrb_define_method(mrb, klass, "initialize",
                     mrb_grn_hash_table_initialize, MRB_ARGS_REQ(1));

  Modified: lib/mrb/mrb_index_cursor.c (+4 -4)
===================================================================
--- lib/mrb/mrb_index_cursor.c    2015-07-16 17:22:21 +0900 (20213b1)
+++ lib/mrb/mrb_index_cursor.c    2015-07-16 17:29:08 +0900 (bcfa0de)
@@ -39,7 +39,7 @@ static struct mrb_data_type mrb_grn_index_cursor_type = {
 };
 
 static mrb_value
-mrb_grn_index_cursor_singleton_open_raw(mrb_state *mrb, mrb_value klass)
+mrb_grn_index_cursor_class_open_raw(mrb_state *mrb, mrb_value klass)
 {
   grn_ctx *ctx = (grn_ctx *)mrb->ud;
   mrb_value mrb_table_cursor;
@@ -212,9 +212,9 @@ grn_mrb_index_cursor_init(grn_ctx *ctx)
   klass = mrb_define_class_under(mrb, module, "IndexCursor", mrb->object_class);
   MRB_SET_INSTANCE_TT(klass, MRB_TT_DATA);
 
-  mrb_define_singleton_method(mrb, (struct RObject *)klass, "open_raw",
-                              mrb_grn_index_cursor_singleton_open_raw,
-                              MRB_ARGS_ARG(2, 1));
+  mrb_define_class_method(mrb, klass, "open_raw",
+                          mrb_grn_index_cursor_class_open_raw,
+                          MRB_ARGS_ARG(2, 1));
 
   mrb_define_method(mrb, klass, "initialize",
                     mrb_grn_index_cursor_initialize, MRB_ARGS_REQ(1));

  Modified: lib/mrb/mrb_table_cursor.c (+4 -4)
===================================================================
--- lib/mrb/mrb_table_cursor.c    2015-07-16 17:22:21 +0900 (76d4429)
+++ lib/mrb/mrb_table_cursor.c    2015-07-16 17:29:08 +0900 (a1a6954)
@@ -38,7 +38,7 @@ static struct mrb_data_type mrb_grn_table_cursor_type = {
 };
 
 static mrb_value
-mrb_grn_table_cursor_singleton_open_raw(mrb_state *mrb, mrb_value klass)
+mrb_grn_table_cursor_class_open_raw(mrb_state *mrb, mrb_value klass)
 {
   grn_ctx *ctx = (grn_ctx *)mrb->ud;
   mrb_value mrb_table;
@@ -160,9 +160,9 @@ grn_mrb_table_cursor_init(grn_ctx *ctx)
   klass = mrb_define_class_under(mrb, module, "TableCursor", mrb->object_class);
   MRB_SET_INSTANCE_TT(klass, MRB_TT_DATA);
 
-  mrb_define_singleton_method(mrb, (struct RObject *)klass, "open_raw",
-                              mrb_grn_table_cursor_singleton_open_raw,
-                              MRB_ARGS_ARG(1, 1));
+  mrb_define_class_method(mrb, klass, "open_raw",
+                          mrb_grn_table_cursor_class_open_raw,
+                          MRB_ARGS_ARG(1, 1));
 
   mrb_define_method(mrb, klass, "initialize",
                     mrb_grn_table_cursor_initialize, MRB_ARGS_REQ(1));
-------------- next part --------------
HTML����������������������������...
下載 



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