From c6defdfa80221df1824bdfebcbe1dd05ad57d6b9 Mon Sep 17 00:00:00 2001 From: suke Date: Wed, 27 Dec 2006 12:00:54 +0000 Subject: [PATCH] remove WIN32OLE::PROPERTY class. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11424 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 +++ ext/win32ole/tests/testWIN32OLE.rb | 10 +++-- ext/win32ole/win32ole.c | 71 ++---------------------------- 3 files changed, 15 insertions(+), 72 deletions(-) diff --git a/ChangeLog b/ChangeLog index 47675cf2c1..22054c3d5c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Wed Dec 27 20:52:32 2006 Masaki Suketa + + * ext/win32ole/win32ole.c: remove WIN32OLE::PROPERTY class. + + * ext/win32ole/tests/testWIN32OLE.rb: ditto. + Tue Dec 26 21:02:14 2006 Masaki Suketa * test/win32ole/test_folderitem2_invokeverb.rb: The argument diff --git a/ext/win32ole/tests/testWIN32OLE.rb b/ext/win32ole/tests/testWIN32OLE.rb index 401825815b..a7cc96ca72 100644 --- a/ext/win32ole/tests/testWIN32OLE.rb +++ b/ext/win32ole/tests/testWIN32OLE.rb @@ -321,10 +321,12 @@ class TestWin32OLE_WITH_MSI < Test::Unit::TestCase @record.setproperty( "StringData", 1, 'dddd') assert_equal('dddd', @record.StringData(1)) end - def test_bracket_equal_with_arg - @record.StringData[1] = 'ffff' - assert_equal('ffff', @record.StringData(1)) - end + + # Win32OLE does not support this style to set property. + # def test_bracket_equal_with_arg + # @record.StringData[1] = 'ffff' + # assert_equal('ffff', @record.StringData(1)) + # end def test__invoke shell=WIN32OLE.new('Shell.Application') diff --git a/ext/win32ole/win32ole.c b/ext/win32ole/win32ole.c index 34eebeff45..b5defc3a29 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.8.0" +#define WIN32OLE_VERSION "0.8.1" typedef HRESULT (STDAPICALLTYPE FNCOCREATEINSTANCEEX) (REFCLSID, IUnknown*, DWORD, COSERVERINFO*, DWORD, MULTI_QI*); @@ -210,7 +210,6 @@ static HRESULT ole_docinfo_from_type(ITypeInfo *, BSTR *, BSTR *, DWORD *, BSTR static char *ole_wc2mb(LPWSTR); static VALUE ole_variant2val(VARIANT*); static void ole_val2variant(VALUE, VARIANT*); -static VALUE create_property_object(VALUE, VALUE, HRESULT, VALUE); typedef struct _Win32OLEIDispatch { @@ -2475,26 +2474,8 @@ ole_invoke(int argc, VALUE *argv, VALUE self, USHORT wFlags, BOOL is_bracket) if (FAILED(hr)) { v = ole_excepinfo2msg(&excepinfo); - if (is_bracket) { - ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "%s", - StringValuePtr(v)); - } else { - /* - * This is the trick to save following script. - * - * installer = WIN32OLE.new("WindowsInstaller.Installer") - * record = installer.CreateRecord(2) - * record.StringData[1] = 'ffff' - * - * record.StringData failed, but we expect [] or []= - * method called next, so we use this trick. - * - * If this trick may be confused. - * If so, we should raise WIN32OLERuntimeError here... - * And we give up saving the above script. - */ - return create_property_object(self, cmd, hr, v); - } + ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "%s", + StringValuePtr(v)); } obj = ole_variant2val(&result); VariantClear(&result); @@ -6870,48 +6851,6 @@ folevariant_value(VALUE self) return val; } -static VALUE -create_property_object(VALUE oleobj, VALUE propname, HRESULT prehr, VALUE premsg) -{ - VALUE prop = rb_funcall(cWIN32OLE_PROPERTY, rb_intern("new"), 0); - rb_ivar_set(prop, rb_intern("oleobj"), oleobj); - rb_ivar_set(prop, rb_intern("property"), propname); - rb_ivar_set(prop, rb_intern("prehresult"), INT2NUM(prehr)); - rb_ivar_set(prop, rb_intern("premsg"), premsg); - return prop; -} - -static VALUE -foleproperty_getproperty(VALUE self, VALUE args) -{ - VALUE oleobj = rb_ivar_get(self, rb_intern("oleobj")); - VALUE params = rb_ary_new(); - rb_ary_push(params, rb_ivar_get(self, rb_intern("property"))); - rb_ary_concat(params, args); - return rb_apply(oleobj, rb_intern("[]"), params); -} - -static VALUE -foleproperty_setproperty(VALUE self, VALUE args) -{ - VALUE oleobj = rb_ivar_get(self, rb_intern("oleobj")); - VALUE params = rb_ary_new(); - rb_ary_push(params, rb_ivar_get(self, rb_intern("property"))); - rb_ary_concat(params, args); - return rb_apply(oleobj, rb_intern("setproperty"), params); -} - -static VALUE -foleproperty_method_missing(VALUE self, VALUE args) -{ - HRESULT hr = NUM2INT(rb_ivar_get(self, rb_intern("prehresult"))); - VALUE prop = rb_ivar_get(self, rb_intern("property")); - VALUE msg = rb_ivar_get(self, rb_intern("premsg")); - ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "%s%s", - StringValuePtr(prop), StringValuePtr(msg)); - return Qnil; -} - void Init_win32ole() { @@ -7105,8 +7044,4 @@ Init_win32ole() eWIN32OLE_RUNTIME_ERROR = rb_define_class("WIN32OLERuntimeError", rb_eRuntimeError); - cWIN32OLE_PROPERTY = rb_define_class_under(cWIN32OLE, "PROPERTY", rb_cObject); - rb_define_method(cWIN32OLE_PROPERTY, "[]", foleproperty_getproperty, -2); - rb_define_method(cWIN32OLE_PROPERTY, "[]=", foleproperty_setproperty, -2); - rb_define_method(cWIN32OLE_PROPERTY, "method_missing", foleproperty_method_missing, -2); }