diff --git a/ext/win32ole/win32ole.c b/ext/win32ole/win32ole.c index 84bb0ba819..960c03da1c 100644 --- a/ext/win32ole/win32ole.c +++ b/ext/win32ole/win32ole.c @@ -2646,9 +2646,7 @@ ole_invoke(int argc, VALUE *argv, VALUE self, USHORT wFlags, BOOL is_bracket) &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 self, USHORT wFlags, BOOL is_bracket) 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, VALUE args, VALUE types, USHORT dispkind) 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 dispid, VALUE args, VALUE types) 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, VALUE *argv, VALUE self) 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, VALUE self) 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) 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, VALUE self) } 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; } } diff --git a/test/win32ole/test_win32ole.rb b/test/win32ole/test_win32ole.rb index c095e6d7ce..5dc4c6cfaa 100644 --- a/test/win32ole/test_win32ole.rb +++ b/test/win32ole/test_win32ole.rb @@ -58,9 +58,10 @@ if defined?(WIN32OLE) 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