* ext/win32ole/win23ole.c (folerecord_method_missing): support

setter of member of WIN32OLE_RECORD object.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46989 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
suke 2014-07-28 11:26:43 +00:00
Родитель 95d1b61a14
Коммит 4d812cf6db
2 изменённых файлов: 34 добавлений и 6 удалений

Просмотреть файл

@ -1,3 +1,8 @@
Mon Jul 28 20:20:08 2014 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* 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@zzak.io>
* vm_eval.c: [DOC] Fix rdoc formatting of patch from [Bug #9551]

Просмотреть файл

@ -143,7 +143,7 @@ const IID IID_IMultiLanguage2 = {0xDCCFC164, 0x2B38, 0x11d2, {0xB7, 0xEC, 0x00,
#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 klass);
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)
* 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)
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);