Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3D Tiles Styling - Check for type mismatches in JS and shader backends #4860

Merged
merged 4 commits into from
Jan 17, 2017

Conversation

lilleyse
Copy link
Contributor

Based on discussion here: CesiumGS/3d-tiles#166

To start this goes through the unary and binary operators and throws errors if the arguments are not the same type. There's a bit more work to be done with the math library, vector constructors, etc.

In some ways this PR is starting the process of changing the styling language to not be as dependent on JavaScript type-conversion rules. Is the end goal of the spec to not rely on JavaScript conventions at all?

@lilleyse
Copy link
Contributor Author

Some tests are broken and I need to write new tests. I don't want to get too far into this unless this is the right direction.

@@ -1060,8 +1104,17 @@ define([
return Cartesian3.add(left, right, ScratchStorage.getCartesian3());
} else if ((right instanceof Cartesian4) && (left instanceof Cartesian4)) {
return Cartesian4.add(left, right, ScratchStorage.getCartesian4());
} else if ((typeof(left) === 'string') || (typeof(right) === 'string')) {
return left + right;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This relies on each types toString function. Should the spec be explicit about how each type is stringified?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See what JavaScript says about toString functions. I want to say yes, we should state how, so things are very well specified, but we would also have to think about how many decimal places, etc.

var left = this._left.evaluate(frameState, feature);
//>>includeStart('debug', pragmas.debug);
if (typeof(left) !== 'boolean') {
throw new DeveloperError('Error: Operation is undefined.');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These exceptions are all fine, but can we be more precise about the type mismatch and any other info we can provide to help devs track down the issue?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's also need need to include Error: in the message, you are throwing an error so it's redundant.

@pjcozzi
Copy link
Contributor

pjcozzi commented Jan 12, 2017

I don't want to get too far into this unless this is the right direction.

Looks reasonable to me. Do you have any concerns?

@pjcozzi
Copy link
Contributor

pjcozzi commented Jan 15, 2017

@lilleyse please bump when ready.

@lilleyse
Copy link
Contributor Author

Ready now.

@Dylan-Brown you'll want to do similar type checking for the other built-in functions in #4865

@pjcozzi
Copy link
Contributor

pjcozzi commented Jan 17, 2017

Looks good!

@pjcozzi pjcozzi merged commit caa46a4 into 3d-tiles Jan 17, 2017
@pjcozzi pjcozzi deleted the type-mismatch branch January 17, 2017 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants