Skip to content

Commit

Permalink
Merge pull request #82 from Moros1138/fix-autocomplete-over-zealousne…
Browse files Browse the repository at this point in the history
…ss-and-compiler-bug-involving-the-geometry-utility

Fix autocomplete over zealousness and compiler bug involving the geometry utility
  • Loading branch information
Moros1138 authored Jun 4, 2024
2 parents 82b4113 + c7fe0f7 commit 893fde0
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 31 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
All notable changes to this project will be documented in this file. Each batch of changes is marked by the date it was published to the repository for deployment to the PGEtinker site.

It is a summary of changes that would be pertinent to the end user of the PGEtinker website. For a comprehensive history of changes made to the project, please refer to the repository's commit history.

## 2024-06-03

- Added Clangd Language server to the backend
Expand All @@ -12,6 +13,8 @@ It is a summary of changes that would be pertinent to the end user of the PGEtin
- Added An easy way to set a panel to have focus, required for an upcoming mobile update
- Added Loading screen
- Removed "show-console" hook to the emscripten template, no longer used
- Fixed Overzealous auto complete
- Fixed Linker error when the Geometry utility was included after the OLC_PGE_APPLICATION macro

## 2024-05-28

Expand Down
78 changes: 47 additions & 31 deletions pgetinker/Compiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,33 @@ class Compiler
private $compilerExitCode;

private $environmentVariables = [];

private $errors = [];

private $errors = [];

private $foundGeometryHeader = false;

private $html = "";

private $implementationMacros = [];

private $linkerCommand = [];

private $libraryMap = [
'OLC_PGE_APPLICATION' => 'olcPixelGameEngine.o',
'OLC_SOUNDWAVE_ENGINE' => 'olcSoundWaveEngine.o',
'OLC_PGEX_GRAPHICS2D' => 'olcPGEX_Graphics2D.o',
'OLC_PGEX_GRAPHICS3D' => 'olcPGEX_Graphics3D.o',
'OLC_PGEX_POPUPMENU' => 'olcPGEX_PopUpMenu.o',
'OLC_PGEX_QUICKGUI' => 'olcPGEX_QuickGUI.o',
'OLC_PGEX_RAYCASTWORLD' => 'olcPGEX_RayCastWorld.o',
'OLC_PGEX_SOUND' => 'olcPGEX_Sound.o',
'OLC_PGEX_SPLASHSCREEN' => 'olcPGEX_SplashScreen.o',
'OLC_PGEX_TRANSFORMEDVIEW' => 'olcPGEX_TransformedView.o',
'OLC_PGEX_WIREFRAME' => 'olcPGEX_Wireframe.o',
'MINIAUDIO_IMPLEMENTATION' => 'miniaudio.o',
'OLC_PGEX_MINIAUDIO' => 'olcPGEX_MiniAudio.o',
];

private $linkerExitCode;

private $linkerInputFiles = [];
Expand Down Expand Up @@ -171,25 +189,9 @@ private function processCodeDetectImplementationMacros($index)
if(!str_contains($this->code[$index], "define"))
return false;

$libraryMap = [
'OLC_PGE_APPLICATION' => 'olcPixelGameEngine.o',
'OLC_SOUNDWAVE_ENGINE' => 'olcSoundWaveEngine.o',
'OLC_PGEX_GRAPHICS2D' => 'olcPGEX_Graphics2D.o',
'OLC_PGEX_GRAPHICS3D' => 'olcPGEX_Graphics3D.o',
'OLC_PGEX_POPUPMENU' => 'olcPGEX_PopUpMenu.o',
'OLC_PGEX_QUICKGUI' => 'olcPGEX_QuickGUI.o',
'OLC_PGEX_RAYCASTWORLD' => 'olcPGEX_RayCastWorld.o',
'OLC_PGEX_SOUND' => 'olcPGEX_Sound.o',
'OLC_PGEX_SPLASHSCREEN' => 'olcPGEX_SplashScreen.o',
'OLC_PGEX_TRANSFORMEDVIEW' => 'olcPGEX_TransformedView.o',
'OLC_PGEX_WIREFRAME' => 'olcPGEX_Wireframe.o',
'MINIAUDIO_IMPLEMENTATION' => 'miniaudio.o',
'OLC_PGEX_MINIAUDIO' => 'olcPGEX_MiniAudio.o',
];

$foundImplementationMacro = false;

foreach($libraryMap as $macro => $objectFileName)
foreach($this->libraryMap as $macro => $objectFileName)
{
preg_match(
'/(.*)\s*#\s*define?\s+' . $macro . '(.*)/',
Expand All @@ -206,19 +208,11 @@ private function processCodeDetectImplementationMacros($index)
if(!empty(trim($match[1][0])) || !empty(trim($match[2][0])))
continue;

// blank the line
$this->code[$index] = "";
$this->implementationMacros[] = [
"macro" => $macro,
"lineIndex" => $index
];

if($macro == "OLC_PGE_APPLICATION" && $this->foundGeometryHeader)
{
$objectFileName = "olcPixelGameEngine_withGeometry.o";
$this->logger->info("Found the need for geometry utility support");
}

// indicate that we use this library
$this->linkerInputFiles[] = "./lib/{$objectFileName}";

$this->logger->info("Found implementation macro: {$macro}");
$foundImplementationMacro = true;
break;
}
Expand Down Expand Up @@ -390,6 +384,28 @@ public function processCode()
continue;
}


if(count($this->implementationMacros) != 0)
{
foreach($this->implementationMacros as $implementation)
{
if($implementation["macro"] == "OLC_PGE_APPLICATION")
{
Log::info("Made it here");
if($this->foundGeometryHeader)
{
$this->linkerInputFiles[] = "./lib/olcPixelGameEngine_withGeometry.o";
$this->code[$implementation["lineIndex"]] = "";
continue;
}
}

$this->linkerInputFiles[] = "./lib/" . $this->libraryMap[$implementation["macro"]];
$this->code[$implementation["lineIndex"]] = "";
continue;
}
}

$this->logger->info("finished processing code");

return (count($this->errors) == 0);
Expand Down
1 change: 1 addition & 0 deletions resources/js/lib/monacoConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const getUserConfiguration = (theme) =>
"editor.mouseWheelZoom": "on",
"editor.wordBasedSuggestions": "off",
"editor.quickSuggestionDelay": 500,
"editor.inlayHints.enabled": "off",
});
}

Expand Down

0 comments on commit 893fde0

Please sign in to comment.