Skip to content

Commit

Permalink
Using FWK_FATAL directly instead of command-line defined 'FATAL'
Browse files Browse the repository at this point in the history
  • Loading branch information
nadult committed Nov 26, 2023
1 parent 967c7f7 commit 6b8908e
Show file tree
Hide file tree
Showing 33 changed files with 60 additions and 59 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ all: lib tools tests

CFLAGS_linux = $(shell $(PKG_CONFIG) --cflags $(LIBS_shared)) -Umain
CFLAGS_mingw = $(shell $(PKG_CONFIG) --cflags $(LIBS_shared)) -Umain
CFLAGS = -Isrc/ -Iextern/imgui/ -DFATAL=FWK_FATAL -DDUMP=FWK_DUMP
CFLAGS = -Isrc/ -Iextern/imgui/
BUILD_DIR = $(FWK_BUILD_DIR)
PCH_SOURCE := src/fwk_pch.h

Expand Down
2 changes: 1 addition & 1 deletion include/fwk/sys/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace fwk {

// Either returns valid pointer or fails on FATAL
// Either returns valid pointer or fails on FWK_FATAL
// Default new[] and delete[] operators also use these functions.
void *allocate(size_t size);
void *allocate(size_t size, size_t alignment);
Expand Down
2 changes: 1 addition & 1 deletion include/fwk/vulkan/vulkan_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Error makeVkError(const char *file, int line, VkResult, const char *function_nam
return FWK_VK_ERROR(#func, result); \
}

// Calls given function with passed arguments, stops program with FATAL on error
// Calls given function with passed arguments, stops program with FWK_FATAL on error
#define FWK_VK_CALL(func, ...) \
{ \
auto result = func(__VA_ARGS__); \
Expand Down
4 changes: 2 additions & 2 deletions src/any.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ namespace detail {
}

void reportAnyError(TypeInfo requested, TypeInfo current) {
FATAL("Invalid value type in any: %s; requested: %s", current.name().c_str(),
requested.name().c_str());
FWK_FATAL("Invalid value type in any: %s; requested: %s", current.name().c_str(),
requested.name().c_str());
}

}
Expand Down
6 changes: 3 additions & 3 deletions src/audio/al_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const char *errorToString(int id) {
void testError(const char *message) {
int last_error = alGetError();
if(last_error != AL_NO_ERROR)
FATAL("%s. %s", message, errorToString(last_error));
FWK_FATAL("%s. %s", message, errorToString(last_error));
}

void uploadToBuffer(const Sound &sound, unsigned buffer_id) {
Expand Down Expand Up @@ -68,9 +68,9 @@ struct AlDevice::Impl {
: device(nullptr), context(nullptr), sources(max_sources, 0), free_sources(max_sources, 0),
num_free_sources(0), last_time(0.0) {
if(!(device = alcOpenDevice(0)))
FATAL("Error in alcOpenDevice");
FWK_FATAL("Error in alcOpenDevice");
if(!(context = alcCreateContext(device, 0)))
FATAL("Error in alcCreateContext");
FWK_FATAL("Error in alcCreateContext");
alcMakeContextCurrent(context);

alGetError();
Expand Down
4 changes: 2 additions & 2 deletions src/audio/ogg_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct OggStream::Impl {
Impl(ZStr file_name) {
memset(&vorbis_file, 0, sizeof(vorbis_file));
if(ov_fopen(file_name.c_str(), &vorbis_file) != 0)
FATAL("Error while opening ogg stream: %s\n", file_name.c_str());
FWK_FATAL("Error while opening ogg stream: %s\n", file_name.c_str());
}
~Impl() { ov_clear(&vorbis_file); }

Expand Down Expand Up @@ -41,7 +41,7 @@ Sound OggStream::makeSound() const {
int bit_stream = 0;
int ret = ov_read(vf, buffer, sizeof(buffer), 0, 2, 1, &bit_stream);
if(ret < 0)
FATAL("Error while reading from ogg stream: %s", m_file_name.c_str());
FWK_FATAL("Error while reading from ogg stream: %s", m_file_name.c_str());
if(!ret)
break;
data.insert(end(data), buffer, buffer + ret);
Expand Down
6 changes: 3 additions & 3 deletions src/format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ void TextFormatter::append_(const char *format_str, int arg_count, const Func *f
if(isOneOf(funcs[n], opt_funcs))
num_format_args++;
if(num_percent != arg_count - num_format_args)
FATAL("Invalid nr of arguments passed: %d, expected: %d\nFormat string: \"%s\"",
arg_count - num_format_args, num_percent, format_str);
FWK_FATAL("Invalid nr of arguments passed: %d, expected: %d\nFormat string: \"%s\"",
arg_count - num_format_args, num_percent, format_str);
#endif

for(int n = 0; n < arg_count; n++) {
Expand Down Expand Up @@ -159,7 +159,7 @@ void TextFormatter::stdFormat(const char *format, ...) {
va_end(ap);

if(ret < 0)
FATAL("Error in vsnprintf(\"%s\"): errno: %s(%d)", format, strerror(errno), errno);
FWK_FATAL("Error in vsnprintf(\"%s\"): errno: %s(%d)", format, strerror(errno), errno);

int new_offset = m_offset + ret;
if(new_offset + 1 <= m_data.size()) {
Expand Down
2 changes: 1 addition & 1 deletion src/geom/delaunay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ vector<VertexIdPair> cdtFilterSide(const GeomGraph<int2> &igraph, CSpan<VertexId
//DASSERT(igraph.isPlanar()); // TODO: make it work
PERF_SCOPE();

FATAL("test me");
FWK_FATAL("test me");
GeomGraph<int2> temp;
for(auto vert : igraph.verts())
temp.addVertexAt(vert, igraph(vert));
Expand Down
6 changes: 3 additions & 3 deletions src/geom/geom_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ GeomGraph<T>::GeomGraph(const Graph &graph, PodVector<Point> points, PointMap po
}

if(graph.numTris())
FATAL("handle me please");
FWK_FATAL("handle me please");
}

template <class T> GeomGraph<T>::GeomGraph(CSpan<Triangle> tris) {
Expand Down Expand Up @@ -221,7 +221,7 @@ template <class T> int GeomGraph<T>::compare(const GeomGraph &rhs) const {
// TODO: test it
if(auto cmp = Graph::compare(rhs))
return cmp;
FATAL("writeme");
FWK_FATAL("writeme");
//if(auto cmp = m_points.compare(rhs.m_points))
// return cmp;
return 0;
Expand Down Expand Up @@ -355,7 +355,7 @@ template <class T> vector<EdgeId> GeomGraph<T>::findIntersectors() const {
vector<EdgeId> out;

if constexpr(dim<T> == 3) {
FATAL("write me");
FWK_FATAL("write me");
}

auto grid = makeGrid();
Expand Down
4 changes: 2 additions & 2 deletions src/geom/graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ Graph Graph::reversed() const {
Graph out;

if(numTris())
FATAL("check me");
FWK_FATAL("check me");

out.reserveEdges(edgesSpread());
out.reserveVerts(vertsSpread());
Expand Down Expand Up @@ -583,7 +583,7 @@ int Graph::compare(const Graph &rhs) const {
if(int cmp = m_tris.compare(rhs.m_tris))
return cmp;

FATAL("writeme");
FWK_FATAL("writeme");
return 0;
}

Expand Down
4 changes: 2 additions & 2 deletions src/geom/voronoi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ CellId Voronoi::cellId(EdgeId id) const {

vector<EdgeId> Voronoi::arcSegments(EdgeId edge) const {
vector<EdgeId> out;
FATAL("write me");
FWK_FATAL("write me");
return out;
}

vector<EdgeId> Voronoi::cellArcs(CellId) const {
vector<EdgeId> out;
FATAL("write me");
FWK_FATAL("write me");
return out;
}

Expand Down
2 changes: 1 addition & 1 deletion src/gfx/animated_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ vector<SimpleDrawCall> AnimatedModel::genDrawCalls(VulkanDevice &device,
const SimpleMaterialSet &materials,
const Matrix4 &matrix) const {
vector<SimpleDrawCall> out;
FATAL("writeme");
FWK_FATAL("writeme");

/*out.reserve(m_meshes.size());
for(auto &mesh_data : m_meshes) {
Expand Down
2 changes: 1 addition & 1 deletion src/gfx/investigate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void investigateOnFail(const Expected<void> &expected) {
return investigate(wrapper);
} else if(const VisFunc3 *stored_func = val) {
auto wrapper = [&](Canvas3D &canvas, double2 mouse_pos) -> string {
FATAL("fixme");
FWK_FATAL("fixme");
//auto result = (*stored_func)(canvas, mouse_pos);
//return format("%\n%", result, expected.error());
return "";
Expand Down
6 changes: 3 additions & 3 deletions src/gfx/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ vector<ColoredTriangle> Mesh::coloredTris(CSpan<IColor> colors) const {
vector<Mesh> Mesh::split(int max_vertices) const {
vector<Mesh> out;
if(!hasIndices())
FATAL("Write me, please");
FWK_FATAL("Write me, please");

for(int n = 0; n < m_indices.size(); n++) {
const auto &sub_indices = m_indices[n];
Expand All @@ -139,7 +139,7 @@ Mesh Mesh::merge(vector<Mesh> meshes) {
// TODO: Merging skinned meshes
for(const auto &mesh : meshes) {
if(!mesh.hasIndices())
FATAL("Write me");
FWK_FATAL("Write me");
}

if(meshes.size() == 1)
Expand Down Expand Up @@ -263,7 +263,7 @@ vector<float3> Mesh::lines() const {
vector<SimpleDrawCall> Mesh::genDrawCalls(VulkanDevice &device, const SimpleMaterialSet &materials,
const AnimatedData *anim_data,
const Matrix4 &matrix) const {
FATAL("writeme");
FWK_FATAL("writeme");
vector<SimpleDrawCall> out;
/*
if(anim_data) {
Expand Down
2 changes: 1 addition & 1 deletion src/gfx/mesh_buffers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ vector<Matrix4> MeshBuffers::mapPose(const Pose &pose) const {

MeshBuffers MeshBuffers::remap(const vector<int> &mapping) const {
if(hasSkin())
FATAL("FIXME");
FWK_FATAL("FIXME");

vector<float3> out_positions(mapping.size());
vector<float3> out_normals(normals ? mapping.size() : 0);
Expand Down
2 changes: 1 addition & 1 deletion src/gfx/mesh_constructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Mesh Mesh::makeTetrahedron(const Tetrahedron &tet) {

Mesh Mesh::makePlane(const Plane3F &plane, const float3 &start, float size) {
DASSERT(size > epsilon<float>);
FATAL("Test me");
FWK_FATAL("Test me");

float3 p[3] = {{-size, -size, -size}, {size, size, size}, {size, -size, size}};
for(int i = 0; i < 3; i++)
Expand Down
2 changes: 1 addition & 1 deletion src/gfx/mesh_indices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ MeshIndices MeshIndices::changeTopology(MeshIndices indices, Topology new_type)
return indices;

if(new_type == Topology::triangle_strip)
FATAL("Please write me");
FWK_FATAL("Please write me");
if(new_type == Topology::triangle_list) {
auto tris = indices.trisIndices();
indices.m_data.reserve(tris.size() * 3);
Expand Down
2 changes: 1 addition & 1 deletion src/gfx/pose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ vector<int> Pose::mapNames(const vector<string> &names) const {
while(m_name_map[src_index].first != name) {
src_index++;
if(src_index == m_name_map.size())
FATAL("Cannot find node in pose: %s", name.c_str());
FWK_FATAL("Cannot find node in pose: %s", name.c_str());
}

out[dst_map[n].second] = m_name_map[src_index++].second;
Expand Down
4 changes: 2 additions & 2 deletions src/gfx/shader_compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ Ex<CompilationResult> ShaderCompiler::compileFile(VShaderStage stage, ZStr file_

ShaderDefId ShaderCompiler::add(ShaderDefinition def) {
if(find(def.name))
FATAL("ShaderDefinition already exists: '%s'", def.name.c_str());
FWK_FATAL("ShaderDefinition already exists: '%s'", def.name.c_str());
auto id = ShaderDefId(m_impl->shader_defs.nextFreeIndex());

m_impl->shader_def_map.emplace(def.name, id);
Expand Down Expand Up @@ -336,7 +336,7 @@ Maybe<ShaderDefId> ShaderCompiler::find(ZStr name) const {
const ShaderDefinition &ShaderCompiler::operator[](ZStr name) const {
auto id = find(name);
if(!id)
FATAL("ShaderDefinition not found: '%s'", name.c_str());
FWK_FATAL("ShaderDefinition not found: '%s'", name.c_str());
return m_impl->shader_defs[*id];
}

Expand Down
2 changes: 1 addition & 1 deletion src/gui/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void Gui::updateDpiAndFonts(VulkanWindow &window, bool is_initial) {
// TODO: font recreation
/*auto *bd = ImGui_ImplVulkan_GetBackendData();
if(bd && bd->FontImage) {
FATAL("TODO: fixme");
FWK_FATAL("TODO: fixme");
}*/

if(!is_initial)
Expand Down
2 changes: 1 addition & 1 deletion src/io/gzip_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ GzipStream::~GzipStream() {
}
}

// TODO: use FATAL in these?
// TODO: use FWK_FATAL in these?
Ex<GzipStream> GzipStream::decompressor(Stream &input, Maybe<i64> load_limit) {
DASSERT(input.isLoading());

Expand Down
4 changes: 2 additions & 2 deletions src/io/stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ BaseStream::~BaseStream() {
}
}

void BaseStream::saveData(CSpan<char>) { FATAL("Un-implemented saveData called"); }
void BaseStream::loadData(Span<char>) { FATAL("Un-implemented loadData called"); }
void BaseStream::saveData(CSpan<char>) { FWK_FATAL("Un-implemented saveData called"); }
void BaseStream::loadData(Span<char>) { FWK_FATAL("Un-implemented loadData called"); }
void BaseStream::seek(i64 pos) {
DASSERT_GE(pos, 0);
DASSERT_LE(pos, m_size);
Expand Down
2 changes: 1 addition & 1 deletion src/math/box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace fwk {

template <class T> void checkBoxRangeDetailed(const T &min, const T &max) {
if(!validBoxRange(min, max))
FATAL("Invalid box range: %s", format("% - %", min, max).c_str());
FWK_FATAL("Invalid box range: %s", format("% - %", min, max).c_str());
}

void checkBoxRange(const float2 &min, const float2 &max) { return checkBoxRangeDetailed(min, max); }
Expand Down
2 changes: 1 addition & 1 deletion src/math/line.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ TEMPLATE auto TLINE::isectParam(const Line &rhs) const -> PRIsectParam {
auto t1 = dot<PVec>(diff, perpendicular(vec2));
return ratDivide(t1, tdot);
} else {
FATAL("write me please");
FWK_FATAL("write me please");
return {};
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/math/segment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ TEMPLATE auto TSEG::isectParam(const Segment &rhs) const -> PRIsectParam {
return ratDivide(t1, tdot);
return {};
} else {
FATAL("write me please");
FWK_FATAL("write me please");
return {};
}
}
Expand All @@ -129,7 +129,7 @@ TEMPLATE auto TSEG::isectParam(const Box<Vec> &box) const -> PRIsectParam {
auto param = asRay()->isectParam(box).asInterval() / length();
return param.min > T(1) || param.max < T(0) ? IsectParam() : param;
} else {
FATAL("write me please");
FWK_FATAL("write me please");
return {};
}
}
Expand All @@ -138,7 +138,7 @@ TEMPLATE auto TSEG::isectParam(const Box<Vec> &box) const -> PRIsectParam {
TEMPLATE template <c_float U>
auto TSEG::isectParamPlane(const Plane<T, dim> &plane) const -> IsectParam {
if constexpr(dim == 2) {
FATAL("write me");
FWK_FATAL("write me");
return {};
} else {
if(empty())
Expand Down Expand Up @@ -189,7 +189,7 @@ TEMPLATE auto TSEG::isectParam(const Triangle<T, dim> &tri) const -> Pair<PPRIse
return {PPRIsectParam(ratDivide<PPT>(t, d)), is_front};
return {};
} else {
FATAL("write me please");
FWK_FATAL("write me please");
return {};
}
}
Expand All @@ -198,15 +198,15 @@ TEMPLATE auto TSEG::isect(const Segment &segment) const -> Isect {
if constexpr(is_fpt<T>)
return at(isectParam(segment));

FATAL("write me");
FWK_FATAL("write me");
return {};
}

TEMPLATE auto TSEG::isect(const Box<Vec> &box) const -> Isect {
if constexpr(is_fpt<T>)
return at(isectParam(box));

FATAL("write me");
FWK_FATAL("write me");
return {};
}

Expand All @@ -230,7 +230,7 @@ TEMPLATE IsectClass TSEG::classifyIsect(const Point &point) const {
return IsectClass::point;
}
} else {
FATAL("write me please");
FWK_FATAL("write me please");
}

return IsectClass::none;
Expand Down Expand Up @@ -356,7 +356,7 @@ TEMPLATE auto TSEG::clip(const Box<TVec> &input_rect) const -> Maybe<Segment<PRe
}

if constexpr(dim == 3) {
FATAL("write me");
FWK_FATAL("write me");
} else {
// TODO: naming
// TODO: early out
Expand Down
2 changes: 1 addition & 1 deletion src/math/triangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ template <class T, int N>
template <class U, EnableInDimension<U, 3>...>
Triangle2<T> Triangle<T, N>::projection2D() const {
if constexpr(!is_same<T, float>) {
FATAL("Please fix me!");
FWK_FATAL("Please fix me!");
return {};
} else {
Projection proj(*this);
Expand Down
Loading

0 comments on commit 6b8908e

Please sign in to comment.