Skip to content

Commit

Permalink
Initial work on refactoring and breaking logic up into separate files
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy-rifkin committed Nov 13, 2023
1 parent 20cd140 commit 5a2efd7
Show file tree
Hide file tree
Showing 8 changed files with 1,083 additions and 979 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ target_sources(
${target_name} PRIVATE
# src
src/assert.cpp
src/analysis.cpp
src/utils.cpp
)

# link dependencies
Expand Down
9 changes: 0 additions & 9 deletions include/assert/assert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1411,15 +1411,6 @@ using libassert::ASSERTION;

#define VERIFY(expr, ...) ASSERT_INVOKE(expr, true, true, "VERIFY", verification, , __VA_ARGS__)

#ifndef LIBASSERT_IS_CPP // keep macros for the .cpp
#undef LIBASSERT_IS_CLANG
#undef LIBASSERT_IS_GCC
#undef LIBASSERT_IS_MSVC
#undef LIBASSERT_ATTR_COLD
#undef LIBASSERT_ATTR_NOINLINE
#undef LIBASSERT_PRIMITIVE_ASSERT
#endif

#endif

// Intentionally done outside the include guard. Libc++ leaks `assert` (among other things), so the include for
Expand Down
758 changes: 758 additions & 0 deletions src/analysis.cpp

Large diffs are not rendered by default.

40 changes: 40 additions & 0 deletions src/analysis.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#ifndef ANALYSIS_HPP
#define ANALYSIS_HPP

#include <string>
#include <string_view>

#include <assert/assert.hpp>

namespace libassert::detail {
struct highlight_block {
std::string_view color;
std::string content;
};

LIBASSERT_ATTR_COLD
std::string prettify_type(std::string type);

LIBASSERT_ATTR_COLD
std::string highlight(const std::string& expression);

LIBASSERT_ATTR_COLD
std::vector<highlight_block> highlight_blocks(const std::string& expression);

LIBASSERT_ATTR_COLD
std::vector<highlight_block> highlight_blocks(const std::string& expression);

LIBASSERT_ATTR_COLD literal_format get_literal_format(const std::string& expression);

LIBASSERT_ATTR_COLD std::string trim_suffix(const std::string& expression);

LIBASSERT_ATTR_COLD bool is_bitwise(std::string_view op);

LIBASSERT_ATTR_COLD
std::pair<std::string, std::string> decompose_expression(
const std::string& expression,
const std::string_view target_op
);
}

#endif
Loading

0 comments on commit 5a2efd7

Please sign in to comment.