ruby-changes:34906
From: suke <ko1@a...>
Date: Mon, 28 Jul 2014 20:26:53 +0900 (JST)
Subject: [ruby-changes:34906] suke:r46989 (trunk): * ext/win32ole/win23ole.c (folerecord_method_missing): support
suke 2014-07-28 20:26:43 +0900 (Mon, 28 Jul 2014) New Revision: 46989 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=46989 Log: * ext/win32ole/win23ole.c (folerecord_method_missing): support setter of member of WIN32OLE_RECORD object. Modified files: trunk/ChangeLog trunk/ext/win32ole/win32ole.c Index: ChangeLog =================================================================== --- ChangeLog (revision 46988) +++ ChangeLog (revision 46989) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Mon Jul 28 20:20:08 2014 Masaki Suketa <masaki.suketa@n...> + + * ext/win32ole/win23ole.c (folerecord_method_missing): support + setter of member of WIN32OLE_RECORD object. + Mon Jul 28 06:37:19 2014 Zachary Scott <e@z...> * vm_eval.c: [DOC] Fix rdoc formatting of patch from [Bug #9551] Index: ext/win32ole/win32ole.c =================================================================== --- ext/win32ole/win32ole.c (revision 46988) +++ ext/win32ole/win32ole.c (revision 46989) @@ -143,7 +143,7 @@ const IID IID_IMultiLanguage2 = {0xDCCFC https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L143 #define WC2VSTR(x) ole_wc2vstr((x), TRUE) -#define WIN32OLE_VERSION "1.6.3" +#define WIN32OLE_VERSION "1.6.4" typedef HRESULT (STDAPICALLTYPE FNCOCREATEINSTANCEEX) (REFCLSID, IUnknown*, DWORD, COSERVERINFO*, DWORD, MULTI_QI*); @@ -610,7 +610,7 @@ static VALUE folerecord_s_allocate(VALUE https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L610 static VALUE folerecord_initialize(VALUE self, VALUE args); static VALUE folerecord_to_h(VALUE self); static VALUE folerecord_typename(VALUE self); -static VALUE folerecord_method_missing(VALUE self, VALUE member); +static VALUE folerecord_method_missing(int argc, VALUE *argv, VALUE self); static void init_enc2cp(void); static void free_enc2cp(void); @@ -9499,10 +9499,33 @@ folerecord_typename(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L9499 * If the member name is not correct, KeyError exception is raised. */ static VALUE -folerecord_method_missing(VALUE self, VALUE name) +folerecord_method_missing(int argc, VALUE *argv, VALUE self) { - VALUE fields = rb_ivar_get(self, rb_intern("fields")); - return rb_hash_fetch(fields, rb_sym_to_s(name)); + long len = 0; + VALUE name; + VALUE ch; + char *p; + VALUE fields; + + rb_check_arity(argc, 1, 2); + fields = rb_ivar_get(self, rb_intern("fields")); + if (argc == 1) { + name = rb_sym_to_s(argv[0]); + return rb_hash_fetch(fields, name); + } else if (argc == 2) { + name = rb_sym_to_s(argv[0]); + len = RSTRING_LEN(name); + ch = rb_str_subseq(name, len-1, 1); + p = RSTRING_PTR(ch); + if (*p == '=') { + name = rb_str_subseq(name, 0, len-1); + rb_hash_fetch(fields, name); + return rb_hash_aset(fields, name, argv[1]); + } else { + rb_raise(rb_eRuntimeError, "unknown member name:`%s`", RSTRING_PTR(name)); + } + } + return Qnil; } static void @@ -9827,7 +9850,7 @@ Init_win32ole(void) https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L9850 rb_define_method(cWIN32OLE_RECORD, "initialize", folerecord_initialize, -2); rb_define_method(cWIN32OLE_RECORD, "to_h", folerecord_to_h, 0); rb_define_method(cWIN32OLE_RECORD, "typename", folerecord_typename, 0); - rb_define_method(cWIN32OLE_RECORD, "method_missing", folerecord_method_missing, 1); + rb_define_method(cWIN32OLE_RECORD, "method_missing", folerecord_method_missing, -1); eWIN32OLERuntimeError = rb_define_class("WIN32OLERuntimeError", rb_eRuntimeError); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/