* ext/win32ole/win32ole_typelib.c: use typed data.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47746 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
suke 2014-09-30 09:47:38 +00:00
Родитель b208e060f2
Коммит d7b32ffd64
2 изменённых файлов: 23 добавлений и 5 удалений

Просмотреть файл

@ -1,3 +1,7 @@
Tue Sep 30 18:46:31 2014 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* ext/win32ole/win32ole_typelib.c: use typed data.
Tue Sep 30 09:51:46 2014 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
* common.mk: fixed broken reference of update-config_files task

Просмотреть файл

@ -9,7 +9,8 @@ static VALUE oletypelib_path(VALUE guid, VALUE version);
static HRESULT oletypelib_from_guid(VALUE guid, VALUE version, ITypeLib **ppTypeLib);
static VALUE foletypelib_s_typelibs(VALUE self);
static VALUE oletypelib_set_member(VALUE self, ITypeLib *pTypeLib);
static void oletypelib_free(struct oletypelibdata *poletypelib);
static void oletypelib_free(void *ptr);
static size_t oletypelib_size(const void *ptr);
static VALUE foletypelib_s_allocate(VALUE klass);
static VALUE oletypelib_search_registry(VALUE self, VALUE typelib);
static void oletypelib_get_libattr(ITypeLib *pTypeLib, TLIBATTR **ppTLibAttr);
@ -30,6 +31,12 @@ static VALUE typelib_file_from_clsid(VALUE ole);
static VALUE foletypelib_ole_types(VALUE self);
static VALUE foletypelib_inspect(VALUE self);
static const rb_data_type_t oletypelib_datatype = {
"win32ole_typelib",
{NULL, oletypelib_free, oletypelib_size,},
NULL, NULL, RUBY_TYPED_FREE_IMMEDIATELY
};
static VALUE
reg_get_typelib_file_path(HKEY hkey)
{
@ -99,7 +106,7 @@ ITypeLib *
itypelib(VALUE self)
{
struct oletypelibdata *ptlib;
Data_Get_Struct(self, struct oletypelibdata, ptlib);
TypedData_Get_Struct(self, struct oletypelibdata, &oletypelib_datatype, ptlib);
return ptlib->pTypeLib;
}
@ -182,25 +189,32 @@ static VALUE
oletypelib_set_member(VALUE self, ITypeLib *pTypeLib)
{
struct oletypelibdata *ptlib;
Data_Get_Struct(self, struct oletypelibdata, ptlib);
TypedData_Get_Struct(self, struct oletypelibdata, &oletypelib_datatype, ptlib);
ptlib->pTypeLib = pTypeLib;
return self;
}
static void
oletypelib_free(struct oletypelibdata *poletypelib)
oletypelib_free(void *ptr)
{
struct oletypelibdata *poletypelib = ptr;
OLE_FREE(poletypelib->pTypeLib);
free(poletypelib);
}
static size_t
oletypelib_size(const void *ptr)
{
return ptr ? sizeof(struct oletypelibdata) : 0;
}
static VALUE
foletypelib_s_allocate(VALUE klass)
{
struct oletypelibdata *poletypelib;
VALUE obj;
ole_initialize();
obj = Data_Make_Struct(klass, struct oletypelibdata, 0, oletypelib_free, poletypelib);
obj = TypedData_Make_Struct(klass, struct oletypelibdata, &oletypelib_datatype, poletypelib);
poletypelib->pTypeLib = NULL;
return obj;
}