summaryrefslogtreecommitdiff
path: root/ext/win32ole
diff options
context:
space:
mode:
authorsuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-25 22:46:15 +0000
committersuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-25 22:46:15 +0000
commit5d2ce2fb40fecc7ad8431886d2bc3ab2aa0a69ec (patch)
tree5dd041e781038b14ace319df575d081bdd797dfb /ext/win32ole
parent1fe90db5380117580ae41be4f3d01686aaa73697 (diff)
ext/win32ole/win32ole.c (ole_val2variant, ole_invoke): refactoring.
use ole_variant2variant to convert WIN32OLE_VARIANT object to VARIANT object. ext/win32ole/win32ole_variant.c: refactoring. add ole_variant2variant. ext/win32ole/win32ole_variant.h: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/win32ole')
-rw-r--r--ext/win32ole/win32ole.c8
-rw-r--r--ext/win32ole/win32ole_variant.c13
-rw-r--r--ext/win32ole/win32ole_variant.h6
3 files changed, 16 insertions, 11 deletions
diff --git a/ext/win32ole/win32ole.c b/ext/win32ole/win32ole.c
index d239d9c..bb59752 100644
--- a/ext/win32ole/win32ole.c
+++ b/ext/win32ole/win32ole.c
@@ -1217,7 +1217,6 @@ void
ole_val2variant(VALUE val, VARIANT *var)
{
struct oledata *pole;
- struct olevariantdata *pvar;
if(rb_obj_is_kind_of(val, cWIN32OLE)) {
Data_Get_Struct(val, struct oledata, pole);
OLE_ADDREF(pole->pDispatch);
@@ -1226,8 +1225,7 @@ ole_val2variant(VALUE val, VARIANT *var)
return;
}
if (rb_obj_is_kind_of(val, cWIN32OLE_VARIANT)) {
- Data_Get_Struct(val, struct olevariantdata, pvar);
- VariantCopy(var, &(pvar->var));
+ ole_variant2variant(val, var);
return;
}
if (rb_obj_is_kind_of(val, cWIN32OLE_RECORD)) {
@@ -2538,7 +2536,6 @@ ole_invoke(int argc, VALUE *argv, VALUE self, USHORT wFlags, BOOL is_bracket)
unsigned int cNamedArgs;
int n;
struct oleparam op;
- struct olevariantdata *pvar;
memset(&excepinfo, 0, sizeof(EXCEPINFO));
VariantInit(&result);
@@ -2633,8 +2630,7 @@ ole_invoke(int argc, VALUE *argv, VALUE self, USHORT wFlags, BOOL is_bracket)
VariantInit(&op.dp.rgvarg[n]);
param = rb_ary_entry(paramS, i-cNamedArgs);
if (rb_obj_is_kind_of(param, cWIN32OLE_VARIANT)) {
- Data_Get_Struct(param, struct olevariantdata, pvar);
- VariantCopy(&op.dp.rgvarg[n], &(pvar->var));
+ ole_variant2variant(param, &op.dp.rgvarg[n]);
} else {
ole_val2variant(param, &realargs[n]);
V_VT(&op.dp.rgvarg[n]) = VT_VARIANT | VT_BYREF;
diff --git a/ext/win32ole/win32ole_variant.c b/ext/win32ole/win32ole_variant.c
index ef5227b..308e555 100644
--- a/ext/win32ole/win32ole_variant.c
+++ b/ext/win32ole/win32ole_variant.c
@@ -1,5 +1,10 @@
#include "win32ole.h"
+struct olevariantdata {
+ VARIANT realvar;
+ VARIANT var;
+};
+
static void olevariant_free(struct olevariantdata *pvar);
static void ole_val2olevariantdata(VALUE val, VARTYPE vt, struct olevariantdata *pvar);
static void ole_val2variant_err(VALUE val, VARIANT *var);
@@ -665,6 +670,14 @@ folevariant_set_value(VALUE self, VALUE val)
}
void
+ole_variant2variant(VALUE val, VARIANT *var)
+{
+ struct olevariantdata *pvar;
+ Data_Get_Struct(val, struct olevariantdata, pvar);
+ VariantCopy(var, &(pvar->var));
+}
+
+void
Init_win32ole_variant(void)
{
cWIN32OLE_VARIANT = rb_define_class("WIN32OLE_VARIANT", rb_cObject);
diff --git a/ext/win32ole/win32ole_variant.h b/ext/win32ole/win32ole_variant.h
index d06aa34..efe7ea8 100644
--- a/ext/win32ole/win32ole_variant.h
+++ b/ext/win32ole/win32ole_variant.h
@@ -1,12 +1,8 @@
#ifndef WIN32OLE_VARIANT_H
#define WIN32OLE_VARIANT_H 1
-struct olevariantdata {
- VARIANT realvar;
- VARIANT var;
-};
-
VALUE cWIN32OLE_VARIANT;
+void ole_variant2variant(VALUE val, VARIANT *var);
void Init_win32ole_variant(void);
#endif