Skip to content

Commit

Permalink
feat: BufferManip for way better maintainability; Composition > Inher…
Browse files Browse the repository at this point in the history
…itance (#10)

- The `BufferManip` class now composes `BufferInfo`, which only holds variables.
- Stop using `std::any`. Instead, use a custom `PointerID` class, which stores a `typeid` corresponding to the original type of the `void*` for further type checks.
- Use `Executor` instead of `Context`. This leads to a composition class with `Context` for executing runnable fmt strings.

Should be totally backward compatible for API use. For flags, `=` has been replaced by `#` to follow <fmt> format
  • Loading branch information
0-Sacha authored Oct 23, 2024
1 parent b5a8448 commit e28d143
Show file tree
Hide file tree
Showing 143 changed files with 5,002 additions and 8,551 deletions.
1 change: 1 addition & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Examples/
external_dev/
4 changes: 2 additions & 2 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ common --show_timestamps
common --verbose_failures
test --test_output=errors

common:clang_tidy --aspects @bazel_utilities//tools:clang_tidy.bzl%clang_tidy
common:clang_tidy --aspects @bazel_utilities//tools/clang_tidy:clang_tidy.bzl%clang_tidy
common:clang_tidy --output_groups=+report
common:clang_tidy --spawn_strategy=local
common:clang_tidy --aspects_parameters=skip_headers=True

common:clang_format --aspects @bazel_utilities//tools:clang_format.bzl%clang_format
common:clang_format --aspects @bazel_utilities//tools/clang_format:clang_format.bzl%clang_format
common:clang_format --output_groups=+report
common:clang_format --spawn_strategy=local

Expand Down
12 changes: 6 additions & 6 deletions .buildkite/linux_amd64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ agents:
queue: "agent-runners-linux-amd64"

steps:
- label: ":bazel: Build and Test on gcc"
- label: ":bazel: Build and Test on gcc (W asan)"
commands:
- CC=gcc bazelisk build //...
- CC=gcc bazelisk test //...
- CC=gcc bazelisk build --features=asan //...
- CC=gcc bazelisk test --features=asan //...

- label: ":bazel: Build and Test on Clang"
- label: ":bazel: Build and Test on Clang (W asan)"
commands:
- CC=clang bazelisk build //...
- CC=clang bazelisk test //...
- CC=clang bazelisk build --features=asan //...
- CC=clang bazelisk test --features=asan //...
37 changes: 37 additions & 0 deletions .github/workflows/CodeChecker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: CodeChecker

on:
push:
branches:
- '**'
pull_request:
branches:
- '**'

jobs:
codechecker-ubuntu-latest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bazelbuild/setup-bazelisk@v3
- name: Mount bazel cache
uses: actions/cache@v4
with:
path: "~/.cache/bazel"
key: bazel

- name: build & retreive compile_commands.json
run: |
bazelisk clean
bazelisk build //...
bazelisk run //conf:compile_commands
- uses: whisperity/[email protected]
id: codechecker
with:
logfile: ${{ github.workspace }}/compile_commands.json

- uses: actions/upload-artifact@v4
with:
name: "CodeChecker Bug Reports"
path: ${{ steps.codechecker.outputs.result-html-dir }}
8 changes: 4 additions & 4 deletions .github/workflows/StreamFormat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ jobs:
run: gcc --version
- name: Building...
run: CC=gcc bazelisk build //...
- name: Testing...
run: CC=gcc bazelisk test //...
- name: Testing... (W asan)
run: CC=gcc bazelisk test --features=asan //...

ubuntu-latest-clang:
runs-on: ubuntu-latest
Expand All @@ -60,5 +60,5 @@ jobs:
run: clang++-17 --version
- name: Building...
run: CC=clang++-17 bazelisk build //...
- name: Testing...
run: CC=clang++-17 bazelisk test //...
- name: Testing... (W asan)
run: CC=clang++-17 bazelisk test --features=asan //...
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ Asset
# Tests
TestSuite_FMT.json

# Coverage
# Coverage / Checker
genhtml
.codechecker

# External Dev
external_dev
Expand Down
21 changes: 21 additions & 0 deletions Examples/WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "bazel_utilities",
strip_prefix = "bazel_utilities-7c379bd1b6a4ae0ff5123b63385f92fb527bd687",
urls = [ "https://github.com/0-Sacha/bazel_utilities/archive/7c379bd1b6a4ae0ff5123b63385f92fb527bd687.zip" ],
integrity = "sha256-L5hWrjLMFOdplqV6X0xCyvINMjhnQHSTXynUYZNm9Qs="
)

http_archive(
name = "bazel_winlibs_mingw",
strip_prefix = "bazel_winlibs_mingw-09c1b538db4fa262bba152b24b7c1d61079e5abe",
urls = [ "https://github.com/0-Sacha/bazel_winlibs_mingw/archive/09c1b538db4fa262bba152b24b7c1d61079e5abe.zip" ],
integrity = "sha256-rxd9695aR8gQ7sOFiz1YUDURvdgqi+3o3GLygEVLuas="
)

load("@bazel_winlibs_mingw//:rules.bzl", "winlibs_mingw_toolchain")
# winlibs_mingw_toolchain(
# "mingw",
# copts = [ "-g", "-O0" ],
# )
7 changes: 7 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@ module(

# Deps
bazel_dep(name = "rules_cc", version = "0.0.9")

bazel_dep(name = "hedron_compile_commands", dev_dependency = True)
git_override(
module_name = "hedron_compile_commands",
remote = "https://github.com/hedronvision/bazel-compile-commands-extractor.git",
commit = "1e08f8e0507b6b6b1f4416a9a22cf5c28beaba93",
)
2 changes: 1 addition & 1 deletion Tests/FMT/ComplexPattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

PCT_TEST_GROUP(FMT, COMPLEX_PATTERN);

#define TEST_FMT(fmt_test, expected, ...) PCT_EQ(StreamFormat::FMT::FormatString(fmt_test, __VA_ARGS__), expected)
#define TEST_FMT(fmt_test, expected, ...) PCT_EQ(StreamFormat::FMT::FormatString(fmt_test, __VA_ARGS__), std::string(expected))

PCT_TEST_FUNC(COMPLEX_PATTERN, UNESCAPED_ESCAPE_PATTERN)
{
Expand Down
110 changes: 57 additions & 53 deletions Tests/FMT/Globber.cpp
Original file line number Diff line number Diff line change
@@ -1,68 +1,72 @@
#include "BaseFMTTests.h"

#include "StreamFormat/FMT/Context/ParserContext/UtilityFunctions.h"
#include "StreamFormat/FMT/Context/ParserExecutor/UtilityFunctions.h"

#include "StreamFormat/FMT/Buffer/Utils/PatternMatching/Glob.h"
#include "StreamFormat/FMT/Buffer/Utils/BufferGlobberManip.h"

PCT_TEST_GROUP(FMT, GLOBBER);
#define TEST_GLOBBER(data, glob) \
{ \
StreamFormat::FMT::Detail::BasicBufferIn<char> p_buffer(data); \
StreamFormat::FMT::Detail::BasicBufferIn<char> p_glob(glob); \
StreamFormat::FMT::Detail::Globber<char, char>::BufferInExecGlob(p_buffer, p_glob); \
PCT_ASSERT(p_buffer.IsEnd()); \
}
#define TEST_GLOBBER(data, glob) \
{ \
StreamFormat::FMT::Detail::BufferInfoView<char> p_buffer(data); \
StreamFormat::FMT::Detail::BufferInfoView<char> p_glob(glob); \
StreamFormat::FMT::Detail::Globber<const char>::BufferInExecGlob(p_buffer, \
p_glob); \
PCT_ASSERT( \
StreamFormat::FMT::Detail::BufferAccess(p_buffer).IsEndOfString()); \
}

PCT_TEST_FUNC(GLOBBER, BASIC_WILDCARD){TEST_GLOBBER("qwerty", "qwerty") TEST_GLOBBER("qwerty", "q?erty") TEST_GLOBBER("qwerty", "q?????") TEST_GLOBBER("qwerty", "qwer?y")
TEST_GLOBBER("qwerty", "qwert?") TEST_GLOBBER("qwerty", "??????") TEST_GLOBBER("qwerty", "*") TEST_GLOBBER("qwerty", "******")
TEST_GLOBBER("qwerty", "*?**?*")}
PCT_TEST_FUNC(GLOBBER, BASIC_WILDCARD){
TEST_GLOBBER("qwerty", "qwerty") TEST_GLOBBER("qwerty", "q?erty")
TEST_GLOBBER("qwerty", "q?????") TEST_GLOBBER("qwerty", "qwer?y")
TEST_GLOBBER("qwerty", "qwert?") TEST_GLOBBER("qwerty", "??????")
TEST_GLOBBER("qwerty", "*") TEST_GLOBBER("qwerty", "******")
TEST_GLOBBER("qwerty", "*?**?*")}

PCT_TEST_GROUP(FMT, PARSE_GLOBBER);
PCT_TEST_FUNC(PARSE_GLOBBER, PG_BASIC_WILDCARD)
{
int k = 0;
StreamFormat::FMT::Parse("|123|", "|{}|", k);
PCT_EQ(k, 123);
PCT_TEST_FUNC(PARSE_GLOBBER, PG_BASIC_WILDCARD) {
int k = 0;
StreamFormat::FMT::Parse("|123|", "|{}|", k);
PCT_EQ(k, 123);

{
char test[5];
StreamFormat::FMT::Parse("|test|", "|{}|", test);
PCT_EQ(std::string(test), std::string("test"));
}
{
char test[5];
StreamFormat::FMT::Parse("|test|", "|{}|", test);
// PCT_EQ(std::string(test), std::string("test"));
}

{
char test[4];
StreamFormat::FMT::Parse("|test|", "|{:no-zero-end}|", test);
PCT_EQ(std::string(test, 4), std::string("test"));
}
{
char test[4];
StreamFormat::FMT::Parse("|test|", "|{:no-zero-end}|", test);
// PCT_EQ(std::string(test, 4), std::string("test"));
}

{
char test[4];
StreamFormat::FMT::Parse("|test|", "|{}t|", test);
PCT_EQ(std::string(test), std::string("tes"));
}
{
char test[4];
StreamFormat::FMT::Parse("|test|", "|{}t|", test);
// PCT_EQ(std::string(test), std::string("tes"));
}

{
char test[11];
StreamFormat::FMT::Parse("|test123456|", "|{}|", test);
PCT_EQ(std::string(test), std::string("test123456"));
}
{
char test[11];
StreamFormat::FMT::Parse("|test123456|", "|{}|", test);
// PCT_EQ(std::string(test), std::string("test123456"));
}

{
char test[11];
StreamFormat::FMT::Parse("|test123456|", "|{:glob='*1'}23456|", test);
PCT_EQ(std::string(test), std::string("test1"));
}
{
char test[11];
StreamFormat::FMT::Parse("|test123456|", "|{:glob='*1'}23456|", test);
// PCT_EQ(std::string(test), std::string("test1"));
}

{
char test[11];
// just glob = '????' but compiler are anrgy about trigraph on '??'
StreamFormat::FMT::Parse("|test123456|",
"|{:glob='?"
"?"
"?"
"?'}123456|",
test);
PCT_EQ(std::string(test), std::string("test"));
}
{
char test[11];
// just glob = '????' but compiler are anrgy about trigraph on '??'
StreamFormat::FMT::Parse("|test123456|",
"|{:glob='?"
"?"
"?"
"?'}123456|",
test);
// PCT_EQ(std::string(test), std::string("test"));
}
}
Loading

0 comments on commit e28d143

Please sign in to comment.