Skip to content

Commit

Permalink
feat: Testing Zork++ v0.9.0 with native MSVC import std support
Browse files Browse the repository at this point in the history
Note that a few modules has some troubles compiling:
    - There's issues on the legacy iterator module (pending to review,
left commented now)
    - MSVC refuses to compile the `matrix.cppm` Matrix template type
when we provide template arguments to the Row and Column Matrix template
constructors
    - Tests are yet untested
  • Loading branch information
TheRustifyer committed May 26, 2024
1 parent dc535c4 commit 8e7f384
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 23 deletions.
24 changes: 12 additions & 12 deletions zero/ifc/commons/typedefs.cppm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @brief Provides a custom way of reexport common types and symbols typically
* found on some system headers in a convenient and encapsulated way.
*
*
* The main motivation of this module interface unit is to wrap all the system
* headers that has standard C++ typedefs, avoding the user to have to include
* on every file that is required those definitions, that also must be defined
Expand All @@ -14,8 +14,8 @@
* Defined in header <cstring>
* Defined in header <ctime>
* Defined in header <cuchar>
*
* Defined in header <cwchar> (since C++17)
*
* Defined in header <cwchar> (since C++17)
* ```
*/

Expand All @@ -26,33 +26,33 @@ export module typedefs;
#elif defined(__GNUC__)
import <cstdio>;
#elif defined(_MSC_VER)
import std.core;
import std.compat;
#endif

export namespace zero {
/**
* @brief `zero::size_t` is a typedef for wrapping the `std::size_t`, which is the unsigned integer type of the result
* @brief `zero::size_t` is a typedef for wrapping the `std::size_t`, which is the unsigned integer type of the result
* of the sizeof operator as well as the sizeof... operator and the alignof operator.
* The bit width of std::size_t is not less than 16.
* zero::size_t can store the maximum size of a theoretically possible object of any type (including array).
* A type whose size cannot be represented by zero::size_t is ill-formed. On many platforms
* A type whose size cannot be represented by zero::size_t is ill-formed. On many platforms
* (an exception is systems with segmented addressing) zero::size_t can safely store the value of any non-member pointer,
* in which case it is synonymous with std::uintptr_t.
* in which case it is synonymous with std::uintptr_t.
*/
typedef std::size_t size_t;

/**
* @brief zero::ptrdiff_t is a type alias for the std::ptrdiff_t,
* @brief zero::ptrdiff_t is a type alias for the std::ptrdiff_t,
* being the signed integer type of the result of subtracting two pointers.
*
* is used for pointer arithmetic and array indexing, if negative values are
* possible.
*
* is used for pointer arithmetic and array indexing, if negative values are
* possible.
* Programs that use other types, such as int, may fail on, e.g. 64-bit systems
* when the index exceeds INT_MAX or if it relies on 32-bit modular arithmetic
*
*
* Most common place of use if usually working with iterators, specially to fullfil
* the `difference_type` template argument
*/
Expand Down
12 changes: 6 additions & 6 deletions zero/ifc/math/linear_algebra/matrix.cppm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export module math.linear_algebra:matrix;

import std;
import std.compat;

export {
template <std::size_t Elements, typename Type>
Expand Down Expand Up @@ -59,7 +59,7 @@ export {
template <typename T>
concept ColumnMatrix = std::is_same_v<T, ColumnOrientation>;

template <std::size_t Rows, std::size_t Cols, typename T = int, MatrixOrientation Orientation = RowOrientation>
template <typename T = int, MatrixOrientation Orientation = RowOrientation, std::size_t Rows = 3, std::size_t Cols = 3>
class Matrix {
// BIG TODO the names for Rows and Cols size are non worth. Better MxN, so we can play with the orientation
private:
Expand All @@ -76,13 +76,13 @@ export {
Matrix() = delete;

/// Row Matrix constructor
constexpr Matrix<Rows, Cols, T>(
constexpr Matrix(
std::initializer_list<DataRow> rows
) requires RowMatrix<Orientation> : data {rows} {}
) requires RowMatrix<RowOrientation> : data {rows} {}
/// Column Matrix constructor
constexpr Matrix<Cols, Rows, T>(
constexpr Matrix(
std::initializer_list<DataCol> columns
) requires ColumnMatrix<Orientation> : data {columns} {}
) requires ColumnMatrix<ColumnOrientation> : data {columns} {}

template <std::size_t RowIndex>
[[nodiscard]] constexpr auto row() -> Row<Cols, T> requires (RowMatrix<Orientation>) {
Expand Down
10 changes: 5 additions & 5 deletions zero/main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import std;
import zero;
import collections;
import iterator;
// import iterator;
import container;
import type_info;
import physics;
Expand All @@ -13,7 +13,7 @@ import tsuite;

// Forward decls
void run_containers_examples();
void run_output_iterator_examples();
// void run_output_iterator_examples();
void run_quantities_examples();
void run_formatter_and_stylize_examples();
void run_print_examples();
Expand Down Expand Up @@ -89,7 +89,7 @@ int main() {
// Forces a warning that alerts the user that the test will be discarded, since already
// exists one with the same identifier in the given suite
TEST_CASE(suite, "Addition Test", testAddition);
// Register a test case designed to fail, useful for testing the behavior
// Register a test case designed to fail, useful for testing the behavior
// of RUN_TESTS with different failure modes.
TEST_CASE(suite, "Subtraction Test", testSubtraction);

Expand Down Expand Up @@ -135,7 +135,7 @@ void run_containers_examples() {
std::cout << " - [const Container<T>*] Value: " << value << std::endl;
}

void run_output_iterator_examples() {
/* void run_output_iterator_examples() {
std::cout << "Using output iterator with ostream: ";
zero::iterator::legacy::output_iter<std::ostream> out1(std::cout);
out1 = 1;
Expand Down Expand Up @@ -190,7 +190,7 @@ void run_output_iterator_examples() {
std::cout << x << ' ';
std::cout << '\n';
}
} */

void run_quantities_examples() {
using namespace zero::physics;
Expand Down
89 changes: 89 additions & 0 deletions zork_config/zork_windows_msvc.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
[project]
name = "Zero"
authors = [ "Zero Day Code" ]
compilation_db = true
project_root = "zero"

[compiler]
cpp_compiler = "msvc"
cpp_standard = "latest"
# extra_args = [
# ]

[build]
output_dir = "./out"

[executable]
executable_name = "zero"
sources = [ "zero/*.cpp" ]

[tests]
tests_executable_name = "zero_tests"
sources = [ "tests/math/*.cpp", "tests/*.cpp" ]

[modules]
base_ifcs_dir = "zero/ifc"
interfaces = [
{ file = 'commons/typedefs.cppm' },
{ file = 'text/str_manip.cppm' },
{ file = 'text/formatter.cppm' },
{ file = 'text/stylizer.cppm' },
{ file = 'text/print_utils.cppm' },
{ file = 'types/type_info.cppm' },
{ file = 'types/type_traits.cppm' },
{ file = 'commons/concepts.cppm', dependencies = ['typedefs'] },

### The testing suite
{ file = 'test-suite/assertions.cppm', partition = { module = 'tsuite' } },
# Root
{ file = 'test-suite/suite.cppm', module_name = 'tsuite' },

# ### Iterator library
# { file = 'iterators/internal/iterator_detail.cpp', partition = { module = 'iterator', partition_name = 'detail', is_internal_partition = true } },
# { file = 'iterators/iterator_concepts.cppm', partition = { module = 'iterator', partition_name = 'concepts' } },
# # Modern
# { file = 'iterators/iterator_facade.cppm', partition = { module = 'iterator' } },
# { file = 'iterators/input_iterator.cppm', partition = { module = 'iterator' } },
# # Legacy
# { file = 'iterators/legacy/legacy_iterator.cppm', partition = { module = 'iterator' } },
# { file = 'iterators/legacy/legacy_input_iterator.cppm', partition = { module = 'iterator' } },
# { file = 'iterators/legacy/legacy_output_iterator.cppm', partition = { module = 'iterator' } },
# # Root
# { file = 'iterators/iterator.cppm' },

### The collections/containers librar
{ file = 'collections/container.cppm', dependencies = ['type_info'] },
{ file = 'collections/array.cppm', dependencies = ['typedefs', 'concepts', 'iterator', 'container'] },
# Root
{ file = 'collections/collections.cppm', dependencies = ['array'] },

### Math library
# The operations library
{ file = 'math/ops/arithmetic.cppm', partition = { module = 'math.ops', partition_name = 'arithmetic' } },
{ file = 'math/ops/algebraic.cppm', partition = { module = 'math.ops', partition_name = 'algebraic' } },
{ file = 'math/ops/math.ops.cppm' },
# The linear algebra library
{ file = 'math/linear_algebra/matrix.cppm', partition = { module = 'math.linear_algebra', partition_name = 'matrix' } },
{ file = 'math/linear_algebra/root.cppm', module_name = 'math.linear_algebra' },
# General
{ file = 'math/symbols.cppm', module_name = 'math.symbols' },
# Root
{ file = 'math/math.cppm' },

### The physics library
# The quantities library
{ file = 'physics/quantities/internal/quantities_detail.cpp', partition = { module = 'physics.quantities', partition_name = 'quantities.detail' } },

{ file = 'physics/quantities/ratios.cppm', partition = { module = 'physics.quantities' } },
{ file = 'physics/quantities/units.symbols.cppm', module_name = 'units.symbols', partition = { module = 'physics.quantities' } },
{ file = 'physics/quantities/dimensions.cppm', module_name = 'dimensions', partition = { module = 'physics.quantities' } },
{ file = 'physics/quantities/units.cppm', module_name = 'units', partition = { module = 'physics.quantities' } },
{ file = 'physics/quantities/quantity.cppm', partition = { module = 'physics.quantities' } },
{ file = 'physics/quantities/physics.quantities.cppm' },
# Root
{ file = 'physics/physics.cppm' },

# The main interface of the project
{ file = 'zero.cppm' }
]

0 comments on commit 8e7f384

Please sign in to comment.