[前][次][番号順一覧][スレッド一覧]

ruby-changes:34757

From: suke <ko1@a...>
Date: Wed, 16 Jul 2014 23:06:03 +0900 (JST)
Subject: [ruby-changes:34757] suke:r46840 (trunk): * ext/win32ole/win32ole.c (ole_variant2val): support array of

suke	2014-07-16 23:05:52 +0900 (Wed, 16 Jul 2014)

  New Revision: 46840

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=46840

  Log:
    * ext/win32ole/win32ole.c (ole_variant2val): support array of
      VT_RECORD variant.

  Modified files:
    trunk/ChangeLog
    trunk/ext/win32ole/win32ole.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 46839)
+++ ChangeLog	(revision 46840)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Jul 16 23:01:43 2014  Masaki Suketa <masaki.suketa@n...>
+
+	* ext/win32ole/win32ole.c (ole_variant2val): support array of
+	  VT_RECORD variant.
+
 Wed Jul 16 20:21:49 2014  Naohisa Goto  <ngotogenome@g...>
 
 	* vm_core.h (struct rb_iseq_struct): stack_max is changed to int
Index: ext/win32ole/win32ole.c
===================================================================
--- ext/win32ole/win32ole.c	(revision 46839)
+++ ext/win32ole/win32ole.c	(revision 46840)
@@ -143,7 +143,7 @@ const IID IID_IMultiLanguage2 = {0xDCCFC https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L143
 
 #define WC2VSTR(x) ole_wc2vstr((x), TRUE)
 
-#define WIN32OLE_VERSION "1.5.8"
+#define WIN32OLE_VERSION "1.5.9"
 
 typedef HRESULT (STDAPICALLTYPE FNCOCREATEINSTANCEEX)
     (REFCLSID, IUnknown*, DWORD, COSERVERINFO*, DWORD, MULTI_QI*);
@@ -2104,11 +2104,15 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L2104
 ole_variant2val(VARIANT *pvar)
 {
     VALUE obj = Qnil;
+    VARTYPE vt = V_VT(pvar);
     HRESULT hr;
-    while ( V_VT(pvar) == (VT_BYREF | VT_VARIANT) )
+    while ( vt == (VT_BYREF | VT_VARIANT) ) {
         pvar = V_VARIANTREF(pvar);
+        vt = V_VT(pvar);
+    }
 
     if(V_ISARRAY(pvar)) {
+        VARTYPE vt_base = vt & VT_TYPEMASK;
         SAFEARRAY *psa = V_ISBYREF(pvar) ? *V_ARRAYREF(pvar) : V_ARRAY(pvar);
         UINT i = 0;
         LONG *pid, *plb, *pub;
@@ -2119,9 +2123,6 @@ ole_variant2val(VARIANT *pvar) https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L2123
             return obj;
         }
         dim = SafeArrayGetDim(psa);
-        VariantInit(&variant);
-        V_VT(&variant) = (V_VT(pvar) & ~VT_ARRAY) | VT_BYREF;
-
         pid = ALLOC_N(LONG, dim);
         plb = ALLOC_N(LONG, dim);
         pub = ALLOC_N(LONG, dim);
@@ -2142,9 +2143,20 @@ ole_variant2val(VARIANT *pvar) https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L2143
         if (SUCCEEDED(hr)) {
             obj = rb_ary_new();
             i = 0;
+            VariantInit(&variant);
+            V_VT(&variant) = vt_base | VT_BYREF;
+            if (vt_base == VT_RECORD) {
+                hr = SafeArrayGetRecordInfo(psa, &V_RECORDINFO(&variant));
+                if (SUCCEEDED(hr)) {
+                    V_VT(&variant) = VT_RECORD;
+                }
+            }
             while (i < dim) {
                 ary_new_dim(obj, pid, plb, dim);
-                hr = SafeArrayPtrOfIndex(psa, pid, &V_BYREF(&variant));
+                if (vt_base == VT_RECORD)
+                    hr = SafeArrayPtrOfIndex(psa, pid, &V_RECORD(&variant));
+                else
+                    hr = SafeArrayPtrOfIndex(psa, pid, &V_BYREF(&variant));
                 if (SUCCEEDED(hr)) {
                     val = ole_variant2val(&variant);
                     ary_store_dim(obj, pid, plb, dim, val);
@@ -2352,7 +2364,6 @@ ole_variant2val(VARIANT *pvar) https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L2364
         VALUE fields = Qnil;
         VALUE val;
         VALUE key;
-
         obj = rb_funcall(cWIN32OLE_RECORD, rb_intern("new"), 0);
         hr = pri->lpVtbl->GetName(pri, &bstr);
         if (SUCCEEDED(hr)) {
@@ -3548,7 +3559,6 @@ ole_invoke(int argc, VALUE *argv, VALUE https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L3559
         op.dp.rgdispidNamedArgs = ALLOCA_N( DISPID, 1 );
         op.dp.rgdispidNamedArgs[0] = DISPID_PROPERTYPUT;
     }
-
     hr = pole->pDispatch->lpVtbl->Invoke(pole->pDispatch, DispID,
                                          &IID_NULL, lcid, wFlags, &op.dp,
                                          &result, &excepinfo, &argErr);

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]