summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorsuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-07-28 11:26:43 +0000
committersuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-07-28 11:26:43 +0000
commit4d812cf6db84e7b79ec427bdbdd21228b270a907 (patch)
treef8cda9a75e9bb3fcb15f7622691e52adab93cbfe /ext
parent95d1b61a146f9e88564d3df7e648b78881741a61 (diff)
* 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
Diffstat (limited to 'ext')
-rw-r--r--ext/win32ole/win32ole.c35
1 files changed, 29 insertions, 6 deletions
diff --git a/ext/win32ole/win32ole.c b/ext/win32ole/win32ole.c
index eb00c938bcf..4ffd32fb700 100644
--- a/ext/win32ole/win32ole.c
+++ b/ext/win32ole/win32ole.c
@@ -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);