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

[NativeScript] added global type tag system #17980

Merged

Conversation

karroffel
Copy link
Contributor

This adds a map for library-defined global type tags. This is useful for safe casting and type checking on the library side.

@karroffel karroffel added this to the 3.1 milestone Apr 4, 2018
@karroffel karroffel force-pushed the nativescript-1.1-global-type-tags branch 3 times, most recently from 6f78908 to 4cb8109 Compare April 4, 2018 22:02
@Zylann
Copy link
Contributor

Zylann commented Apr 5, 2018

How is it working for testing base class types? For example, if the function expects a CustomSprite, but you are passing a CustomAnimatedSprite (which however inherits CustomSprite)?

@karroffel
Copy link
Contributor Author

This global type tag system is not intended to be used with custom classes. It's there to tag all objects with a value that the language bindings can work with, so when you pass a CustomSprite, then the type tag generated for that wrapper will be for Sprite.

The check that you are describing is already possible with the type tag system on master.

This global system was added so that

Object *o = get_the_object();
Reference *r = Object::cast_to<Reference>(o);

works, but without this PR the language bindings would have to do name compares for this.

@karroffel karroffel merged commit eaa5dfb into godotengine:master Apr 5, 2018
@karroffel karroffel deleted the nativescript-1.1-global-type-tags branch April 18, 2018 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants