[Groonga-commit] ranguba/rroonga at b1e0df4 [bind-grn_get_global_error_message] Try to bind grn_get_global_error_message()

Back to archive index

Masafumi Yokoyama null+****@clear*****
Sat Mar 5 23:05:58 JST 2016


Masafumi Yokoyama	2016-03-05 23:05:58 +0900 (Sat, 05 Mar 2016)

  New Revision: b1e0df4d558ae586431b07d45f64507641be7575
  https://github.com/ranguba/rroonga/commit/b1e0df4d558ae586431b07d45f64507641be7575

  Message:
    Try to bind grn_get_global_error_message()

  Added files:
    ext/groonga/rb-grn-global-error.c
  Modified files:
    ext/groonga/rb-grn.h
    ext/groonga/rb-groonga.c

  Added: ext/groonga/rb-grn-global-error.c (+50 -0) 100644
===================================================================
--- /dev/null
+++ ext/groonga/rb-grn-global-error.c    2016-03-05 23:05:58 +0900 (9d1c379)
@@ -0,0 +1,50 @@
+/* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+  Copyright (C) 2016  Masafumi Yokoyama <yokoyama �� clear-code.com>
+
+  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 "rb-grn.h"
+
+/*
+ * Document-class: Groonga::GlobalError
+ *
+ * This class manages global error in the current process.
+ */
+
+/*
+ * Gets the global error message in current process.
+ *
+ * @overload message
+ *   @return [String, nil] The error message.
+ *
+ * @since 6.0.0
+ */
+static VALUE
+rb_grn_global_error_get_message (VALUE klass)
+{
+    return rb_str_new_cstr(grn_get_global_error_message());
+}
+
+void
+rb_grn_init_global_error (VALUE mGrn)
+{
+    VALUE cGrnGlobalError;
+
+    cGrnGlobalError = rb_define_class_under(mGrn, "GlobalError", rb_cObject);
+
+    rb_define_singleton_method(cGrnGlobalError, "message",
+                               rb_grn_global_error_get_message, 0);
+}

  Modified: ext/groonga/rb-grn.h (+2 -0)
===================================================================
--- ext/groonga/rb-grn.h    2016-03-05 23:05:14 +0900 (b8c6e44)
+++ ext/groonga/rb-grn.h    2016-03-05 23:05:58 +0900 (021ea07)
@@ -302,6 +302,7 @@ RB_GRN_VAR VALUE rb_cGrnColumnExpressionBuilder;
 RB_GRN_VAR VALUE rb_cGrnPlugin;
 RB_GRN_VAR VALUE rb_cGrnNormalizer;
 RB_GRN_VAR VALUE rb_cGrnIndex;
+RB_GRN_VAR VALUE rb_cGrnGlobalError;
 
 void           rb_grn_init_utils                    (VALUE mGrn);
 void           rb_grn_init_exception                (VALUE mGrn);
@@ -357,6 +358,7 @@ void           rb_grn_init_normalizer               (VALUE mGrn);
 void           rb_grn_init_thread                   (VALUE mGrn);
 void           rb_grn_init_config                   (VALUE mGrn);
 void           rb_grn_init_index                    (VALUE mGrn);
+void           rb_grn_init_global_error             (VALUE mGrn);
 
 VALUE          rb_grn_rc_to_exception               (grn_rc rc);
 const char    *rb_grn_rc_to_message                 (grn_rc rc);

  Modified: ext/groonga/rb-groonga.c (+1 -0)
===================================================================
--- ext/groonga/rb-groonga.c    2016-03-05 23:05:14 +0900 (2e9d26a)
+++ ext/groonga/rb-groonga.c    2016-03-05 23:05:58 +0900 (481ac06)
@@ -220,4 +220,5 @@ Init_groonga (void)
     rb_grn_init_thread(mGrn);
     rb_grn_init_config(mGrn);
     rb_grn_init_index(mGrn);
+    rb_grn_init_global_error(mGrn);
 }
-------------- next part --------------
HTML����������������������������...
Download 



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