Translate PlaceholderParser::apply_config to C++.

This commit is contained in:
Y. Sapir 2014-06-13 16:32:11 +03:00 committed by Alessandro Ranellucci
parent e88545b966
commit a837e26f51
4 changed files with 109 additions and 31 deletions

View file

@ -30,32 +30,6 @@ sub update_timestamp {
$self->_single_set('version', $Slic3r::VERSION);
}
sub apply_config {
my ($self, $config) = @_;
# options with single value
my @opt_keys = grep $Slic3r::Config::Options->{$_}{cli} !~ /\@$/,
grep !$Slic3r::Config::Options->{$_}{multiline},
@{$config->get_keys};
$self->_single_set($_, $config->serialize($_)) for @opt_keys;
# options with multiple values
foreach my $opt_key (@opt_keys) {
my $value = $config->$opt_key;
next unless ref($value) eq 'ARRAY';
# TODO: this is a workaroud for XS string param handling
# https://rt.cpan.org/Public/Bug/Display.html?id=94110
no warnings 'void';
"$_" for @$value;
$self->_multiple_set("${opt_key}_" . $_, $value->[$_]."") for 0..$#$value;
$self->_multiple_set($opt_key, $value->[0]."");
if ($Slic3r::Config::Options->{$opt_key}{type} eq 'point') {
$self->_multiple_set("${opt_key}_X", $value->[0]."");
$self->_multiple_set("${opt_key}_Y", $value->[1]."");
}
}
}
# TODO: or this could be an alias
sub set {
my ($self, $key, $val) = @_;