[Groonga-commit] ranguba/rroonga at 8553bd1 [master] Add RSYMBOL2CSTR for Ruby symbol -> C string

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Sep 29 22:27:47 JST 2014


Kouhei Sutou	2014-09-29 22:27:47 +0900 (Mon, 29 Sep 2014)

  New Revision: 8553bd12e3aeec0f5ef4ab286e05261d9b06c93c
  https://github.com/ranguba/rroonga/commit/8553bd12e3aeec0f5ef4ab286e05261d9b06c93c

  Message:
    Add RSYMBOL2CSTR for Ruby symbol -> C string
    
    SYM2STR is confused name because we can't know about "STR" is Ruby
    string or C string. "SYM" means Ruby symbol. So "STR" will be
    misunderstood as Ruby string.

  Modified files:
    ext/groonga/rb-grn-context.c
    ext/groonga/rb-grn-table.c
    ext/groonga/rb-grn.h

  Modified: ext/groonga/rb-grn-context.c (+1 -1)
===================================================================
--- ext/groonga/rb-grn-context.c    2014-09-29 22:09:51 +0900 (d2131ed)
+++ ext/groonga/rb-grn-context.c    2014-09-29 22:27:47 +0900 (58f011b)
@@ -902,7 +902,7 @@ rb_grn_context_array_reference (VALUE self, VALUE name_or_id)
     context = SELF(self);
     switch (TYPE(name_or_id)) {
       case T_SYMBOL:
-        name = SYM2STR(name_or_id);
+        name = RSYMBOL2CSTR(name_or_id);
         name_size = strlen(name);
         object = rb_grn_context_get_backward_compatibility(context,
                                                            name, name_size);

  Modified: ext/groonga/rb-grn-table.c (+1 -1)
===================================================================
--- ext/groonga/rb-grn-table.c    2014-09-29 22:09:51 +0900 (60ea9f2)
+++ ext/groonga/rb-grn-table.c    2014-09-29 22:27:47 +0900 (fae5ef9)
@@ -470,7 +470,7 @@ ruby_object_to_column_name (VALUE rb_name,
 {
     switch (TYPE(rb_name)) {
       case T_SYMBOL:
-        *name = SYM2STR(rb_name);
+        *name = RSYMBOL2CSTR(rb_name);
         *name_size = strlen(*name);
         break;
       case T_STRING:

  Modified: ext/groonga/rb-grn.h (+3 -3)
===================================================================
--- ext/groonga/rb-grn.h    2014-09-29 22:09:51 +0900 (a07795c)
+++ ext/groonga/rb-grn.h    2014-09-29 22:27:47 +0900 (65889d5)
@@ -41,9 +41,7 @@
 #endif
 
 #ifndef HAVE_RB_SYM2STR
-#  define SYM2STR(name) (rb_id2name(SYM2ID(name)))
-#else
-#  define SYM2STR(name) (RSTRING_PTR(rb_sym2str(name)))
+#  define rb_sym2str(symbol) (rb_id2str(SYM2ID(symbol)))
 #endif
 
 #ifndef HAVE_RB_ID2SYM
@@ -606,6 +604,8 @@ VALUE          rb_grn_column_expression_builder_build
 #define RVAL2CBOOL(object)            (RTEST(object))
 #define CBOOL2RVAL(boolean)           ((boolean) ? Qtrue : Qfalse)
 
+#define RSYMBOL2CSTR(rb_symbol)       (RSTRING_PTR(rb_sym2str(rb_symbol)))
+
 #define RVAL2GRNENCODING(object, context) \
                                       (rb_grn_encoding_from_ruby_object(object, context))
 #define GRNENCODING2RVAL(encoding)    (rb_grn_encoding_to_ruby_object(encoding))
-------------- next part --------------
HTML����������������������������...
Descargar 



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