From fd4c31a00e232ac9e494d4cc00462b58af61198c Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Sat, 15 Sep 2012 21:14:04 +0200 Subject: [PATCH] generate header when output file ends with 'h' --- src/main.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 00fea98..edb0f1c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -36,6 +36,7 @@ #include "sdl/InitSDL.h" #include +#include #include #include #include @@ -138,12 +139,23 @@ int main(int argc, char **argv) { switch (args.DetectRunLevel()) { case Arguments::COMPILE: { - std::ofstream testOut(args.OutfilePath()); - Compiler(intp).Write(testOut); + int length(std::strlen(args.OutfilePath())); + switch (args.OutfilePath()[length - 1]) { + case 'h': { + std::ofstream outstream(args.OutfilePath()); + source.WriteHeader(outstream); + break; + } + default: + case 'o': { + std::ofstream outstream(args.OutfilePath()); + Compiler(intp).Write(outstream); + break; + } + } return 0; } - case Arguments::DUMP: - { + case Arguments::DUMP: { std::cout << source << std::endl; return 0; } -- 2.39.2