Run code formatting on EventsCodeGenerator.cpp

This commit is contained in:
Florian Rival
2020-05-04 18:31:52 +02:00
committed by Florian Rival
parent 93e8dd4002
commit cb14f7cfa5

View File

@@ -4,7 +4,9 @@
* reserved. This project is released under the MIT License.
*/
#include "GDCore/Events/CodeGeneration/EventsCodeGenerator.h"
#include <algorithm>
#include "GDCore/CommonTools.h"
#include "GDCore/Events/CodeGeneration/EventsCodeGenerationContext.h"
#include "GDCore/Events/Tools/EventsCodeNameMangler.h"
@@ -898,24 +900,25 @@ gd::String EventsCodeGenerator::GenerateObject(
//(references to) objects lists. We statically declare and construct them to
// avoid re-creating them at runtime. Arrays are passed as reference in JS and
// we always use the same static arrays, making this possible.
auto declareMapOfObjects = [this](
const std::vector<gd::String>& objects,
const gd::EventsCodeGenerationContext& context) {
gd::String objectsMapName = GetCodeNamespaceAccessor() + "mapOf";
gd::String mapDeclaration;
for (auto& objectName : objects) {
// The map name must be unique for each set of objects lists.
objectsMapName += ManObjListName(GetObjectListName(objectName, context));
auto declareMapOfObjects =
[this](const std::vector<gd::String>& objects,
const gd::EventsCodeGenerationContext& context) {
gd::String objectsMapName = GetCodeNamespaceAccessor() + "mapOf";
gd::String mapDeclaration;
for (auto& objectName : objects) {
// The map name must be unique for each set of objects lists.
objectsMapName +=
ManObjListName(GetObjectListName(objectName, context));
if (!mapDeclaration.empty()) mapDeclaration += ", ";
mapDeclaration += "\"" + ConvertToString(objectName) +
"\": " + GetObjectListName(objectName, context);
}
if (!mapDeclaration.empty()) mapDeclaration += ", ";
mapDeclaration += "\"" + ConvertToString(objectName) +
"\": " + GetObjectListName(objectName, context);
}
AddCustomCodeOutsideMain(objectsMapName + " = Hashtable.newFrom({" +
mapDeclaration + "});");
return objectsMapName;
};
AddCustomCodeOutsideMain(objectsMapName + " = Hashtable.newFrom({" +
mapDeclaration + "});");
return objectsMapName;
};
gd::String output;
if (type == "objectList") {