ruby-changes:35766
From: suke <ko1@a...>
Date: Wed, 8 Oct 2014 21:45:05 +0900 (JST)
Subject: [ruby-changes:35766] suke:r47848 (trunk): ext/win32ole/win32ole_variable.c: use typed data.
suke 2014-10-08 21:44:54 +0900 (Wed, 08 Oct 2014) New Revision: 47848 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47848 Log: ext/win32ole/win32ole_variable.c: use typed data. Modified files: trunk/ChangeLog trunk/ext/win32ole/win32ole_variable.c Index: ChangeLog =================================================================== --- ChangeLog (revision 47847) +++ ChangeLog (revision 47848) @@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Wed Oct 8 21:44:10 2014 Masaki Suketa <masaki.suketa@n...> + + * ext/win32ole/win32ole_variable.c: use typed data. + Wed Oct 8 16:36:47 2014 gogo tanaka <mail@t...> * test/ruby/test_syntax.rb: added syntax tests of underscore Index: ext/win32ole/win32ole_variable.c =================================================================== --- ext/win32ole/win32ole_variable.c (revision 47847) +++ ext/win32ole/win32ole_variable.c (revision 47848) @@ -5,7 +5,8 @@ struct olevariabledata { https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole_variable.c#L5 UINT index; }; -static void olevariable_free(struct olevariabledata *polevar); +static void olevariable_free(void *ptr); +static size_t olevariable_size(const void *ptr); static VALUE folevariable_name(VALUE self); static VALUE ole_variable_ole_type(ITypeInfo *pTypeInfo, UINT var_index); static VALUE folevariable_ole_type(VALUE self); @@ -21,13 +22,26 @@ static VALUE ole_variable_varkind(ITypeI https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole_variable.c#L22 static VALUE folevariable_varkind(VALUE self); static VALUE folevariable_inspect(VALUE self); +static const rb_data_type_t olevariable_datatype = { + "win32ole_variable", + {NULL, olevariable_free, olevariable_size,}, + NULL, NULL, RUBY_TYPED_FREE_IMMEDIATELY +}; + static void -olevariable_free(struct olevariabledata *polevar) +olevariable_free(void *ptr) { + struct olevariabledata *polevar = ptr; OLE_FREE(polevar->pTypeInfo); free(polevar); } +static size_t +olevariable_size(const void *ptr) +{ + return ptr ? sizeof(struct olevariabledata) : 0; +} + /* * Document-class: WIN32OLE_VARIABLE * @@ -38,8 +52,8 @@ VALUE https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole_variable.c#L52 create_win32ole_variable(ITypeInfo *pTypeInfo, UINT index, VALUE name) { struct olevariabledata *pvar; - VALUE obj = Data_Make_Struct(cWIN32OLE_VARIABLE, struct olevariabledata, - 0,olevariable_free,pvar); + VALUE obj = TypedData_Make_Struct(cWIN32OLE_VARIABLE, struct olevariabledata, + &olevariable_datatype, pvar); pvar->pTypeInfo = pTypeInfo; OLE_ADDREF(pTypeInfo); pvar->index = index; @@ -111,7 +125,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole_variable.c#L125 folevariable_ole_type(VALUE self) { struct olevariabledata *pvar; - Data_Get_Struct(self, struct olevariabledata, pvar); + TypedData_Get_Struct(self, struct olevariabledata, &olevariable_datatype, pvar); return ole_variable_ole_type(pvar->pTypeInfo, pvar->index); } @@ -145,7 +159,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole_variable.c#L159 folevariable_ole_type_detail(VALUE self) { struct olevariabledata *pvar; - Data_Get_Struct(self, struct olevariabledata, pvar); + TypedData_Get_Struct(self, struct olevariabledata, &olevariable_datatype, pvar); return ole_variable_ole_type_detail(pvar->pTypeInfo, pvar->index); } @@ -189,7 +203,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole_variable.c#L203 folevariable_value(VALUE self) { struct olevariabledata *pvar; - Data_Get_Struct(self, struct olevariabledata, pvar); + TypedData_Get_Struct(self, struct olevariabledata, &olevariable_datatype, pvar); return ole_variable_value(pvar->pTypeInfo, pvar->index); } @@ -235,7 +249,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole_variable.c#L249 folevariable_visible(VALUE self) { struct olevariabledata *pvar; - Data_Get_Struct(self, struct olevariabledata, pvar); + TypedData_Get_Struct(self, struct olevariabledata, &olevariable_datatype, pvar); return ole_variable_visible(pvar->pTypeInfo, pvar->index); } @@ -291,7 +305,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole_variable.c#L305 folevariable_variable_kind(VALUE self) { struct olevariabledata *pvar; - Data_Get_Struct(self, struct olevariabledata, pvar); + TypedData_Get_Struct(self, struct olevariabledata, &olevariable_datatype, pvar); return ole_variable_kind(pvar->pTypeInfo, pvar->index); } @@ -331,7 +345,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole_variable.c#L345 folevariable_varkind(VALUE self) { struct olevariabledata *pvar; - Data_Get_Struct(self, struct olevariabledata, pvar); + TypedData_Get_Struct(self, struct olevariabledata, &olevariable_datatype, pvar); return ole_variable_varkind(pvar->pTypeInfo, pvar->index); } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/