Skip to content

Commit

Permalink
Merge alpha.2
Browse files Browse the repository at this point in the history
  • Loading branch information
thqby committed Aug 22, 2023
2 parents f338a3d + f79d792 commit b388a2e
Show file tree
Hide file tree
Showing 24 changed files with 765 additions and 340 deletions.
53 changes: 52 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,65 @@
"version": "0.2.0",
"configurations": [
{
"name": "Debug x64w",
"name": "Debug x64w C++",
"type": "cppvsdbg",
"request": "launch",
"program": "bin_debug/AutoHotkey64.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"preLaunchTask": "build-debug"
},
{
"name": "Debug x64w AHK",
"type": "autohotkey",
"request": "launch",
"program": "${file}",
"runtime": "${workspaceRoot}/bin_debug/AutoHotkey64.exe",
"useDebugDirective": true,
"args": [],
"variableCategories": [
{
"label": "Local",
"source": "Local",
},
{
"label": "Static",
"source": "Static",
},
{
"label": "Global",
"source": "Global",
"noduplicate": true,
},
{
"label": "Global Classes",
"source": "Global",
"matchers": [
{
"className": "Class",
},
],
},
{
"label": "Global Functions",
"source": "Global",
"matchers": [
{
"className": "Func",
},
],
},
{
"label": "Built-in Global",
"source": "Global",
"matchers": [
{
"builtin": true
},
],
},
]
}
]
}
1 change: 1 addition & 0 deletions AutoHotkeyx.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@
<AhkVersionN4>$([System.Text.RegularExpressions.Regex]::Replace($(GitDescription), ".*-(\d+)-g.*", "$1"))</AhkVersionN4>
<AhkVersionN4 Condition="'$(AhkVersionN4)'=='$(GitDescription)'">0</AhkVersionN4>
<AhkVersionN>$([System.Text.RegularExpressions.Regex]::Replace($(RawAhkVersion), "\.(\d+)([^\.\d].*)?", ",$1")),$(AhkVersionN4)</AhkVersionN>
<AhkVersionN>$([System.Text.RegularExpressions.Regex]::Replace($(AhkVersionN), "^(\d+,\d+,)(\d+)$", "${1}0,$2"))</AhkVersionN>
</PropertyGroup>
<Message Text="RAW_AHK_VERSION sourced from git: '$(RawAhkVersion)'" Importance="high" />
<Message Text="AHK_VERSION_N sourced from git: '$(AhkVersionN)'" Importance="high" />
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ AutoHotkey_H v2 started as a fork of [AutoHotkey_L v2](https://github.com/Lexiko

- After 2.0.4
- The com component has changed for the dll version, some methods are incorporated into [IAutoHotkeyLib](README-LIB.md#lib-api).
- The calling convention of export functions is changed from `cdecl` to `stdcall`.
- Merge alpha.1

- After 2.0.5
- Merge alpha.2

## Classes List
```typescript
Expand Down
13 changes: 9 additions & 4 deletions debug.natvis
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,21 @@
<DisplayString Condition="symbol == SYM_INTEGER">{value_int64}</DisplayString>
<DisplayString Condition="symbol == SYM_FLOAT">{value_double}</DisplayString>
<DisplayString Condition="symbol == SYM_OBJECT">{object}</DisplayString>
<DisplayString Condition="symbol == SYM_VAR">{var}</DisplayString>
<DisplayString Condition="symbol == SYM_VAR &amp;&amp; (*(UINT*)var->mName &amp; 0xffffff00) != 0xcdcdcd00">{*var}</DisplayString>
<DisplayString Condition="symbol == SYM_VAR &amp;&amp; var_deref->type == 0 &amp;&amp; (UINT)var_deref->marker != 0xcdcdcdcd">{*var_deref}</DisplayString>
<DisplayString Condition="symbol == SYM_COUNT">(end marker)</DisplayString>
<DisplayString Condition="symbol &gt;= SYM_OPERAND_END">{symbol,en} {error_reporting_marker,sub}</DisplayString>
<DisplayString>{symbol,en}</DisplayString>
<Expand>
<Item Name="value" Condition="symbol == SYM_STRING">marker</Item>
<Item Name="length" Condition="symbol == SYM_STRING">marker_length</Item>
<Item Name="value" Condition="symbol == SYM_INTEGER">value_int64</Item>
<Item Name="value" Condition="symbol == SYM_FLOAT">value_double</Item>
<Item Name="object" Condition="symbol == SYM_OBJECT">object</Item>
<Item Name="var" Condition="symbol == SYM_VAR">var</Item>
<Item Name="var_deref" Condition="symbol == SYM_VAR">var_deref</Item>
<Item Name="var" Condition="symbol == SYM_VAR &amp;&amp; (*(UINT*)var->mName &amp; 0xffffff00) != 0xcdcdcd00">var</Item>
<Item Name="var_deref" Condition="symbol == SYM_VAR &amp;&amp; var_deref->type == 0 &amp;&amp; (UINT)var_deref->marker != 0xcdcdcdcd">var_deref</Item>
<Item Name="callsite" Condition="symbol == SYM_FUNC">callsite</Item>
<Item Name="marker" Condition="symbol == SYM_OPAREN">marker</Item>
<Item Name="outer" Condition="symbol == SYM_OPAREN">outer_param_list</Item>
</Expand>
</Type>
<Type Name="Var">
Expand All @@ -45,6 +47,9 @@
<Item Name="object" Condition="mAttrib &amp; 0x40">mObject</Item>
</Expand>
</Type>
<Type Name="DerefType">
<DisplayString>{marker,[length]sub}</DisplayString>
</Type>
<Type Name="Func">
<DisplayString>{mName,sub}()</DisplayString>
</Type>
Expand Down
5 changes: 1 addition & 4 deletions source/Debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1219,10 +1219,7 @@ int Debugger::GetPropertyValue(Var &aVar, PropertySource &aProp)
{
aProp.value.Free();
aProp.value.mem_to_free = nullptr; // Any value would be overwritten but this must be cleared manually.
if (aVar.IsUninitializedNormalVar())
aProp.value.symbol = SYM_MISSING;
else
aVar.ToToken(aProp.value);
aVar.ToToken(aProp.value);
}
return DEBUGGER_E_OK;
}
Expand Down
28 changes: 22 additions & 6 deletions source/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,7 @@ bool MsgSleep(int aSleepDuration, MessageMode aMode)
{
do_special_msg_filter = false; // Set default.
if (g_nFileDialogs) // v1.0.44.12: Also do the special Peek/msg filter below for FileSelect because testing shows that frequently-running timers disrupt the ability to double-click.
{
GetClassName(fore_window, wnd_class_name, _countof(wnd_class_name));
do_special_msg_filter = !_tcscmp(wnd_class_name, _T("#32770")); // Due to checking g_nFileDialogs above, this means that this dialog is probably FileSelect rather than MsgBox/InputBox/DirSelect (even if this guess is wrong, it seems fairly inconsequential to filter the messages since other pump beneath us on the call-stack will handle them ok).
}
do_special_msg_filter = IsWindowStandardDialog(fore_window); // Due to checking g_nFileDialogs above, this means that this dialog is probably FileSelect rather than MsgBox/InputBox/DirSelect (even if this guess is wrong, it seems fairly inconsequential to filter the messages since other pump beneath us on the call-stack will handle them ok).
if (!do_special_msg_filter && (focused_control = GetFocus()))
{
GetClassName(focused_control, wnd_class_name, _countof(wnd_class_name));
Expand Down Expand Up @@ -1451,8 +1448,7 @@ bool MsgSleep(int aSleepDuration, MessageMode aMode)
if ((fore_window = GetForegroundWindow()) != NULL // There is a foreground window.
&& GetWindowThreadProcessId(fore_window, NULL) == g_MainThreadID) // And it belongs to our main thread (the main thread is the only one that owns any windows).
{
GetClassName(fore_window, wnd_class_name, _countof(wnd_class_name));
if (!_tcscmp(wnd_class_name, _T("#32770"))) // MsgBox, InputBox, FileSelect, DirSelect dialog.
if (IsWindowStandardDialog(fore_window)) // MsgBox, InputBox, FileSelect, DirSelect dialog.
{
g->CalledByIsDialogMessageOrDispatch = true; // In case there is any way IsDialogMessage() can call one of our own window proc's rather than that of a MsgBox, etc.
g->CalledByIsDialogMessageOrDispatchMsg = msg.message; // Added in v1.0.44.11 because it's known that IsDialogMessage can change the message number (e.g. WM_KEYDOWN->WM_NOTIFY for UpDowns)
Expand Down Expand Up @@ -2041,6 +2037,24 @@ BOOL IsInterruptible()



bool MsgWaitUnpause()
{
auto &g = *::g;
auto aThreadID = CURRENT_THREADID;
while (g.IsPaused)
{
MsgWaitForMultipleObjects(0, nullptr, FALSE, INFINITE, QS_ALLINPUT);
if ((char)g.IsPaused == -1) // thqby: Used to terminate a thread
return true;
else if (g_MainThreadID != aThreadID)
Sleep(SLEEP_INTERVAL);
else MsgSleep(-1);
}
return false;
}



VOID CALLBACK MsgBoxTimeout(HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
{
// Unfortunately, it appears that MessageBox() will return zero rather
Expand Down Expand Up @@ -2147,6 +2161,8 @@ bool MenuIsModeless(HMENU aMenu)
return (mi.dwStyle & MNS_MODELESS);
}



#ifndef CONFIG_DLL
bool AHKModule()
{
Expand Down
6 changes: 2 additions & 4 deletions source/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ void InitNewThread(int aPriority, bool aSkipUninterruptible, bool aIncrementThre
void ResumeUnderlyingThread();
BOOL IsInterruptible();

bool MsgWaitUnpause();

VOID CALLBACK MsgBoxTimeout(HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime);
VOID CALLBACK InputTimeout(HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime);
VOID CALLBACK RefreshInterruptibility(HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime);
Expand All @@ -102,10 +104,6 @@ void InitMenuPopup(HMENU aMenu);
void UninitMenuPopup(HMENU aMenu);
bool MenuIsModeless(HMENU aMenu);

void InitMenuPopup(HMENU aMenu);
void UninitMenuPopup(HMENU aMenu);
bool MenuIsModeless(HMENU aMenu);

#ifndef CONFIG_DLL
bool AHKModule();
#endif
Expand Down
23 changes: 14 additions & 9 deletions source/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,9 @@ enum SymbolType // For use with ExpandExpression() and IsNumeric().
, SYM_BEGIN = SYM_OPERAND_END // SYM_BEGIN is a special marker to simplify the code.
#define IS_OPERAND(symbol) ((symbol) < SYM_OPERAND_END)
, SYM_POST_INCREMENT, SYM_POST_DECREMENT // Kept in this position for use by YIELDS_AN_OPERAND() [helps performance].
#define IS_POSTFIX_OPERATOR(symbol) ((symbol) == SYM_POST_INCREMENT || (symbol) == SYM_POST_DECREMENT)
, SYM_DOT // DOT must precede SYM_OPAREN so YIELDS_AN_OPERAND(SYM_GET) == TRUE, allowing auto-concat to work for it even though it is positioned after its second operand.
, SYM_MAYBE
#define IS_POSTFIX_OPERATOR(symbol) ((symbol) <= SYM_MAYBE && (symbol) >= SYM_POST_INCREMENT)
, SYM_DOT // DOT must precede SYM_OPAREN so YIELDS_AN_OPERAND(SYM_DOT) to get the right result (TRUE), since its RHS operand is embedded in the operator itself.
, SYM_CPAREN, SYM_CBRACKET, SYM_CBRACE, SYM_OPAREN, SYM_OBRACKET, SYM_OBRACE, SYM_COMMA // CPAREN (close-paren)/CBRACKET/CBRACE must come right before OPAREN for YIELDS_AN_OPERAND.
#define IS_OPAREN_LIKE(symbol) ((symbol) <= SYM_OBRACE && (symbol) >= SYM_OPAREN)
#define IS_CPAREN_LIKE(symbol) ((symbol) <= SYM_CBRACE && (symbol) >= SYM_CPAREN)
Expand All @@ -187,13 +188,15 @@ enum SymbolType // For use with ExpandExpression() and IsNumeric().
#define YIELDS_AN_OPERAND(symbol) ((symbol) < SYM_OPAREN) // CPAREN also covers the tail end of a function call. Post-inc/dec yields an operand for things like Var++ + 2. Definitely needs the parentheses around symbol.
, SYM_ASSIGN, SYM_ASSIGN_ADD, SYM_ASSIGN_SUBTRACT, SYM_ASSIGN_MULTIPLY, SYM_ASSIGN_DIVIDE, SYM_ASSIGN_INTEGERDIVIDE
, SYM_ASSIGN_BITOR, SYM_ASSIGN_BITXOR, SYM_ASSIGN_BITAND, SYM_ASSIGN_BITSHIFTLEFT, SYM_ASSIGN_BITSHIFTRIGHT, SYM_ASSIGN_BITSHIFTRIGHT_LOGICAL // SYM_ASSIGN_BITSHIFTLEFT_LOGICAL doesn't exist but <<<= is the same as <<=
, SYM_ASSIGN_MAYBE
, SYM_ASSIGN_CONCAT // THIS MUST BE KEPT AS THE LAST (AND SYM_ASSIGN THE FIRST) BECAUSE THEY'RE USED IN A RANGE-CHECK.
#define IS_ASSIGNMENT_EXCEPT_POST_AND_PRE(symbol) (symbol <= SYM_ASSIGN_CONCAT && symbol >= SYM_ASSIGN) // Check upper bound first for short-circuit performance.
#define IS_ASSIGNMENT_OR_POST_OP(symbol) (IS_ASSIGNMENT_EXCEPT_POST_AND_PRE(symbol) || symbol == SYM_POST_INCREMENT || symbol == SYM_POST_DECREMENT)
, SYM_IFF_ELSE, SYM_IFF_THEN // THESE TERNARY OPERATORS MUST BE KEPT IN THIS ORDER AND ADJACENT TO THE BELOW.
, SYM_OR_MAYBE, SYM_OR, SYM_AND // MUST BE KEPT IN THIS ORDER AND ADJACENT TO THE ABOVE for the range checks below.
#define IS_SHORT_CIRCUIT_OPERATOR(symbol) ((symbol) <= SYM_AND && (symbol) >= SYM_IFF_THEN) // Excludes SYM_IFF_ELSE, which acts as a simple jump after the THEN branch is evaluated.
#define SYM_USES_CIRCUIT_TOKEN(symbol) ((symbol) <= SYM_AND && (symbol) >= SYM_IFF_ELSE)
#define IS_SHORT_CIRCUIT_OPERATOR(symbol) ((symbol) <= SYM_AND && ((symbol) >= SYM_IFF_THEN || (symbol) == SYM_MAYBE)) // Excludes SYM_IFF_ELSE, which acts as a simple jump after the THEN branch is evaluated.
#define SYM_USES_CIRCUIT_TOKEN(symbol) ((symbol) <= SYM_AND && ((symbol) >= SYM_IFF_ELSE || (symbol) == SYM_MAYBE))
#define SYM_MAYBE_IGNORES_ON_STACK(symbol) (SYM_USES_CIRCUIT_TOKEN(symbol) && (symbol) != SYM_IFF_THEN || (symbol) == SYM_ASSIGN)
, SYM_IS
, SYM_EQUAL, SYM_EQUALCASE, SYM_NOTEQUAL, SYM_NOTEQUALCASE // =, ==, !=, !==... Keep this in sync with IS_RELATIONAL_OPERATOR() below.
#define IS_EQUALITY_OPERATOR(symbol) (symbol >= SYM_EQUAL && symbol <= SYM_NOTEQUALCASE)
Expand Down Expand Up @@ -237,9 +240,8 @@ enum SymbolType // For use with ExpandExpression() and IsNumeric().
(IS_ASSIGNMENT_EXCEPT_POST_AND_PRE(sym) \
|| sym == SYM_PRE_INCREMENT || sym == SYM_PRE_DECREMENT)


enum VarRefUsageType { VARREF_READ = 0, VARREF_ISSET, VARREF_READ_MAYBE
, VARREF_REF, VARREF_LVALUE, VARREF_OUTPUT_VAR };
, VARREF_REF, VARREF_LVALUE, VARREF_LVALUE_MAYBE, VARREF_OUTPUT_VAR };
#define VARREF_IS_WRITE(var_usage) ((var_usage) >= VARREF_REF)
#define VARREF_IS_READ(var_usage) ((var_usage) == VARREF_READ || (var_usage) == VARREF_READ_MAYBE) // But not VARREF_ISSET.

Expand Down Expand Up @@ -317,6 +319,8 @@ struct DECLSPEC_NOVTABLE IDebugProperties
#define IT_CALL 2
#define IT_BITMASK 3 // bit-mask for the above.

#define BIMF_UNSET_ARG_1 8 // Flag used by BuiltInMethod.

#define IF_IGNORE_DEFAULT 0x000008
#define IF_BYPASS_METAFUNC 0x000010 // Skip invocation of meta-functions, such as when calling __Init or __Delete.
#define IF_SUBSTITUTE_THIS 0x000020 // "this" is a substitute object (i.e. ValueBase()), so prohibit new value properties.
Expand All @@ -327,6 +331,8 @@ struct DECLSPEC_NOVTABLE IDebugProperties
#define EIF_VARIADIC 0x010000
#define EIF_STACK_MEMBER 0x020000
#define EIF_LEAVE_PARAMS 0x040000
#define EIF_UNSET_RETURN 0x100000
#define EIF_UNSET_PROP 0x200000


// Helper function for event handlers and __Delete:
Expand Down Expand Up @@ -356,13 +362,12 @@ struct ExprTokenType // Something in the compiler hates the name TokenType, so
CallSite *callsite; // for SYM_FUNC, and (while parsing) SYM_ASSIGN etc.
DerefType *var_deref; // for SYM_VAR while parsing
Var *var; // for SYM_VAR and SYM_DYNAMIC
LPTSTR marker; // for SYM_STRING and (while parsing) SYM_OPAREN
LPTSTR marker; // for SYM_STRING
ExprTokenType *circuit_token; // for short-circuit operators
};
union // Due to the outermost union, this doesn't increase the total size of the struct on x86 builds (but it does on x64).
{
CallSite *outer_param_list; // Used by ExpressionToPostfix().
LPTSTR error_reporting_marker; // Used by ExpressionToPostfix() for binary and unary operators.
LPCTSTR error_reporting_marker; // Used by ExpressionToPostfix() for binary and unary operators.
size_t marker_length;
VarRefUsageType var_usage; // for SYM_DYNAMIC and SYM_VAR (at load time)
};
Expand Down
2 changes: 1 addition & 1 deletion source/error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ ResultType Line::ValidateVarUsage(Var *aVar, int aUsage)
if ( VARREF_IS_WRITE(aUsage)
&& (aUsage == VARREF_REF
? aVar->Type() != VAR_NORMAL // Aliasing VAR_VIRTUAL is currently unsupported.
: aVar->IsReadOnly()) )
: aVar->IsReadOnly() && aUsage != VARREF_LVALUE_MAYBE) )
return VarIsReadOnlyError(aVar, aUsage);
return OK;
}
Expand Down
2 changes: 1 addition & 1 deletion source/globaldata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ Action g_act[] =

// ASSIGNEXPR: Give it a name for Line::ToText().
// 1st param is the target, 2nd (optional) is the value:
, {_T(":="), 2, 2} // Same, though param #2 is flagged as numeric so that expression detection is automatic.
, {_T(":="), 2, 2}

// ACT_EXPRESSION, which is a stand-alone expression outside of any IF or assignment-command;
// e.g. fn1(123, fn2(y)) or x&=3
Expand Down
8 changes: 4 additions & 4 deletions source/lib/DllCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,16 +221,16 @@ DYNARESULT DynaCall(void *aFunction, DYNAPARM aParam[], int aParamCount, DWORD &
#endif // WIN32_PLATFORM
#ifdef _WIN64

int params_left = aParamCount, i = 0;
int params_left = aParamCount, i = 0, r = 0;
DWORD_PTR regArgs[4];
DWORD_PTR* stackArgs = NULL;
size_t stackArgsSize = 0;

// The first four parameters are passed in x64 through registers... like ARM :D
if (aRet)
regArgs[i++] = (DWORD_PTR)aRet;
for(; (i < 4) && params_left; i++, params_left--)
regArgs[i] = DynaParamToElement(aParam[i]);
regArgs[r++] = (DWORD_PTR)aRet;
for(; i < 4 && params_left; --params_left)
regArgs[r++] = DynaParamToElement(aParam[i++]);

// Copy the remaining parameters
if(params_left)
Expand Down
4 changes: 2 additions & 2 deletions source/lib/functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ md_func(IL_Add, (In, UIntPtr, ImageList), (In, String, Filename), (In_Opt, Int32
md_func_x(IL_Create, IL_Create, UIntPtr, (In_Opt, Int32, InitialCount), (In_Opt, Int32, GrowCount), (In_Opt, Bool32, LargeIcons))
md_func_x(IL_Destroy, IL_Destroy, Bool32, (In, UIntPtr, ImageList))

md_func(ImageSearch, (Out, Variant, X), (Out, Variant, Y), (In, Int32, X1), (In, Int32, Y1), (In, Int32, X2), (In, Int32, Y2), (In, String, Image), (Ret, Bool32, Found))
md_func(ImageSearch, (Out_Opt, Variant, X), (Out_Opt, Variant, Y), (In, Int32, X1), (In, Int32, Y1), (In, Int32, X2), (In, Int32, Y2), (In, String, Image), (Ret, Bool32, Found))

md_func(IniDelete, (In, String, Path), (In, String, Section), (In_Opt, String, Key))
md_func(IniRead, (In, String, Path), (In_Opt, String, Section), (In_Opt, String, Key), (In_Opt, String, Default), (Ret, String, RetVal))
Expand Down Expand Up @@ -213,7 +213,7 @@ md_func(Pause, (In_Opt, Int32, NewState))
md_func_v(Persistent, (In_Opt, Bool32, NewValue), (Ret, Bool32, OldValue))

md_func(PixelGetColor, (In, Int32, X), (In, Int32, Y), (In_Opt, String, Mode), (Ret, String, Color))
md_func(PixelSearch, (Ret, Bool32, Found), (Out, Variant, X), (Out, Variant, Y), (In, Int32, X1), (In, Int32, Y1), (In, Int32, X2), (In, Int32, Y2), (In, UInt32, Color), (In_Opt, Int32, Variation))
md_func(PixelSearch, (Ret, Bool32, Found), (Out_Opt, Variant, X), (Out_Opt, Variant, Y), (In, Int32, X1), (In, Int32, Y1), (In, Int32, X2), (In, Int32, Y2), (In, UInt32, Color), (In_Opt, Int32, Variation))

#undef PostMessage
md_func_x(PostMessage, ScriptPostMessage, FResult, (In, UInt32, Msg), (In_Opt, Variant, wParam), (In_Opt, Variant, lParam), MD_CONTROL_ARGS_OPT)
Expand Down
Loading

0 comments on commit b388a2e

Please sign in to comment.