* [core] Bump gl-js version * [core] Implement image expression * [core] Use new image expression * [core] Coerce image expression to / from string * [core] Serialize evaluated image * [core] Pass available images to layout * [core] Pass images to evaluation context * [core] Set available flag value based on image availability * [core] Allow image coercion to boolean to indicate image availability * [core] Coalesce image expression * [core] Add image expression to next build system * [core] Align serialization format and evaluated type with gl-js * [core] Add images to expression evaluation method * [core] Add support for Image expression to expression test runner * [core] Unskip image expression tests * [core] Update unit tests * [core] Use image expression in annotation manager * [core] Add string to ImageExpression conversion * [core] Add image expression to expression dsl * [core] Convert tokens for implicitly created Image literal * [core] Fix clang format * [core] Split generated style code lines that are over 120 characters * [core] Add unit test for image expression equality * [core] Add image property expression evaluation unit test * [core] Unskip image expression render test * [core] Skip 'in' expression tests * [core] Ignore fill-pattern/update-feature-state render test * [core] Rename Image::serialize to Image::toValue
101 lines
2.9 KiB
C++
101 lines
2.9 KiB
C++
#pragma once
|
|
|
|
#include "filesystem.hpp"
|
|
|
|
#include <mbgl/style/expression/expression.hpp>
|
|
#include <mbgl/util/feature.hpp>
|
|
#include <mbgl/util/optional.hpp>
|
|
#include <mbgl/util/rapidjson.hpp>
|
|
|
|
#include <set>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
using namespace mbgl;
|
|
|
|
struct Input {
|
|
Input(optional<float> zoom_,
|
|
optional<double> heatmapDensity_,
|
|
std::set<std::string> availableImages_,
|
|
Feature feature_)
|
|
: zoom(std::move(zoom_)),
|
|
heatmapDensity(std::move(heatmapDensity_)),
|
|
availableImages(std::move(availableImages_)),
|
|
feature(std::move(feature_)) {}
|
|
optional<float> zoom;
|
|
optional<double> heatmapDensity;
|
|
std::set<std::string> availableImages;
|
|
Feature feature;
|
|
};
|
|
|
|
struct Compiled {
|
|
bool operator==(const Compiled& other) const {
|
|
bool typeEqual = success == other.success &&
|
|
isFeatureConstant == other.isFeatureConstant &&
|
|
isZoomConstant == other.isZoomConstant &&
|
|
serializedType == other.serializedType &&
|
|
errors == other.errors;
|
|
return typeEqual;
|
|
}
|
|
|
|
bool success = false;
|
|
bool isFeatureConstant = false;
|
|
bool isZoomConstant = false;
|
|
std::string serializedType;
|
|
std::vector<Value> errors;
|
|
};
|
|
|
|
struct TestResult {
|
|
Compiled compiled;
|
|
optional<Value> expression;
|
|
optional<Value> outputs;
|
|
optional<Value> serialized;
|
|
};
|
|
|
|
struct PropertySpec {
|
|
std::string type;
|
|
std::string value;
|
|
std::size_t length = 0;
|
|
bool isDataDriven = false;
|
|
optional<Value> expression;
|
|
};
|
|
|
|
class TestData {
|
|
public:
|
|
std::vector<Input> inputs;
|
|
TestResult expected;
|
|
TestResult result;
|
|
TestResult recompiled;
|
|
optional<PropertySpec> spec;
|
|
JSDocument document;
|
|
};
|
|
|
|
struct Ignore {
|
|
Ignore(std::string id_, std::string reason_)
|
|
: id(std::move(id_)),
|
|
reason(std::move(reason_)) {}
|
|
|
|
std::string id;
|
|
std::string reason;
|
|
};
|
|
|
|
using Arguments = std::tuple<filesystem::path, std::vector<filesystem::path>, bool, uint32_t>;
|
|
Arguments parseArguments(int argc, char** argv);
|
|
|
|
using Ignores = std::vector<Ignore>;
|
|
Ignores parseExpressionIgnores();
|
|
optional<TestData> parseTestData(const filesystem::path&);
|
|
|
|
std::string toJSON(const Value& value, unsigned indent = 0, bool singleLine = false);
|
|
JSDocument toDocument(const Value&);
|
|
Value toValue(const Compiled&);
|
|
optional<Value> toValue(const style::expression::Value&);
|
|
|
|
std::unique_ptr<style::expression::Expression> parseExpression(const JSValue&,
|
|
optional<PropertySpec>&,
|
|
TestResult&);
|
|
std::unique_ptr<style::expression::Expression> parseExpression(const optional<Value>&,
|
|
optional<PropertySpec>&,
|
|
TestResult&);
|
|
|