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

Method __Item

source/script_object.cpp:784–810  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

782
783
784ResultType Map::__Item(ResultToken &aResultToken, int aID, int aFlags, ExprTokenType *aParam[], int aParamCount)
785{
786 if (!IS_INVOKE_SET) // Get or call.
787 {
788 if (!GetItem(aResultToken, *aParam[0]))
789 {
790 if (ParamIndexIsOmitted(1))
791 {
792 auto result = Invoke(aResultToken, IT_GET, _T("Default"), ExprTokenType { this }, nullptr, 0);
793 if (result == INVOKE_NOT_HANDLED)
794 _o_throw(ERR_NO_KEY, ParamIndexToString(0, _f_number_buf), ErrorPrototype::Key);
795 return result;
796 }
797 // Otherwise, caller provided a default value.
798 aResultToken.CopyValueFrom(*aParam[1]);
799 }
800 if (aResultToken.symbol == SYM_OBJECT)
801 aResultToken.object->AddRef();
802 return OK;
803 }
804 else
805 {
806 if (!SetItem(*aParam[1], *aParam[0]))
807 _o_throw_oom;
808 }
809 return OK;
810}
811
812
813ResultType Map::Set(ResultToken &aResultToken, int aID, int aFlags, ExprTokenType *aParam[], int aParamCount)

Callers

nothing calls this directly

Calls 2

CopyValueFromMethod · 0.80
AddRefMethod · 0.45

Tested by

no test coverage detected