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

Method GetMethod

source/script_object.cpp:2276–2296  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2274}
2275
2276IObject *Object::GetMethod(name_t name)
2277{
2278 // Return the function(?) object which would be called if the named property is called,
2279 // or nullptr if that would require invoking a getter. Does not verify that the object
2280 // is callable, and does not support primitive values (even in the unusual case that Call
2281 // has been implemented via the value's base/prototype).
2282 bool dynamic_only = false;
2283 for (Object *that = this; that; that = that->mBase)
2284 {
2285 if (auto field = that->FindField(name))
2286 {
2287 if (field->symbol != SYM_DYNAMIC)
2288 return (dynamic_only || field->symbol != SYM_OBJECT) ? nullptr : field->object;
2289 if (auto func = field->prop->Method())
2290 return func; // Method takes precedence over any inherited value or getter.
2291 if (field->prop->Getter())
2292 dynamic_only = true; // Getter takes precedence over any inherited value.
2293 }
2294 }
2295 return nullptr;
2296}
2297
2298bool Object::HasMethod(name_t aName)
2299{

Callers 1

BIF_DECLFunction · 0.80

Calls 3

MethodMethod · 0.80
GetterMethod · 0.80
FindFieldMethod · 0.45

Tested by

no test coverage detected