Skip to content

Commit

Permalink
Add runtime namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
albin-johansson committed Oct 10, 2024
1 parent 490d5c2 commit d5f29c5
Show file tree
Hide file tree
Showing 91 changed files with 298 additions and 254 deletions.
3 changes: 2 additions & 1 deletion source/base/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ target_sources(tactile-base
"inc/tactile/base/render/renderer_options.hpp"
"inc/tactile/base/render/texture.hpp"
"inc/tactile/base/render/window.hpp"
"inc/tactile/base/runtime/plugin.hpp"
"inc/tactile/base/runtime/runtime.hpp"
"inc/tactile/base/util/buffer.hpp"
"inc/tactile/base/util/chrono.hpp"
"inc/tactile/base/util/concepts.hpp"
Expand All @@ -61,5 +63,4 @@ target_sources(tactile-base
"inc/tactile/base/util/tile_matrix.hpp"
"inc/tactile/base/id.hpp"
"inc/tactile/base/prelude.hpp"
"inc/tactile/base/runtime.hpp"
)
2 changes: 0 additions & 2 deletions source/core/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ target_sources(tactile-core
"src/model/model.cpp"
"src/model/settings.cpp"
"src/numeric/random.cpp"
"src/platform/dynamic_library.cpp"
"src/platform/environment.cpp"
"src/platform/file_dialog.cpp"
"src/platform/filesystem.cpp"
Expand Down Expand Up @@ -203,7 +202,6 @@ target_sources(tactile-core
"inc/tactile/core/model/model.hpp"
"inc/tactile/core/model/settings.hpp"
"inc/tactile/core/numeric/random.hpp"
"inc/tactile/core/platform/dynamic_library.hpp"
"inc/tactile/core/platform/environment.hpp"
"inc/tactile/core/platform/file_dialog.hpp"
"inc/tactile/core/platform/filesystem.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#pragma once

#include "tactile/base/prelude.hpp"
#include "tactile/base/runtime.hpp"
#include "tactile/base/runtime/runtime.hpp"

namespace tactile::core {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include "tactile/base/io/save/save_format_id.hpp"
#include "tactile/base/prelude.hpp"
#include "tactile/base/runtime.hpp"
#include "tactile/base/runtime/runtime.hpp"

namespace tactile::core {

Expand Down
2 changes: 1 addition & 1 deletion source/core/lib/inc/tactile/core/tactile_app.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "tactile/base/prelude.hpp"
#include "tactile/base/render/renderer.hpp"
#include "tactile/base/render/window.hpp"
#include "tactile/base/runtime.hpp"
#include "tactile/base/runtime/runtime.hpp"
#include "tactile/core/event/component_event_handler.hpp"
#include "tactile/core/event/edit_event_handler.hpp"
#include "tactile/core/event/event_dispatcher.hpp"
Expand Down
2 changes: 1 addition & 1 deletion source/core/lib/src/event/file_event_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "tactile/core/event/file_event_handler.hpp"

#include "tactile/base/io/save/save_format.hpp"
#include "tactile/base/runtime.hpp"
#include "tactile/base/runtime/runtime.hpp"
#include "tactile/core/debug/validation.hpp"
#include "tactile/core/document/map_view_impl.hpp"
#include "tactile/core/event/event_dispatcher.hpp"
Expand Down
2 changes: 1 addition & 1 deletion source/core/lib/src/event/map_event_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include "tactile/base/io/save/save_format.hpp"
#include "tactile/base/numeric/vec_format.hpp"
#include "tactile/base/runtime.hpp"
#include "tactile/base/runtime/runtime.hpp"
#include "tactile/core/debug/validation.hpp"
#include "tactile/core/document/map_view_impl.hpp"
#include "tactile/core/event/dialog_events.hpp"
Expand Down
2 changes: 1 addition & 1 deletion source/core/lib/src/tactile_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include "tactile/base/render/renderer.hpp"
#include "tactile/base/render/window.hpp"
#include "tactile/base/runtime.hpp"
#include "tactile/base/runtime/runtime.hpp"
#include "tactile/core/debug/validation.hpp"
#include "tactile/core/event/view_events.hpp"
#include "tactile/core/log/logger.hpp"
Expand Down
16 changes: 8 additions & 8 deletions source/json_util/inc/tactile/json_util/json_io.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace tactile {
[[nodiscard]]
inline auto load_json(const std::filesystem::path& path) -> std::optional<nlohmann::json>
{
log(LogLevel::kDebug, "Parsing JSON: {}", path.string());
runtime::log(LogLevel::kDebug, "Parsing JSON: {}", path.string());

try {
std::ifstream stream {path, std::ios::in};
Expand All @@ -39,13 +39,13 @@ inline auto load_json(const std::filesystem::path& path) -> std::optional<nlohma
return json;
}

log(LogLevel::kError, "Could not open JSON file");
runtime::log(LogLevel::kError, "Could not open JSON file");
}
catch (const std::exception& error) {
log(LogLevel::kError, "JSON parse error: {}", error.what());
runtime::log(LogLevel::kError, "JSON parse error: {}", error.what());
}
catch (...) {
log(LogLevel::kError, "JSON parse error");
runtime::log(LogLevel::kError, "JSON parse error");
}

return std::nullopt;
Expand All @@ -66,7 +66,7 @@ inline auto save_json(const std::filesystem::path& path,
const nlohmann::json& json,
const int indentation) -> std::expected<void, ErrorCode>
{
log(LogLevel::kDebug, "Saving JSON: {}", path.string());
runtime::log(LogLevel::kDebug, "Saving JSON: {}", path.string());

try {
std::ofstream stream {path, std::ios::out | std::ios::trunc};
Expand All @@ -76,13 +76,13 @@ inline auto save_json(const std::filesystem::path& path,
return {};
}

log(LogLevel::kError, "Could not open JSON stream");
runtime::log(LogLevel::kError, "Could not open JSON stream");
}
catch (const std::exception& error) {
log(LogLevel::kError, "JSON save error: {}", error.what());
runtime::log(LogLevel::kError, "JSON save error: {}", error.what());
}
catch (...) {
log(LogLevel::kError, "JSON save error");
runtime::log(LogLevel::kError, "JSON save error");
}

return std::unexpected {ErrorCode::kBadFileStream};
Expand Down
2 changes: 1 addition & 1 deletion source/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@

auto main(const int argc, char* argv[]) -> int
{
return tactile::launch(argc, argv);
return tactile::runtime::launch(argc, argv);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
#include <memory> // unique_ptr

#include "tactile/base/prelude.hpp"
#include "tactile/base/runtime/plugin.hpp"
#include "tactile/godot_tscn/api.hpp"
#include "tactile/godot_tscn/godot_scene_format.hpp"
#include "tactile/runtime/plugin.hpp"

namespace tactile::godot_tscn {

Expand Down
10 changes: 5 additions & 5 deletions source/plugins/godot_tscn/lib/src/gd3_exporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ auto _emit_map_file(const Gd3Map& map, const SaveFormatWriteOptions& options)
-> std::expected<void, ErrorCode>
{
const auto path = options.base_dir / "map.tscn";
log(LogLevel::kDebug, "Generating map scene '{}'", path.string());
runtime::log(LogLevel::kDebug, "Generating map scene '{}'", path.string());

std::ofstream stream {path, std::ios::out | std::ios::trunc};
if (!stream.good()) {
Expand Down Expand Up @@ -481,10 +481,10 @@ auto _save_tileset_images(const Gd3Tileset& tileset, const SaveFormatWriteOption
for (const auto& tile_atlas : tileset.atlases) {
const auto dest = options.base_dir / tile_atlas.image_path.filename(); // FIXME

log(LogLevel::kDebug,
"Copying texture '{}' to '{}'",
tile_atlas.image_path.filename().string(),
dest.string());
runtime::log(LogLevel::kDebug,
"Copying texture '{}' to '{}'",
tile_atlas.image_path.filename().string(),
dest.string());

std::error_code copy_error {};
std::filesystem::copy(tile_atlas.image_path,
Expand Down
2 changes: 1 addition & 1 deletion source/plugins/godot_tscn/lib/src/godot_scene_format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ auto GodotSceneFormat::save_map(const IMapView& map,
return std::unexpected {ErrorCode::kNotSupported};
}
catch (const std::exception& error) {
log(LogLevel::kError, "Unexpected Godot export error: {}", error.what());
runtime::log(LogLevel::kError, "Unexpected Godot export error: {}", error.what());
}

return std::unexpected {ErrorCode::kUnknown};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

#include <new> // nothrow

#include "tactile/base/runtime.hpp"
#include "tactile/base/runtime/runtime.hpp"
#include "tactile/runtime/logging.hpp"

namespace tactile::godot_tscn {

void GodotSceneFormatPlugin::load(IRuntime* runtime)
{
log(LogLevel::kTrace, "Loading Godot TSCN format plugin");
runtime::log(LogLevel::kTrace, "Loading Godot TSCN format plugin");
m_runtime = runtime;

m_format = std::make_unique<GodotSceneFormat>();
Expand All @@ -20,7 +20,7 @@ void GodotSceneFormatPlugin::load(IRuntime* runtime)

void GodotSceneFormatPlugin::unload()
{
log(LogLevel::kTrace, "Unloading Godot TSCN format plugin");
runtime::log(LogLevel::kTrace, "Unloading Godot TSCN format plugin");

m_runtime->set_save_format(SaveFormatId::kGodotTscn, nullptr);
m_format.reset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#pragma once

#include "tactile/base/prelude.hpp"
#include "tactile/runtime/plugin.hpp"
#include "tactile/base/runtime/plugin.hpp"
#include "tactile/yaml/api.hpp"

namespace tactile {
Expand Down
4 changes: 2 additions & 2 deletions source/plugins/tactile_yaml/lib/src/yaml_format_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ namespace tactile {

void YamlFormatPlugin::load(IRuntime* runtime)
{
log(LogLevel::kTrace, "Loading Tactile YAML format plugin");
runtime::log(LogLevel::kTrace, "Loading Tactile YAML format plugin");
mRuntime = runtime;
}

void YamlFormatPlugin::unload()
{
log(LogLevel::kTrace, "Unloading Tactile YAML format plugin");
runtime::log(LogLevel::kTrace, "Unloading Tactile YAML format plugin");
mRuntime = nullptr;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

#include <nlohmann/json.hpp>

#include "tactile/base/io/save/ir.hpp"
#include "tactile/base/debug/error_code.hpp"
#include "tactile/base/io/save/ir.hpp"
#include "tactile/base/prelude.hpp"
#include "tactile/tiled_tmj/api.hpp"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

#include <nlohmann/json.hpp>

#include "tactile/base/io/save/ir.hpp"
#include "tactile/base/debug/error_code.hpp"
#include "tactile/base/io/save/ir.hpp"
#include "tactile/base/prelude.hpp"
#include "tactile/tiled_tmj/api.hpp"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <memory> // unique_ptr

#include "tactile/base/prelude.hpp"
#include "tactile/runtime/plugin.hpp"
#include "tactile/base/runtime/plugin.hpp"
#include "tactile/tiled_tmj/api.hpp"
#include "tactile/tiled_tmj/tmj_save_format.hpp"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ auto parse_type(const std::string_view type) -> std::expected<AttributeType, Err
return AttributeType::kObject;
}

log(LogLevel::kError, "Invalid TMJ property type: {}", type);
runtime::log(LogLevel::kError, "Invalid TMJ property type: {}", type);
return std::unexpected {ErrorCode::kParseError};
}

Expand All @@ -63,7 +63,7 @@ auto parse_value(const nlohmann::json& value_json, const AttributeType type)

const auto length = value->size();
if (length != 0 && length != 7 && length != 9) {
log(LogLevel::kError, "Invalid TMJ property color length: {}", length);
runtime::log(LogLevel::kError, "Invalid TMJ property color length: {}", length);
return std::unexpected {ErrorCode::kParseError};
}

Expand All @@ -74,7 +74,7 @@ auto parse_value(const nlohmann::json& value_json, const AttributeType type)
attribute = Attribute {*color};
}
else {
log(LogLevel::kError, "Invalid color property value: {}", *value);
runtime::log(LogLevel::kError, "Invalid color property value: {}", *value);
return std::unexpected {ErrorCode::kParseError};
}
}
Expand Down
4 changes: 2 additions & 2 deletions source/plugins/tiled_tmj/lib/src/tmj_format_layer_emitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "tactile/base/io/compress/compressor.hpp"
#include "tactile/base/io/tile_io.hpp"
#include "tactile/base/numeric/saturate_cast.hpp"
#include "tactile/base/runtime.hpp"
#include "tactile/base/runtime/runtime.hpp"
#include "tactile/runtime/logging.hpp"
#include "tactile/tiled_tmj/tmj_format_meta_emitter.hpp"
#include "tactile/tiled_tmj/tmj_format_object_emitter.hpp"
Expand Down Expand Up @@ -52,7 +52,7 @@ auto emit_tile_layer(const IRuntime& runtime,
if (tile_compression.has_value()) {
const auto* compression_format = runtime.get_compression_format(*tile_compression);
if (!compression_format) {
log(LogLevel::kError, "Could not find suitable compression format");
runtime::log(LogLevel::kError, "Could not find suitable compression format");
return std::unexpected {ErrorCode::kNotSupported};
}

Expand Down
20 changes: 10 additions & 10 deletions source/plugins/tiled_tmj/lib/src/tmj_format_layer_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "tactile/base/io/compress/compressor.hpp"
#include "tactile/base/io/tile_io.hpp"
#include "tactile/base/numeric/index_2d.hpp"
#include "tactile/base/runtime.hpp"
#include "tactile/base/runtime/runtime.hpp"
#include "tactile/runtime/logging.hpp"
#include "tactile/tiled_tmj/tmj_format_attribute_parser.hpp"
#include "tactile/tiled_tmj/tmj_format_object_parser.hpp"
Expand Down Expand Up @@ -64,9 +64,9 @@ auto parse_base64_tile_data(const IRuntime& runtime,

auto decompressed_bytes = compression_format->decompress(decoded_bytes);
if (!decompressed_bytes.has_value()) {
log(LogLevel::kError,
"Could not decompress tile data: {}",
to_string(decompressed_bytes.error()));
runtime::log(LogLevel::kError,
"Could not decompress tile data: {}",
to_string(decompressed_bytes.error()));
return std::unexpected {ErrorCode::kParseError};
}

Expand Down Expand Up @@ -95,10 +95,10 @@ auto parse_csv_tile_data(const nlohmann::json& data_json, ir::Layer& layer)
const auto expected_tile_count = layer.extent.rows * layer.extent.cols;

if (std::cmp_not_equal(real_tile_count, expected_tile_count)) {
log(LogLevel::kError,
"Bad tile layer tile count, expected {} but got {}",
expected_tile_count,
real_tile_count);
runtime::log(LogLevel::kError,
"Bad tile layer tile count, expected {} but got {}",
expected_tile_count,
real_tile_count);
return std::unexpected {ErrorCode::kParseError};
}

Expand Down Expand Up @@ -149,7 +149,7 @@ auto parse_tile_layer(const IRuntime& runtime,
compression = CompressionFormat::kZstd;
}
else {
log(LogLevel::kError, "Invalid tile compression format: {}", compression_name);
runtime::log(LogLevel::kError, "Invalid tile compression format: {}", compression_name);
return std::unexpected {ErrorCode::kParseError};
}
}
Expand All @@ -175,7 +175,7 @@ auto parse_tile_layer(const IRuntime& runtime,
}
}
else {
log(LogLevel::kError, "Invalid tile layer encoding: {}", encoding);
runtime::log(LogLevel::kError, "Invalid tile layer encoding: {}", encoding);
return std::unexpected {ErrorCode::kParseError};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace tactile {
auto emit_tiled_tmj_map(const IMapView& map) -> nlohmann::json
{
if (map.component_count() > 0) {
log(LogLevel::kWarn, "Components are ignored in Tiled TMJ save files");
runtime::log(LogLevel::kWarn, "Components are ignored in Tiled TMJ save files");
}

const auto extent = map.get_extent();
Expand Down
Loading

0 comments on commit d5f29c5

Please sign in to comment.