MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / StripComments

Function StripComments

BaseTools/Source/Python/Ecc/c.py:937–981  ·  view source on GitHub ↗
(Str)

Source from the content-addressed store, hash-verified

935 return Dict
936
937def StripComments(Str):
938 Str += ' '
939 ListFromStr = list(Str)
940
941 InComment = False
942 DoubleSlashComment = False
943 Index = 0
944 while Index < len(ListFromStr):
945 # meet new line, then no longer in a comment for //
946 if ListFromStr[Index] == '\n':
947 if InComment and DoubleSlashComment:
948 InComment = False
949 DoubleSlashComment = False
950 Index += 1
951 # check for */ comment end
952 elif InComment and not DoubleSlashComment and ListFromStr[Index] == '*' and ListFromStr[Index + 1] == '/':
953 ListFromStr[Index] = ' '
954 Index += 1
955 ListFromStr[Index] = ' '
956 Index += 1
957 InComment = False
958 # set comments to spaces
959 elif InComment:
960 ListFromStr[Index] = ' '
961 Index += 1
962 # check for // comment
963 elif ListFromStr[Index] == '/' and ListFromStr[Index + 1] == '/':
964 InComment = True
965 DoubleSlashComment = True
966
967 # check for /* comment start
968 elif ListFromStr[Index] == '/' and ListFromStr[Index + 1] == '*':
969 ListFromStr[Index] = ' '
970 Index += 1
971 ListFromStr[Index] = ' '
972 Index += 1
973 InComment = True
974 else:
975 Index += 1
976
977 # restore from List to String
978 Str = "".join(ListFromStr)
979 Str = Str.rstrip(' ')
980
981 return Str
982
983def GetFinalTypeValue(Type, FieldName, TypedefDict, SUDict):
984 Value = TypedefDict.get(Type)

Callers 3

GetParamListFunction · 0.70
GetFinalTypeValueFunction · 0.70

Calls 2

lenFunction · 0.85
joinMethod · 0.80

Tested by

no test coverage detected