@Override
protected Variant invoke(int dispId, int flags, Variant[] params) throws HResultException,
InvocationTargetException {
if (dispId == 0 && (flags & COM.DISPATCH_PROPERTYGET) != 0) {
// MAGIC: this is the default property, let's just do toString()
return new Variant(toString());
} else if (dispId == 1) {
if ((flags & COM.DISPATCH_METHOD) != 0) {
try {
IDispatch frameWnd =
params[0].getType() == COM.VT_DISPATCH ? params[0].getDispatch() : null;
boolean success = gwtOnLoad(frameWnd);
// boolean return type
return new Variant(success);
} catch (SWTException e) {
throw new HResultException(COM.E_INVALIDARG);
}
} else if ((flags & COM.DISPATCH_PROPERTYGET) != 0) {
// property get on the method itself
try {
IDispatchImpl funcObj = new IDispatchImpl() {
// do nothing, just return some IDispatch
@Override
protected Variant invoke(int dispId, int flags, Variant[] params)
throws HResultException, InstantiationException, InvocationTargetException {
return new Variant();
}
@Override
protected void getIDsOfNames(String[] names, int[] ids) throws HResultException {
}
};
IDispatch disp = new IDispatch(funcObj.getAddress());
disp.AddRef();
return new Variant(disp);
} catch (Exception e) {
// just return VT_EMPTY
return new Variant();
}
}
throw new HResultException(COM.E_NOTSUPPORTED);
}
// The specified member id is out of range.