Satisfy test suite with new XS based config

xs-config
Alessandro Ranellucci 2013-12-22 01:38:10 +01:00
parent 9fb62e671f
commit c0070a8d54
5 changed files with 17 additions and 17 deletions

View File

@ -905,13 +905,13 @@ sub write_gcode {
$extruder->absolute_E, $extruder->extruded_volume/1000;
}
if ($Slic3r::Config->gcode_comments) {
if ($self->config->gcode_comments) {
# append full config
print $fh "\n";
foreach my $opt_key (sort keys %{$Slic3r::Config}) {
foreach my $opt_key (sort @{$self->config->get_keys}) {
next if $Slic3r::Config::Options->{$opt_key}{shortcut};
next if $Slic3r::Config::Options->{$opt_key}{gui_only};
printf $fh "; %s = %s\n", $opt_key, $Slic3r::Config->serialize($opt_key);
printf $fh "; %s = %s\n", $opt_key, $self->config->serialize($opt_key);
}
}

View File

@ -40,7 +40,7 @@ ConfigBase::set_deserialize(const t_config_option_key opt_key, std::string str)
opt->deserialize(str);
}
float
double
ConfigBase::get_abs_value(const t_config_option_key opt_key) {
// get option definition
assert(this->def->count(opt_key) != 0);
@ -84,7 +84,7 @@ ConfigBase::get(t_config_option_key opt_key) {
} else if (ConfigOptionFloats* optv = dynamic_cast<ConfigOptionFloats*>(opt)) {
AV* av = newAV();
av_fill(av, optv->values.size()-1);
for (std::vector<float>::iterator it = optv->values.begin(); it != optv->values.end(); ++it)
for (std::vector<double>::iterator it = optv->values.begin(); it != optv->values.end(); ++it)
av_store(av, it - optv->values.begin(), newSVnv(*it));
return newRV_noinc((SV*)av);
} else if (ConfigOptionInt* optv = dynamic_cast<ConfigOptionInt*>(opt)) {

View File

@ -46,11 +46,11 @@ class ConfigOptionFloat : public ConfigOption
class ConfigOptionFloats : public ConfigOption
{
public:
std::vector<float> values;
std::vector<double> values;
std::string serialize() {
std::ostringstream ss;
for (std::vector<float>::const_iterator it = this->values.begin(); it != this->values.end(); ++it) {
for (std::vector<double>::const_iterator it = this->values.begin(); it != this->values.end(); ++it) {
if (it - this->values.begin() != 0) ss << ",";
ss << *it;
}
@ -171,7 +171,7 @@ class ConfigOptionStrings : public ConfigOption
class ConfigOptionFloatOrPercent : public ConfigOption
{
public:
float value;
double value;
bool percent;
ConfigOptionFloatOrPercent() : value(0), percent(false) {};
@ -185,7 +185,7 @@ class ConfigOptionFloatOrPercent : public ConfigOption
void deserialize(std::string str) {
if (str.find_first_of("%") != std::string::npos) {
sscanf(str.c_str(), "%f%%", &this->value);
sscanf(str.c_str(), "%lf%%", &this->value);
this->percent = true;
} else {
this->value = ::atof(str.c_str());
@ -211,7 +211,7 @@ class ConfigOptionPoint : public ConfigOption
};
void deserialize(std::string str) {
sscanf(str.c_str(), "%f%*1[,x]%f", &this->point.x, &this->point.y);
sscanf(str.c_str(), "%lf%*1[,x]%lf", &this->point.x, &this->point.y);
};
};
@ -237,7 +237,7 @@ class ConfigOptionPoints : public ConfigOption
std::string point_str;
while (std::getline(is, point_str, ',')) {
Pointf point;
sscanf(point_str.c_str(), "%fx%f", &point.x, &point.y);
sscanf(point_str.c_str(), "%lfx%lf", &point.x, &point.y);
this->points.push_back(point);
}
};
@ -392,7 +392,7 @@ class ConfigBase
void apply(ConfigBase &other, bool ignore_nonexistent = false);
std::string serialize(const t_config_option_key opt_key);
void set_deserialize(const t_config_option_key opt_key, std::string str);
float get_abs_value(const t_config_option_key opt_key);
double get_abs_value(const t_config_option_key opt_key);
#ifdef SLIC3RXS
SV* as_hash();

View File

@ -47,9 +47,9 @@ class Point
class Pointf
{
public:
float x;
float y;
explicit Pointf(float _x = 0, float _y = 0): x(_x), y(_y) {};
double x;
double y;
explicit Pointf(double _x = 0, double _y = 0): x(_x), y(_y) {};
#ifdef SLIC3RXS
void from_SV(SV* point_sv);

View File

@ -14,7 +14,7 @@
void set(t_config_option_key opt_key, SV* value);
void set_deserialize(t_config_option_key opt_key, std::string str);
std::string serialize(t_config_option_key opt_key);
float get_abs_value(t_config_option_key opt_key);
double get_abs_value(t_config_option_key opt_key);
void apply(DynamicPrintConfig* other)
%code{% THIS->apply(*other, true); %};
void apply_static(PrintConfig* other)
@ -35,7 +35,7 @@
void set(t_config_option_key opt_key, SV* value);
void set_deserialize(t_config_option_key opt_key, std::string str);
std::string serialize(t_config_option_key opt_key);
float get_abs_value(t_config_option_key opt_key);
double get_abs_value(t_config_option_key opt_key);
void apply_dynamic(DynamicPrintConfig* other)
%code{% THIS->apply(*other, true); %};
std::vector<std::string> get_keys()