1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

ext/win32ole/win32ole_type.c: use typed data.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47754 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
suke 2014-10-01 12:16:35 +00:00
parent 2b0cc32c1a
commit 8d00b43b30
2 changed files with 23 additions and 5 deletions

View file

@ -1,3 +1,7 @@
Wed Oct 1 21:14:34 2014 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* ext/win32ole/win32ole_type.c: use typed data.
Wed Oct 1 18:15:42 2014 Nolan Evans <nolane@gmail.com>
* compile.c: remove commented out code.

View file

@ -4,7 +4,8 @@ struct oletypedata {
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_sources(VALUE self);
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);
*/
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
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)
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;
}