Compare commits

...

2 Commits

Author SHA1 Message Date
c3316810f5 CMake fixes? 2025-02-11 01:19:20 -06:00
8cb1584a00 Cleaning? Still trying to do preproc work 2025-02-11 01:18:26 -06:00
5 changed files with 53 additions and 144 deletions

1
.gitignore vendored
View File

@ -1,4 +1,3 @@
*.lnk
build/
.vscode/
CMakeLists.txt

95
.vscode/settings.json vendored
View File

@ -1,95 +0,0 @@
{
"files.associations": {
"iostream": "cpp",
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"*.tcc": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"compare": "cpp",
"concepts": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"string": "cpp",
"unordered_map": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"fstream": "cpp",
"initializer_list": "cpp",
"iosfwd": "cpp",
"istream": "cpp",
"limits": "cpp",
"new": "cpp",
"numbers": "cpp",
"ostream": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"cinttypes": "cpp",
"typeinfo": "cpp",
"charconv": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"format": "cpp",
"ios": "cpp",
"locale": "cpp",
"mutex": "cpp",
"queue": "cpp",
"ranges": "cpp",
"ratio": "cpp",
"span": "cpp",
"stop_token": "cpp",
"thread": "cpp",
"xfacet": "cpp",
"xiosbase": "cpp",
"xlocale": "cpp",
"xlocbuf": "cpp",
"xlocinfo": "cpp",
"xlocmes": "cpp",
"xlocmon": "cpp",
"xlocnum": "cpp",
"xloctime": "cpp",
"xmemory": "cpp",
"xstring": "cpp",
"xtr1common": "cpp",
"xutility": "cpp",
"chrono": "cpp",
"condition_variable": "cpp",
"iomanip": "cpp",
"semaphore": "cpp",
"variant": "cpp",
"forward_list": "cpp",
"map": "cpp",
"xstddef": "cpp",
"xtree": "cpp"
},
"cmake.generator": "Ninja",
"cmake.configureSettings": {
"CMAKE_MAKE_PROGRAM": "C:/Users/naifa/Documents/Projects/ninja/ninja.exe",
"CMAKE_C_COMPILER": "path_to_mingw/bin/gcc.exe",
"CMAKE_CXX_COMPILER": "path_to_mingw/bin/g++.exe",
"CMAKE_EXPORT_COMPILE_COMMANDS": true
},
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools"
}

28
.vscode/tasks.json vendored
View File

@ -1,28 +0,0 @@
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++.exe build active file",
"command": "C:\\msys64\\ucrt64\\bin\\g++.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}

View File

@ -47,6 +47,14 @@ protected:
std::string formatString(const std::string&, const char* shad=nullptr, const std::string& file="", int line=-1);
};
class ShaderUnit {
std::string rawSource;
std::string preprocSource;
std::map<std::string, std::string> defines;
std::map<uint8_t, ShaderUnit*> includes;
uint8_t vMajor=0, vMinor=0;
};
class ShaderPreprocessor {
public:
typedef ShaderPreprocessorError::Codes Codes;

View File

@ -359,36 +359,61 @@ std::stringstream ShaderPreprocessor::process(std::stringstream& code) const {
std::string line;
const std::vector<std::string> preprocKeys = {
"#include",
"//",
"/*",
"*/"
"#define",
"#ifdef",
"#ifndef",
"#endif"
};
const size_t keysListSize = preprocKeys.size();
enum Context : uint8_t {
Code,
LineComment,
BlockComment
BlockComment,
FalseBranch
};
Context currcontext = Code;
bool blockcomment = false;
const size_t keysListSize = preprocKeys.size();
std::vector<size_t> keysIdx(keysListSize);
size_t linecom, blockstart, blockend;
// Use linked list to count char len of each line
while(std::getline(code, line)) {
if (!blockcomment) {
for (int i = 0; i < keysListSize; ++i) {
keysIdx[i] = line.find(preprocKeys[i]);
switch (currcontext) {
case Code:
if (linecom != std::string::npos) {
size_t preprocIdx;
for (int i = 0; i < keysListSize; ++i) {
preprocIdx = line.find(preprocKeys[i]);
keysIdx[i] = (preprocIdx < linecom) ? preprocIdx: std::string::npos;
}
} else if (blockstart != std::string::npos) {
size_t preprocIdx;
for (int i = 0; i < keysListSize; ++i) {
preprocIdx = line.find(preprocKeys[i]);
keysIdx[i] = (preprocIdx < blockstart) ? preprocIdx: std::string::npos;
}
} else {
for (int i = 0; i < keysListSize; ++i) {
keysIdx[i] = line.find(preprocKeys[i]);
}
}
} else if (keysIdx[2] == std::string::npos) {
if (keysIdx)
break;
case BlockComment:
if (blockend == std::string::npos) {
ret << line;
} else {
size_t newpos = code.tellg() - line.size() + blockend;
line.resize(blockend);
ret << line;
code.seekg(newpos);
continue;
}
break;
case FalseBranch:
ret << line;
} else {
}
}
if (keysIdx[0] != std::string::npos) {
if (keysIdx[1] != std::string::npos) {
if ( (keysIdx[0] > keysIdx[1]) ) {
}
break;
default:
ret << line;
break;
}
}
}