Code: Select all
ob := { var: "value" }
como := ComObject(9, &ob) ; create a ComObj wrapper around the AHK object in order to force the usage of the IDispatch implementation
MsgBox % como.var ; 'Member not found'
Code: Select all
ob := { var: "value" }
como := ComObject(9, &ob) ; create a ComObj wrapper around the AHK object in order to force the usage of the IDispatch implementation
MsgBox % como.var ; 'Member not found'
Code: Select all
_Director_ParseResponse(resp)
{
colon := InStr(resp, ":")
return { Verb: SubStr(resp, 1, colon-1), Value: CUnescape(SubStr(resp, colon+1)) }
}
Code: Select all
@@ -1512,12 +1512,38 @@ STDMETHODIMP IObjectComCompatible::Invoke(DISPID dispIdMember, REFIID riid, LCID
for (;;)
{
switch (static_cast<IObject *>(this)->Invoke(result_token, this_token, flags, first_param, param_count))
{
case FAIL:
+ {
result_to_return = E_FAIL;
+ if (g->ThrownToken)
+ {
+ if (IObject *pObj = TokenToObject(*g->ThrownToken))
+ {
+ if (Object *obj = dynamic_cast<Object*>(pObj))
+ {
+ result_to_return = DISP_E_EXCEPTION;
+
+ ExprTokenType tempTok;
+
+ ZeroMemory(pExcepInfo, sizeof(EXCEPINFO));
+ pExcepInfo->scode = result_to_return;
+ if (obj->GetItem(tempTok, _T("what")))
+ pExcepInfo->bstrSource = SysAllocString(TokenToString(tempTok, result_token_buf));
+ if (obj->GetItem(tempTok, _T("message")))
+ pExcepInfo->bstrDescription = SysAllocString(TokenToString(tempTok, result_token_buf));
+ if (obj->GetItem(tempTok, _T("file")))
+ pExcepInfo->bstrHelpFile = SysAllocString(TokenToString(tempTok, result_token_buf));
+ if (obj->GetItem(tempTok, _T("line")))
+ pExcepInfo->dwHelpContext = (DWORD)TokenToInt64(tempTok);
+ }
+ }
+ g_script.FreeExceptionToken(g->ThrownToken);
+ }
break;
+ }
case INVOKE_NOT_HANDLED:
if ((flags & IT_BITMASK) != IT_GET)
{
if (wFlags & DISPATCH_PROPERTYGET)
{
That was my intention, as I was inclined minimize the cost to code size, but because I neglected to clear g->ThrownToken, the behaviour can be a bit inconsistent. For instance, this can show "Error: Fail" after showing the COM error dialog:I've noticed that AHK exceptions are swallowed by the IDispatch implementation.
Code: Select all
sc := ComObjCreate("ScriptControl"), sc.Language := "JScript"
sc.AddObject("IThrow", Func("IThrow")), sc.Eval("IThrow()")
IThrow() {
throw Exception("Fail")
}
Users browsing this forum: No registered users and 37 guests