Calling Methods From FORTRAN 77

All SIDL methods are implemented as FORTRAN 77 subroutines regardless of whether they have a return value or not. For object methods, the object or interface pointer is passed as the first argument to the subroutine before all the formally declared arguments. The exception is static methods, where the object or interface pointer does not appear in the argument list at all.

When a method has a return value, a variable to hold the return value should be passed as an argument following the formally declared arguments. This extra argument behaves like an out parameter.

The name of the subroutine that FORTRAN 77 clients should call is derived from the fully qualified name of the class and the name(s) of the method. If the method is specified as overloaded (i.e., has a name extension), the method's full name will be used. That is, the concatenation of the short name and the name extension will be used for a unique method name. Hence, to determine the subroutine name for FORTRAN 77, take the fully qualified name, replace all the periods with underscores, append an underscore, append the short method name, append the method name extension (if any) and then append "_f".

For example, to call the deleteRef() method on a sidl.BaseInterface interface, you would write:


       integer*8 interface1, interface2
       logical areSame
C      code to initialize interface1 & interface 2 here
       call sidl_BaseInterface_deleteRef_f(interface1)

To call the isSame method on a sidl.BaseInterface , you would write:


       call sidl_BaseInterface_queryInt_f(interface1, 'My.Interface.Name', interface2)

To call the queryInt method on a sidl.BaseInterface, you would write:


      call sidl_BaseInterface_queryInt_f(interface1, 'My.Interface.Name', interface2)

Examples of calls to SIDL overloaded methods are based on the overload_sample.sidl file shown in Section 5.6. Recall that the file describes three versions of the getValue method. The first takes no arguments, the second takes an integer argument, and the third takes a boolean. Each is called in the code snippet below:


      integer*8 t
      logical b1, bretval
      integer*4 i1, iretval

      call Overload_Sample__create_f (t)

      call Overload_Sample_getValue_f (t, iretval)
      call Overload_Sample_getValueInt_f (t, i1, iretval)
      call Overload_Sample_getValueBool_f (t, b1, bretval)

For interfaces and classes, there are two implicit methods called _cast() and _cast2(). Both of these methods are used to convert from one type to another, and each can be used for upcasting up downcasting. Neither method will increment the reference count of the object.

_cast() is a static method. It tries to convert its opaque argument to the type of the class indicated by the method name. For example, x_y_z__cast(obj, xyz) will try to convert obj to type x.y.z. If xyz is nonzero, the cast was successful.

_cast2() is an object method. Its return type is opaque, and it has one formal argument, a string in addition to the implicit object/interface reference. The _cast() method attempts to cast the object/interface to the named type. It is similar to the queryInt method in sidl.BaseInterface except it does not increment the reference count of the return object or interface, and it may return an object or an interface pointer. The queryInt() method always returns an interface pointer.

For non-abstract classes, there is an implicit method called _create(). It creates and returns an instance of the class.

Here are examples of the use of these two methods:


      integer*8 object, interface
      call sidl_BaseClass__create_f(object)
      call sidl_BaseInterface__cast_f(object, interface)
c     the following call to _cast2 is equivalent to the previous _cast call
      call sidl_BaseClass__cast2_f(object, 'SIDL.BaseInterface',
     $     interface)
      

Please note the presence of two underscores between BaseClass and create and between BaseClass and cast; the extra underscore is there because the first character of the method name is an underscore.

Here is an example call to the addSearchPath() in the sidl.Loader class:


      call sidl_Loader_addSearchPath_f('/try/looking/here')
      

Your FORTRAN 77 must manage any object references created by the calls you make.



babel-0.10.2
users_guide Last Modified 2005-03-23

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