restore the old cast semantic

the `*_cast` methods should fail instead of returning NULL (as the `*_try_cast()` methods do). Restore old semantic and add some methods to API.