summaryrefslogtreecommitdiff
path: root/ext/win32ole
diff options
context:
space:
mode:
authorsuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-08 12:44:54 +0000
committersuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-08 12:44:54 +0000
commitb61cb94e9488fc2ec905b063c422fa6ec0e1e1c0 (patch)
treebb6449fad3e2b65572bf45ca4cece34c376c0398 /ext/win32ole
parentc8d7d587ac11f3bea5cdac5a332b13bb9eb21447 (diff)
ext/win32ole/win32ole_variable.c: use typed data.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/win32ole')
-rw-r--r--ext/win32ole/win32ole_variable.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/ext/win32ole/win32ole_variable.c b/ext/win32ole/win32ole_variable.c
index fb67fdd..9b142f9 100644
--- a/ext/win32ole/win32ole_variable.c
+++ b/ext/win32ole/win32ole_variable.c
@@ -5,7 +5,8 @@ struct olevariabledata {
UINT index;
};
-static void olevariable_free(struct olevariabledata *polevar);
+static void olevariable_free(void *ptr);
+static size_t olevariable_size(const void *ptr);
static VALUE folevariable_name(VALUE self);
static VALUE ole_variable_ole_type(ITypeInfo *pTypeInfo, UINT var_index);
static VALUE folevariable_ole_type(VALUE self);
@@ -21,13 +22,26 @@ static VALUE ole_variable_varkind(ITypeInfo *pTypeInfo, UINT var_index);
static VALUE folevariable_varkind(VALUE self);
static VALUE folevariable_inspect(VALUE self);
+static const rb_data_type_t olevariable_datatype = {
+ "win32ole_variable",
+ {NULL, olevariable_free, olevariable_size,},
+ NULL, NULL, RUBY_TYPED_FREE_IMMEDIATELY
+};
+
static void
-olevariable_free(struct olevariabledata *polevar)
+olevariable_free(void *ptr)
{
+ struct olevariabledata *polevar = ptr;
OLE_FREE(polevar->pTypeInfo);
free(polevar);
}
+static size_t
+olevariable_size(const void *ptr)
+{
+ return ptr ? sizeof(struct olevariabledata) : 0;
+}
+
/*
* Document-class: WIN32OLE_VARIABLE
*
@@ -38,8 +52,8 @@ VALUE
create_win32ole_variable(ITypeInfo *pTypeInfo, UINT index, VALUE name)
{
struct olevariabledata *pvar;
- VALUE obj = Data_Make_Struct(cWIN32OLE_VARIABLE, struct olevariabledata,
- 0,olevariable_free,pvar);
+ VALUE obj = TypedData_Make_Struct(cWIN32OLE_VARIABLE, struct olevariabledata,
+ &olevariable_datatype, pvar);
pvar->pTypeInfo = pTypeInfo;
OLE_ADDREF(pTypeInfo);
pvar->index = index;
@@ -111,7 +125,7 @@ static VALUE
folevariable_ole_type(VALUE self)
{
struct olevariabledata *pvar;
- Data_Get_Struct(self, struct olevariabledata, pvar);
+ TypedData_Get_Struct(self, struct olevariabledata, &olevariable_datatype, pvar);
return ole_variable_ole_type(pvar->pTypeInfo, pvar->index);
}
@@ -145,7 +159,7 @@ static VALUE
folevariable_ole_type_detail(VALUE self)
{
struct olevariabledata *pvar;
- Data_Get_Struct(self, struct olevariabledata, pvar);
+ TypedData_Get_Struct(self, struct olevariabledata, &olevariable_datatype, pvar);
return ole_variable_ole_type_detail(pvar->pTypeInfo, pvar->index);
}
@@ -189,7 +203,7 @@ static VALUE
folevariable_value(VALUE self)
{
struct olevariabledata *pvar;
- Data_Get_Struct(self, struct olevariabledata, pvar);
+ TypedData_Get_Struct(self, struct olevariabledata, &olevariable_datatype, pvar);
return ole_variable_value(pvar->pTypeInfo, pvar->index);
}
@@ -235,7 +249,7 @@ static VALUE
folevariable_visible(VALUE self)
{
struct olevariabledata *pvar;
- Data_Get_Struct(self, struct olevariabledata, pvar);
+ TypedData_Get_Struct(self, struct olevariabledata, &olevariable_datatype, pvar);
return ole_variable_visible(pvar->pTypeInfo, pvar->index);
}
@@ -291,7 +305,7 @@ static VALUE
folevariable_variable_kind(VALUE self)
{
struct olevariabledata *pvar;
- Data_Get_Struct(self, struct olevariabledata, pvar);
+ TypedData_Get_Struct(self, struct olevariabledata, &olevariable_datatype, pvar);
return ole_variable_kind(pvar->pTypeInfo, pvar->index);
}
@@ -331,7 +345,7 @@ static VALUE
folevariable_varkind(VALUE self)
{
struct olevariabledata *pvar;
- Data_Get_Struct(self, struct olevariabledata, pvar);
+ TypedData_Get_Struct(self, struct olevariabledata, &olevariable_datatype, pvar);
return ole_variable_varkind(pvar->pTypeInfo, pvar->index);
}