PlaceholderParser: Fixed compilation issues, added integration test

with FDM slicing process.
This commit is contained in:
Vojtech Bubnik 2023-03-23 09:23:20 +01:00
parent c28585ab7f
commit e46891fa8c
2 changed files with 16 additions and 5 deletions

View File

@ -737,7 +737,7 @@ namespace client
// Table to translate symbol tag to a human readable error message.
static std::map<std::string, std::string> tag_to_error_message;
static void evaluate_full_macro(const MyContext *ctx, bool &result) { result = ! ctx->just_boolean_expression; }
static bool evaluate_full_macro(const MyContext *ctx) { return ! ctx->just_boolean_expression; }
const ConfigOption* optptr(const t_config_option_key &opt_key) const override
{
@ -1570,13 +1570,12 @@ namespace client
template<typename Iterator>
struct InterpolateTableContext {
template<typename Iterator>
struct Item {
double x;
boost::iterator_range<Iterator> it_range_x;
double y;
};
std::vector<Item<Iterator>> table;
std::vector<Item> table;
static void init(const expr<Iterator> &x) {
if (!x.numeric_type())
@ -1785,8 +1784,8 @@ namespace client
// Also the start symbol switches between the "full macro syntax" and a "boolean expression only",
// depending on the context->just_boolean_expression flag. This way a single static expression parser
// could serve both purposes.
start = eps[px::bind(&MyContext::evaluate_full_macro, _r1, _a)] >
( (eps(_a==true) > text_block(_r1) [_val=_1])
start =
( (eps(px::bind(&MyContext::evaluate_full_macro, _r1)) > text_block(_r1) [_val=_1])
| conditional_expression(_r1) [ px::bind(&expr<Iterator>::evaluate_boolean_to_string, _1, _val) ]
) > eoi;
start.name("start");

View File

@ -258,4 +258,16 @@ SCENARIO("Custom G-code", "[CustomGCode]")
REQUIRE(match_count == 2);
}
}
GIVEN("before_layer_gcode increments global variable") {
auto config = Slic3r::DynamicPrintConfig::new_with({
{ "start_gcode", "{global counter=0}" },
{ "before_layer_gcode", ";Counter{counter=counter+1;counter}\n" }
});
std::string gcode = Slic3r::Test::slice({ Slic3r::Test::TestMesh::cube_20x20x20 }, config);
THEN("The counter is emitted multiple times before layer change.") {
REQUIRE(Slic3r::Test::contains(gcode, ";Counter1\n"));
REQUIRE(Slic3r::Test::contains(gcode, ";Counter2\n"));
REQUIRE(Slic3r::Test::contains(gcode, ";Counter3\n"));
}
}
}