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

ruby-changes:36058

From: suke <ko1@a...>
Date: Sun, 26 Oct 2014 07:46:27 +0900 (JST)
Subject: [ruby-changes:36058] suke:r48139 (trunk): ext/win32ole/win32ole.c (ole_val2variant, ole_invoke): refactoring.

suke	2014-10-26 07:46:15 +0900 (Sun, 26 Oct 2014)

  New Revision: 48139

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

  Log:
    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.

  Modified files:
    trunk/ChangeLog
    trunk/ext/win32ole/win32ole.c
    trunk/ext/win32ole/win32ole_variant.c
    trunk/ext/win32ole/win32ole_variant.h
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 48138)
+++ ChangeLog	(revision 48139)
@@ -1,3 +1,13 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Oct 26 07:40:11 2014  Masaki Suketa <masaki.suketa@n...>
+
+	* 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  <akr@f...>
 
 	* io.c (io_binwrite_string): Test writev() failure.
Index: ext/win32ole/win32ole.c
===================================================================
--- ext/win32ole/win32ole.c	(revision 48138)
+++ ext/win32ole/win32ole.c	(revision 48139)
@@ -1217,7 +1217,6 @@ void https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L1217
 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) https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L1225
         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 https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L2536
     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 https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L2630
             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;
Index: ext/win32ole/win32ole_variant.c
===================================================================
--- ext/win32ole/win32ole_variant.c	(revision 48138)
+++ ext/win32ole/win32ole_variant.c	(revision 48139)
@@ -1,5 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole_variant.c#L1
 #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 https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole_variant.c#L670
 }
 
 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);
Index: ext/win32ole/win32ole_variant.h
===================================================================
--- ext/win32ole/win32ole_variant.h	(revision 48138)
+++ ext/win32ole/win32ole_variant.h	(revision 48139)
@@ -1,12 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole_variant.h#L1
 #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

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

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