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

Add Cast::dynamic_cast() #206

Merged
merged 2 commits into from Jul 27, 2017

Conversation

Projects
None yet
3 participants
@sdroege
Member

sdroege commented Jul 27, 2017

This does all type-checking at runtime and is required because it's not
always statically known at compile-time whether an object implements an
interface or not.

Also add notes about this limitation to Cast::downcast() and Cast::upcast().

And change Cast::is() to only perform runtime checking. It was always
doing runtime checking anyway, but in addition did compile-time checking
which is more restricted. If compile-time checking is wanted in
addition, Downcast::can_downcast() can be used for the old behaviour.

#205

@sdroege

This comment has been minimized.

Show comment
Hide comment
@sdroege

sdroege Jul 27, 2017

Member

This is basically the same as downcast but without compile-time constraints. Confirmed to work well here for casting a GstElement to the GstURIHandler interface (which some plugin-defined GstElement subclasses implement, others don't).

Member

sdroege commented Jul 27, 2017

This is basically the same as downcast but without compile-time constraints. Confirmed to work well here for casting a GstElement to the GstURIHandler interface (which some plugin-defined GstElement subclasses implement, others don't).

@EPashkin

This comment has been minimized.

Show comment
Hide comment
@EPashkin

EPashkin Jul 27, 2017

Member

👍

Member

EPashkin commented Jul 27, 2017

👍

@GuillaumeGomez

This comment has been minimized.

Show comment
Hide comment
@GuillaumeGomez

GuillaumeGomez Jul 27, 2017

Member

Just one nit and it's good for me.

Member

GuillaumeGomez commented Jul 27, 2017

Just one nit and it's good for me.

sdroege added some commits Jul 27, 2017

Add Cast::dynamic_cast()
This does all type-checking at runtime and is required because it's not
always statically known at compile-time whether an object implements an
interface or not.

Also add notes about this limitation to Cast::downcast() and Cast::upcast().

And change Cast::is() to only perform runtime checking. It was always
doing runtime checking anyway, but in addition did compile-time checking
which is more restricted. If compile-time checking is wanted in
addition, Downcast::can_downcast() can be used for the old behaviour.

#205
@sdroege

This comment has been minimized.

Show comment
Hide comment
@sdroege

sdroege Jul 27, 2017

Member

Done, thanks

Member

sdroege commented Jul 27, 2017

Done, thanks

@GuillaumeGomez

This comment has been minimized.

Show comment
Hide comment
@GuillaumeGomez

GuillaumeGomez Jul 27, 2017

Member

Thanks!

Member

GuillaumeGomez commented Jul 27, 2017

Thanks!

@GuillaumeGomez GuillaumeGomez merged commit 08ccf3a into gtk-rs:master Jul 27, 2017

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment