Simplifying lambda function in CompilerStack::getInterface()

This commit is contained in:
Lefteris Karapetsas 2014-12-02 17:18:09 +01:00
parent af9fb9917c
commit 06998aa2d2

View File

@ -100,24 +100,22 @@ string const& CompilerStack::getInterface()
Json::Value inputs(Json::arrayValue); Json::Value inputs(Json::arrayValue);
Json::Value outputs(Json::arrayValue); Json::Value outputs(Json::arrayValue);
auto streamVariables = [&](vector<ASTPointer<VariableDeclaration>> const& _vars, auto streamVariables = [](vector<ASTPointer<VariableDeclaration>> const& _vars)
Json::Value &json)
{ {
Json::Value params(Json::arrayValue);
for (ASTPointer<VariableDeclaration> const& var: _vars) for (ASTPointer<VariableDeclaration> const& var: _vars)
{ {
Json::Value input; Json::Value input;
input["name"] = var->getName(); input["name"] = var->getName();
input["type"] = var->getType()->toString(); input["type"] = var->getType()->toString();
json.append(input); params.append(input);
} }
return params;
}; };
method["name"] = f->getName(); method["name"] = f->getName();
streamVariables(f->getParameters(), inputs); method["inputs"] = streamVariables(f->getParameters());
method["inputs"] = inputs; method["outputs"] = streamVariables(f->getReturnParameters());
streamVariables(f->getReturnParameters(), outputs);
method["outputs"] = outputs;
methods.append(method); methods.append(method);
} }
m_interface = writer.write(methods); m_interface = writer.write(methods);