static VALUE
fole_missing(int argc, VALUE *argv, VALUE self)
{
VALUE mid, org_mid, sym, v;
const char* mname;
long n;
rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS);
mid = org_mid = argv[0];
sym = rb_check_symbol(&mid);
if (!NIL_P(sym)) mid = rb_sym2str(sym);
mname = StringValueCStr(mid);
if(!mname) {
rb_raise(rb_eRuntimeError, "fail: unknown method or property");
}
n = RSTRING_LEN(mid);
if(mname[n-1] == '=') {
rb_check_arity(argc, 2, 2);
argv[0] = rb_enc_associate(rb_str_subseq(mid, 0, n-1), cWIN32OLE_enc);
return ole_propertyput(self, argv[0], argv[1]);
}
else {
argv[0] = rb_enc_associate(rb_str_dup(mid), cWIN32OLE_enc);
v = ole_invoke(argc, argv, self, DISPATCH_METHOD|DISPATCH_PROPERTYGET, FALSE);
if (v == rb_eNoMethodError) {
argv[0] = org_mid;
return rb_call_super(argc, argv);
}
return v;
}
}