aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt1
-rwxr-xr-xscripts/add_version_headers17
-rw-r--r--yage/core/camera2d.cpp1
-rw-r--r--yage/core/camera2d.h4
-rw-r--r--yage/core/imageloader.cpp4
-rw-r--r--yage/core/imageloader.h4
-rw-r--r--yage/core/inputmanager.h2
-rw-r--r--yage/core/logger.cpp2
-rw-r--r--yage/core/logger.h3
-rw-r--r--yage/core/logsink.h3
-rw-r--r--yage/core/spritesheet.cpp33
-rw-r--r--yage/core/spritesheet.h7
-rw-r--r--yage/math/math.h14
-rw-r--r--yage/yage.h1
14 files changed, 50 insertions, 46 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 957224a5..8fd23f7e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -55,4 +55,5 @@ if(UNIT_TESTS)
make_test(syncqueuetest 1)
make_test(activetest 1)
make_test(structtest ${SIMULATION_RUNS})
+ make_test(defaultfiletest ${SIMULATION_RUNS})
endif()
diff --git a/scripts/add_version_headers b/scripts/add_version_headers
index c4fd3ffc..c3b26566 100755
--- a/scripts/add_version_headers
+++ b/scripts/add_version_headers
@@ -24,10 +24,12 @@ import os
import re
import sys
+from subprocess import call
-header = """/* ---------------------------------------------------------------\
--------------
- * {0}
+
+header = """/** ---------------------------------------------------------------\
+------------
+ * @file: {0}
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
@@ -38,7 +40,7 @@ header = """/* ---------------------------------------------------------------\
lic_regex = re.compile(
- "\/\* -+\n \* ([a-z]+\.(?:cpp|h)|\{0\})\n(?: \*[ a-zA-Z0-9_.,\-()<>@]*\n)+ \* -+\n \*/", re.MULTILINE)
+ "\/(?:\*|\*\*) -+\n \* ((?:@file: )?[a-z]+\.(?:cpp|h)|\{0\})\n(?: \*[ a-zA-Z0-9_.,\-()<>@]*\n)+ \* -+\n \*/", re.MULTILINE)
class HeaderUpdate(object):
@@ -102,12 +104,19 @@ class HeaderUpdate(object):
not re.match(self.exclude_re, fileName)):
fileOperation(os.path.join(subdir, fileName))
+ def runClangFormat(self):
+ def clangFormatFileOpration(filePath):
+ call(["clang-format", "-i", filePath])
+
+ self._traverseDir(self.starting_dir, clangFormatFileOpration)
+
def main(argv):
update = HeaderUpdate(exclude_re="^picopng\.cpp",
match_dir=".*yage|.*tests",
exclude_dir=".*lib.*|.*build.*")
update.updateHeader()
+ update.runClangFormat()
if __name__ == "__main__":
diff --git a/yage/core/camera2d.cpp b/yage/core/camera2d.cpp
index d5640c3f..a2d40a78 100644
--- a/yage/core/camera2d.cpp
+++ b/yage/core/camera2d.cpp
@@ -7,6 +7,7 @@
*/
#include "camera2d.h"
+#include "glslprogram.h"
#include <glad/glad.h>
diff --git a/yage/core/camera2d.h b/yage/core/camera2d.h
index 333f907d..5d2fc8a2 100644
--- a/yage/core/camera2d.h
+++ b/yage/core/camera2d.h
@@ -17,14 +17,14 @@
#ifndef YAGE_CAMERA2D_H
#define YAGE_CAMERA2D_H
-#include "glslprogram.h"
-
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
namespace yage
{
+class GlslProgram;
+
class Camera2D
{
private:
diff --git a/yage/core/imageloader.cpp b/yage/core/imageloader.cpp
index ae67a94a..45424799 100644
--- a/yage/core/imageloader.cpp
+++ b/yage/core/imageloader.cpp
@@ -7,11 +7,9 @@
*/
#include "imageloader.h"
+#include "texture.h"
-#ifndef UNIT_TESTS
#include <glad/glad.h>
-#endif
-
#include <yage/core/iomanager.h>
#include <yage/core/picopng.h>
diff --git a/yage/core/imageloader.h b/yage/core/imageloader.h
index ab9f9e4d..ca68bd58 100644
--- a/yage/core/imageloader.h
+++ b/yage/core/imageloader.h
@@ -9,13 +9,13 @@
#ifndef IMAGE_LOADER_H
#define IMAGE_LOADER_H
-#include "texture.h"
-
#include <string>
namespace yage
{
+class Texture;
+
class ImageLoader
{
public:
diff --git a/yage/core/inputmanager.h b/yage/core/inputmanager.h
index 9fabd997..4b74ed90 100644
--- a/yage/core/inputmanager.h
+++ b/yage/core/inputmanager.h
@@ -24,5 +24,7 @@ public:
void keyReleased(unsigned key);
bool isKeyPressed(unsigned key) const;
};
+
} // namespace yage
+
#endif
diff --git a/yage/core/logger.cpp b/yage/core/logger.cpp
index 7a58efb6..355de5bc 100644
--- a/yage/core/logger.cpp
+++ b/yage/core/logger.cpp
@@ -10,6 +10,8 @@
#include "logmessage.h"
#include "logsink.h"
+#include <yage/util/active.h>
+
#include <algorithm>
#include <iostream>
#include <string>
diff --git a/yage/core/logger.h b/yage/core/logger.h
index 76f38641..44c35227 100644
--- a/yage/core/logger.h
+++ b/yage/core/logger.h
@@ -9,8 +9,6 @@
#ifndef YAGE_CORE_LOGGER_H
#define YAGE_CORE_LOGGER_H
-#include <yage/util/active.h>
-
#include <memory>
#include <string>
#include <vector>
@@ -18,6 +16,7 @@
namespace yage
{
+class Active;
class LogMessage;
class LogSink;
diff --git a/yage/core/logsink.h b/yage/core/logsink.h
index 064abc63..b597fc24 100644
--- a/yage/core/logsink.h
+++ b/yage/core/logsink.h
@@ -6,9 +6,12 @@
* ----------------------------------------------------------------------------
*/
+/// @file
+
#ifndef YAGE_CORE_LOGSINK_H
#define YAGE_CORE_LOGSINK_H
+/// @todo remove the include to make compilation faster
#include "logmessage.h"
#include <memory>
diff --git a/yage/core/spritesheet.cpp b/yage/core/spritesheet.cpp
index e18d7fe8..f61b668a 100644
--- a/yage/core/spritesheet.cpp
+++ b/yage/core/spritesheet.cpp
@@ -6,27 +6,26 @@
* ----------------------------------------------------------------------------
*/
-/** @file
- */
+/// @file
#include "spritesheet.h"
+#include <rapidjson/document.h>
+#include <yage/core/imageloader.h>
+
#include <cassert>
#include <fstream>
#include <sstream>
#include <stdexcept>
-#include <rapidjson/document.h>
-#include <yage/core/imageloader.h>
-
-using namespace std;
-using namespace rapidjson;
-using namespace yage::details;
+using rapidjson::Document;
+using yage::details::Coordinate;
+using yage::details::SpriteMap;
namespace yage
{
-SpriteSheet::SpriteSheet(string pngFileName, string jsonFileName)
+SpriteSheet::SpriteSheet(std::string pngFileName, std::string jsonFileName)
{
int jsonWidth, jsonHeight;
fileLocations_ =
@@ -34,23 +33,23 @@ SpriteSheet::SpriteSheet(string pngFileName, string jsonFileName)
texture_ = ImageLoader::loadPng(pngFileName);
if (texture_.width != jsonWidth)
- throw runtime_error("JSON width does not match texture width");
+ throw std::runtime_error("JSON width does not match texture width");
if (texture_.height != jsonHeight)
- throw runtime_error("JSON height does not match texture height");
+ throw std::runtime_error("JSON height does not match texture height");
}
-string SpriteSheet::fileContent(string jsonFileName) const
+std::string SpriteSheet::fileContent(std::string jsonFileName) const
{
- ifstream inputFile(jsonFileName);
+ std::ifstream inputFile(jsonFileName);
- stringstream stream;
+ std::stringstream stream;
stream << inputFile.rdbuf();
return stream.str();
}
SpriteMap SpriteSheet::parseJson(int &width, int &height,
- string jsonContent) const
+ std::string jsonContent) const
{
SpriteMap spriteMap;
Document jsonAtlas;
@@ -62,7 +61,7 @@ SpriteMap SpriteSheet::parseJson(int &width, int &height,
for (auto &texture : jsonAtlas["sprites"].GetObject()) {
Coordinate coord;
for (auto &value : texture.value.GetObject()) {
- string keyName{value.value.GetString()};
+ std::string keyName{value.value.GetString()};
int keyValue{value.value.GetInt()};
if (keyName == "x") {
coord.x = keyValue;
@@ -73,7 +72,7 @@ SpriteMap SpriteSheet::parseJson(int &width, int &height,
} else if (keyName == "height") {
coord.height = keyValue;
} else {
- throw runtime_error("JSON key incorrect: " + keyName);
+ throw std::runtime_error("JSON key incorrect: " + keyName);
}
}
spriteMap[texture.name.GetString()] = coord;
diff --git a/yage/core/spritesheet.h b/yage/core/spritesheet.h
index 2ead0ba1..6ae8d266 100644
--- a/yage/core/spritesheet.h
+++ b/yage/core/spritesheet.h
@@ -6,12 +6,15 @@
* ----------------------------------------------------------------------------
*/
-/** @file
- */
+/// @file
#ifndef YAGE_SPRITESHEET_H
#define YAGE_SPRITESHEET_H
+/** @todo think of removing this, by, for example, using a pointer
+ * This could be more efficient when copying the texture out of the
+ * spritesheet.
+ */
#include "texture.h"
#include <rapidjson/reader.h>
diff --git a/yage/math/math.h b/yage/math/math.h
deleted file mode 100644
index 87f1af6c..00000000
--- a/yage/math/math.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/* ----------------------------------------------------------------------------
- * math.h
- *
- * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
- * MIT License, see LICENSE file for more details.
- * ----------------------------------------------------------------------------
- */
-
-#ifndef YAGE_MATH_H
-#define YAGE_MATH_H
-
-#include "matrix.h"
-
-#endif
diff --git a/yage/yage.h b/yage/yage.h
index 630bc1be..f15b9ad0 100644
--- a/yage/yage.h
+++ b/yage/yage.h
@@ -15,6 +15,7 @@
#define YAGE_YAGE_H
#include "core/camera2d.h"
+#include "core/defaultfile.h"
#include "core/glslprogram.h"
#include "core/imageloader.h"
#include "core/inputmanager.h"