[ruby/win32ole] Use the scoped names in inspect and error messages

https://github.com/ruby/win32ole/commit/2f51493bd1
This commit is contained in:
Nobuyoshi Nakada 2023-12-31 17:02:58 +09:00 committed by git
parent baef72da36
commit 1e2d088dd3
13 changed files with 28 additions and 28 deletions

View File

@ -2215,7 +2215,7 @@ fole_s_show_help(int argc, VALUE *argv, VALUE self)
helpfile = target; helpfile = target;
} }
if (!RB_TYPE_P(helpfile, T_STRING)) { if (!RB_TYPE_P(helpfile, T_STRING)) {
rb_raise(rb_eTypeError, "1st parameter must be (String|WIN32OLE_TYPE|WIN32OLE_METHOD)"); rb_raise(rb_eTypeError, "1st parameter must be (String|WIN32OLE::Type|WIN32OLE::Method)");
} }
hwnd = ole_show_help(helpfile, helpcontext); hwnd = ole_show_help(helpfile, helpcontext);
if(hwnd == 0) { if(hwnd == 0) {
@ -3529,7 +3529,7 @@ fole_type(VALUE self)
type = ole_type_from_itypeinfo(pTypeInfo); type = ole_type_from_itypeinfo(pTypeInfo);
OLE_RELEASE(pTypeInfo); OLE_RELEASE(pTypeInfo);
if (type == Qnil) { if (type == Qnil) {
rb_raise(rb_eRuntimeError, "failed to create WIN32OLE_TYPE obj from ITypeInfo"); rb_raise(rb_eRuntimeError, "failed to create WIN32OLE::Type obj from ITypeInfo");
} }
return type; return type;
} }

View File

@ -277,7 +277,7 @@ folemethod_initialize(VALUE self, VALUE oletype, VALUE method)
} }
} }
else { else {
rb_raise(rb_eTypeError, "1st argument should be WIN32OLE_TYPE object"); rb_raise(rb_eTypeError, "1st argument should be WIN32OLE::Type object");
} }
return obj; return obj;
} }
@ -920,7 +920,7 @@ folemethod_params(VALUE self)
static VALUE static VALUE
folemethod_inspect(VALUE self) folemethod_inspect(VALUE self)
{ {
return default_inspect(self, "WIN32OLE_METHOD"); return default_inspect(self, "WIN32OLE::Method");
} }
VALUE cWIN32OLE_METHOD; VALUE cWIN32OLE_METHOD;

View File

@ -139,7 +139,7 @@ oleparam_ole_param(VALUE self, VALUE olemethod, int n)
* *
* tobj = WIN32OLE::Type.new('Microsoft Scripting Runtime', 'IFileSystem') * tobj = WIN32OLE::Type.new('Microsoft Scripting Runtime', 'IFileSystem')
* method = WIN32OLE::Method.new(tobj, 'CreateTextFile') * method = WIN32OLE::Method.new(tobj, 'CreateTextFile')
* param = WIN32OLE::Param.new(method, 2) # => #<WIN32OLE_PARAM:Overwrite=true> * param = WIN32OLE::Param.new(method, 2) # => #<WIN32OLE::Param:Overwrite=true>
* *
*/ */
static VALUE static VALUE
@ -147,7 +147,7 @@ foleparam_initialize(VALUE self, VALUE olemethod, VALUE n)
{ {
int idx; int idx;
if (!rb_obj_is_kind_of(olemethod, cWIN32OLE_METHOD)) { if (!rb_obj_is_kind_of(olemethod, cWIN32OLE_METHOD)) {
rb_raise(rb_eTypeError, "1st parameter must be WIN32OLE_METHOD object"); rb_raise(rb_eTypeError, "1st parameter must be WIN32OLE::Method object");
} }
idx = RB_FIX2INT(n); idx = RB_FIX2INT(n);
return oleparam_ole_param(self, olemethod, idx); return oleparam_ole_param(self, olemethod, idx);
@ -416,7 +416,7 @@ foleparam_inspect(VALUE self)
rb_str_cat2(detail, "="); rb_str_cat2(detail, "=");
rb_str_concat(detail, rb_inspect(defval)); rb_str_concat(detail, rb_inspect(defval));
} }
return make_inspect("WIN32OLE_PARAM", detail); return make_inspect("WIN32OLE::Param", detail);
} }
void void

View File

@ -303,7 +303,7 @@ folerecord_initialize(VALUE self, VALUE typename, VALUE oleobj) {
hr = E_FAIL; hr = E_FAIL;
} }
} else { } else {
rb_raise(rb_eArgError, "2nd argument should be WIN32OLE object or WIN32OLE_TYPELIB object"); rb_raise(rb_eArgError, "2nd argument should be WIN32OLE object or WIN32OLE::TypeLib object");
} }
if (FAILED(hr)) { if (FAILED(hr)) {
@ -584,7 +584,7 @@ folerecord_inspect(VALUE self)
tname = rb_inspect(tname); tname = rb_inspect(tname);
} }
field = rb_inspect(folerecord_to_h(self)); field = rb_inspect(folerecord_to_h(self));
return rb_sprintf("#<WIN32OLE_RECORD(%"PRIsVALUE") %"PRIsVALUE">", return rb_sprintf("#<WIN32OLE::Record(%"PRIsVALUE") %"PRIsVALUE">",
tname, tname,
field); field);
} }

View File

@ -145,7 +145,7 @@ foletype_s_typelibs(VALUE self)
"WIN32OLE::Type.typelibs", "WIN32OLE::Type.typelibs",
"WIN32OLE::TypeLib.typelibs.collect{t|t.name}"); "WIN32OLE::TypeLib.typelibs.collect{t|t.name}");
*/ */
return rb_eval_string("WIN32OLE_TYPELIB.typelibs.collect{|t|t.name}"); return rb_eval_string("WIN32OLE::TypeLib.typelibs.collect{|t|t.name}");
} }
/* /*
@ -829,7 +829,7 @@ foletype_impl_ole_types(VALUE self)
* object and having IMPLTYPEFLAG_FSOURCE. * object and having IMPLTYPEFLAG_FSOURCE.
* tobj = WIN32OLE::Type.new('Microsoft Internet Controls', "InternetExplorer") * tobj = WIN32OLE::Type.new('Microsoft Internet Controls', "InternetExplorer")
* p tobj.source_ole_types * p tobj.source_ole_types
* # => [#<WIN32OLE_TYPE:DWebBrowserEvents2>, #<WIN32OLE_TYPE:DWebBrowserEvents>] * # => [#<WIN32OLE::Type:DWebBrowserEvents2>, #<WIN32OLE::Type:DWebBrowserEvents>]
*/ */
static VALUE static VALUE
foletype_source_ole_types(VALUE self) foletype_source_ole_types(VALUE self)
@ -845,7 +845,7 @@ foletype_source_ole_types(VALUE self)
* Returns the array of WIN32OLE::Type object which is implemented by the WIN32OLE::Type * Returns the array of WIN32OLE::Type object which is implemented by the WIN32OLE::Type
* object and having IMPLTYPEFLAG_FSOURCE and IMPLTYPEFLAG_FDEFAULT. * object and having IMPLTYPEFLAG_FSOURCE and IMPLTYPEFLAG_FDEFAULT.
* tobj = WIN32OLE::Type.new('Microsoft Internet Controls', "InternetExplorer") * tobj = WIN32OLE::Type.new('Microsoft Internet Controls', "InternetExplorer")
* p tobj.default_event_sources # => [#<WIN32OLE_TYPE:DWebBrowserEvents2>] * p tobj.default_event_sources # => [#<WIN32OLE::Type:DWebBrowserEvents2>]
*/ */
static VALUE static VALUE
foletype_default_event_sources(VALUE self) foletype_default_event_sources(VALUE self)
@ -862,7 +862,7 @@ foletype_default_event_sources(VALUE self)
* object and having IMPLTYPEFLAG_FDEFAULT. * object and having IMPLTYPEFLAG_FDEFAULT.
* tobj = WIN32OLE::Type.new('Microsoft Internet Controls', "InternetExplorer") * tobj = WIN32OLE::Type.new('Microsoft Internet Controls', "InternetExplorer")
* p tobj.default_ole_types * p tobj.default_ole_types
* # => [#<WIN32OLE_TYPE:IWebBrowser2>, #<WIN32OLE_TYPE:DWebBrowserEvents2>] * # => [#<WIN32OLE::Type:IWebBrowser2>, #<WIN32OLE::Type:DWebBrowserEvents2>]
*/ */
static VALUE static VALUE
foletype_default_ole_types(VALUE self) foletype_default_ole_types(VALUE self)
@ -878,12 +878,12 @@ foletype_default_ole_types(VALUE self)
* Returns the type name with class name. * Returns the type name with class name.
* *
* ie = WIN32OLE.new('InternetExplorer.Application') * ie = WIN32OLE.new('InternetExplorer.Application')
* ie.ole_type.inspect => #<WIN32OLE_TYPE:IWebBrowser2> * ie.ole_type.inspect => #<WIN32OLE::Type:IWebBrowser2>
*/ */
static VALUE static VALUE
foletype_inspect(VALUE self) foletype_inspect(VALUE self)
{ {
return default_inspect(self, "WIN32OLE_TYPE"); return default_inspect(self, "WIN32OLE::Type");
} }
VALUE cWIN32OLE_TYPE; VALUE cWIN32OLE_TYPE;

View File

@ -814,12 +814,12 @@ foletypelib_ole_types(VALUE self)
* Returns the type library name with class name. * Returns the type library name with class name.
* *
* tlib = WIN32OLE::TypeLib.new('Microsoft Excel 9.0 Object Library') * tlib = WIN32OLE::TypeLib.new('Microsoft Excel 9.0 Object Library')
* tlib.inspect # => "<#WIN32OLE_TYPELIB:Microsoft Excel 9.0 Object Library>" * tlib.inspect # => "<#WIN32OLE::TypeLib:Microsoft Excel 9.0 Object Library>"
*/ */
static VALUE static VALUE
foletypelib_inspect(VALUE self) foletypelib_inspect(VALUE self)
{ {
return default_inspect(self, "WIN32OLE_TYPELIB"); return default_inspect(self, "WIN32OLE::TypeLib");
} }
VALUE cWIN32OLE_TYPELIB; VALUE cWIN32OLE_TYPELIB;

View File

@ -362,7 +362,7 @@ folevariable_inspect(VALUE self)
VALUE v = rb_inspect(folevariable_value(self)); VALUE v = rb_inspect(folevariable_value(self));
VALUE n = folevariable_name(self); VALUE n = folevariable_name(self);
VALUE detail = rb_sprintf("%"PRIsVALUE"=%"PRIsVALUE, n, v); VALUE detail = rb_sprintf("%"PRIsVALUE"=%"PRIsVALUE, n, v);
return make_inspect("WIN32OLE_VARIABLE", detail); return make_inspect("WIN32OLE::Variable", detail);
} }
VALUE cWIN32OLE_VARIABLE; VALUE cWIN32OLE_VARIABLE;

View File

@ -357,7 +357,7 @@ check_type_val2variant(VALUE val)
case T_NIL: case T_NIL:
break; break;
default: default:
rb_raise(rb_eTypeError, "can not convert WIN32OLE_VARIANT from type %s", rb_raise(rb_eTypeError, "can not convert WIN32OLE::Variant from type %s",
rb_obj_classname(val)); rb_obj_classname(val));
} }
} }
@ -422,7 +422,7 @@ folevariant_initialize(VALUE self, VALUE args)
vvt = rb_ary_entry(args, 1); vvt = rb_ary_entry(args, 1);
vt = RB_NUM2INT(vvt); vt = RB_NUM2INT(vvt);
if ((vt & VT_TYPEMASK) == VT_RECORD) { if ((vt & VT_TYPEMASK) == VT_RECORD) {
rb_raise(rb_eArgError, "not supported VT_RECORD WIN32OLE_VARIANT object"); rb_raise(rb_eArgError, "not supported VT_RECORD WIN32OLE::Variant object");
} }
ole_val2olevariantdata(val, vt, pvar); ole_val2olevariantdata(val, vt, pvar);
} }

View File

@ -127,7 +127,7 @@ if defined?(WIN32OLE_METHOD)
end end
def test_inspect def test_inspect
assert_equal("#<WIN32OLE_METHOD:NameSpace>", @m_namespace.inspect) assert_equal("#<WIN32OLE::Method:NameSpace>", @m_namespace.inspect)
end end
end end

View File

@ -43,7 +43,7 @@ if defined?(WIN32OLE_PARAM)
assert_equal("OverWriteFiles", param.name) assert_equal("OverWriteFiles", param.name)
assert_equal(WIN32OLE_PARAM, param.class) assert_equal(WIN32OLE_PARAM, param.class)
assert_equal(true, param.default) assert_equal(true, param.default)
assert_equal("#<WIN32OLE_PARAM:OverWriteFiles=true>", param.inspect) assert_equal("#<WIN32OLE::Param:OverWriteFiles=true>", param.inspect)
end end
def test_name def test_name
@ -91,8 +91,8 @@ if defined?(WIN32OLE_PARAM)
end end
def test_inspect def test_inspect
assert_equal("#<WIN32OLE_PARAM:Source>", @param_source.inspect) assert_equal("#<WIN32OLE::Param:Source>", @param_source.inspect)
assert_equal("#<WIN32OLE_PARAM:OverWriteFiles=true>", @param_overwritefiles.inspect) assert_equal("#<WIN32OLE::Param:OverWriteFiles=true>", @param_overwritefiles.inspect)
end end
end end
end end

View File

@ -178,7 +178,7 @@ if defined?(WIN32OLE_TYPE)
end end
def test_inspect def test_inspect
assert_equal("#<WIN32OLE_TYPE:Shell>", @ole_type.inspect) assert_equal("#<WIN32OLE::Type:Shell>", @ole_type.inspect)
end end
# WIN32OLE_TYPE.typelibs will be obsoleted. # WIN32OLE_TYPE.typelibs will be obsoleted.

View File

@ -110,7 +110,7 @@ if defined?(WIN32OLE_TYPELIB)
def test_inspect def test_inspect
tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation") tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
assert_equal("#<WIN32OLE_TYPELIB:Microsoft Shell Controls And Automation>", tlib.inspect) assert_equal("#<WIN32OLE::TypeLib:Microsoft Shell Controls And Automation>", tlib.inspect)
end end
end end

View File

@ -58,8 +58,8 @@ if defined?(WIN32OLE_VARIABLE)
end end
def test_inspect def test_inspect
assert_equal("#<WIN32OLE_VARIABLE:ssfDESKTOP=0>", @var1.inspect) assert_equal("#<WIN32OLE::Variable:ssfDESKTOP=0>", @var1.inspect)
assert_equal("#<WIN32OLE_VARIABLE:UILevel=nil>", @var2.inspect) assert_equal("#<WIN32OLE::Variable:UILevel=nil>", @var2.inspect)
end end
end end