// Whatever the caller asks for, try to find it via reflection.
//
if (dispId == DISPID_MAGIC_GETGLOBALREF && myGlobalRef != 0) {
// Handle specially.
//
return new Variant(myGlobalRef);
} else if (dispId == 0) {
if ((flags & COM.DISPATCH_METHOD) != 0) {
// implicit call -- "m()"
// not supported -- fall through to unsupported failure
} else if ((flags & COM.DISPATCH_PROPERTYGET) != 0) {
// implicit toString -- "'foo' + m"
return new Variant(getTarget().toString());
}
} else if (dispId > 0) {
if (javaDispatch.isMethod(dispId)) {
Method method = javaDispatch.getMethod(dispId);
if ((flags & COM.DISPATCH_METHOD) != 0) {
// This is a method call.
return callMethod(classLoader, getTarget(), params, method);
} else if (flags == COM.DISPATCH_PROPERTYGET) {
// The function is being accessed as a property.
IDispatchImpl funcObj = new MethodDispatch(classLoader, method);
IDispatch disp = new IDispatch(funcObj.getAddress());
disp.AddRef();
return new Variant(disp);
}
} else if (javaDispatch.isField(dispId)) {
Field field = javaDispatch.getField(dispId);
if (flags == COM.DISPATCH_PROPERTYGET) {
return SwtOleGlue.convertObjectToVariant(classLoader,
field.getType(), javaDispatch.getFieldValue(dispId));
} else if ((flags & (COM.DISPATCH_PROPERTYPUT | COM.DISPATCH_PROPERTYPUTREF)) != 0) {
javaDispatch.setFieldValue(dispId, JsValueGlue.get(new JsValueIE6(
params[0]), field.getType(), "Setting field '"
+ field.getName() + "'"));
return new Variant();
}
}
} else {
// The specified member id is out of range.
throw new HResultException(COM.DISP_E_MEMBERNOTFOUND);