summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Frank <flori@ping.de>2015-01-02 23:22:09 +0100
committerFlorian Frank <flori@ping.de>2015-01-02 23:38:12 +0100
commit05ba45c2d46c8ff4807613b60b204f85a7720997 (patch)
treecbbbbe68a9643dc98f1ee6507cc023026ab133fc
parent0a7c982b38b65b7b23c0bccbc056ec9213132e4e (diff)
downloadjson-05ba45c2d46c8ff4807613b60b204f85a7720997.tar.gz
Fall back to Data_* wrappers on ancient rubies
-rw-r--r--ext/json/ext/generator/generator.c2
-rw-r--r--ext/json/ext/generator/generator.h6
-rw-r--r--ext/json/ext/parser/parser.c2
-rw-r--r--ext/json/ext/parser/parser.h6
-rw-r--r--ext/json/ext/parser/parser.rl4
5 files changed, 19 insertions, 1 deletions
diff --git a/ext/json/ext/generator/generator.c b/ext/json/ext/generator/generator.c
index f789a89..a474fbb 100644
--- a/ext/json/ext/generator/generator.c
+++ b/ext/json/ext/generator/generator.c
@@ -515,6 +515,7 @@ static size_t State_memsize(const void *ptr)
return size;
}
+#ifdef NEW_TYPEDDATA_WRAPPER
static const rb_data_type_t JSON_Generator_State_type = {
"JSON/Generator/State",
{NULL, State_free, State_memsize,},
@@ -523,6 +524,7 @@ static const rb_data_type_t JSON_Generator_State_type = {
RUBY_TYPED_FREE_IMMEDIATELY,
#endif
};
+#endif
static JSON_Generator_State *State_allocate(void)
{
diff --git a/ext/json/ext/generator/generator.h b/ext/json/ext/generator/generator.h
index 7bf8408..02193f0 100644
--- a/ext/json/ext/generator/generator.h
+++ b/ext/json/ext/generator/generator.h
@@ -147,6 +147,12 @@ static VALUE cState_ascii_only_p(VALUE self);
static VALUE cState_depth(VALUE self);
static VALUE cState_depth_set(VALUE self, VALUE depth);
static FBuffer *cState_prepare_buffer(VALUE self);
+#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
diff --git a/ext/json/ext/parser/parser.c b/ext/json/ext/parser/parser.c
index efb4dac..8824b30 100644
--- a/ext/json/ext/parser/parser.c
+++ b/ext/json/ext/parser/parser.c
@@ -2123,6 +2123,7 @@ static size_t JSON_memsize(const void *ptr)
return sizeof(*json) + FBUFFER_CAPA(json->fbuffer);
}
+#ifdef NEW_TYPEDDATA_WRAPPER
static const rb_data_type_t JSON_Parser_type = {
"JSON/Parser",
{JSON_mark, JSON_free, JSON_memsize,},
@@ -2131,6 +2132,7 @@ static const rb_data_type_t JSON_Parser_type = {
RUBY_TYPED_FREE_IMMEDIATELY,
#endif
};
+#endif
static VALUE cJSON_parser_s_allocate(VALUE klass)
{
diff --git a/ext/json/ext/parser/parser.h b/ext/json/ext/parser/parser.h
index 45afbc2..418637f 100644
--- a/ext/json/ext/parser/parser.h
+++ b/ext/json/ext/parser/parser.h
@@ -73,6 +73,12 @@ 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 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
diff --git a/ext/json/ext/parser/parser.rl b/ext/json/ext/parser/parser.rl
index d3ba554..2af1cc6 100644
--- a/ext/json/ext/parser/parser.rl
+++ b/ext/json/ext/parser/parser.rl
@@ -611,7 +611,7 @@ static VALUE convert_encoding(VALUE source)
* the default.
* * *create_additions*: If set to false, the Parser doesn't create
* additions even if a matching class and create_id was found. This option
- * defaults to true.
+ * defaults to false.
* * *object_class*: Defaults to Hash
* * *array_class*: Defaults to Array
*/
@@ -846,6 +846,7 @@ static size_t JSON_memsize(const void *ptr)
return sizeof(*json) + FBUFFER_CAPA(json->fbuffer);
}
+#ifdef NEW_TYPEDDATA_WRAPPER
static const rb_data_type_t JSON_Parser_type = {
"JSON/Parser",
{JSON_mark, JSON_free, JSON_memsize,},
@@ -854,6 +855,7 @@ static const rb_data_type_t JSON_Parser_type = {
RUBY_TYPED_FREE_IMMEDIATELY,
#endif
};
+#endif
static VALUE cJSON_parser_s_allocate(VALUE klass)
{