-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Eviscerate mbgl expression to Foundation JSON object conversion #11389
Eviscerate mbgl expression to Foundation JSON object conversion #11389
Conversation
Tests are currently failing because of an incomplete implementation of the |
a46f9ff
to
b9575c1
Compare
for (NSExpression *component in components) { | ||
if (component.expressionType != NSConstantValueExpressionType) { | ||
return nil; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this requiring the components of an RGB(A) expression to be literals? If so, note that that isn't required by the core "rgb"
/ "rgba"
expressions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is a convenience. If it returns nil
, then the caller will synthesize a colorWithRed:green:blue:alpha:
function expression instead, which can take arbitrary expressions as the components.
84284ba
to
2bb3b5c
Compare
2bb3b5c
to
ea4c49f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is looking good.
This is what I have reviewed so far and needs to address the missing tests.
Documentation
- [ ] Public class/methods/properties/structs are documented.
- [ ] Documentation has Jazzy friendly links.
Code readability.
- [ ] Header imports are not duplicated.
- Method names has clear purpose.
- Usage of appropriate data types.
- [ ] Use of auto for C++ objects.
- [ ] Pointer returns.
Code functionality.
- [ ] Check project files are included on both platforms (ios, macos).
- Shared functionality is implemented on both platforms.
- Has no retain cycles.
- Has no side effects.
- Test cases test each scenario.
ea4c49f
to
bffc8e4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍🏼(just need to add the tests)
bffc8e4
to
6a3fd64
Compare
@@ -223,7 +223,11 @@ mbgl::Value Interpolate<T>::serialize() const { | |||
|
|||
interpolator.match( | |||
[&](const ExponentialInterpolator& exponential) { | |||
serialized.emplace_back(std::vector<mbgl::Value>{{ std::string("exponential"), exponential.base }}); | |||
if (exponential.base == 1) { | |||
serialized.emplace_back(std::vector<mbgl::Value>{{ std::string("linear") }}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@anandthakker @ChrisLoer, 02de0ce adds this special case so that ["linear"]
round-trips as ["linear"]
and not ["exponential", 1]
. This balances out the existing special case in parseInterpolate()
that converts ["linear"]
to ExponentialInterpolator(1.0)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this is a problem, actually:
[
"interpolate",
[
- "exponential",
1
+ "linear"
],
[
"heatmap-density"
],
0,
[
"rgba",
0,
0,
0,
1
],
1,
[
"rgba",
255,
0,
0,
1
]
]
* failed heatmap-density basic
This is caused by fixtures in GL JS:
We can adjust those fixtures, but I’m not sure how feasible it is to get that into the release-boba branch in time for a beta. For now, I may need to revert 02de0ce and work around this round-tripping issue in the SDK’s unit tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updating the fixtures shouldn't take too long even though there's the annoying JS/native PR dance:
- Checkout master in the gl-js submodule
- run
UPDATE=1 yarn run test-expressions
from the native side - Go go back into the submodule, verify the diff is just the exponential->linear change
- Create a GL JS PR, merge to master
- Update the pin on native
release-boba
is already on a pretty recent pin of GL JS, I don't think you should have too much trouble updating the pin.
Too bad, I thought about putting in a "linear" special case in the first place but I think we decided we didn't have a need for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries, I initially thought it would be OK because we weren’t trying to serialize to literally the same thing, only semantically the same thing. But this turned out to be one of the trickier things to work around in the SDK’s roundtripping unit tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the step-by-step explanation: #11564.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does solving this cause the opposite problem, where ["exponential", 1.0]
roundtrips as ["linear"]
rather than ["exponential", 1.0]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does, but it’s semantically equivalent, correct? Just as ["to-rgba", ["rgba", …]]
gets collapsed down to ["literal", …]
, I think it’d be slightly less surprising for roundtripping to introduce this syntactic sugar than for it to remove the syntactic sugar. That was my takeaway from #8457 anyways.
(This change is actually part of #11565; this PR is based on that one.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 makes sense, just wanted to make sure that this was the intent
db208e6
to
4aec7d8
Compare
I split out #11565 to fix the linear interpolator issue; this PR depends on it. (A bit more yarn came out than I expected there.) #11391 is once again rearing its ugly head, failing macOS builds on CI but not locally on High Sierra:
|
All the builds now pass on CI, other than nitpick, which will pass once mapbox/mapbox-gl-js#6427 and #11565 land. |
MGLJSONObjectFromMBGLValue() is just a literal translation from C++ types to Foundation types; no need for expression-specific literal wrapping.
605083a
to
99d02d4
Compare
Piggy-back on #11156 to more robustly and succintly convert
mbgl::style::expression::Expression
s to JSON-style Foundation objects.Before merging this PR, I might consider mergingMGLJSONObjectFromMBGLValue()
withValueEvaluator
.Fixes #11254. Depends on #11391 and #11565.
/cc @anandthakker