Skip to content

Commit

Permalink
Format pass
Browse files Browse the repository at this point in the history
  • Loading branch information
dashodanger committed Jun 9, 2024
1 parent 615269b commit f2f3cba
Show file tree
Hide file tree
Showing 96 changed files with 39,726 additions and 31,719 deletions.
29 changes: 29 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
BasedOnStyle: Microsoft
AlignConsecutiveAssignments: Consecutive
AlignConsecutiveBitFields: Consecutive
AlignConsecutiveDeclarations: Consecutive
AlignConsecutiveMacros: Consecutive
AlignTrailingComments:
Kind: Always
OverEmptyLines: 2
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^<ext/.*\.h>'
Priority: 2
SortPriority: 0
CaseSensitive: false
- Regex: '^<.*\.h>'
Priority: 1
SortPriority: 0
CaseSensitive: false
- Regex: '^<.*'
Priority: 2
SortPriority: 0
CaseSensitive: false
- Regex: '.*'
Priority: 3
SortPriority: 0
CaseSensitive: false
IncludeIsMainRegex: '([-_](test|unittest))?$'
IncludeIsMainSourceRegex: ''
SortIncludes: CaseSensitive
34 changes: 19 additions & 15 deletions libraries/filename_formatter/ff.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,32 @@
#define FILENAME_FORMATTER_FF_H

#ifdef __cplusplus
extern "C" {
extern "C"
{
#endif

#include <stdbool.h>

enum { TOK_EOF = 1 };
enum
{
TOK_EOF = 1
};

extern void year(void);
extern void month(void);
extern void day(void);
extern void hour(void);
extern void minute(void);
extern void second(void);
extern void game(void);
extern void port(void);
extern void theme(void);
extern void version(void);
extern void count(void);
extern void raw_append(const char *string);
extern void year(void);
extern void month(void);
extern void day(void);
extern void hour(void);
extern void minute(void);
extern void second(void);
extern void game(void);
extern void port(void);
extern void theme(void);
extern void version(void);
extern void count(void);
extern void raw_append(const char *string);

#ifdef __cplusplus
}
#endif

#endif // FILENAME_FORMATTER_FF_H
#endif // FILENAME_FORMATTER_FF_H
94 changes: 66 additions & 28 deletions libraries/filename_formatter/ff_main.cpp
Original file line number Diff line number Diff line change
@@ -1,64 +1,102 @@
#include "ff.h"
#include <chrono>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <string>
#include <ctime>

extern "C" {
#include "ff.h"

extern "C"
{
#include "lex.yy.h"
}

std::time_t now_;
std::tm now;
std::tm now;
std::string gameValue;
std::string portValue;
std::string themeValue;
std::string countValue;
std::string versionValue;
std::string result;

void year() { result.append(std::to_string(now.tm_year + 1900)); }
void year()
{
result.append(std::to_string(now.tm_year + 1900));
}

void month() { result.append(std::to_string(now.tm_mon + 1)); }
void month()
{
result.append(std::to_string(now.tm_mon + 1));
}

void day() { result.append(std::to_string(now.tm_mday)); }
void day()
{
result.append(std::to_string(now.tm_mday));
}

void hour() { result.append(std::to_string(now.tm_hour)); }
void hour()
{
result.append(std::to_string(now.tm_hour));
}

void minute() { result.append(std::to_string(now.tm_min)); }
void minute()
{
result.append(std::to_string(now.tm_min));
}

void second() { result.append(std::to_string(now.tm_sec)); }
void second()
{
result.append(std::to_string(now.tm_sec));
}

void game() { result.append(gameValue); }
void game()
{
result.append(gameValue);
}

void port() { result.append(portValue); }
void port()
{
result.append(portValue);
}

void theme() { result.append(themeValue); }
void theme()
{
result.append(themeValue);
}

void count() { result.append(countValue); }
void count()
{
result.append(countValue);
}

void version() { result.append(versionValue); }
void version()
{
result.append(versionValue);
}

void raw_append(const char *string) { result.append(string); }
void raw_append(const char *string)
{
result.append(string);
}

const char *ff_main(const char *levelcount, const char *game,
const char *port, const char *theme, const char *version,
const char *format) {
gameValue = game;
portValue = port;
themeValue = theme;
countValue = levelcount;
versionValue = version;
const char *ff_main(const char *levelcount, const char *game, const char *port, const char *theme, const char *version,
const char *format)
{
gameValue = game;
portValue = port;
themeValue = theme;
countValue = levelcount;
versionValue = version;
std::string input = format;
result.clear();
now_ =
std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
now = *std::localtime(&now_);
now_ = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
now = *std::localtime(&now_);

auto buffer_state = yy_scan_bytes(input.c_str(), input.size());
yy_switch_to_buffer(buffer_state);
while (yylex() != TOK_EOF) {
while (yylex() != TOK_EOF)
{
}

return result.c_str();
Expand Down
3 changes: 1 addition & 2 deletions libraries/filename_formatter/ff_main.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
const char *ff_main(const char *levelcount, const char *game,
const char *port, const char *theme, const char *version,
const char *ff_main(const char *levelcount, const char *game, const char *port, const char *theme, const char *version,
const char *format);
Loading

0 comments on commit f2f3cba

Please sign in to comment.