implicit uvalue's ctor from value, remove all uvalue's dynamic operators

This commit is contained in:
BlackMATov
2023-01-12 09:44:55 +07:00
parent b60912b6fd
commit 1ebd2e75ed
25 changed files with 410 additions and 767 deletions

View File

@@ -79,5 +79,5 @@ TEST_CASE("meta/meta_examples/class/usage") {
const meta::uvalue rectangle_v = rectangle_type.create(10, 20);
// calls the method with the dynamic rectangle instance 'rectangle_v'
CHECK(rectangle_area.invoke(rectangle_v) == 200);
CHECK(rectangle_area.invoke(rectangle_v).get_as<int>() == 200);
}

View File

@@ -38,7 +38,7 @@ TEST_CASE("meta/meta_examples/enum/type") {
// prints all enumerators
std::cout << "* align" << std::endl;
for ( auto&& [index, evalue] : align_type.get_evalues() ) {
std::cout << " - " << index.get_name() << "/" << evalue.get_underlying_value() << std::endl;
std::cout << " - " << index.get_name() << "/" << evalue.get_underlying_value().get_as<int>() << std::endl;
}
}
@@ -54,5 +54,5 @@ TEST_CASE("meta/meta_examples/enum/usage") {
CHECK(align_type.value_to_name(e) == "center");
// ... and back again
CHECK(align_type.name_to_value("center") == e);
CHECK(align_type.name_to_value("center").get_as<align>() == e);
}

View File

@@ -57,9 +57,9 @@ TEST_CASE("meta/meta_examples/inplace") {
CHECK(ivec2_ptr.get_type() == meta::resolve_type<ivec2*>());
// interacts with the created object as usual
CHECK(ivec2_x.get(ivec2_ptr) == 2);
CHECK(ivec2_y.get(ivec2_ptr) == 3);
CHECK(ivec2_length2(ivec2_ptr) == 13);
CHECK(ivec2_x.get(ivec2_ptr).get_as<int>() == 2);
CHECK(ivec2_y.get(ivec2_ptr).get_as<int>() == 3);
CHECK(ivec2_length2(ivec2_ptr).get_as<int>() == 13);
// you must manually call the object's destructor
CHECK(ivec2_type.destroy_at(ivec2_buffer.get_memory()));

View File

@@ -73,7 +73,7 @@ TEST_CASE("meta/meta_examples/method/usage") {
// checks the type and value of the result
CHECK(ivec2_add_result_value.get_type() == meta::resolve_type<ivec2>());
CHECK(ivec2_add_result_value == ivec2{42, 21});
CHECK(ivec2_add_result_value.get_as<ivec2>() == ivec2{42, 21});
// checks the result of our manipulations
CHECK(v == ivec2{42, 21});

View File

@@ -72,18 +72,18 @@ TEST_CASE("meta/meta_examples/scopes/local") {
const meta::function dot3_function = math_scope.get_function("dot3");
// calls and checks found functions
CHECK(dot2_function(ivec2{3,4}, ivec2{5,6}) == 39);
CHECK(dot3_function(ivec3{3,4,5}, ivec3{6,7,8}) == 86);
CHECK(dot2_function(ivec2{3,4}, ivec2{5,6}).get_as<int>() == 39);
CHECK(dot3_function(ivec3{3,4,5}, ivec3{6,7,8}).get_as<int>() == 86);
// and free variables, of course
const meta::variable unit2_variable = math_scope.get_variable("unit2");
const meta::variable unit3_variable = math_scope.get_variable("unit3");
// checks and uses found variables with functions
CHECK(unit2_variable.get() == ivec2{1,1});
CHECK(unit3_variable.get() == ivec3{1,1,1});
CHECK(dot2_function(unit2_variable.get(), unit2_variable.get()) == 2);
CHECK(dot3_function(unit3_variable.get(), unit3_variable.get()) == 3);
CHECK(unit2_variable.get().get_as<ivec2>() == ivec2{1,1});
CHECK(unit3_variable.get().get_as<ivec3>() == ivec3{1,1,1});
CHECK(dot2_function(unit2_variable.get(), unit2_variable.get()).get_as<int>() == 2);
CHECK(dot3_function(unit3_variable.get(), unit3_variable.get()).get_as<int>() == 3);
}
TEST_CASE("meta/meta_examples/scopes/global") {
@@ -106,6 +106,6 @@ TEST_CASE("meta/meta_examples/scopes/global") {
const meta::variable unit3_variable = math_scope.get_variable("unit3");
// everything works as expected
CHECK(dot2_function(unit2_variable.get(), unit2_variable.get()) == 2);
CHECK(dot3_function(unit3_variable.get(), unit3_variable.get()) == 3);
CHECK(dot2_function(unit2_variable.get(), unit2_variable.get()).get_as<int>() == 2);
CHECK(dot3_function(unit3_variable.get(), unit3_variable.get()).get_as<int>() == 3);
}

View File

@@ -44,6 +44,6 @@ TEST_CASE("meta/meta_examples/variable/usage") {
// prints all variables in the scope
std::cout << "* " << constants_scope.get_name() << std::endl;
for ( auto&& [index, variable] : constants_scope.get_variables() ) {
std::cout << " - " << index.get_name() << ":" << variable.get() << std::endl;
std::cout << " - " << index.get_name() << ":" << variable.get().get_as<double>() << std::endl;
}
}