1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-26 22:57:00 +02:00
vcmi/lib/rmg
Alexander Wilms 73019c204d Replace redundant types with auto for the lvalues of template factory functions for smart pointers
grep -r --include \*.h --include \*.cpp "= std::" * | grep -v auto | grep -Po ".*[^ ]+ [^ ]+ [^ ]*[ ]*=.*;" | grep -v "auto\|int\|char\|bool\|float|\double\|for\|if\|googletest\|fuzzylite\|size_t\|using\|return" | grep -v double | grep -v si64 | grep -v si32 | grep -v ui32 | grep \< | grep -v float | tr -d '\t' | grep -v assert > redundant_types.txt

import re

with open("redundant_types.txt") as f:
    for line in f:
        line = line.strip()
        path = line.split(":", 1)[0]
        original_code = ":".join(line.split(":")[1:]).strip()

        print()
        print(path)
        print(original_code)
        prefix = "auto "
        if original_code.startswith("static"):
            static = True
        else:
            static = False

        cpp_type = " ".join(original_code.split("=")[0].strip().split(" ")[0:-1])
        print(cpp_type)

        if static:
            new_code = "static auto "+ " ".join(original_code.split(" ")[2:])
        else:
            new_code = "auto "+ " ".join(original_code.split(" ")[1:])
        print(new_code)

        if True:
            with open(path, "r") as f:
                filedata = f.read()

            filedata = filedata.replace(original_code, new_code)

            with open(path, "w") as f:
                f.write(filedata)
2024-01-17 12:50:00 +00:00
..
modificators Remove duplicate semicolons 2024-01-16 19:02:39 +00:00
threadpool Replace redundant types with auto for the lvalues of template factory functions for smart pointers 2024-01-17 12:50:00 +00:00
CMapGenerator.cpp Remove few more implicit conversions 2023-11-15 15:55:19 +02:00
CMapGenerator.h Define each identifier in a dedicated statement 2024-01-10 00:22:23 +00:00
CMapGenOptions.cpp Fix unused variable 2023-12-10 09:50:25 +01:00
CMapGenOptions.h Define each identifier in a dedicated statement 2024-01-10 00:22:23 +00:00
CRmgTemplate.cpp Removed remaining usages of std::vector<bool> 2023-11-15 15:55:18 +02:00
CRmgTemplate.h Define each identifier in a dedicated statement 2024-01-10 00:22:23 +00:00
CRmgTemplateStorage.cpp Removed remaining usages of std::vector<bool> 2023-11-15 15:55:18 +02:00
CRmgTemplateStorage.h Removed remaining usages of std::vector<bool> 2023-11-15 15:55:18 +02:00
CZonePlacer.cpp Remove duplicate semicolons 2024-01-16 19:02:39 +00:00
CZonePlacer.h Smarter scaling for forces between zones. 2023-06-23 21:43:12 +02:00
float3.h Define each identifier in a dedicated statement 2024-01-10 00:22:23 +00:00
Functions.cpp Split some map object files into smaller files. Reduced includes usage. 2023-06-02 21:47:37 +03:00
Functions.h Refactored Functions.cpp, removed unused function. 2023-05-20 07:55:28 +02:00
RmgArea.cpp Reverted change that seems to cause regression 2023-12-21 17:55:08 +01:00
RmgArea.h Multiple optimizations to avoid copying and allocating tiles for rmg::Area 2023-12-18 13:52:03 +01:00
RmgMap.cpp Merge pull request #3362 from IvanSavenko/terrain_decorations 2023-12-22 23:39:32 +02:00
RmgMap.h Merge pull request #3362 from IvanSavenko/terrain_decorations 2023-12-22 23:39:32 +02:00
RmgObject.cpp Definitive solution for Corpse 2023-12-21 12:29:45 +01:00
RmgObject.h Define each identifier in a dedicated statement 2024-01-10 00:22:23 +00:00
RmgPath.cpp Minor optimizations 2023-12-13 22:10:39 +01:00
RmgPath.h
TileInfo.cpp Converted (almost) all namespace enum's to enum classes 2023-08-25 13:38:02 +03:00
TileInfo.h Converted (almost) all namespace enum's to enum classes 2023-08-25 13:38:02 +03:00
Zone.cpp Final and perfect treasue nd obstacle density 2023-12-19 09:24:43 +01:00
Zone.h Extra cache for search area 2023-12-13 22:13:42 +01:00