mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-23 22:54:08 -06:00
Finished porting PlaceholderParser to XS
This commit is contained in:
parent
249088b4f8
commit
580d28d071
10 changed files with 87 additions and 98 deletions
|
@ -1,28 +0,0 @@
|
|||
package Slic3r::GCode::PlaceholderParser;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub process {
|
||||
my ($self, $string, $extra) = @_;
|
||||
|
||||
# extra variables have priority over the stored ones
|
||||
if ($extra) {
|
||||
my $regex = join '|', keys %$extra;
|
||||
$string =~ s/\[($regex)\]/$extra->{$1}/eg;
|
||||
}
|
||||
{
|
||||
my $regex = join '|', @{$self->_single_keys};
|
||||
$string =~ s/\[($regex)\]/$self->_single_get("$1")/eg;
|
||||
}
|
||||
{
|
||||
my $regex = join '|', @{$self->_multiple_keys};
|
||||
$string =~ s/\[($regex)\]/$self->_multiple_get("$1")/egx;
|
||||
|
||||
# unhandled indices are populated using the first value
|
||||
$string =~ s/\[($regex)_\d+\]/$self->_multiple_get("$1")/egx;
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
1;
|
Loading…
Add table
Add a link
Reference in a new issue