MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / findFunctionCall

Function findFunctionCall

JUCE/modules/juce_core/javascript/juce_Javascript.cpp:139–171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

137 DynamicObject::Ptr scope;
138
139 var findFunctionCall (const CodeLocation& location, const var& targetObject, const Identifier& functionName) const
140 {
141 if (auto* o = targetObject.getDynamicObject())
142 {
143 if (auto* prop = getPropertyPointer (*o, functionName))
144 return *prop;
145
146 for (auto* p = o->getProperty (getPrototypeIdentifier()).getDynamicObject(); p != nullptr;
147 p = p->getProperty (getPrototypeIdentifier()).getDynamicObject())
148 {
149 if (auto* prop = getPropertyPointer (*p, functionName))
150 return *prop;
151 }
152
153 // if there's a class with an overridden DynamicObject::hasMethod, this avoids an error
154 if (o->hasMethod (functionName))
155 return {};
156 }
157
158 if (targetObject.isString())
159 if (auto* m = findRootClassProperty (StringClass::getClassName(), functionName))
160 return *m;
161
162 if (targetObject.isArray())
163 if (auto* m = findRootClassProperty (ArrayClass::getClassName(), functionName))
164 return *m;
165
166 if (auto* m = findRootClassProperty (ObjectClass::getClassName(), functionName))
167 return *m;
168
169 location.throwError ("Unknown function '" + functionName.toString() + "'");
170 return {};
171 }
172
173 var* findRootClassProperty (const Identifier& className, const Identifier& propName) const
174 {

Callers

nothing calls this directly

Calls 11

getPropertyPointerFunction · 0.85
getPrototypeIdentifierFunction · 0.85
findRootClassPropertyFunction · 0.85
getClassNameFunction · 0.85
getDynamicObjectMethod · 0.80
hasMethodMethod · 0.80
getPropertyMethod · 0.45
isStringMethod · 0.45
isArrayMethod · 0.45
throwErrorMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected