Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[ios, macos] Map style spec expression operators to expression syntaxes
Browse files Browse the repository at this point in the history
  • Loading branch information
1ec5 committed Dec 18, 2017
1 parent f934d41 commit c67744f
Show file tree
Hide file tree
Showing 4 changed files with 203 additions and 2 deletions.
67 changes: 67 additions & 0 deletions platform/darwin/docs/guides/For Style Authors.md.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,73 @@ translation downward. This is the reverse of how `CGVector` is interpreted on
iOS.
<% } -%>
### Expression operators
In style specification | Method, function, or predicate type | Format string syntax
-----------------------|-------------------------------------|---------------------
`array` | |
`boolean` | |
`literal` | `+[NSExpression expressionForConstantValue:]` | `%@` representing `NSArray` or `NSDictionary`
`number` | |
`string` | |
`to-boolean` | `boolValue` |
`to-color` | |
`to-number` | `mgl_numberWithFallbackValues:` |
`to-string` | `stringValue` |
`typeof` | |
`geometry-type` | |
`id` | |
`properties` | |
`at` | |
`get` | `+[NSExpression expressionForKeyPath:]` | Key path
`has` | |
`length` | `count:` | `count({1, 2, 2, 3, 4, 7, 9})`
`!` | `NSNotPredicateType` | `NOT (p0 OR … OR pn)`
`!=` | `NSNotEqualToPredicateOperatorType` | `key != value`
`<` | `NSLessThanPredicateOperatorType` | `key < value`
`<=` | `NSLessThanOrEqualToPredicateOperatorType` | `key <= value`
`==` | `NSEqualToPredicateOperatorType` | `key == value`
`>` | `NSGreaterThanPredicateOperatorType` | `key > value`
`>=` | `NSGreaterThanOrEqualToPredicateOperatorType` | `key >= value`
`all` | `NSAndPredicateType` | `p0 AND … AND pn`
`any` | `NSOrPredicateType` | `p0 OR … OR pn`
`case` | `+[NSExpression expressionForConditional:trueExpression:falseExpression:]` | `TERNARY(condition, trueExpression, falseExpression)`
`coalesce` | |
`match` | |
`interpolate` | `mgl_interpolateWithCurveType:parameters:stops:` |
`step` | `mgl_stepWithMinimum:stops:` |
`let` | `mgl_expressionWithContext:` |
`var` | `+[NSExpression expressionForVariable:]` | `$variable`
`concat` | `stringByAppendingString:` |
`downcase` | `lowercase:` | `lowercase('DOWNTOWN')`
`upcase` | `uppercase:` | `uppercase('Elysian Fields')`
`rgb` | |
`rgba` | |
`to-rgba` | |
`-` | `from:subtract:` | `2 - 1`
`*` | `multiply:by:` | `1 * 2`
`/` | `divide:by:` | `1 / 2`
`%` | `modulus:by:` |
`^` | `raise:toPower:` | `2 ** 2`
`+` | `add:to:` | `1 + 2`
`acos` | |
`asin` | |
`atan` | |
`cos` | |
`e` | | `%@` representing `NSNumber` containing `M_E`
`ln` | `ln:` | `ln(2)`
`ln2` | |
`log10` | `log:` | `log(1)`
`log2` | |
`max` | `max:` | `max({1, 2, 2, 3, 4, 7, 9})`
`min` | `min:` | `min({1, 2, 2, 3, 4, 7, 9})`
`pi` | | `%@` representing `NSNumber` containing `M_PI`
`sin` | |
`sqrt` | `sqrt:` | `sqrt(2)`
`tan` | |
`zoom` | | `$zoom`
`heatmap-density` | | `$heatmapDensity`
### Style functions
A _style function_ allows you to vary the value of a layout or paint attribute
Expand Down
4 changes: 2 additions & 2 deletions platform/darwin/docs/guides/Predicates and Expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ The following comparison operators are supported:

The following compound operators are supported:

`NSPredicateOperatorType` | Format string syntax
`NSCompoundPredicateType` | Format string syntax
--------------------------|---------------------
`NSAndPredicateType` | `predicate1 AND predicate2`<br />`predicate1 && predicate2`
`NSOrPredicateType` | `predicate1 OR predicate2`<br />`predicate1 || predicate2`
Expand Down Expand Up @@ -152,7 +152,7 @@ Initializer parameter | Format string syntax
`modulus:by:` | `modulus:by:(1, 2)`
`sqrt:` | `sqrt(2)`
`log:` | `log(10)`
`ln:` | `log(e)`
`ln:` | `ln(2)`
`raise:toPower:` | `2 ** 2`
`exp:` | `exp(0)`
`ceiling:` | `ceiling(0.99999)`
Expand Down
67 changes: 67 additions & 0 deletions platform/ios/docs/guides/For Style Authors.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,73 @@ in Swift
are specified in counterclockwise order, in contrast to the clockwise order
defined by the style specification.

### Expression operators

In style specification | Method, function, or predicate type | Format string syntax
-----------------------|-------------------------------------|---------------------
`array` | |
`boolean` | |
`literal` | `+[NSExpression expressionForConstantValue:]` | `%@` representing `NSArray` or `NSDictionary`
`number` | |
`string` | |
`to-boolean` | `boolValue` |
`to-color` | |
`to-number` | `mgl_numberWithFallbackValues:` |
`to-string` | `stringValue` |
`typeof` | |
`geometry-type` | |
`id` | |
`properties` | |
`at` | |
`get` | `+[NSExpression expressionForKeyPath:]` | Key path
`has` | |
`length` | `count:` | `count({1, 2, 2, 3, 4, 7, 9})`
`!` | `NSNotPredicateType` | `NOT (p0 OR … OR pn)`
`!=` | `NSNotEqualToPredicateOperatorType` | `key != value`
`<` | `NSLessThanPredicateOperatorType` | `key < value`
`<=` | `NSLessThanOrEqualToPredicateOperatorType` | `key <= value`
`==` | `NSEqualToPredicateOperatorType` | `key == value`
`>` | `NSGreaterThanPredicateOperatorType` | `key > value`
`>=` | `NSGreaterThanOrEqualToPredicateOperatorType` | `key >= value`
`all` | `NSAndPredicateType` | `p0 AND … AND pn`
`any` | `NSOrPredicateType` | `p0 OR … OR pn`
`case` | `+[NSExpression expressionForConditional:trueExpression:falseExpression:]` | `TERNARY(condition, trueExpression, falseExpression)`
`coalesce` | |
`match` | |
`interpolate` | `mgl_interpolateWithCurveType:parameters:stops:` |
`step` | `mgl_stepWithMinimum:stops:` |
`let` | `mgl_expressionWithContext:` |
`var` | `+[NSExpression expressionForVariable:]` | `$variable`
`concat` | `stringByAppendingString:` |
`downcase` | `lowercase:` | `lowercase('DOWNTOWN')`
`upcase` | `uppercase:` | `uppercase('Elysian Fields')`
`rgb` | |
`rgba` | |
`to-rgba` | |
`-` | `from:subtract:` | `2 - 1`
`*` | `multiply:by:` | `1 * 2`
`/` | `divide:by:` | `1 / 2`
`%` | `modulus:by:` |
`^` | `raise:toPower:` | `2 ** 2`
`+` | `add:to:` | `1 + 2`
`acos` | |
`asin` | |
`atan` | |
`cos` | |
`e` | | `%@` representing `NSNumber` containing `M_E`
`ln` | `ln:` | `ln(2)`
`ln2` | |
`log10` | `log:` | `log(1)`
`log2` | |
`max` | `max:` | `max({1, 2, 2, 3, 4, 7, 9})`
`min` | `min:` | `min({1, 2, 2, 3, 4, 7, 9})`
`pi` | | `%@` representing `NSNumber` containing `M_PI`
`sin` | |
`sqrt` | `sqrt:` | `sqrt(2)`
`tan` | |
`zoom` | | `$zoom`
`heatmap-density` | | `$heatmapDensity`

### Style functions

A _style function_ allows you to vary the value of a layout or paint attribute
Expand Down
67 changes: 67 additions & 0 deletions platform/macos/docs/guides/For Style Authors.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,73 @@ offset or translation upward, while a negative `CGVector.dy` means an offset or
translation downward. This is the reverse of how `CGVector` is interpreted on
iOS.

### Expression operators

In style specification | Method, function, or predicate type | Format string syntax
-----------------------|-------------------------------------|---------------------
`array` | |
`boolean` | |
`literal` | `+[NSExpression expressionForConstantValue:]` | `%@` representing `NSArray` or `NSDictionary`
`number` | |
`string` | |
`to-boolean` | `boolValue` |
`to-color` | |
`to-number` | `mgl_numberWithFallbackValues:` |
`to-string` | `stringValue` |
`typeof` | |
`geometry-type` | |
`id` | |
`properties` | |
`at` | |
`get` | `+[NSExpression expressionForKeyPath:]` | Key path
`has` | |
`length` | `count:` | `count({1, 2, 2, 3, 4, 7, 9})`
`!` | `NSNotPredicateType` | `NOT (p0 OR … OR pn)`
`!=` | `NSNotEqualToPredicateOperatorType` | `key != value`
`<` | `NSLessThanPredicateOperatorType` | `key < value`
`<=` | `NSLessThanOrEqualToPredicateOperatorType` | `key <= value`
`==` | `NSEqualToPredicateOperatorType` | `key == value`
`>` | `NSGreaterThanPredicateOperatorType` | `key > value`
`>=` | `NSGreaterThanOrEqualToPredicateOperatorType` | `key >= value`
`all` | `NSAndPredicateType` | `p0 AND … AND pn`
`any` | `NSOrPredicateType` | `p0 OR … OR pn`
`case` | `+[NSExpression expressionForConditional:trueExpression:falseExpression:]` | `TERNARY(condition, trueExpression, falseExpression)`
`coalesce` | |
`match` | |
`interpolate` | `mgl_interpolateWithCurveType:parameters:stops:` |
`step` | `mgl_stepWithMinimum:stops:` |
`let` | `mgl_expressionWithContext:` |
`var` | `+[NSExpression expressionForVariable:]` | `$variable`
`concat` | `stringByAppendingString:` |
`downcase` | `lowercase:` | `lowercase('DOWNTOWN')`
`upcase` | `uppercase:` | `uppercase('Elysian Fields')`
`rgb` | |
`rgba` | |
`to-rgba` | |
`-` | `from:subtract:` | `2 - 1`
`*` | `multiply:by:` | `1 * 2`
`/` | `divide:by:` | `1 / 2`
`%` | `modulus:by:` |
`^` | `raise:toPower:` | `2 ** 2`
`+` | `add:to:` | `1 + 2`
`acos` | |
`asin` | |
`atan` | |
`cos` | |
`e` | | `%@` representing `NSNumber` containing `M_E`
`ln` | `ln:` | `ln(2)`
`ln2` | |
`log10` | `log:` | `log(1)`
`log2` | |
`max` | `max:` | `max({1, 2, 2, 3, 4, 7, 9})`
`min` | `min:` | `min({1, 2, 2, 3, 4, 7, 9})`
`pi` | | `%@` representing `NSNumber` containing `M_PI`
`sin` | |
`sqrt` | `sqrt:` | `sqrt(2)`
`tan` | |
`zoom` | | `$zoom`
`heatmap-density` | | `$heatmapDensity`

### Style functions

A _style function_ allows you to vary the value of a layout or paint attribute
Expand Down

0 comments on commit c67744f

Please sign in to comment.