[Groonga-commit] ranguba/rroonga at e5eabe1 [master] Add Groonga::Type#builtin?

Back to archive index

Kouhei Sutou null+****@clear*****
Mon May 16 16:55:33 JST 2016


Kouhei Sutou	2016-05-16 16:55:33 +0900 (Mon, 16 May 2016)

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

  Message:
    Add Groonga::Type#builtin?

  Modified files:
    ext/groonga/rb-grn-type.c
    test/test-type.rb

  Modified: ext/groonga/rb-grn-type.c (+15 -0)
===================================================================
--- ext/groonga/rb-grn-type.c    2016-05-16 16:50:51 +0900 (3566b03)
+++ ext/groonga/rb-grn-type.c    2016-05-16 16:55:33 +0900 (90dc479)
@@ -174,6 +174,18 @@ rb_grn_type_variable_size_p (VALUE self)
 }
 
 static VALUE
+rb_grn_type_builtin_p (VALUE self)
+{
+    grn_ctx *context = NULL;
+    grn_obj *type;
+    grn_id id;
+
+    type = RVAL2GRNOBJECT(self, &context);
+    id =  grn_obj_id(context, type);
+    return CBOOL2RVAL(grn_type_id_is_builtin(context, id));
+}
+
+static VALUE
 rb_grn_type_unsigned_integer_p (VALUE self)
 {
     grn_obj *type;
@@ -253,6 +265,9 @@ rb_grn_init_type (VALUE mGrn)
     rb_define_method(rb_cGrnType, "variable_size?",
                      rb_grn_type_variable_size_p, 0);
 
+    rb_define_method(rb_cGrnType, "builtin?",
+                     rb_grn_type_builtin_p, 0);
+
     rb_define_method(rb_cGrnType, "unsigned_integer?",
                      rb_grn_type_unsigned_integer_p, 0);
     rb_define_alias(rb_cGrnType, "uint?", "unsigned_integer?");

  Modified: test/test-type.rb (+6 -0)
===================================================================
--- test/test-type.rb    2016-05-16 16:50:51 +0900 (f00b606)
+++ test/test-type.rb    2016-05-16 16:55:33 +0900 (ba287d7)
@@ -59,6 +59,12 @@ class TypeTest < Test::Unit::TestCase
     assert_false(Groonga["Int32"].variable_size?)
   end
 
+  def test_builtin?
+    assert do
+      Groonga["Int32"].builtin?
+    end
+  end
+
   def test_unsigned_integer?
     assert_true(Groonga["UInt32"].unsigned_integer?)
   end
-------------- next part --------------
HTML����������������������������...
Télécharger 



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