The C binding for interfaces and classes includes two methods for perform type casts. The methods are named _cast and _cast2. The leading underscore prevents these builtin methods from conflicting with a user method because user methods cannot begin with an underscore. Neither of these methods increases the reference count of the underlying object -- this is contrary to standard methods that always return new reference counts. Here are the signatures for _cast and _cast2 from SIDL.BaseClass.
SIDL_BaseClass SIDL_BaseClass__cast( void* obj); void* SIDL_BaseClass__cast2( void* obj, const char* type);
The _cast method attempts to cast a SIDL interface or object pointer to a pointer to SIDL.BaseClass. The _cast2 method attempts to cast a SIDL interface or object pointer to a pointer to an interface or object pointer of the type named type. In the case of _cast2, the client is responsible for casting the return value into the proper pointer type. Both methods are NULL safe. A NULL return value indicates that the cast failed or that obj was NULL.
Non-abstract classes have an additional implicit method called _create to create new instances of the class. Interfaces and abstract classes do not have this method because you cannot instantiate them. The _create method returns a new reference that the client must manage. Here is an example of its signature.
/** * Constructor function for the class. */ SIDL_BaseClass SIDL_BaseClass__create(void);