allow functions to be referenced from constants

fixes #224
This commit is contained in:
Konstantin Käfer
2014-05-21 10:29:36 +02:00
parent 7f00a63fd0
commit 752661ae6e
2 changed files with 23 additions and 19 deletions

View File

@@ -391,16 +391,18 @@ FunctionProperty::fn StyleParser::parseFunctionType(JSVal type) {
}
FunctionProperty StyleParser::parseFunction(JSVal value) {
JSVal rvalue = replaceConstant(value);
FunctionProperty property;
if (value.IsArray()) {
if (value.Size() < 1) {
if (rvalue.IsArray()) {
if (rvalue.Size() < 1) {
throw Style::exception("value function does not have arguments");
}
property.function = parseFunctionType(value[(rapidjson::SizeType)0]);
for (rapidjson::SizeType i = 1; i < value.Size(); ++i) {
JSVal stop = value[i];
property.function = parseFunctionType(rvalue[(rapidjson::SizeType)0]);
for (rapidjson::SizeType i = 1; i < rvalue.Size(); ++i) {
JSVal stop = rvalue[i];
if (stop.IsObject()) {
if (!stop.HasMember("z")) {
throw Style::exception("stop must have zoom level specification");
@@ -427,9 +429,9 @@ FunctionProperty StyleParser::parseFunction(JSVal value) {
throw Style::exception("function argument must be a numeric value");
}
}
} else if (value.IsNumber()) {
} else if (rvalue.IsNumber()) {
property.function = &functions::constant;
property.values.push_back(value.GetDouble());
property.values.push_back(rvalue.GetDouble());
}
return property;