[core] InterpolateBase → Interpolate; Interpolate → InterpolateImpl

This commit is contained in:
John Firebaugh
2018-06-28 08:21:30 -07:00
parent 1dd35eface
commit e323daf71f
7 changed files with 25 additions and 25 deletions

View File

@@ -11,9 +11,9 @@ namespace mbgl {
namespace style {
namespace expression {
optional<variant<const InterpolateBase*, const Step*, ParsingError>> findZoomCurve(const expression::Expression* e);
optional<variant<const Interpolate*, const Step*, ParsingError>> findZoomCurve(const expression::Expression* e);
variant<const InterpolateBase*, const Step*> findZoomCurveChecked(const expression::Expression* e);
variant<const Interpolate*, const Step*> findZoomCurveChecked(const expression::Expression* e);
} // namespace expression
} // namespace style

View File

@@ -16,9 +16,9 @@ namespace expression {
ParseResult parseInterpolate(const mbgl::style::conversion::Convertible& value, ParsingContext& ctx);
class InterpolateBase : public Expression {
class Interpolate : public Expression {
public:
InterpolateBase(const type::Type& type_,
Interpolate(const type::Type& type_,
Interpolator interpolator_,
std::unique_ptr<Expression> input_,
std::map<double, std::unique_ptr<Expression>> stops_
@@ -56,7 +56,7 @@ public:
}
bool operator==(const Expression& e) const override {
if (auto rhs = dynamic_cast<const InterpolateBase*>(&e)) {
if (auto rhs = dynamic_cast<const Interpolate*>(&e)) {
if (interpolator != rhs->interpolator ||
*input != *(rhs->input) ||
stops.size() != rhs->stops.size())

View File

@@ -54,7 +54,7 @@ public:
float interpolationFactor(const Range<float>& inputLevels, const float inputValue) const {
return zoomCurve.match(
[&](const expression::InterpolateBase* z) {
[&](const expression::Interpolate* z) {
return z->interpolationFactor(Range<double> { inputLevels.min, inputLevels.max }, inputValue);
},
[&](const expression::Step*) { return 0.0f; }
@@ -83,7 +83,7 @@ public:
private:
std::shared_ptr<expression::Expression> expression;
const variant<const expression::InterpolateBase*, const expression::Step*> zoomCurve;
const variant<const expression::Interpolate*, const expression::Step*> zoomCurve;
};
} // namespace style

View File

@@ -89,7 +89,7 @@ public:
float interpolationFactor(const Range<float>& inputLevels, const float inputValue) const {
return zoomCurve.match(
[&](const expression::InterpolateBase* z) {
[&](const expression::Interpolate* z) {
return z->interpolationFactor(Range<double> { inputLevels.min, inputLevels.max }, inputValue);
},
[&](const expression::Step*) { return 0.0f; }
@@ -119,7 +119,7 @@ public:
private:
optional<T> defaultValue;
std::shared_ptr<expression::Expression> expression;
const variant<const expression::InterpolateBase*, const expression::Step*> zoomCurve;
const variant<const expression::Interpolate*, const expression::Step*> zoomCurve;
};
} // namespace style

View File

@@ -10,8 +10,8 @@ namespace mbgl {
namespace style {
namespace expression {
optional<variant<const InterpolateBase*, const Step*, ParsingError>> findZoomCurve(const expression::Expression* e) {
optional<variant<const InterpolateBase*, const Step*, ParsingError>> result;
optional<variant<const Interpolate*, const Step*, ParsingError>> findZoomCurve(const expression::Expression* e) {
optional<variant<const Interpolate*, const Step*, ParsingError>> result;
if (auto let = dynamic_cast<const Let*>(e)) {
result = findZoomCurve(let->getResult());
@@ -23,7 +23,7 @@ optional<variant<const InterpolateBase*, const Step*, ParsingError>> findZoomCur
break;
}
}
} else if (auto curve = dynamic_cast<const InterpolateBase*>(e)) {
} else if (auto curve = dynamic_cast<const Interpolate*>(e)) {
auto z = dynamic_cast<CompoundExpressionBase*>(curve->getInput().get());
if (z && z->getName() == "zoom") {
result = {curve};
@@ -40,7 +40,7 @@ optional<variant<const InterpolateBase*, const Step*, ParsingError>> findZoomCur
}
e->eachChild([&](const Expression& child) {
optional<variant<const InterpolateBase*, const Step*, ParsingError>> childResult(findZoomCurve(&child));
optional<variant<const Interpolate*, const Step*, ParsingError>> childResult(findZoomCurve(&child));
if (childResult) {
if (childResult->is<ParsingError>()) {
result = childResult;
@@ -59,13 +59,13 @@ optional<variant<const InterpolateBase*, const Step*, ParsingError>> findZoomCur
return result;
}
variant<const InterpolateBase*, const Step*> findZoomCurveChecked(const expression::Expression* e) {
variant<const Interpolate*, const Step*> findZoomCurveChecked(const expression::Expression* e) {
return findZoomCurve(e)->match(
[](const ParsingError&) -> variant<const InterpolateBase*, const Step*> {
[](const ParsingError&) -> variant<const Interpolate*, const Step*> {
assert(false);
return {};
},
[](auto zoomCurve) -> variant<const InterpolateBase*, const Step*> {
[](auto zoomCurve) -> variant<const Interpolate*, const Step*> {
return {std::move(zoomCurve)};
}
);

View File

@@ -8,13 +8,13 @@ namespace expression {
using namespace mbgl::style::conversion;
template <typename T>
class Interpolate : public InterpolateBase {
class InterpolateImpl : public Interpolate {
public:
Interpolate(type::Type type_,
InterpolateImpl(type::Type type_,
Interpolator interpolator_,
std::unique_ptr<Expression> input_,
std::map<double, std::unique_ptr<Expression>> stops_
) : InterpolateBase(std::move(type_), std::move(interpolator_), std::move(input_), std::move(stops_))
) : Interpolate(std::move(type_), std::move(interpolator_), std::move(input_), std::move(stops_))
{
static_assert(util::Interpolatable<T>::value, "Interpolate expression requires an interpolatable value type.");
}
@@ -235,12 +235,12 @@ ParseResult createInterpolate(type::Type type,
ParsingContext& ctx) {
return type.match(
[&](const type::NumberType&) -> ParseResult {
return ParseResult(std::make_unique<Interpolate<double>>(
return ParseResult(std::make_unique<InterpolateImpl<double>>(
type, interpolator, std::move(input), std::move(stops)
));
},
[&](const type::ColorType&) -> ParseResult {
return ParseResult(std::make_unique<Interpolate<Color>>(
return ParseResult(std::make_unique<InterpolateImpl<Color>>(
type, interpolator, std::move(input), std::move(stops)
));
},
@@ -249,7 +249,7 @@ ParseResult createInterpolate(type::Type type,
ctx.error("Type " + toString(type) + " is not interpolatable.");
return ParseResult();
}
return ParseResult(std::make_unique<Interpolate<std::vector<Value>>>(
return ParseResult(std::make_unique<InterpolateImpl<std::vector<Value>>>(
type, interpolator, std::move(input), std::move(stops)
));
},
@@ -260,7 +260,7 @@ ParseResult createInterpolate(type::Type type,
);
}
std::vector<optional<Value>> InterpolateBase::possibleOutputs() const {
std::vector<optional<Value>> Interpolate::possibleOutputs() const {
std::vector<optional<Value>> result;
for (const auto& stop : stops) {
for (auto& output : stop.second->possibleOutputs()) {
@@ -270,7 +270,7 @@ std::vector<optional<Value>> InterpolateBase::possibleOutputs() const {
return result;
}
mbgl::Value InterpolateBase::serialize() const {
mbgl::Value Interpolate::serialize() const {
std::vector<mbgl::Value> serialized;
serialized.emplace_back(getOperator());

View File

@@ -216,7 +216,7 @@ ParseResult ParsingContext::parseExpression(const Convertible& value, TypeAnnota
ParseResult ParsingContext::parseLayerPropertyExpression(const Convertible& value, TypeAnnotationOption typeAnnotationOption) {
ParseResult parsed = parse(value, typeAnnotationOption);
if (parsed && !isZoomConstant(**parsed)) {
optional<variant<const InterpolateBase*, const Step*, ParsingError>> zoomCurve = findZoomCurve(parsed->get());
optional<variant<const Interpolate*, const Step*, ParsingError>> zoomCurve = findZoomCurve(parsed->get());
if (!zoomCurve) {
error(R"("zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.)");
return ParseResult();