diff options
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | ext/win32ole/win32ole.c | 29 | ||||
-rw-r--r-- | test/win32ole/test_win32ole_method.rb | 4 | ||||
-rw-r--r-- | test/win32ole/test_win32ole_param.rb | 85 |
4 files changed, 123 insertions, 4 deletions
@@ -1,3 +1,12 @@ +Sat Apr 8 18:06:28 2006 Masaki Suketa <masaki.suketa@nifty.ne.jp> + + * ext/win32ole/win32ole.c: add WIN32OLE_METHOD#inspect, + WIN32OLE_PARAM#inspect. + + * test/win32ole/test_win32ole_method.rb: ditto. + + * add test/win32ole/test_win32ole_param.rb. + Fri Apr 7 22:11:30 2006 Masaki Suketa <masaki.suketa@nifty.ne.jp> * ext/win32ole/win32ole.c(foletypelib_initialize): WIN32OLE_TYPELIB.new diff --git a/ext/win32ole/win32ole.c b/ext/win32ole/win32ole.c index 393eef6737..dc99536343 100644 --- a/ext/win32ole/win32ole.c +++ b/ext/win32ole/win32ole.c @@ -79,7 +79,7 @@ #define WC2VSTR(x) ole_wc2vstr((x), TRUE) -#define WIN32OLE_VERSION "0.7.4" +#define WIN32OLE_VERSION "0.7.5" typedef HRESULT (STDAPICALLTYPE FNCOCREATEINSTANCEEX) (REFCLSID, IUnknown*, DWORD, COSERVERINFO*, DWORD, MULTI_QI*); @@ -6233,6 +6233,13 @@ folemethod_params(self) return ole_method_params(pmethod->pTypeInfo, pmethod->index); } +static VALUE +folemethod_inspect(self) + VALUE self; +{ + return default_inspect(self, "WIN32OLE_METHOD"); +} + /* * Document-class: WIN32OLE_PARAM * @@ -6502,6 +6509,20 @@ static VALUE foleparam_default(self) pparam->index); } +static VALUE +foleparam_inspect(self) + VALUE self; +{ + VALUE detail = foleparam_name(self); + VALUE defval = foleparam_default(self); + if (defval != Qnil) { + rb_str_cat2(detail, "="); + rb_str_concat(detail, rb_funcall(defval, rb_intern("inspect"), 0)); + } + return make_inspect("WIN32OLE_PARAM", detail); +} + + /* * Document-class: WIN32OLE_EVENT @@ -7484,6 +7505,7 @@ Init_win32ole() rb_define_method(cWIN32OLE_METHOD, "size_opt_params", folemethod_size_opt_params, 0); rb_define_method(cWIN32OLE_METHOD, "params", folemethod_params, 0); rb_define_alias(cWIN32OLE_METHOD, "to_s", "name"); + rb_define_method(cWIN32OLE_METHOD, "inspect", folemethod_inspect, 0); cWIN32OLE_PARAM = rb_define_class("WIN32OLE_PARAM", rb_cObject); rb_define_method(cWIN32OLE_PARAM, "name", foleparam_name, 0); @@ -7495,13 +7517,12 @@ Init_win32ole() rb_define_method(cWIN32OLE_PARAM, "retval?", foleparam_retval, 0); rb_define_method(cWIN32OLE_PARAM, "default", foleparam_default, 0); rb_define_alias(cWIN32OLE_PARAM, "to_s", "name"); + rb_define_method(cWIN32OLE_PARAM, "inspect", foleparam_inspect, 0); cWIN32OLE_EVENT = rb_define_class("WIN32OLE_EVENT", rb_cObject); - + rb_define_singleton_method(cWIN32OLE_EVENT, "message_loop", fev_s_msg_loop, 0); rb_define_alloc_func(cWIN32OLE_EVENT, fev_s_allocate); rb_define_method(cWIN32OLE_EVENT, "initialize", fev_initialize, -1); - rb_define_singleton_method(cWIN32OLE_EVENT, "message_loop", fev_s_msg_loop, 0); - rb_define_method(cWIN32OLE_EVENT, "on_event", fev_on_event, -1); rb_define_method(cWIN32OLE_EVENT, "on_event_with_outargs", fev_on_event_with_outargs, -1); diff --git a/test/win32ole/test_win32ole_method.rb b/test/win32ole/test_win32ole_method.rb index 363156e3de..c5581932d2 100644 --- a/test/win32ole/test_win32ole_method.rb +++ b/test/win32ole/test_win32ole_method.rb @@ -128,5 +128,9 @@ if defined?(WIN32OLE_METHOD) assert_equal(@m_namespace.name, @m_namespace.to_s) end + def test_inspect + assert_equal("#<WIN32OLE_METHOD:NameSpace>", @m_namespace.inspect) + end + end end diff --git a/test/win32ole/test_win32ole_param.rb b/test/win32ole/test_win32ole_param.rb new file mode 100644 index 0000000000..e238736000 --- /dev/null +++ b/test/win32ole/test_win32ole_param.rb @@ -0,0 +1,85 @@ +begin + require 'win32ole' +rescue LoadError +end + +require "test/unit" + +if defined?(WIN32OLE_PARAM) + class TestWIN32OLE_PARAM < Test::Unit::TestCase + + def setup + ole_type = WIN32OLE_TYPE.new("Microsoft Internet Controls", "WebBrowser") + m_navigate = WIN32OLE_METHOD.new(ole_type, "Navigate") + m_before_navigate = WIN32OLE_METHOD.new(ole_type, "BeforeNavigate") + params = m_navigate.params + @param_url = params[0] + @param_flags = params[1] + @param_cancel = m_before_navigate.params[5] + + ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "ShellLinkObject") + m_geticonlocation = WIN32OLE_METHOD.new(ole_type, "GetIconLocation") + @param_pbs = m_geticonlocation.params[0] + + ole_type = WIN32OLE_TYPE.new("Microsoft HTML Object Library", "FontNames") + m_count = WIN32OLE_METHOD.new(ole_type, "Count") + @param_p = m_count.params[0] + + ole_type = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "FileSystemObject") + m_copyfile = WIN32OLE_METHOD.new(ole_type, "CopyFile") + @param_overwritefiles = m_copyfile.params[2] + end + + def test_name + assert_equal('URL', @param_url.name) + assert_equal('Flags', @param_flags.name) + assert_equal('Cancel', @param_cancel.name) + end + + def test_ole_type + assert_equal('BSTR', @param_url.ole_type) + assert_equal('VARIANT', @param_flags.ole_type) + end + + def test_ole_type_detail + assert_equal(['BSTR'], @param_url.ole_type_detail) + assert_equal(['PTR', 'VARIANT'], @param_flags.ole_type_detail) + end + + def test_input? + assert(@param_url.input?) + assert(@param_cancel.input?) + assert(!@param_pbs.input?) + end + + def test_output? + assert(!@param_url.output?) + assert(@param_cancel.output?) + assert(@param_pbs.output?) + end + + def test_optional? + assert(!@param_url.optional?) + assert(@param_flags.optional?) + end + + def test_retval? + assert(!@param_url.retval?) + assert(@param_p.retval?) + end + + def test_default + assert_equal(nil, @param_url.default) + assert_equal(true, @param_overwritefiles.default) + end + + def test_to_s + assert_equal(@param_url.name, @param_url.to_s) + end + + def test_inspect + assert_equal("#<WIN32OLE_PARAM:URL>", @param_url.inspect) + assert_equal("#<WIN32OLE_PARAM:OverWriteFiles=true>", @param_overwritefiles.inspect) + end + end +end |