diff --git a/ChangeLog b/ChangeLog index 17a6a36864..3d62648b18 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Sun Oct 26 07:40:11 2014 Masaki Suketa + + * 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. + Sat Oct 25 22:28:17 2014 Tanaka Akira * io.c (io_binwrite_string): Test writev() failure. diff --git a/ext/win32ole/win32ole.c b/ext/win32ole/win32ole.c index d239d9caf8..bb59752ff7 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 ef5227b5c9..308e555e4e 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); @@ -664,6 +669,14 @@ folevariant_set_value(VALUE self, VALUE val) return Qnil; } +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) { diff --git a/ext/win32ole/win32ole_variant.h b/ext/win32ole/win32ole_variant.h index d06aa34b61..efe7ea8bef 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