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

ruby-changes:48215

From: suke <ko1@a...>
Date: Sun, 22 Oct 2017 08:57:15 +0900 (JST)
Subject: [ruby-changes:48215] suke:r60330 (trunk): ext/win32ole/win32ole.c (fole_missing): set receiver in NoMethodError.

suke	2017-10-22 08:57:10 +0900 (Sun, 22 Oct 2017)

  New Revision: 60330

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

  Log:
    ext/win32ole/win32ole.c (fole_missing): set receiver in NoMethodError.
    test/win32ole/test_win32ole.rb: ditto.

  Modified files:
    trunk/ext/win32ole/win32ole.c
    trunk/test/win32ole/test_win32ole.rb
Index: ext/win32ole/win32ole.c
===================================================================
--- ext/win32ole/win32ole.c	(revision 60329)
+++ ext/win32ole/win32ole.c	(revision 60330)
@@ -2646,9 +2646,7 @@ ole_invoke(int argc, VALUE *argv, VALUE https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L2646
                 &wcmdname, 1, lcid, &DispID);
         SysFreeString(wcmdname);
         if(FAILED(hr)) {
-            ole_raise(hr, rb_eNoMethodError,
-                    "unknown property or method: `%s'",
-                    StringValuePtr(cmd));
+            return rb_eNoMethodError;
         }
     }
 
@@ -2850,7 +2848,11 @@ ole_invoke(int argc, VALUE *argv, VALUE https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L2848
 static VALUE
 fole_invoke(int argc, VALUE *argv, VALUE self)
 {
-    return ole_invoke(argc, argv, self, DISPATCH_METHOD|DISPATCH_PROPERTYGET, FALSE);
+    VALUE v = ole_invoke(argc, argv, self, DISPATCH_METHOD|DISPATCH_PROPERTYGET, FALSE);
+    if (v == rb_eNoMethodError) {
+        return rb_call_super(argc, argv);
+    }
+    return v;
 }
 
 static VALUE
@@ -2863,8 +2865,7 @@ ole_invoke2(VALUE self, VALUE dispid, VA https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L2865
     VARIANT result;
     DISPPARAMS dispParams;
     VARIANTARG* realargs = NULL;
-    int i, j;
-    VALUE obj = Qnil;
+    int i, j; VALUE obj = Qnil;
     VALUE tp, param;
     VALUE v;
     VARTYPE vt;
@@ -3118,7 +3119,11 @@ fole_setproperty2(VALUE self, VALUE disp https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L3119
 static VALUE
 fole_setproperty_with_bracket(int argc, VALUE *argv, VALUE self)
 {
-    return ole_invoke(argc, argv, self, DISPATCH_PROPERTYPUT, TRUE);
+    VALUE v = ole_invoke(argc, argv, self, DISPATCH_PROPERTYPUT, TRUE);
+    if (v == rb_eNoMethodError) {
+        return rb_call_super(argc, argv);
+    }
+    return v;
 }
 
 /*
@@ -3137,7 +3142,11 @@ fole_setproperty_with_bracket(int argc, https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L3142
 static VALUE
 fole_setproperty(int argc, VALUE *argv, VALUE self)
 {
-    return ole_invoke(argc, argv, self, DISPATCH_PROPERTYPUT, FALSE);
+    VALUE v = ole_invoke(argc, argv, self, DISPATCH_PROPERTYPUT, FALSE);
+    if (v == rb_eNoMethodError) {
+        return rb_call_super(argc, argv);
+    }
+    return v;
 }
 
 /*
@@ -3159,7 +3168,11 @@ fole_setproperty(int argc, VALUE *argv, https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L3168
 static VALUE
 fole_getproperty_with_bracket(int argc, VALUE *argv, VALUE self)
 {
-    return ole_invoke(argc, argv, self, DISPATCH_PROPERTYGET, TRUE);
+    VALUE v = ole_invoke(argc, argv, self, DISPATCH_PROPERTYGET, TRUE);
+    if (v == rb_eNoMethodError) {
+        return rb_call_super(argc, argv);
+    }
+    return v;
 }
 
 static VALUE
@@ -3342,11 +3355,11 @@ fole_each(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L3355
 static VALUE
 fole_missing(int argc, VALUE *argv, VALUE self)
 {
-    VALUE mid, sym;
+    VALUE mid, org_mid, sym, v;
     const char* mname;
     long n;
     rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS);
-    mid = argv[0];
+    mid = org_mid = argv[0];
     sym = rb_check_symbol(&mid);
     if (!NIL_P(sym)) mid = rb_sym2str(sym);
     mname = StringValueCStr(mid);
@@ -3362,7 +3375,12 @@ fole_missing(int argc, VALUE *argv, VALU https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L3375
     }
     else {
         argv[0] = rb_enc_associate(rb_str_dup(mid), cWIN32OLE_enc);
-        return ole_invoke(argc, argv, self, DISPATCH_METHOD|DISPATCH_PROPERTYGET, FALSE);
+        v = ole_invoke(argc, argv, self, DISPATCH_METHOD|DISPATCH_PROPERTYGET, FALSE);
+        if (v == rb_eNoMethodError) {
+            argv[0] = org_mid;
+            return rb_call_super(argc, argv);
+        }
+        return v;
     }
 }
 
Index: test/win32ole/test_win32ole.rb
===================================================================
--- test/win32ole/test_win32ole.rb	(revision 60329)
+++ test/win32ole/test_win32ole.rb	(revision 60330)
@@ -58,9 +58,10 @@ if defined?(WIN32OLE) https://github.com/ruby/ruby/blob/trunk/test/win32ole/test_win32ole.rb#L58
 
     def test_no_method_error
       exc = assert_raise(NoMethodError) {
-          @dict1.non_exist_method
+        @dict1.non_exist_method
       }
       assert_match(/non_exist_method/, exc.message)
+      assert_kind_of(WIN32OLE, exc.receiver)
     end
 
     def test_ole_methods

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

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