summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorsuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-30 09:47:38 +0000
committersuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-30 09:47:38 +0000
commitd7b32ffd64cb4248e325732c0e0430c65cddef24 (patch)
tree5aa153a76177236f9a660b81095a15243232eb8d /ext
parentb208e060f2b6c35fd6da2fd025e54edcd6055c8d (diff)
* 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
Diffstat (limited to 'ext')
-rw-r--r--ext/win32ole/win32ole_typelib.c24
1 files changed, 19 insertions, 5 deletions
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;
}