MCPcopy Create free account
hub / github.com/AutoHotkey/AutoHotkey / CreateHotFunc

Method CreateHotFunc

source/script2.cpp:4767–4807  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4765}
4766
4767UserFunc* Script::CreateHotFunc()
4768{
4769 // Should only be called during load time.
4770 // Creates a new function for hotkeys and hotstrings.
4771 // Caller should abort loading if this function returns nullptr.
4772
4773 if (mUnusedHotFunc)
4774 {
4775 auto tmp = mLastHotFunc = g->CurrentFunc = mUnusedHotFunc;
4776 mUnusedHotFunc = nullptr;
4777 mHotFuncs.mCount++; // DefineFunc "removed" this func previously.
4778 ASSERT(mHotFuncs.mItem[mHotFuncs.mCount - 1] == tmp);
4779 return tmp;
4780 }
4781
4782 static LPCTSTR sName = _T("<Hotkey>");
4783 auto func = new UserFunc(sName);
4784
4785 if (!func)
4786 {
4787 MemoryError();
4788 return nullptr;
4789 }
4790
4791 g->CurrentFunc = func; // Must do this before calling AddVar
4792
4793 // Add one parameter to hold the name of the hotkey/hotstring when triggered:
4794 func->mParam = SimpleHeap::Alloc<FuncParam>();
4795 if ( !(func->mParam[0].var = AddVar(_T("ThisHotkey"), 10, &func->mVars, 0, VAR_DECLARE_LOCAL | VAR_LOCAL_FUNCPARAM)) )
4796 return nullptr;
4797
4798 func->mParam[0].default_type = PARAM_DEFAULT_NONE;
4799 func->mParam[0].is_byref = false;
4800 func->mParamCount = 1;
4801 func->mMinParams = 1;
4802 func->mIsFuncExpression = false;
4803
4804 mLastHotFunc = func;
4805 mHotFuncs.Insert(func, mHotFuncs.mCount);
4806 return func;
4807}
4808
4809ResultType MsgBoxParseOptions(LPTSTR aOptions, int &aType, double &aTimeout, HWND &aOwner)
4810{

Callers

nothing calls this directly

Calls 2

MemoryErrorFunction · 0.85
InsertMethod · 0.45

Tested by

no test coverage detected