Looks like the reworked C++ preferences start to work again.

This commit is contained in:
bubnikv 2017-11-02 16:21:34 +01:00
parent 95c284c764
commit e8b6d92d4d
26 changed files with 469 additions and 512 deletions

View file

@ -12,14 +12,14 @@ use List::Util qw(first max);
# The C++ counterpart is a constant singleton.
our $Options = print_config_def();
# overwrite the hard-coded readonly value (this information is not available in XS)
$Options->{threads}{readonly} = !$Slic3r::have_threads;
# generate accessors
# Generate accessors.
{
no strict 'refs';
for my $opt_key (keys %$Options) {
*{$opt_key} = sub { $_[0]->get($opt_key) };
*{$opt_key} = sub {
#print "Slic3r::Config::accessor $opt_key\n";
$_[0]->get($opt_key)
};
}
}
@ -64,61 +64,6 @@ sub new_from_cli {
return $self;
}
# CLASS METHODS:
# Write a "Windows" style ini file with categories enclosed in squre brackets.
# Used by config-bundle-to-config.pl and to save slic3r.ini.
sub write_ini {
my $class = shift;
my ($file, $ini) = @_;
Slic3r::open(\my $fh, '>', $file);
binmode $fh, ':utf8';
my $localtime = localtime;
printf $fh "# generated by Slic3r $Slic3r::VERSION on %s\n", "$localtime";
# make sure the _ category is the first one written
foreach my $category (sort { ($a eq '_') ? -1 : ($a cmp $b) } keys %$ini) {
printf $fh "\n[%s]\n", $category if $category ne '_';
foreach my $key (sort keys %{$ini->{$category}}) {
printf $fh "%s = %s\n", $key, $ini->{$category}{$key};
}
}
close $fh;
}
# Parse a "Windows" style ini file with categories enclosed in squre brackets.
# Returns a hash of hashes over strings.
# {category}{name}=value
# Non-categorized entries are stored under a category '_'.
# Used by config-bundle-to-config.pl and to read slic3r.ini.
sub read_ini {
my $class = shift;
my ($file) = @_;
local $/ = "\n";
Slic3r::open(\my $fh, '<', $file)
or die "Unable to open $file: $!\n";
binmode $fh, ':utf8';
my $ini = { _ => {} };
my $category = '_';
while (<$fh>) {
s/\R+$//;
next if /^\s+/;
next if /^$/;
next if /^\s*#/;
if (/^\[(.+?)\]$/) {
$category = $1;
next;
}
/^(\w+) *= *(.*)/ or die "Unreadable configuration file (invalid data at line $.)\n";
$ini->{$category}{$1} = $2;
}
close $fh;
return $ini;
}
package Slic3r::Config::Static;
use parent 'Slic3r::Config';