summaryrefslogtreecommitdiff
path: root/ext/win32ole/win32ole_type.c
diff options
context:
space:
mode:
authorsuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-01 12:16:35 +0000
committersuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-01 12:16:35 +0000
commit8d00b43b305552414273143eea5d4e510c5ab342 (patch)
tree713be8ae66880a4ea9627563292148b90b58d388 /ext/win32ole/win32ole_type.c
parent2b0cc32c1a74da7eba2fd5dfbe07a57e8228b5a8 (diff)
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
Diffstat (limited to 'ext/win32ole/win32ole_type.c')
-rw-r--r--ext/win32ole/win32ole_type.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/ext/win32ole/win32ole_type.c b/ext/win32ole/win32ole_type.c
index 00db09e191..f35e65923d 100644
--- a/ext/win32ole/win32ole_type.c
+++ b/ext/win32ole/win32ole_type.c
@@ -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;
}