Feature #10739 ยป json-1.8.2.patch
ext/json/generator/generator.c | ||
---|---|---|
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,},
|
||
... | ... | |
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
|
||
}
|
||
/*
|
ext/json/generator/generator.h | ||
---|---|---|
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; \
|
||
... | ... | |
\
|
||
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)
|
||
... | ... | |
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)
|
||
... | ... | |
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
|
ext/json/parser/parser.c | ||
---|---|---|
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,},
|
||
... | ... | |
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
|
||
}
|
||
/*
|
ext/json/parser/parser.h | ||
---|---|---|
#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
|
||
... | ... | |
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)
|
||
... | ... | |
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
|
ext/json/parser/parser.rl | ||
---|---|---|
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,},
|
||
... | ... | |
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
|
||
}
|
||
/*
|