1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00
vcmi/lib/mapping
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
..
CDrawRoadsOperation.cpp Fix generation of roads and rivers near map edge 2023-04-13 16:26:03 +03:00
CDrawRoadsOperation.h Define each identifier in a dedicated statement 2024-01-10 00:22:23 +00:00
CMap.cpp Do not ignore block-visit objects when computing guardian locations 2023-11-28 19:32:03 +02:00
CMap.h Implemented serialization of MapObjectSubID, refactoring of related code 2023-11-17 21:18:34 +02:00
CMapDefines.h convert line endings from CRLF (Windows) to LF (Linux/Unix) 2023-10-19 16:23:21 +02:00
CMapEditManager.cpp Implemented configurable level of decorations for terrains 2023-12-22 17:41:30 +02:00
CMapEditManager.h Implemented configurable level of decorations for terrains 2023-12-22 17:41:30 +02:00
CMapHeader.cpp Resolve intentionality issues 2024-01-10 00:23:24 +00:00
CMapHeader.h Remove pointer to CGObjectInstance from map header 2023-11-17 16:39:15 +02:00
CMapInfo.cpp code review 2023-12-16 21:10:27 +01:00
CMapInfo.h convert line endings from CRLF (Windows) to LF (Linux/Unix) 2023-10-19 16:23:21 +02:00
CMapOperation.cpp Fix water generation, try to improve decoration level a bit 2023-12-22 18:35:38 +02:00
CMapOperation.h Define each identifier in a dedicated statement 2024-01-10 00:22:23 +00:00
CMapService.cpp Define each identifier in a dedicated statement 2024-01-10 00:22:23 +00:00
CMapService.h Mod compatibility check is now in a separate class and not part of 2023-11-08 21:27:05 +02:00
MapEditUtils.cpp Implemented configurable level of decorations for terrains 2023-12-22 17:41:30 +02:00
MapEditUtils.h Define each identifier in a dedicated statement 2024-01-10 00:22:23 +00:00
MapFeaturesH3M.cpp Fix loading of maps with Grail or Diplomat Suit placed on map 2023-11-27 14:08:49 +02:00
MapFeaturesH3M.h convert line endings from CRLF (Windows) to LF (Linux/Unix) 2023-10-19 16:23:21 +02:00
MapFormat.h Fix CI build 2023-05-31 23:18:39 +03:00
MapFormatH3M.cpp Do not crash if Scholar is not a rewardable object 2023-12-16 13:46:29 +02:00
MapFormatH3M.h Merge branch 'josch/dos2unix' into develop 2023-10-22 18:39:03 +03:00
MapFormatJson.cpp Replace redundant types with auto for the lvalues of template factory functions for smart pointers 2024-01-17 12:50:00 +00:00
MapFormatJson.h convert line endings from CRLF (Windows) to LF (Linux/Unix) 2023-10-19 16:23:21 +02:00
MapIdentifiersH3M.cpp Fixed map startup 2023-11-17 16:19:07 +02:00
MapIdentifiersH3M.h Improvements to type safety of Identifier class 2023-10-04 18:05:23 +03:00
MapReaderH3M.cpp Remove duplicate semicolons 2024-01-16 19:02:39 +00:00
MapReaderH3M.h Win/loss conditions now use VariantIdentifier. Removed non-implemented 2023-11-15 15:55:19 +02:00
ObstacleProxy.cpp Do not calculate area for invalid positions 2023-12-13 22:06:47 +01:00
ObstacleProxy.h Redesign map editor rendering 2023-10-20 01:25:06 +02:00