diff --git a/examples/style/hex-layout.sky b/examples/style/hex-layout.sky index 3f223c39558..15982a0af08 100644 --- a/examples/style/hex-layout.sky +++ b/examples/style/hex-layout.sky @@ -115,8 +115,8 @@ } } sky.registerLayoutManager('beehive', BeehiveLayoutManager); - let BeehiveCountStyleValueType = new StyleValueType(); - BeehiveCountStyleValueType.addParser((tokens) => { + let BeehiveCountStyleGrammar = new StyleGrammar(); + BeehiveCountStyleGrammar.addParser((tokens) => { let token = tokens.next(); if (token.done) throw new Error(); @@ -126,13 +126,11 @@ throw new Error(); if (Math.trunc(token.value.value) != token.value.value) // is integer throw new Error(); - return { - value: token.value.value; - } + return new NumericStyleValue(token.value.value); }); sky.registerProperty({ name: 'beehive-count', - type: BeehiveCountStyleValueType, + type: BeehiveCountStyleGrammar, inherits: true, initialValue: 5, needsLayout: true, diff --git a/examples/style/sky-core-styles.sky b/examples/style/sky-core-styles.sky index 640236ae40c..fdc20f4ba1b 100644 --- a/examples/style/sky-core-styles.sky +++ b/examples/style/sky-core-styles.sky @@ -21,8 +21,8 @@ SKY MODULE displayTypes.set(displayValue, layoutManagerConstructor); }; - module.exports.DisplayStyleValueType = new StyleValueType(); // value is null or a LayoutManagerConstructor - module.exports.DisplayStyleValueType.addParser((tokens) => { + module.exports.DisplayStyleGrammar = new StyleGrammar(); // value is null or a LayoutManagerConstructor + module.exports.DisplayStyleGrammar.addParser((tokens) => { let token = tokens.next(); if (token.done) throw new Error(); @@ -37,14 +37,14 @@ SKY MODULE internals.registerProperty({ name: 'display', - type: module.exports.DisplayStyleValueType, + type: module.exports.DisplayStyleGrammar, inherits: false, initialValue: internals.BlockLayoutManager, needsLayout: true, }); - module.exports.PositiveLengthStyleValueType = new StyleValueType(); // value is a ParsedValue whose value (once resolved) is a number in 96dpi pixels, >=0 - module.exports.PositiveLengthStyleValueType.addParser((tokens) => { + module.exports.PositiveLengthStyleGrammar = new StyleGrammar(); // value is a ParsedValue whose value (once resolved) is a number in 96dpi pixels, >=0 + module.exports.PositiveLengthStyleGrammar.addParser((tokens) => { // just handle "px" let token = tokens.next(); if (token.done) @@ -62,21 +62,21 @@ SKY MODULE internals.registerProperty({ name: 'min-width', - type: module.exports.PositiveLengthStyleValueType, + type: module.exports.PositiveLengthStyleGrammar, inherits: false, initialValue: 0, needsLayout: true, }); internals.registerProperty({ name: 'min-height', - type: module.exports.PositiveLengthStyleValueType, + type: module.exports.PositiveLengthStyleGrammar, inherits: false, initialValue: 0, needsLayout: true, }); - module.exports.PositiveLengthOrAutoStyleValueType = new StyleValueType(); // value is a ParsedValue whose value (once resolved) is either a number in 96dpi pixels (>=0) or null (meaning 'auto') - module.exports.PositiveLengthOrAutoStyleValueType.addParser((tokens) => { + module.exports.PositiveLengthOrAutoStyleGrammar = new StyleGrammar(); // value is a ParsedValue whose value (once resolved) is either a number in 96dpi pixels (>=0) or null (meaning 'auto') + module.exports.PositiveLengthOrAutoStyleGrammar.addParser((tokens) => { // handle 'auto' let token = tokens.next(); if (token.done) @@ -89,27 +89,27 @@ SKY MODULE value: null, }; }); - module.exports.PositiveLengthOrAutoStyleValueType.addParser((tokens) => { - return module.exports.PositiveLengthStyleValueType.parse(tokens); + module.exports.PositiveLengthOrAutoStyleGrammar.addParser((tokens) => { + return module.exports.PositiveLengthStyleGrammar.parse(tokens); }); internals.registerProperty({ name: 'width', - type: module.exports.PositiveLengthOrAutoStyleValueType, + type: module.exports.PositiveLengthOrAutoStyleGrammar, inherits: false, initialValue: null, needsLayout: true, }); internals.registerProperty({ name: 'height', - type: module.exporets.PositiveLengthOrAutoStyleValueType, + type: module.exporets.PositiveLengthOrAutoStyleGrammar, inherits: false, initialValue: null, needsLayout: true, }); - module.exports.PositiveLengthOrInfinityStyleValueType = new StyleValueType(); // value is a ParsedValue whose value (once resolved) is either a number in 96dpi pixels (>=0) or Infinity - module.exports.PositiveLengthOrInfinityStyleValueType.addParser((tokens) => { + module.exports.PositiveLengthOrInfinityStyleGrammar = new StyleGrammar(); // value is a ParsedValue whose value (once resolved) is either a number in 96dpi pixels (>=0) or Infinity + module.exports.PositiveLengthOrInfinityStyleGrammar.addParser((tokens) => { // handle 'infinity' let token = tokens.next(); if (token.done) @@ -122,20 +122,20 @@ SKY MODULE value: Infinity, }; }); - module.exports.PositiveLengthOrInfinityStyleValueType.addParser((tokens) => { - return module.exports.PositiveLengthStyleValueType.parse(tokens); + module.exports.PositiveLengthOrInfinityStyleGrammar.addParser((tokens) => { + return module.exports.PositiveLengthStyleGrammar.parse(tokens); }); internals.registerProperty({ name: 'width', - type: module.exports.PositiveLengthOrInfinityStyleValueType, + type: module.exports.PositiveLengthOrInfinityStyleGrammar, inherits: false, initialValue: Infinity, needsLayout: true, }); internals.registerProperty({ name: 'height', - type: module.exporets.PositiveLengthOrInfinityStyleValueType, + type: module.exporets.PositiveLengthOrInfinityStyleGrammar, inherits: false, initialValue: Infinity, needsLayout: true, diff --git a/examples/style/toolbar-layout.sky b/examples/style/toolbar-layout.sky index e290eb22922..c806067e528 100644 --- a/examples/style/toolbar-layout.sky +++ b/examples/style/toolbar-layout.sky @@ -10,7 +10,7 @@ SKY MODULE sky.registerLayoutManager('spring', module.exports.SpringLayoutManager); sky.registerProperty({ name: 'toolbar-spacing', - type: sky.PositiveLengthStyleValueType, + type: sky.PositiveLengthStyleGrammar, inherits: true, initialValue: 8, needsLayout: true,