[Groonga-commit] groonga/groonga [master] grn_db_register_by_name() -> grn_plugin_register(). #834

Back to archive index

null+****@clear***** null+****@clear*****
2011年 2月 7日 (月) 15:29:01 JST


Kouhei Sutou	2011-02-07 06:29:01 +0000 (Mon, 07 Feb 2011)

  New Revision: 69da1974bd12257446a258837a20c113b67597bc

  Log:
    grn_db_register_by_name() -> grn_plugin_register(). #834

  Modified files:
    include/groonga.h
    lib/db.c
    lib/plugin.c
    lib/plugin_in.h
    lib/proc.c
    lib/token.c

  Modified: include/groonga.h (+3 -3)
===================================================================
--- include/groonga.h    2011-02-04 06:52:21 +0000 (42c9b69)
+++ include/groonga.h    2011-02-07 06:29:01 +0000 (9874a8a)
@@ -1,4 +1,4 @@
-/* Copyright(C) 2009 Brazil
+/* Copyright(C) 2009-2011 Brazil
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -586,8 +586,8 @@ GRN_API grn_obj *grn_ctx_at(grn_ctx *ctx, grn_id id);
 GRN_API grn_obj *grn_type_create(grn_ctx *ctx, const char *name, unsigned name_size,
                                  grn_obj_flags flags, unsigned int size);
 
-GRN_API grn_rc grn_db_register(grn_ctx *ctx, const char *path);
-GRN_API grn_rc grn_db_register_by_name(grn_ctx *ctx, const char *name);
+GRN_API grn_rc grn_plugin_register(grn_ctx *ctx, const char *name);
+GRN_API grn_rc grn_plugin_register_by_path(grn_ctx *ctx, const char *path);
 
 /**
  * grn_proc_create:

  Modified: lib/db.c (+2 -2)
===================================================================
--- lib/db.c    2011-02-04 06:52:21 +0000 (96b68fd)
+++ lib/db.c    2011-02-07 06:29:01 +0000 (352b35b)
@@ -1,5 +1,5 @@
 /* -*- c-basic-offset: 2 -*- */
-/* Copyright(C) 2009 Brazil
+/* Copyright(C) 2009-2011 Brazil
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -5818,7 +5818,7 @@ grn_ctx_at(grn_ctx *ctx, grn_id id)
                   break;
                 case GRN_PROC :
                   GET_PATH(spec, buffer, s, id);
-                  grn_db_register(ctx, buffer);
+                  grn_plugin_register_by_path(ctx, buffer);
                   break;
                 case GRN_EXPR :
                   {

  Modified: lib/plugin.c (+46 -46)
===================================================================
--- lib/plugin.c    2011-02-04 06:52:21 +0000 (9c09e6d)
+++ lib/plugin.c    2011-02-07 06:29:01 +0000 (25d5679)
@@ -1,5 +1,5 @@
 /* -*- c-basic-offset: 2 -*- */
-/* Copyright(C) 2009-2010 Brazil
+/* Copyright(C) 2009-2011 Brazil
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -60,6 +60,45 @@ grn_plugin_path(grn_ctx *ctx, grn_id id)
 #define GRN_PLUGIN_FUNC_PREFIX "grn_plugin_impl_"
 
 static grn_rc
+grn_plugin_call_init (grn_ctx *ctx, grn_id id)
+{
+  grn_plugin *plugin;
+  if (!grn_hash_get_value(ctx, grn_plugins, id, &plugin)) {
+    return GRN_INVALID_ARGUMENT;
+  }
+  if (plugin->init_func) {
+    return plugin->init_func(ctx);
+  }
+  return GRN_SUCCESS;
+}
+
+static grn_rc
+grn_plugin_call_register(grn_ctx *ctx, grn_id id)
+{
+  grn_plugin *plugin;
+  if (!grn_hash_get_value(ctx, grn_plugins, id, &plugin)) {
+    return GRN_INVALID_ARGUMENT;
+  }
+  if (plugin->register_func) {
+    return plugin->register_func(ctx);
+  }
+  return GRN_SUCCESS;
+}
+
+static grn_rc
+grn_plugin_call_fin(grn_ctx *ctx, grn_id id)
+{
+  grn_plugin *plugin;
+  if (!grn_hash_get_value(ctx, grn_plugins, id, &plugin)) {
+    return GRN_INVALID_ARGUMENT;
+  }
+  if (plugin->fin_func) {
+    return plugin->fin_func(ctx);
+  }
+  return GRN_SUCCESS;
+}
+
+static grn_rc
 grn_plugin_initialize(grn_ctx *ctx, grn_plugin *plugin,
                       grn_dl dl, grn_id id, const char *path)
 {
@@ -92,7 +131,7 @@ grn_plugin_initialize(grn_ctx *ctx, grn_plugin *plugin,
 
   if (!ctx->rc) {
     ctx->impl->plugin_path = path;
-    grn_plugin_init(ctx, id);
+    grn_plugin_call_init(ctx, id);
     ctx->impl->plugin_path = NULL;
   }
 
@@ -149,7 +188,7 @@ grn_plugin_close(grn_ctx *ctx, grn_id id)
 {
   grn_plugin *plugin;
 
-  grn_plugin_fin(ctx, id);
+  grn_plugin_call_fin(ctx, id);
   if (!grn_hash_get_value(ctx, grn_plugins, id, &plugin)) {
     return GRN_INVALID_ARGUMENT;
   }
@@ -181,45 +220,6 @@ grn_plugin_sym(grn_ctx *ctx, grn_id id, const char *symbol)
 }
 
 grn_rc
-grn_plugin_init (grn_ctx *ctx, grn_id id)
-{
-  grn_plugin *plugin;
-  if (!grn_hash_get_value(ctx, grn_plugins, id, &plugin)) {
-    return GRN_INVALID_ARGUMENT;
-  }
-  if (plugin->init_func) {
-    return plugin->init_func(ctx);
-  }
-  return GRN_SUCCESS;
-}
-
-grn_rc
-grn_plugin_register (grn_ctx *ctx, grn_id id)
-{
-  grn_plugin *plugin;
-  if (!grn_hash_get_value(ctx, grn_plugins, id, &plugin)) {
-    return GRN_INVALID_ARGUMENT;
-  }
-  if (plugin->register_func) {
-    return plugin->register_func(ctx);
-  }
-  return GRN_SUCCESS;
-}
-
-grn_rc
-grn_plugin_fin(grn_ctx *ctx, grn_id id)
-{
-  grn_plugin *plugin;
-  if (!grn_hash_get_value(ctx, grn_plugins, id, &plugin)) {
-    return GRN_INVALID_ARGUMENT;
-  }
-  if (plugin->fin_func) {
-    return plugin->fin_func(ctx);
-  }
-  return GRN_SUCCESS;
-}
-
-grn_rc
 grn_plugins_init(void)
 {
   grn_plugins = grn_hash_create(&grn_gctx, NULL, PATH_MAX, sizeof(grn_plugin *),
@@ -240,7 +240,7 @@ grn_plugins_fin(void)
 }
 
 grn_rc
-grn_db_register(grn_ctx *ctx, const char *path)
+grn_plugin_register_by_path(grn_ctx *ctx, const char *path)
 {
   grn_id id;
   grn_obj *db;
@@ -296,7 +296,7 @@ grn_db_register(grn_ctx *ctx, const char *path)
 
     if (id) {
       ctx->impl->plugin_path = path;
-      ctx->rc = grn_plugin_register(ctx, id);
+      ctx->rc = grn_plugin_call_register(ctx, id);
       ctx->impl->plugin_path = NULL;
       if (ctx->rc) {
         grn_plugin_close(ctx, id);
@@ -368,7 +368,7 @@ default_plugins_dir(void)
 #endif /* WIN32 */
 
 grn_rc
-grn_db_register_by_name(grn_ctx *ctx, const char *name)
+grn_plugin_register(grn_ctx *ctx, const char *name)
 {
   const char *plugins_dir;
   char dir_last_char;
@@ -384,5 +384,5 @@ grn_db_register_by_name(grn_ctx *ctx, const char *name)
     strcat(path, PATH_SEPARATOR);
   }
   strcat(path, name);
-  return grn_db_register(ctx, path);
+  return grn_plugin_register_by_path(ctx, path);
 }

  Modified: lib/plugin_in.h (+1 -4)
===================================================================
--- lib/plugin_in.h    2011-02-04 06:52:21 +0000 (5cab93e)
+++ lib/plugin_in.h    2011-02-07 06:29:01 +0000 (bc64998)
@@ -1,5 +1,5 @@
 /* -*- c-basic-offset: 2 -*- */
-/* Copyright(C) 2010 Brazil
+/* Copyright(C) 2010-2011 Brazil
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -56,9 +56,6 @@ grn_rc grn_plugins_init(void);
 grn_rc grn_plugins_fin(void);
 grn_id grn_plugin_open(grn_ctx *ctx, const char *filename);
 grn_rc grn_plugin_close(grn_ctx *ctx, grn_id id);
-grn_rc grn_plugin_init(grn_ctx *ctx, grn_id id);
-grn_rc grn_plugin_register(grn_ctx *ctx, grn_id id);
-grn_rc grn_plugin_fin(grn_ctx *ctx, grn_id id);
 grn_id grn_plugin_get(grn_ctx *ctx, const char *filename);
 const char *grn_plugin_path(grn_ctx *ctx, grn_id id);
 

  Modified: lib/proc.c (+2 -2)
===================================================================
--- lib/proc.c    2011-02-04 06:52:21 +0000 (95b130c)
+++ lib/proc.c    2011-02-07 06:29:01 +0000 (96e45e1)
@@ -1,5 +1,5 @@
 /* -*- c-basic-offset: 2 -*- */
-/* Copyright(C) 2009-2010 Brazil
+/* Copyright(C) 2009-2011 Brazil
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -2004,7 +2004,7 @@ proc_register(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_data)
   if (GRN_TEXT_LEN(VAR(0))) {
     const char *name;
     name = GRN_TEXT_VALUE(VAR(0));
-    grn_db_register_by_name(ctx, name);
+    grn_plugin_register(ctx, name);
   } else {
     ERR(GRN_INVALID_ARGUMENT, "path is required");
   }

  Modified: lib/token.c (+2 -2)
===================================================================
--- lib/token.c    2011-02-04 06:52:21 +0000 (6bc5289)
+++ lib/token.c    2011-02-07 06:29:01 +0000 (9154d3f)
@@ -1,5 +1,5 @@
 /* -*- c-basic-offset: 2 -*- */
-/* Copyright(C) 2009 Brazil
+/* Copyright(C) 2009-2011 Brazil
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -544,7 +544,7 @@ grn_db_init_mecab_tokenizer(grn_ctx *ctx)
   case GRN_ENC_EUC_JP :
   case GRN_ENC_UTF8 :
   case GRN_ENC_SJIS :
-    return grn_db_register_by_name(ctx, "tokenizers/mecab");
+    return grn_plugin_register(ctx, "tokenizers/mecab");
   default :
     return GRN_OPERATION_NOT_SUPPORTED;
   }




Groonga-commit メーリングリストの案内
Back to archive index