diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-10-04 23:33:09 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-10-04 23:33:09 +0000 |
commit | bdfc2e29420d360eebf9dd1cf23668750bb8c8e8 (patch) | |
tree | b5a6b2fa7419c58ad9bf34929260069ddb4e4938 /ext/json/generator/generator.h | |
parent | ab7695fc5080fe0313ec4b62f3abb3156df08e3b (diff) | |
download | ruby-bdfc2e29420d360eebf9dd1cf23668750bb8c8e8.tar.gz |
json/generator: typed data
* ext/json/generator/generator.c (JSON_Generator_State_type): turn
into typed data.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47797 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/json/generator/generator.h')
-rw-r--r-- | ext/json/generator/generator.h | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/ext/json/generator/generator.h b/ext/json/generator/generator.h index db885d48aa..ddd1aa8a30 100644 --- a/ext/json/generator/generator.h +++ b/ext/json/generator/generator.h @@ -78,9 +78,12 @@ typedef struct JSON_Generator_StateStruct { long buffer_initial_length; } JSON_Generator_State; +#define GET_STATE_TO(self, state) \ + TypedData_Get_Struct(self, JSON_Generator_State, &JSON_Generator_State_type, state) + #define GET_STATE(self) \ JSON_Generator_State *state; \ - Data_Get_Struct(self, JSON_Generator_State, state) + GET_STATE_TO(self, state) #define GENERATE_JSON(type) \ FBuffer *buffer; \ @@ -89,7 +92,7 @@ typedef struct JSON_Generator_StateStruct { \ rb_scan_args(argc, argv, "01", &Vstate); \ Vstate = cState_from_state_s(cState, Vstate); \ - Data_Get_Struct(Vstate, JSON_Generator_State, 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) @@ -108,7 +111,7 @@ static VALUE mTrueClass_to_json(int argc, VALUE *argv, VALUE self); static VALUE mFalseClass_to_json(int argc, VALUE *argv, VALUE self); static VALUE mNilClass_to_json(int argc, VALUE *argv, VALUE self); static VALUE mObject_to_json(int argc, VALUE *argv, VALUE self); -static void State_free(JSON_Generator_State *state); +static void State_free(void *state); static JSON_Generator_State *State_allocate(void); static VALUE cState_s_allocate(VALUE klass); static VALUE cState_configure(VALUE self, VALUE opts); @@ -144,5 +147,6 @@ 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); +static const rb_data_type_t JSON_Generator_State_type; #endif |