Implicitly defined methods

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 built in 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. Every object has these two methods, we will use sidl.BaseClass as an example. 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);



babel-0.10.2
users_guide Last Modified 2005-03-23

http://www.llnl.gov/CASC/components
components@llnl.gov