Browse Source

ASEnumBinder: Remove unnecessary code, use refs in cycles

1vanK 5 years ago
parent
commit
e1661eebe0

+ 3 - 3
Source/Tools/BindingGenerator/ASEnumBinder.cpp

@@ -80,7 +80,7 @@ static void ProcessEnum(const EnumAnalyzer& analyzer)
 
         processedEnum.registration_.push_back("engine->RegisterTypedef(\"" + enumTypeName + "\", \"" + asEnumBaseType + "\");");
 
-        for (string enumerator : analyzer.GetEnumerators())
+        for (const string& enumerator : analyzer.GetEnumerators())
         {
             string constName = enumTypeName + "_" + enumerator;
             processedEnum.glue_.push_back("static const " + cppEnumBaseType + " " + constName + " = " + enumerator + ";");
@@ -123,12 +123,12 @@ void ProcessAllEnums()
     NamespaceAnalyzer namespaceAnalyzer(SourceData::namespaceUrho3D_);
     vector<EnumAnalyzer> enumAnalyzers = namespaceAnalyzer.GetEnums();
 
-    for (EnumAnalyzer enumAnalyzer : enumAnalyzers)
+    for (const EnumAnalyzer& enumAnalyzer : enumAnalyzers)
         ProcessEnum(enumAnalyzer);
 
     vector<GlobalFunctionAnalyzer> globalFunctionAnalyzers = namespaceAnalyzer.GetFunctions();
 
-    for (GlobalFunctionAnalyzer globalFunctionAnalyzer : globalFunctionAnalyzers)
+    for (const GlobalFunctionAnalyzer& globalFunctionAnalyzer : globalFunctionAnalyzers)
     {
         string functionName = globalFunctionAnalyzer.GetName();
 

+ 2 - 30
Source/Tools/BindingGenerator/ASResult.cpp

@@ -37,34 +37,6 @@ ASGeneratedFile_WithRegistrationFunction::ASGeneratedFile_WithRegistrationFuncti
 
 // ============================================================================
 
-void ASGeneratedFile_Enums::Save()
-{
-    ofstream out(outputFilePath_);
-
-    out <<
-        "// DO NOT EDIT. This file is generated\n"
-        "\n"
-        "// We need register all enums before registration of any members because members can use any enums\n"
-        "\n"
-        "#include \"../Precompiled.h\"\n"
-        "#include \"../AngelScript/APITemplates.h\"\n"
-        "\n"
-        "#include \"../AngelScript/GeneratedIncludes.h\"\n"
-        "\n"
-        "namespace Urho3D\n"
-        "{\n"
-        "\n"
-        << glue_.str() <<
-        "void " << functionName_ << "(asIScriptEngine* engine)\n"
-        "{\n"
-        << reg_.str() <<
-        "}\n"
-        "\n"
-        "}\n";
-}
-
-// ============================================================================
-
 void ASGeneratedFile_Classes::Save()
 {
     ofstream out(outputFilePath_);
@@ -240,7 +212,7 @@ void ASGeneratedFile_Templates::Save()
         "}\n";
 }
 
-bool ProcessedEnum::operator < (const ProcessedEnum& rhs) const
+bool ProcessedEnum::operator <(const ProcessedEnum& rhs) const
 {
     if (insideDefine_ == rhs.insideDefine_)
         return name_ < rhs.name_;
@@ -413,7 +385,7 @@ namespace Result
 
         isFirst = true;
 
-        for (string header : ignoredHeaders_)
+        for (const string& header : ignoredHeaders_)
         {
             string insideDefine = InsideDefine(header);
 

+ 0 - 8
Source/Tools/BindingGenerator/ASResult.h

@@ -58,14 +58,6 @@ public:
     ASGeneratedFile_WithRegistrationFunction(const string& outputFilePath, const string& functionName);
 };
 
-class ASGeneratedFile_Enums : public ASGeneratedFile_WithRegistrationFunction
-{
-public:
-    using ASGeneratedFile_WithRegistrationFunction::ASGeneratedFile_WithRegistrationFunction;
-    
-    void Save() override;
-};
-
 class ASGeneratedFile_Classes : public ASGeneratedFile_WithRegistrationFunction
 {
 public: