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

Method GetEnumProp

source/script_object.cpp:2109–2157  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2107
2108
2109ResultType Object::GetEnumProp(UINT &aIndex, Var *aName, Var *aVal, int aVarCount)
2110{
2111 for ( ; aIndex < mFields.Length(); ++aIndex)
2112 {
2113 FieldType &field = mFields[aIndex];
2114 if (aVal)
2115 {
2116 if (field.symbol == SYM_DYNAMIC)
2117 {
2118 // Skip it if it can't be called without parameters, or if there's no getter in this object
2119 // (consistent with inherited properties that have neither getter nor setter defined here).
2120 // Also skip if this is a class prototype, since that isn't an instance of the class and
2121 // therefore isn't a valid target for a method/property call.
2122 if (field.prop->MaxParams > 0 || !field.prop->Getter() || IsClassPrototype())
2123 continue;
2124
2125 FuncResult result_token;
2126 ExprTokenType getter(field.prop->Getter());
2127 ExprTokenType object(this);
2128 auto *param = &object;
2129 auto result = getter.object->Invoke(result_token, IT_CALL, nullptr, getter, &param, 1);
2130 if (result == FAIL || result == EARLY_EXIT)
2131 return result;
2132 if (result_token.mem_to_free)
2133 {
2134 ASSERT(result_token.symbol == SYM_STRING && result_token.mem_to_free == result_token.marker);
2135 aVal->AcceptNewMem(result_token.mem_to_free, result_token.marker_length);
2136 }
2137 else
2138 {
2139 aVal->Assign(result_token);
2140 result_token.Free();
2141 }
2142 }
2143 else
2144 {
2145 ExprTokenType value;
2146 field.ToToken(value);
2147 aVal->Assign(value);
2148 }
2149 }
2150 if (aName)
2151 {
2152 aName->Assign(field.name);
2153 }
2154 return CONDITION_TRUE;
2155 }
2156 return CONDITION_FALSE;
2157}
2158
2159
2160ResultType Map::GetEnumItem(UINT &aIndex, Var *aKey, Var *aVal, int aVarCount)

Callers

nothing calls this directly

Calls 7

GetterMethod · 0.80
AcceptNewMemMethod · 0.80
LengthMethod · 0.45
InvokeMethod · 0.45
AssignMethod · 0.45
FreeMethod · 0.45
ToTokenMethod · 0.45

Tested by

no test coverage detected