mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
ext/win32ole/win32ole.c (fole_missing): set receiver in NoMethodError.
test/win32ole/test_win32ole.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60330 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
4b8c94dd84
commit
6f889b50d9
2 changed files with 32 additions and 13 deletions
|
@ -2646,9 +2646,7 @@ ole_invoke(int argc, VALUE *argv, VALUE self, USHORT wFlags, BOOL is_bracket)
|
||||||
&wcmdname, 1, lcid, &DispID);
|
&wcmdname, 1, lcid, &DispID);
|
||||||
SysFreeString(wcmdname);
|
SysFreeString(wcmdname);
|
||||||
if(FAILED(hr)) {
|
if(FAILED(hr)) {
|
||||||
ole_raise(hr, rb_eNoMethodError,
|
return rb_eNoMethodError;
|
||||||
"unknown property or method: `%s'",
|
|
||||||
StringValuePtr(cmd));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2850,7 +2848,11 @@ ole_invoke(int argc, VALUE *argv, VALUE self, USHORT wFlags, BOOL is_bracket)
|
||||||
static VALUE
|
static VALUE
|
||||||
fole_invoke(int argc, VALUE *argv, VALUE self)
|
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
|
static VALUE
|
||||||
|
@ -2863,8 +2865,7 @@ ole_invoke2(VALUE self, VALUE dispid, VALUE args, VALUE types, USHORT dispkind)
|
||||||
VARIANT result;
|
VARIANT result;
|
||||||
DISPPARAMS dispParams;
|
DISPPARAMS dispParams;
|
||||||
VARIANTARG* realargs = NULL;
|
VARIANTARG* realargs = NULL;
|
||||||
int i, j;
|
int i, j; VALUE obj = Qnil;
|
||||||
VALUE obj = Qnil;
|
|
||||||
VALUE tp, param;
|
VALUE tp, param;
|
||||||
VALUE v;
|
VALUE v;
|
||||||
VARTYPE vt;
|
VARTYPE vt;
|
||||||
|
@ -3118,7 +3119,11 @@ fole_setproperty2(VALUE self, VALUE dispid, VALUE args, VALUE types)
|
||||||
static VALUE
|
static VALUE
|
||||||
fole_setproperty_with_bracket(int argc, VALUE *argv, VALUE self)
|
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
|
static VALUE
|
||||||
fole_setproperty(int argc, VALUE *argv, VALUE self)
|
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
|
static VALUE
|
||||||
fole_getproperty_with_bracket(int argc, VALUE *argv, VALUE self)
|
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
|
static VALUE
|
||||||
|
@ -3342,11 +3355,11 @@ fole_each(VALUE self)
|
||||||
static VALUE
|
static VALUE
|
||||||
fole_missing(int argc, VALUE *argv, VALUE self)
|
fole_missing(int argc, VALUE *argv, VALUE self)
|
||||||
{
|
{
|
||||||
VALUE mid, sym;
|
VALUE mid, org_mid, sym, v;
|
||||||
const char* mname;
|
const char* mname;
|
||||||
long n;
|
long n;
|
||||||
rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS);
|
rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS);
|
||||||
mid = argv[0];
|
mid = org_mid = argv[0];
|
||||||
sym = rb_check_symbol(&mid);
|
sym = rb_check_symbol(&mid);
|
||||||
if (!NIL_P(sym)) mid = rb_sym2str(sym);
|
if (!NIL_P(sym)) mid = rb_sym2str(sym);
|
||||||
mname = StringValueCStr(mid);
|
mname = StringValueCStr(mid);
|
||||||
|
@ -3362,7 +3375,12 @@ fole_missing(int argc, VALUE *argv, VALUE self)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
argv[0] = rb_enc_associate(rb_str_dup(mid), cWIN32OLE_enc);
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,7 @@ if defined?(WIN32OLE)
|
||||||
@dict1.non_exist_method
|
@dict1.non_exist_method
|
||||||
}
|
}
|
||||||
assert_match(/non_exist_method/, exc.message)
|
assert_match(/non_exist_method/, exc.message)
|
||||||
|
assert_kind_of(WIN32OLE, exc.receiver)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_ole_methods
|
def test_ole_methods
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue