Tidy #defines
This commit is contained in:
parent
7e14550cc1
commit
6b89d7e8e7
|
@ -33,9 +33,9 @@ extern char **getFileList(char *dir, int *count);
|
|||
extern long lookup(char *name);
|
||||
extern void playSound(int id);
|
||||
extern char *readFile(char *filename);
|
||||
extern void setAtlasColor(int r, int g, int b, int a);
|
||||
extern void updateControlButton(char *name);
|
||||
extern void updateControlKey(char *name);
|
||||
extern void setAtlasColor(int r, int g, int b, int a);
|
||||
|
||||
extern App app;
|
||||
extern Colors colors;
|
||||
|
|
|
@ -84,7 +84,7 @@ function cleanHeader($headerFile)
|
|||
{
|
||||
$header = file($headerFile);
|
||||
$body = file_get_contents($bodyFile);
|
||||
$isMain = strpos($body, "int main(int argc, char *argv[])");
|
||||
$isMain = strpos($body, "int main(");
|
||||
$lines = [];
|
||||
$defines = [];
|
||||
$functions = [];
|
||||
|
@ -197,6 +197,8 @@ function cleanHeader($headerFile)
|
|||
$functions = array_unique($functions);
|
||||
$structs = array_unique($structs);
|
||||
|
||||
$defines = alignDefines($defines);
|
||||
|
||||
$header = updateExterns($header, $defines, $functions, $structs);
|
||||
|
||||
if ($UPDATE_FILES)
|
||||
|
@ -206,6 +208,30 @@ function cleanHeader($headerFile)
|
|||
}
|
||||
}
|
||||
|
||||
function alignDefines($defines)
|
||||
{
|
||||
$newAligns = [];
|
||||
$largest = 0;
|
||||
$defineName;
|
||||
$defineValue;
|
||||
|
||||
foreach ($defines as $define)
|
||||
{
|
||||
sscanf($define, "%*s %s", $defineName);
|
||||
|
||||
$largest = max($largest, strlen($defineName) + 4);
|
||||
}
|
||||
|
||||
foreach ($defines as $define)
|
||||
{
|
||||
sscanf($define, "%*s %s %[^\n]", $defineName, $defineValue);
|
||||
|
||||
$newAligns[] = "#define " . str_pad($defineName, $largest, " ") . $defineValue . "\n";
|
||||
}
|
||||
|
||||
return $newAligns;
|
||||
}
|
||||
|
||||
function recurseDir($dir)
|
||||
{
|
||||
if ($dir != "../src/json")
|
||||
|
|
Loading…
Reference in New Issue