conversion to c by gemini 4 argon

This commit is contained in:
Patedam committed 2026-10-16 23:40:45 -04:00
1 parent b70e2d21d2
commit f9356f9ba7
369 files changed
+18074 -107634

No files matched your search

+35 -7
View File
@@ -298,10 +298,13 @@ static int CompareFilePaths(const void* a, const void* b)
static bool GenerateUnityFiles(const UnityConfig* ucfg)
{
const char* unityExt = (ucfg->SourceDir[0] != '\0') ? ".c" : ".cpp";
const char* staleExt = (ucfg->SourceDir[0] != '\0') ? ".cpp" : ".c";
FilePathList* srcFiles = CreateFilePathList();
if (ucfg->SourceDir[0] != '\0')
{
CollectFiles(ucfg->SourceDir, NULL, ".cpp", srcFiles);
CollectFiles(ucfg->SourceDir, NULL, ".c", srcFiles);
}
else
{
@@ -328,6 +331,7 @@ static bool GenerateUnityFiles(const UnityConfig* ucfg)
bool anyChanged = false;
char currentUnityPath[MAX_PATH_LEN];
char staleUnityPath[MAX_PATH_LEN];
char* memBuf = (char*)ArenaPush(1024 * 1024);
// Determine hot/cold for each file
@@ -376,7 +380,13 @@ static bool GenerateUnityFiles(const UnityConfig* ucfg)
memOffset += sprintf_s(memBuf + memOffset, (1024 * 1024) - memOffset, "// Empty bucket\n");
}
snprintf(currentUnityPath, sizeof(currentUnityPath), "%s\\%s%d.cpp", ucfg->OutputDir, ucfg->Prefix, b + 1);
snprintf(staleUnityPath, sizeof(staleUnityPath), "%s\\%s%d%s", ucfg->OutputDir, ucfg->Prefix, b + 1, staleExt);
if (FileExists(staleUnityPath)) {
DeleteFileA(staleUnityPath);
anyChanged = true;
}
snprintf(currentUnityPath, sizeof(currentUnityPath), "%s\\%s%d%s", ucfg->OutputDir, ucfg->Prefix, b + 1, unityExt);
FileContent exist = ReadEntireFile(currentUnityPath);
bool write = true;
if (exist.Data && exist.Size == memOffset && memcmp(exist.Data, memBuf, memOffset) == 0) write = false;
@@ -410,8 +420,14 @@ static bool GenerateUnityFiles(const UnityConfig* ucfg)
for (int k = 0; absPath[k]; k++) { if (absPath[k] == '\\') absPath[k] = '/'; }
int memOffset = sprintf_s(memBuf, (1024 * 1024), "#include \"%s\"\n", absPath);
snprintf(staleUnityPath, sizeof(staleUnityPath), "%s\\%s_Hot%d%s", ucfg->OutputDir, ucfg->Prefix, i, staleExt);
if (FileExists(staleUnityPath)) {
DeleteFileA(staleUnityPath);
anyChanged = true;
}
snprintf(currentUnityPath, sizeof(currentUnityPath), "%s\\%s_Hot%d.cpp", ucfg->OutputDir, ucfg->Prefix, i);
snprintf(currentUnityPath, sizeof(currentUnityPath), "%s\\%s_Hot%d%s", ucfg->OutputDir, ucfg->Prefix, i, unityExt);
FileContent exist = ReadEntireFile(currentUnityPath);
bool write = true;
if (exist.Data && exist.Size == memOffset && memcmp(exist.Data, memBuf, memOffset) == 0) write = false;
@@ -438,7 +454,12 @@ static bool GenerateUnityFiles(const UnityConfig* ucfg)
// Cleanup unused cold buckets
for (int b = numBuckets; b < numBuckets + 100; b++)
{
snprintf(currentUnityPath, sizeof(currentUnityPath), "%s\\%s%d.cpp", ucfg->OutputDir, ucfg->Prefix, b + 1);
snprintf(staleUnityPath, sizeof(staleUnityPath), "%s\\%s%d%s", ucfg->OutputDir, ucfg->Prefix, b + 1, staleExt);
if (FileExists(staleUnityPath)) {
DeleteFileA(staleUnityPath);
anyChanged = true;
}
snprintf(currentUnityPath, sizeof(currentUnityPath), "%s\\%s%d%s", ucfg->OutputDir, ucfg->Prefix, b + 1, unityExt);
if (FileExists(currentUnityPath)) {
DeleteFileA(currentUnityPath);
anyChanged = true;
@@ -450,10 +471,15 @@ static bool GenerateUnityFiles(const UnityConfig* ucfg)
// Cleanup unused hot files
for (int i = 0; i < srcFiles->Count + 1000; i++)
{
snprintf(staleUnityPath, sizeof(staleUnityPath), "%s\\%s_Hot%d%s", ucfg->OutputDir, ucfg->Prefix, i, staleExt);
if (FileExists(staleUnityPath)) {
DeleteFileA(staleUnityPath);
anyChanged = true;
}
bool shouldExist = (i < srcFiles->Count && isHot[i]);
if (!shouldExist)
{
snprintf(currentUnityPath, sizeof(currentUnityPath), "%s\\%s_Hot%d.cpp", ucfg->OutputDir, ucfg->Prefix, i);
snprintf(currentUnityPath, sizeof(currentUnityPath), "%s\\%s_Hot%d%s", ucfg->OutputDir, ucfg->Prefix, i, unityExt);
if (FileExists(currentUnityPath)) {
DeleteFileA(currentUnityPath);
anyChanged = true;
@@ -1770,6 +1796,8 @@ static void generate_compile_commands(
}
is_first_entry = false;
const char* lang_flag = EndsWithNoCase(full_path, ".c") ? "/clang:-std=c99" : "/std:c++20";
offset += sprintf_s(json_buf + offset, buffer_size - offset,
" {\n"
" \"directory\": \"%s\",\n"
@@ -1778,10 +1806,10 @@ static void generate_compile_commands(
" \"clang-cl.exe\",\n"
" \"--driver-mode=cl\",\n"
" \"/nologo\",\n"
" \"/std:c++20\",\n"
" \"%s\",\n"
" \"/W4\",\n"
" \"/utf-8\",\n",
cwd, full_path);
cwd, full_path, lang_flag);
for (int d = 0; d < def_common_count; d++)
{