Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/xs
diff options
context:
space:
mode:
authorVojtech Bubnik <bubnikv@gmail.com>2021-06-27 17:04:23 +0300
committerVojtech Bubnik <bubnikv@gmail.com>2021-06-27 17:57:05 +0300
commit0f3cabb5d9c62649c9055798566be1c00533279f (patch)
tree76755bc077e20f22d8ea1860fbcad23e985864c1 /xs
parentad336e2cc0eeb0c42abefb0755607bb252842b6f (diff)
Support for forward compatibility of configurations, user and system
config bundles, project files (3MFs, AMFs). When loading these files, the caller may decide whether to substitute some of the configuration values the current PrusaSlicer version does not understand with some reasonable default value, and whether to report it. If substitution is disabled, an exception is being thrown as before this commit. If substitution is enabled, list of substitutions is returned by the API to be presented to the user. This allows us to introduce for example new firmware flavor key in PrusaSlicer 2.4 while letting PrusaSlicer 2.3.2 to fall back to some default and to report it to the user. When slicing from command line, substutions are performed by default and reported into the console, however substitutions may be either disabled or made silent with the new "config-compatibility" command line option. Substitute enums and bools only. Allow booleans to be parsed as true: "1", "enabled", "on" case insensitive false: "0", "disabled", "off" case insensitive This will allow us in the future for example to switch the draft_shield boolean to an enum with the following values: "disabled" / "enabled" / "limited". Added "enum_bitmask.hpp" - support for type safe sets of options. See for example PresetBundle::load_configbundle(... LoadConfigBundleAttributes flags) for an example of intended usage. WIP: GUI for reporting the list of config substitutions needs to be implemented by @YuSanka.
Diffstat (limited to 'xs')
-rw-r--r--xs/src/perlglue.cpp5
-rw-r--r--xs/xsp/Config.xsp4
-rw-r--r--xs/xsp/Flow.xsp2
-rw-r--r--xs/xsp/Model.xsp2
4 files changed, 7 insertions, 6 deletions
diff --git a/xs/src/perlglue.cpp b/xs/src/perlglue.cpp
index aec6ceb6a..20288243e 100644
--- a/xs/src/perlglue.cpp
+++ b/xs/src/perlglue.cpp
@@ -282,7 +282,7 @@ bool ConfigBase__set(ConfigBase* THIS, const t_config_option_key &opt_key, SV* v
break;
}
default:
- if (! opt->deserialize(std::string(SvPV_nolen(value))))
+ if (! opt->deserialize(std::string(SvPV_nolen(value)), ForwardCompatibilitySubstitutionRule::Disable))
return false;
}
return true;
@@ -295,7 +295,8 @@ bool ConfigBase__set_deserialize(ConfigBase* THIS, const t_config_option_key &op
size_t len;
const char * c = SvPV(str, len);
std::string value(c, len);
- return THIS->set_deserialize_nothrow(opt_key, value);
+ ConfigSubstitutionContext ctxt{ ForwardCompatibilitySubstitutionRule::Disable };
+ return THIS->set_deserialize_nothrow(opt_key, value, ctxt);
}
void ConfigBase__set_ifndef(ConfigBase* THIS, const t_config_option_key &opt_key, SV* value, bool deserialize)
diff --git a/xs/xsp/Config.xsp b/xs/xsp/Config.xsp
index 52a5e7d83..703427035 100644
--- a/xs/xsp/Config.xsp
+++ b/xs/xsp/Config.xsp
@@ -55,7 +55,7 @@
%code%{
auto config = new DynamicPrintConfig();
try {
- config->load(path);
+ config->load(path, ForwardCompatibilitySubstitutionRule::Disable);
RETVAL = config;
} catch (std::exception& e) {
delete config;
@@ -119,7 +119,7 @@
%code%{
auto config = new FullPrintConfig();
try {
- config->load(path);
+ config->load(path, ForwardCompatibilitySubstitutionRule::Disable);
RETVAL = static_cast<GCodeConfig*>(config);
} catch (std::exception& e) {
delete config;
diff --git a/xs/xsp/Flow.xsp b/xs/xsp/Flow.xsp
index 019af16f2..3056b4001 100644
--- a/xs/xsp/Flow.xsp
+++ b/xs/xsp/Flow.xsp
@@ -30,7 +30,7 @@ _new_from_width(CLASS, role, width, nozzle_diameter, height)
float height;
CODE:
ConfigOptionFloatOrPercent optwidth;
- optwidth.deserialize(width);
+ optwidth.deserialize(width, ForwardCompatibilitySubstitutionRule::Disable);
RETVAL = new Flow(Flow::new_from_config_width(role, optwidth, nozzle_diameter, height));
OUTPUT:
RETVAL
diff --git a/xs/xsp/Model.xsp b/xs/xsp/Model.xsp
index 93067ebe3..e7a171efd 100644
--- a/xs/xsp/Model.xsp
+++ b/xs/xsp/Model.xsp
@@ -22,7 +22,7 @@
%name{read_from_file} Model(std::string input_file, bool add_default_instances = true)
%code%{
try {
- RETVAL = new Model(Model::read_from_file(input_file, nullptr, add_default_instances));
+ RETVAL = new Model(Model::read_from_file(input_file, nullptr, nullptr, only_if(add_default_instances, Model::LoadAttribute::AddDefaultInstances)));
} catch (std::exception& e) {
croak("Error while opening %s: %s\n", input_file.c_str(), e.what());
}