diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-12-28 17:03:36 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-12-28 17:03:36 +0000 |
commit | 5547719573c6b37566480eaadf0c17bd0c5529bd (patch) | |
tree | 10ed6697d04576a68cbe11d6d71b4ebcb08616e3 /ext/json/parser | |
parent | d9f384d4304228bb4301c68d45cb9d89986f060f (diff) | |
download | ruby-5547719573c6b37566480eaadf0c17bd0c5529bd.tar.gz |
ext/json: for ancient backward compatibilities
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49050 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/json/parser')
-rw-r--r-- | ext/json/parser/parser.c | 6 | ||||
-rw-r--r-- | ext/json/parser/parser.h | 8 | ||||
-rw-r--r-- | ext/json/parser/parser.rl | 6 |
3 files changed, 20 insertions, 0 deletions
diff --git a/ext/json/parser/parser.c b/ext/json/parser/parser.c index b9f753c56d..b692cb43b6 100644 --- a/ext/json/parser/parser.c +++ b/ext/json/parser/parser.c @@ -2122,6 +2122,7 @@ static size_t JSON_memsize(const void *ptr) return sizeof(*json) + FBUFFER_CAPA(json->fbuffer); } +#ifdef HAVE_TYPE_RB_DATA_TYPE_T static const rb_data_type_t JSON_Parser_type = { "JSON/Parser", {JSON_mark, JSON_free, JSON_memsize,}, @@ -2130,11 +2131,16 @@ static const rb_data_type_t JSON_Parser_type = { RUBY_TYPED_FREE_IMMEDIATELY, #endif }; +#endif 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 } /* diff --git a/ext/json/parser/parser.h b/ext/json/parser/parser.h index 980999a6d7..394b79a4ea 100644 --- a/ext/json/parser/parser.h +++ b/ext/json/parser/parser.h @@ -49,9 +49,15 @@ typedef struct JSON_ParserStruct { #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 @@ -73,7 +79,9 @@ static void JSON_mark(void *json); 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))) diff --git a/ext/json/parser/parser.rl b/ext/json/parser/parser.rl index 0b6fb041c5..e69fe57781 100644 --- a/ext/json/parser/parser.rl +++ b/ext/json/parser/parser.rl @@ -845,6 +845,7 @@ static size_t JSON_memsize(const void *ptr) return sizeof(*json) + FBUFFER_CAPA(json->fbuffer); } +#ifdef HAVE_TYPE_RB_DATA_TYPE_T static const rb_data_type_t JSON_Parser_type = { "JSON/Parser", {JSON_mark, JSON_free, JSON_memsize,}, @@ -853,11 +854,16 @@ static const rb_data_type_t JSON_Parser_type = { RUBY_TYPED_FREE_IMMEDIATELY, #endif }; +#endif 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 } /* |