[前][次][番号順一覧][スレッド一覧]

ruby-changes:37501

From: hsbt <ko1@a...>
Date: Fri, 13 Feb 2015 14:19:26 +0900 (JST)
Subject: [ruby-changes:37501] hsbt:r49582 (trunk): * ext/json: merge upstream from flori/json

hsbt	2015-02-13 14:19:12 +0900 (Fri, 13 Feb 2015)

  New Revision: 49582

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49582

  Log:
    * ext/json: merge upstream from flori/json
      change usage of TypedData. [Feature #10739][ruby-core:67564]

  Modified files:
    trunk/ChangeLog
    trunk/ext/json/generator/generator.c
    trunk/ext/json/generator/generator.h
    trunk/ext/json/parser/parser.c
    trunk/ext/json/parser/parser.h
    trunk/ext/json/parser/parser.rl
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 49581)
+++ ChangeLog	(revision 49582)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Feb 13 14:19:06 2015  SHIBATA Hiroshi  <shibata.hiroshi@g...>
+
+	* ext/json: merge upstream from flori/json
+	  change usage of TypedData. [Feature #10739][ruby-core:67564]
+
 Thu Feb 12 18:34:01 2015  multisnow  <infinity.blick.winkel@g...>
 
 	* ext/openssl/extconf.rb: check RAND_edg to support libressl.
Index: ext/json/generator/generator.c
===================================================================
--- ext/json/generator/generator.c	(revision 49581)
+++ ext/json/generator/generator.c	(revision 49582)
@@ -515,7 +515,7 @@ static size_t State_memsize(const void * https://github.com/ruby/ruby/blob/trunk/ext/json/generator/generator.c#L515
     return size;
 }
 
-#ifdef HAVE_TYPE_RB_DATA_TYPE_T
+#ifdef NEW_TYPEDDATA_WRAPPER
 static const rb_data_type_t JSON_Generator_State_type = {
     "JSON/Generator/State",
     {NULL, State_free, State_memsize,},
@@ -535,11 +535,7 @@ static JSON_Generator_State *State_alloc https://github.com/ruby/ruby/blob/trunk/ext/json/generator/generator.c#L535
 static VALUE cState_s_allocate(VALUE klass)
 {
     JSON_Generator_State *state = State_allocate();
-#ifdef HAVE_TYPE_RB_DATA_TYPE_T
     return TypedData_Wrap_Struct(klass, &JSON_Generator_State_type, state);
-#else
-    return Data_Wrap_Struct(klass, NULL, State_free, state);
-#endif
 }
 
 /*
Index: ext/json/generator/generator.h
===================================================================
--- ext/json/generator/generator.h	(revision 49581)
+++ ext/json/generator/generator.h	(revision 49582)
@@ -78,13 +78,8 @@ typedef struct JSON_Generator_StateStruc https://github.com/ruby/ruby/blob/trunk/ext/json/generator/generator.h#L78
     long buffer_initial_length;
 } JSON_Generator_State;
 
-#ifdef HAVE_TYPE_RB_DATA_TYPE_T
 #define GET_STATE_TO(self, state) \
     TypedData_Get_Struct(self, JSON_Generator_State, &JSON_Generator_State_type, state)
-#else
-#define GET_STATE_TO(self, state) \
-    Data_Get_Struct(self, JSON_Generator_State, state)
-#endif
 
 #define GET_STATE(self)                       \
     JSON_Generator_State *state;              \
@@ -97,7 +92,7 @@ typedef struct JSON_Generator_StateStruc https://github.com/ruby/ruby/blob/trunk/ext/json/generator/generator.h#L92
                                                                                                 \
     rb_scan_args(argc, argv, "01", &Vstate);                                                    \
     Vstate = cState_from_state_s(cState, Vstate);                                               \
-    GET_STATE_TO(Vstate, state);								\
+    TypedData_Get_Struct(Vstate, JSON_Generator_State, &JSON_Generator_State_type, state);	\
     buffer = cState_prepare_buffer(Vstate);                                                     \
     generate_json_##type(buffer, Vstate, state, self);                                          \
     return fbuffer_to_s(buffer)
@@ -152,10 +147,6 @@ static VALUE cState_ascii_only_p(VALUE s https://github.com/ruby/ruby/blob/trunk/ext/json/generator/generator.h#L147
 static VALUE cState_depth(VALUE self);
 static VALUE cState_depth_set(VALUE self, VALUE depth);
 static FBuffer *cState_prepare_buffer(VALUE self);
-#ifdef HAVE_TYPE_RB_DATA_TYPE_T
-static const rb_data_type_t JSON_Generator_State_type;
-#endif
-
 #ifndef ZALLOC
 #define ZALLOC(type) ((type *)ruby_zalloc(sizeof(type)))
 static inline void *ruby_zalloc(size_t n)
@@ -165,5 +156,12 @@ static inline void *ruby_zalloc(size_t n https://github.com/ruby/ruby/blob/trunk/ext/json/generator/generator.h#L156
     return p;
 }
 #endif
+#ifdef TypedData_Wrap_Struct
+static const rb_data_type_t JSON_Generator_State_type;
+#define NEW_TYPEDDATA_WRAPPER 1
+#else
+#define TypedData_Wrap_Struct(klass, ignore, json) Data_Wrap_Struct(klass, NULL, State_free, json)
+#define TypedData_Get_Struct(self, JSON_Generator_State, ignore, json) Data_Get_Struct(self, JSON_Generator_State, json)
+#endif
 
 #endif
Index: ext/json/parser/parser.h
===================================================================
--- ext/json/parser/parser.h	(revision 49581)
+++ ext/json/parser/parser.h	(revision 49582)
@@ -49,15 +49,9 @@ typedef struct JSON_ParserStruct { https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.h#L49
 #define GET_PARSER                          \
     GET_PARSER_INIT;                        \
     if (!json->Vsource) rb_raise(rb_eTypeError, "uninitialized instance")
-#ifdef HAVE_TYPE_RB_DATA_TYPE_T
 #define GET_PARSER_INIT                     \
     JSON_Parser *json;                      \
     TypedData_Get_Struct(self, JSON_Parser, &JSON_Parser_type, json)
-#else
-#define GET_PARSER_INIT                     \
-    JSON_Parser *json;                      \
-    Data_Get_Struct(self, JSON_Parser, json)
-#endif
 
 #define MinusInfinity "-Infinity"
 #define EVIL 0x666
@@ -79,10 +73,6 @@ static void JSON_mark(void *json); https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.h#L73
 static void JSON_free(void *json);
 static VALUE cJSON_parser_s_allocate(VALUE klass);
 static VALUE cParser_source(VALUE self);
-#ifdef HAVE_TYPE_RB_DATA_TYPE_T
-static const rb_data_type_t JSON_Parser_type;
-#endif
-
 #ifndef ZALLOC
 #define ZALLOC(type) ((type *)ruby_zalloc(sizeof(type)))
 static inline void *ruby_zalloc(size_t n)
@@ -92,5 +82,12 @@ static inline void *ruby_zalloc(size_t n https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.h#L82
     return p;
 }
 #endif
+#ifdef TypedData_Wrap_Struct
+static const rb_data_type_t JSON_Parser_type;
+#define NEW_TYPEDDATA_WRAPPER 1
+#else
+#define TypedData_Wrap_Struct(klass, ignore, json) Data_Wrap_Struct(klass, JSON_mark, JSON_free, json)
+#define TypedData_Get_Struct(self, JSON_Parser, ignore, json) Data_Get_Struct(self, JSON_Parser, json)
+#endif
 
 #endif
Index: ext/json/parser/parser.rl
===================================================================
--- ext/json/parser/parser.rl	(revision 49581)
+++ ext/json/parser/parser.rl	(revision 49582)
@@ -845,7 +845,7 @@ static size_t JSON_memsize(const void *p https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.rl#L845
     return sizeof(*json) + FBUFFER_CAPA(json->fbuffer);
 }
 
-#ifdef HAVE_TYPE_RB_DATA_TYPE_T
+#ifdef NEW_TYPEDDATA_WRAPPER
 static const rb_data_type_t JSON_Parser_type = {
     "JSON/Parser",
     {JSON_mark, JSON_free, JSON_memsize,},
@@ -859,11 +859,7 @@ static const rb_data_type_t JSON_Parser_ https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.rl#L859
 static VALUE cJSON_parser_s_allocate(VALUE klass)
 {
     JSON_Parser *json = JSON_allocate();
-#ifdef HAVE_TYPE_RB_DATA_TYPE_T
     return TypedData_Wrap_Struct(klass, &JSON_Parser_type, json);
-#else
-    return Data_Wrap_Struct(klass, JSON_mark, JSON_free, json);
-#endif
 }
 
 /*
Index: ext/json/parser/parser.c
===================================================================
--- ext/json/parser/parser.c	(revision 49581)
+++ ext/json/parser/parser.c	(revision 49582)
@@ -2122,7 +2122,7 @@ static size_t JSON_memsize(const void *p https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L2122
     return sizeof(*json) + FBUFFER_CAPA(json->fbuffer);
 }
 
-#ifdef HAVE_TYPE_RB_DATA_TYPE_T
+#ifdef NEW_TYPEDDATA_WRAPPER
 static const rb_data_type_t JSON_Parser_type = {
     "JSON/Parser",
     {JSON_mark, JSON_free, JSON_memsize,},
@@ -2136,11 +2136,7 @@ static const rb_data_type_t JSON_Parser_ https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L2136
 static VALUE cJSON_parser_s_allocate(VALUE klass)
 {
     JSON_Parser *json = JSON_allocate();
-#ifdef HAVE_TYPE_RB_DATA_TYPE_T
     return TypedData_Wrap_Struct(klass, &JSON_Parser_type, json);
-#else
-    return Data_Wrap_Struct(klass, JSON_mark, JSON_free, json);
-#endif
 }
 
 /*

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]