| 193 | } |
| 194 | |
| 195 | Value MacroProcessor::EvaluateFunction(const Function::Ptr& func, const ResolverList& resolvers, |
| 196 | const CheckResult::Ptr& cr, |
| 197 | const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros, int recursionLevel) |
| 198 | { |
| 199 | Dictionary::Ptr resolvers_this = new Dictionary(); |
| 200 | const auto defaultResolvers (GetDefaultResolvers()); |
| 201 | |
| 202 | for (auto resolverList : {&resolvers, &defaultResolvers}) { |
| 203 | for (auto& resolver: *resolverList) { |
| 204 | resolvers_this->Set(resolver.Name, resolver.Obj); |
| 205 | } |
| 206 | } |
| 207 | |
| 208 | auto internalResolveMacrosShim = [resolvers, cr, resolvedMacros, useResolvedMacros, recursionLevel](const std::vector<Value>& args) { |
| 209 | if (args.size() < 1) |
| 210 | BOOST_THROW_EXCEPTION(std::invalid_argument("Too few arguments for function")); |
| 211 | |
| 212 | String missingMacro; |
| 213 | |
| 214 | return MacroProcessor::InternalResolveMacros(args[0], resolvers, cr, &missingMacro, MacroProcessor::EscapeCallback(), |
| 215 | resolvedMacros, useResolvedMacros, recursionLevel); |
| 216 | }; |
| 217 | |
| 218 | resolvers_this->Set("macro", new Function("macro (temporary)", internalResolveMacrosShim, { "str" })); |
| 219 | |
| 220 | auto internalResolveArgumentsShim = [resolvers, cr, resolvedMacros, useResolvedMacros, recursionLevel](const std::vector<Value>& args) { |
| 221 | if (args.size() < 2) |
| 222 | BOOST_THROW_EXCEPTION(std::invalid_argument("Too few arguments for function")); |
| 223 | |
| 224 | return MacroProcessor::ResolveArguments(args[0], args[1], resolvers, cr, |
| 225 | resolvedMacros, useResolvedMacros, recursionLevel + 1); |
| 226 | }; |
| 227 | |
| 228 | resolvers_this->Set("resolve_arguments", new Function("resolve_arguments (temporary)", internalResolveArgumentsShim, { "command", "args" })); |
| 229 | |
| 230 | return func->InvokeThis(resolvers_this); |
| 231 | } |
| 232 | |
| 233 | Value MacroProcessor::InternalResolveMacros(const String& str, const ResolverList& resolvers, |
| 234 | const CheckResult::Ptr& cr, String *missingMacro, |
nothing calls this directly
no test coverage detected