ruby-changes:35672
From: suke <ko1@a...>
Date: Wed, 1 Oct 2014 21:16:47 +0900 (JST)
Subject: [ruby-changes:35672] suke:r47754 (trunk): ext/win32ole/win32ole_type.c: use typed data.
suke 2014-10-01 21:16:35 +0900 (Wed, 01 Oct 2014) New Revision: 47754 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47754 Log: ext/win32ole/win32ole_type.c: use typed data. Modified files: trunk/ChangeLog trunk/ext/win32ole/win32ole_type.c Index: ChangeLog =================================================================== --- ChangeLog (revision 47753) +++ ChangeLog (revision 47754) @@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Wed Oct 1 21:14:34 2014 Masaki Suketa <masaki.suketa@n...> + + * ext/win32ole/win32ole_type.c: use typed data. + Wed Oct 1 18:15:42 2014 Nolan Evans <nolane@g...> * compile.c: remove commented out code. Index: ext/win32ole/win32ole_type.c =================================================================== --- ext/win32ole/win32ole_type.c (revision 47753) +++ ext/win32ole/win32ole_type.c (revision 47754) @@ -4,7 +4,8 @@ struct oletypedata { https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole_type.c#L4 ITypeInfo *pTypeInfo; }; -static void oletype_free(struct oletypedata *poletype); +static void oletype_free(void *ptr); +static size_t oletype_size(const void *ptr); static VALUE foletype_s_ole_classes(VALUE self, VALUE typelib); static VALUE foletype_s_typelibs(VALUE self); static VALUE foletype_s_progids(VALUE self); @@ -46,6 +47,12 @@ static VALUE foletype_default_event_sour https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole_type.c#L47 static VALUE foletype_default_ole_types(VALUE self); static VALUE foletype_inspect(VALUE self); +static const rb_data_type_t oletype_datatype = { + "win32ole_type", + {NULL, oletype_free, oletype_size,}, + NULL, NULL, RUBY_TYPED_FREE_IMMEDIATELY +}; + /* * Document-class: WIN32OLE_TYPE * @@ -53,16 +60,23 @@ static VALUE foletype_inspect(VALUE self https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole_type.c#L60 */ static void -oletype_free(struct oletypedata *poletype) +oletype_free(void *ptr) { + struct oletypedata *poletype = ptr; OLE_FREE(poletype->pTypeInfo); free(poletype); } +static size_t +oletype_size(const void *ptr) +{ + return ptr ? sizeof(struct oletypedata) : 0; +} + ITypeInfo *itypeinfo(VALUE self) { struct oletypedata *ptype; - Data_Get_Struct(self, struct oletypedata, ptype); + TypedData_Get_Struct(self, struct oletypedata, &oletype_datatype, ptype); return ptype->pTypeInfo; } @@ -171,7 +185,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole_type.c#L185 oletype_set_member(VALUE self, ITypeInfo *pTypeInfo, VALUE name) { struct oletypedata *ptype; - Data_Get_Struct(self, struct oletypedata, ptype); + TypedData_Get_Struct(self, struct oletypedata, &oletype_datatype, ptype); rb_ivar_set(self, rb_intern("name"), name); ptype->pTypeInfo = pTypeInfo; if(pTypeInfo) OLE_ADDREF(pTypeInfo); @@ -184,7 +198,7 @@ foletype_s_allocate(VALUE klass) https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole_type.c#L198 struct oletypedata *poletype; VALUE obj; ole_initialize(); - obj = Data_Make_Struct(klass,struct oletypedata,0,oletype_free,poletype); + obj = TypedData_Make_Struct(klass,struct oletypedata, &oletype_datatype, poletype); poletype->pTypeInfo = NULL; return obj; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/