From 8c3fb4929a4ead95893b0630edd9818fea0c5999 Mon Sep 17 00:00:00 2001 From: suke Date: Mon, 4 Aug 2014 10:49:34 +0000 Subject: * ext/win32ole/win32ole.c (ole_invoke): call rb_hash_foreach instead of rb_block_call. * ext/win32ole/win32ole.c: add comment for rdoc of WIN32OLE_VARIANT class. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47060 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ ext/win32ole/win32ole.c | 38 ++++++++++++++++++++++++++------------ 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 06d8e0c962..38465adc5a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2014年08月04日 19時44分36秒 Masaki Suketa + + * ext/win32ole/win32ole.c (ole_invoke): call rb_hash_foreach instead + of rb_block_call. + + * ext/win32ole/win32ole.c: add comment for rdoc of WIN32OLE_VARIANT + class. + Mon Aug 4 09:12:47 2014 Eric Wong * variable.c: cleanup to use rb_const_lookup diff --git a/ext/win32ole/win32ole.c b/ext/win32ole/win32ole.c index 22d6626b5a..8f5da746be 100644 --- a/ext/win32ole/win32ole.c +++ b/ext/win32ole/win32ole.c @@ -63,7 +63,7 @@ const IID IID_IMultiLanguage2 = {0xDCCFC164, 0x2B38, 0x11d2, {0xB7, 0xEC, 0x00, #define WC2VSTR(x) ole_wc2vstr((x), TRUE) -#define WIN32OLE_VERSION "1.7.1" +#define WIN32OLE_VERSION "1.7.2" typedef HRESULT (STDAPICALLTYPE FNCOCREATEINSTANCEEX) (REFCLSID, IUnknown*, DWORD, COSERVERINFO*, DWORD, MULTI_QI*); @@ -309,7 +309,7 @@ static VALUE fole_s_create_guid(VALUE self); static VALUE fole_s_ole_initialize(VALUE self); static VALUE fole_s_ole_uninitialize(VALUE self); static VALUE fole_initialize(int argc, VALUE *argv, VALUE self); -static VALUE hash2named_arg(RB_BLOCK_CALL_FUNC_ARGLIST(pair, op)); +static int hash2named_arg(VALUE key, VALUE val, VALUE pop); static VALUE set_argv(VARIANTARG* realargs, unsigned int beg, unsigned int end); static VALUE ole_invoke(int argc, VALUE *argv, VALUE self, USHORT wFlags, BOOL is_bracket); static VALUE fole_invoke(int argc, VALUE *argv, VALUE self); @@ -3334,18 +3334,15 @@ fole_initialize(int argc, VALUE *argv, VALUE self) return self; } -static VALUE -hash2named_arg(RB_BLOCK_CALL_FUNC_ARGLIST(pair, op)) +static int +hash2named_arg(VALUE key, VALUE val, VALUE pop) { - struct oleparam* pOp = (struct oleparam *)op; + struct oleparam* pOp = (struct oleparam *)pop; unsigned int index, i; - VALUE key, value; index = pOp->dp.cNamedArgs; - /*--------------------------------------------- the data-type of key must be String or Symbol -----------------------------------------------*/ - key = rb_ary_entry(pair, 0); if(!RB_TYPE_P(key, T_STRING) && !RB_TYPE_P(key, T_SYMBOL)) { /* clear name of dispatch parameters */ for(i = 1; i < index + 1; i++) { @@ -3365,12 +3362,11 @@ hash2named_arg(RB_BLOCK_CALL_FUNC_ARGLIST(pair, op)) /* pNamedArgs[0] is , so "index + 1" */ pOp->pNamedArgs[index + 1] = ole_vstr2wc(key); - value = rb_ary_entry(pair, 1); VariantInit(&(pOp->dp.rgvarg[index])); - ole_val2variant(value, &(pOp->dp.rgvarg[index])); + ole_val2variant(val, &(pOp->dp.rgvarg[index])); pOp->dp.cNamedArgs += 1; - return Qnil; + return ST_CONTINUE; } static VALUE @@ -3464,7 +3460,8 @@ ole_invoke(int argc, VALUE *argv, VALUE self, USHORT wFlags, BOOL is_bracket) op.dp.cArgs = cNamedArgs + argc - 2; op.pNamedArgs = ALLOCA_N(OLECHAR*, cNamedArgs + 1); op.dp.rgvarg = ALLOCA_N(VARIANTARG, op.dp.cArgs); - rb_block_call(param, rb_intern("each"), 0, 0, hash2named_arg, (VALUE)&op); + + rb_hash_foreach(param, hash2named_arg, (VALUE)&op); pDispID = ALLOCA_N(DISPID, cNamedArgs + 1); op.pNamedArgs[0] = ole_vstr2wc(cmd); @@ -8833,6 +8830,23 @@ check_type_val2variant(VALUE val) } } +/* + * Document-class: WIN32OLE_VARIANT + * + * WIN32OLE_VARIANT objects represents OLE variant. + * + * Win32OLE converts Ruby object into OLE variant automatically when + * invoking OLE methods. If OLE method requires the argument which is + * different from the variant by automatic conversion of Win32OLE, you + * can convert the specfied variant type by using WIN32OLE_VARIANT class. + * + * param = WIN32OLE_VARIANT.new(10, WIN32OLE::VARIANT::VT_R4) + * oleobj.method(param) + * + * WIN32OLE_VARIANT does not support VT_RECORD variant. Use WIN32OLE_RECORD + * class instead of WIN32OLE_VARIANT if the VT_RECORD variant is needed. + */ + /* * call-seq: * WIN32OLE_VARIANT.new(val, vartype) #=> WIN32OLE_VARIANT object. -- cgit v1.2.3