Satisfy test suite with new XS based config

This commit is contained in:
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

@ -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);