1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +02:00
vcmi/lib/mapObjects
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
..
CArmedInstance.cpp Add missing antimagic functionality to antimagic garrisons 2023-12-21 18:09:33 +01:00
CArmedInstance.h Add missing antimagic functionality to antimagic garrisons 2023-12-21 18:09:33 +01:00
CBank.cpp Remove few more implicit conversions 2023-11-15 15:55:19 +02:00
CBank.h Use variant identifier in netpacks where applicable 2023-11-08 14:00:23 +02:00
CGCreature.cpp Fix creature appearance on hota maps 2023-11-28 19:31:38 +02:00
CGCreature.h Use variant identifier in netpacks where applicable 2023-11-08 14:00:23 +02:00
CGDwelling.cpp Fixed typo - different type was used to select ID and subID 2023-12-16 13:46:29 +02:00
CGDwelling.h Use variant identifier in netpacks where applicable 2023-11-08 14:00:23 +02:00
CGHeroInstance.cpp Merge pull request #3266 from Laserlicht/puzzle_cheat 2023-12-17 22:16:22 +02:00
CGHeroInstance.h Replace redundant types with auto for the lvalues of template factory functions for smart pointers 2024-01-17 12:50:00 +00:00
CGMarket.cpp Remove all remaining implicit conversion in lib 2023-11-15 15:55:19 +02:00
CGMarket.h Remove all remaining implicit conversion in lib 2023-11-15 15:55:19 +02:00
CGObjectInstance.cpp Working fir for Corpse issue: 2023-12-06 20:49:28 +01:00
CGObjectInstance.h Working fir for Corpse issue: 2023-12-06 20:49:28 +01:00
CGPandoraBox.cpp Fixes warning about usage of unused variable 2023-12-27 22:25:29 +01:00
CGPandoraBox.h Use meta string for messages 2023-09-27 23:11:11 +02:00
CGTownBuilding.cpp Use variant identifier in netpacks where applicable 2023-11-08 14:00:23 +02:00
CGTownBuilding.h Use variant identifier in netpacks where applicable 2023-11-08 14:00:23 +02:00
CGTownInstance.cpp Avoid boost::format that throws exception on invalid format string 2023-12-10 16:37:58 +02:00
CGTownInstance.h Fix error messages in log on map start 2023-11-27 14:08:49 +02:00
CObjectHandler.cpp Reduced number of accesses to CGObjectInstance::subID 2023-11-01 14:43:20 +02:00
CObjectHandler.h Remove no longer used serialization methods 2023-11-08 21:27:05 +02:00
CQuest.cpp Fix localization-related error messages 2023-12-11 18:23:52 +02:00
CQuest.h Fix error messages in log on map start 2023-11-27 14:08:49 +02:00
CRewardableObject.cpp Do not ignore 'canRefuse' flag for select mode 'first' and 'random' 2023-12-23 00:35:51 +02:00
CRewardableObject.h Use variant identifier in netpacks where applicable 2023-11-08 14:00:23 +02:00
IMarket.cpp Remove all remaining implicit conversion in lib 2023-11-15 15:55:19 +02:00
IMarket.h Remove all remaining implicit conversion in lib 2023-11-15 15:55:19 +02:00
IObjectInterface.cpp Do not allow building boat if there is already boat with hero in it 2023-11-28 15:49:03 +02:00
IObjectInterface.h Use variant identifier in netpacks where applicable 2023-11-08 14:00:23 +02:00
MapObjects.h
MiscObjects.cpp Fix possible crash on abandoned mine with no valid resources 2023-12-24 22:05:47 +02:00
MiscObjects.h Add missing antimagic functionality to antimagic garrisons 2023-12-21 18:09:33 +01:00
ObjectTemplate.cpp Fix reading of dimensions of h3 map objects 2023-12-11 21:15:46 +02:00
ObjectTemplate.h Implemented serialization of MapObjectSubID, refactoring of related code 2023-11-17 21:18:34 +02:00