Babel automatically generates two methods for casting between
interfaces and classes
_cast() and _cast2().
The _cast() method, which tries to convert its opaque argument to
the type of the class indicated by the method name, is static.
Similarly, the non-static _cast2() method attempts to convert an
object pointer to the named type -- specified as a string.
For example, the following code snippet creates an instance of
sidl.BaseClass then casts it to sidl.BaseInterface using
each of the two methods
integer*8 object, interface, except
call sidl_BaseClass__create_f(object, except)
call sidl_BaseInterface__cast_f(object, interface, except)
c the following call to _cast2 is equivalent to the previous _cast call
call sidl_BaseClass__cast2_f(object, 'sidl.BaseInterface',
$ interface, except)
In either case, a zero except means the cast was successful and the returned reference (i.e., interface) should be non-zero. Since Babel 0.11.0, both methods increment the reference count when they are able to successfully cast the object. The caller then owns the returned reference.