summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--ext/win32ole/win32ole_typelib.c24
2 files changed, 23 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index ae76278..ed044b7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/ext/win32ole/win32ole_typelib.c b/ext/win32ole/win32ole_typelib.c
index 9a8fdd5..a2058db 100644
--- a/ext/win32ole/win32ole_typelib.c
+++ b/ext/win32ole/win32ole_typelib.c
@@ -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;
}