ext/json: for ancient backward compatibilities
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49050 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d9f384d430
commit
5547719573
@ -515,6 +515,7 @@ static size_t State_memsize(const void *ptr)
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_TYPE_RB_DATA_TYPE_T
|
||||||
static const rb_data_type_t JSON_Generator_State_type = {
|
static const rb_data_type_t JSON_Generator_State_type = {
|
||||||
"JSON/Generator/State",
|
"JSON/Generator/State",
|
||||||
{NULL, State_free, State_memsize,},
|
{NULL, State_free, State_memsize,},
|
||||||
@ -523,6 +524,7 @@ static const rb_data_type_t JSON_Generator_State_type = {
|
|||||||
RUBY_TYPED_FREE_IMMEDIATELY,
|
RUBY_TYPED_FREE_IMMEDIATELY,
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
static JSON_Generator_State *State_allocate(void)
|
static JSON_Generator_State *State_allocate(void)
|
||||||
{
|
{
|
||||||
@ -533,7 +535,11 @@ static JSON_Generator_State *State_allocate(void)
|
|||||||
static VALUE cState_s_allocate(VALUE klass)
|
static VALUE cState_s_allocate(VALUE klass)
|
||||||
{
|
{
|
||||||
JSON_Generator_State *state = State_allocate();
|
JSON_Generator_State *state = State_allocate();
|
||||||
|
#ifdef HAVE_TYPE_RB_DATA_TYPE_T
|
||||||
return TypedData_Wrap_Struct(klass, &JSON_Generator_State_type, state);
|
return TypedData_Wrap_Struct(klass, &JSON_Generator_State_type, state);
|
||||||
|
#else
|
||||||
|
return Data_Wrap_Struct(klass, NULL, State_free, state);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -78,8 +78,13 @@ typedef struct JSON_Generator_StateStruct {
|
|||||||
long buffer_initial_length;
|
long buffer_initial_length;
|
||||||
} JSON_Generator_State;
|
} JSON_Generator_State;
|
||||||
|
|
||||||
|
#ifdef HAVE_TYPE_RB_DATA_TYPE_T
|
||||||
#define GET_STATE_TO(self, state) \
|
#define GET_STATE_TO(self, state) \
|
||||||
TypedData_Get_Struct(self, JSON_Generator_State, &JSON_Generator_State_type, 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) \
|
#define GET_STATE(self) \
|
||||||
JSON_Generator_State *state; \
|
JSON_Generator_State *state; \
|
||||||
@ -147,7 +152,9 @@ static VALUE cState_ascii_only_p(VALUE self);
|
|||||||
static VALUE cState_depth(VALUE self);
|
static VALUE cState_depth(VALUE self);
|
||||||
static VALUE cState_depth_set(VALUE self, VALUE depth);
|
static VALUE cState_depth_set(VALUE self, VALUE depth);
|
||||||
static FBuffer *cState_prepare_buffer(VALUE self);
|
static FBuffer *cState_prepare_buffer(VALUE self);
|
||||||
|
#ifdef HAVE_TYPE_RB_DATA_TYPE_T
|
||||||
static const rb_data_type_t JSON_Generator_State_type;
|
static const rb_data_type_t JSON_Generator_State_type;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef ZALLOC
|
#ifndef ZALLOC
|
||||||
#define ZALLOC(type) ((type *)ruby_zalloc(sizeof(type)))
|
#define ZALLOC(type) ((type *)ruby_zalloc(sizeof(type)))
|
||||||
|
@ -2122,6 +2122,7 @@ static size_t JSON_memsize(const void *ptr)
|
|||||||
return sizeof(*json) + FBUFFER_CAPA(json->fbuffer);
|
return sizeof(*json) + FBUFFER_CAPA(json->fbuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_TYPE_RB_DATA_TYPE_T
|
||||||
static const rb_data_type_t JSON_Parser_type = {
|
static const rb_data_type_t JSON_Parser_type = {
|
||||||
"JSON/Parser",
|
"JSON/Parser",
|
||||||
{JSON_mark, JSON_free, JSON_memsize,},
|
{JSON_mark, JSON_free, JSON_memsize,},
|
||||||
@ -2130,11 +2131,16 @@ static const rb_data_type_t JSON_Parser_type = {
|
|||||||
RUBY_TYPED_FREE_IMMEDIATELY,
|
RUBY_TYPED_FREE_IMMEDIATELY,
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
static VALUE cJSON_parser_s_allocate(VALUE klass)
|
static VALUE cJSON_parser_s_allocate(VALUE klass)
|
||||||
{
|
{
|
||||||
JSON_Parser *json = JSON_allocate();
|
JSON_Parser *json = JSON_allocate();
|
||||||
|
#ifdef HAVE_TYPE_RB_DATA_TYPE_T
|
||||||
return TypedData_Wrap_Struct(klass, &JSON_Parser_type, json);
|
return TypedData_Wrap_Struct(klass, &JSON_Parser_type, json);
|
||||||
|
#else
|
||||||
|
return Data_Wrap_Struct(klass, JSON_mark, JSON_free, json);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -49,9 +49,15 @@ typedef struct JSON_ParserStruct {
|
|||||||
#define GET_PARSER \
|
#define GET_PARSER \
|
||||||
GET_PARSER_INIT; \
|
GET_PARSER_INIT; \
|
||||||
if (!json->Vsource) rb_raise(rb_eTypeError, "uninitialized instance")
|
if (!json->Vsource) rb_raise(rb_eTypeError, "uninitialized instance")
|
||||||
|
#ifdef HAVE_TYPE_RB_DATA_TYPE_T
|
||||||
#define GET_PARSER_INIT \
|
#define GET_PARSER_INIT \
|
||||||
JSON_Parser *json; \
|
JSON_Parser *json; \
|
||||||
TypedData_Get_Struct(self, JSON_Parser, &JSON_Parser_type, 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 MinusInfinity "-Infinity"
|
||||||
#define EVIL 0x666
|
#define EVIL 0x666
|
||||||
@ -73,7 +79,9 @@ static void JSON_mark(void *json);
|
|||||||
static void JSON_free(void *json);
|
static void JSON_free(void *json);
|
||||||
static VALUE cJSON_parser_s_allocate(VALUE klass);
|
static VALUE cJSON_parser_s_allocate(VALUE klass);
|
||||||
static VALUE cParser_source(VALUE self);
|
static VALUE cParser_source(VALUE self);
|
||||||
|
#ifdef HAVE_TYPE_RB_DATA_TYPE_T
|
||||||
static const rb_data_type_t JSON_Parser_type;
|
static const rb_data_type_t JSON_Parser_type;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef ZALLOC
|
#ifndef ZALLOC
|
||||||
#define ZALLOC(type) ((type *)ruby_zalloc(sizeof(type)))
|
#define ZALLOC(type) ((type *)ruby_zalloc(sizeof(type)))
|
||||||
|
@ -845,6 +845,7 @@ static size_t JSON_memsize(const void *ptr)
|
|||||||
return sizeof(*json) + FBUFFER_CAPA(json->fbuffer);
|
return sizeof(*json) + FBUFFER_CAPA(json->fbuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_TYPE_RB_DATA_TYPE_T
|
||||||
static const rb_data_type_t JSON_Parser_type = {
|
static const rb_data_type_t JSON_Parser_type = {
|
||||||
"JSON/Parser",
|
"JSON/Parser",
|
||||||
{JSON_mark, JSON_free, JSON_memsize,},
|
{JSON_mark, JSON_free, JSON_memsize,},
|
||||||
@ -853,11 +854,16 @@ static const rb_data_type_t JSON_Parser_type = {
|
|||||||
RUBY_TYPED_FREE_IMMEDIATELY,
|
RUBY_TYPED_FREE_IMMEDIATELY,
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
static VALUE cJSON_parser_s_allocate(VALUE klass)
|
static VALUE cJSON_parser_s_allocate(VALUE klass)
|
||||||
{
|
{
|
||||||
JSON_Parser *json = JSON_allocate();
|
JSON_Parser *json = JSON_allocate();
|
||||||
|
#ifdef HAVE_TYPE_RB_DATA_TYPE_T
|
||||||
return TypedData_Wrap_Struct(klass, &JSON_Parser_type, json);
|
return TypedData_Wrap_Struct(klass, &JSON_Parser_type, json);
|
||||||
|
#else
|
||||||
|
return Data_Wrap_Struct(klass, JSON_mark, JSON_free, json);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user