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

Function CheckFuncLayoutName

BaseTools/Source/Python/Ecc/c.py:1340–1402  ·  view source on GitHub ↗
(FullFileName)

Source from the content-addressed store, hash-verified

1338 PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_OPTIONAL_FUNCTIONAL_MODIFIER, '', 'Function', Result[1])
1339
1340def CheckFuncLayoutName(FullFileName):
1341 ErrorMsgList = []
1342 # Parameter variable format pattern.
1343 Pattern = re.compile(r'^[A-Z]+\S*[a-z]\S*$')
1344 ParamIgnoreList = ('VOID', '...')
1345 FileID = GetTableID(FullFileName, ErrorMsgList)
1346 if FileID < 0:
1347 return ErrorMsgList
1348
1349 Db = GetDB()
1350 FileTable = 'Identifier' + str(FileID)
1351 SqlStatement = """ select Name, ID, EndColumn, Value
1352 from %s
1353 where Model = %d
1354 """ % (FileTable, DataClass.MODEL_IDENTIFIER_FUNCTION_DECLARATION)
1355 ResultSet = Db.TblFile.Exec(SqlStatement)
1356 for Result in ResultSet:
1357 FuncName = Result[3]
1358 if EccGlobalData.gException.IsException(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_NAME, FuncName):
1359 continue
1360 if Result[2] != 0:
1361 PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_NAME, 'Function name [%s] should appear at the start of a line' % FuncName, FileTable, Result[1])
1362 ParamList = GetParamList(Result[0])
1363 if len(ParamList) == 0:
1364 continue
1365 StartLine = 0
1366 for Param in ParamList:
1367 if Param.StartLine <= StartLine:
1368 PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_NAME, 'Parameter %s should be in its own line.' % Param.Name, FileTable, Result[1])
1369 if Param.StartLine - StartLine > 1:
1370 PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_NAME, 'Empty line appears before Parameter %s.' % Param.Name, FileTable, Result[1])
1371 if not Pattern.match(Param.Name) and not Param.Name in ParamIgnoreList and not EccGlobalData.gException.IsException(ERROR_NAMING_CONVENTION_CHECK_VARIABLE_NAME, Param.Name):
1372 PrintErrorMsg(ERROR_NAMING_CONVENTION_CHECK_VARIABLE_NAME, 'Parameter [%s] NOT follow naming convention.' % Param.Name, FileTable, Result[1])
1373 StartLine = Param.StartLine
1374
1375 if not Result[0].endswith('\n )') and not Result[0].endswith('\r )'):
1376 PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_NAME, '\')\' should be on a new line and indented two spaces', FileTable, Result[1])
1377
1378 SqlStatement = """ select Modifier, ID, FunNameStartColumn, Name
1379 from Function
1380 where BelongsToFile = %d
1381 """ % (FileID)
1382 ResultSet = Db.TblFile.Exec(SqlStatement)
1383 for Result in ResultSet:
1384 FuncName = Result[3]
1385 if EccGlobalData.gException.IsException(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_NAME, FuncName):
1386 continue
1387 if Result[2] != 0:
1388 PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_NAME, 'Function name [%s] should appear at the start of a line' % FuncName, 'Function', Result[1])
1389 ParamList = GetParamList(Result[0])
1390 if len(ParamList) == 0:
1391 continue
1392 StartLine = 0
1393 for Param in ParamList:
1394 if Param.StartLine <= StartLine:
1395 PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_NAME, 'Parameter %s should be in its own line.' % Param.Name, 'Function', Result[1])
1396 if Param.StartLine - StartLine > 1:
1397 PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_NAME, 'Empty line appears before Parameter %s.' % Param.Name, 'Function', Result[1])

Callers

nothing calls this directly

Calls 7

GetTableIDFunction · 0.85
lenFunction · 0.85
IsExceptionMethod · 0.80
GetDBFunction · 0.70
PrintErrorMsgFunction · 0.70
GetParamListFunction · 0.70
ExecMethod · 0.45

Tested by

no test coverage detected