All SIDL methods are implemented as FORTRAN 90 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.
The name of the module that holds the method definitions is derived from the fully qualified name of the class or interface. You can generate the module name by replacing all the periods with underscores. For example, the methods for sidl.SIDLException are defined in a module named sidl_SIDLException in the file sidl_SIDLException.F90. The name of the module holding the derived type of the class or interface is the same as the one holding the methods except that it has _type appended to it. The types for sidl.SIDLException are called sidl_SIDLException_t and sidl_SIDLException_a, for the array, and they are defined in the file sidl_SIDLException_type.F90.
The name of the subroutine that FORTRAN 90 clients is the method's full name from the SIDL description. 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.
For example, to call the deleteRef() method on a SIDL.BaseInterface interface, you would write:
use sidl_BaseInterface type(sidl_BaseInterface_t) :: interface1, interface2 logical :: areSame ! ! code to initialize interface1 & interface 2 here ! call deleteRef(interface1)
To call the isSame method on a sidl.BaseInterface, you would write:
use sidl_BaseInterface ! later in the code call isSame(interface1, interface2, areSame) ! areSame holds the return value
To call the queryInt method on a sidl.BaseInterface, you would write:
use sidl_BaseInterface ! later call queryInt(interface1, 'My.Interface.Name', interface2) ! interface2 holds the return value now
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:
use Overload_Sample type(Overload_Sample_t) :: t logical :: b1, bretval integer (selected_int_kind(9)) :: i1, iretval call new(t) call getValue (t, iretval) call getValueInt (t, i1, iretval) call getValueBool (t, b1, bretval)
Here is an example of what Babel will produce for an enumerated type with some of the whitespace and comments reduced for brevity.
! File: enums_car.F90 ! Symbol: enums.car-v1.0 ! Symbol Type: enumeration ! Babel Version: 0.8.2 ! Description: Client-side module for enums.car module enums_car ! Symbol "enums.car" (version 1.0) integer (selected_int_kind(9)), parameter :: porsche = 911 integer (selected_int_kind(9)), parameter :: ford = 150 integer (selected_int_kind(9)), parameter :: mercedes = 550 end module enums_car
For interfaces and classes, there is an implicit method called cast(). There are actually a set of overloaded methods that support every allowable cast between a type an all its parent types (objects and interfaces). The first argument is the object/interface to be cast, and the second argument is a variable of the desired type. If the value of the second argument after the call is not_null, the cast was successful; otherwise, the cast failed. cast() 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 new(). It creates and returns an instance of the class.
Here are examples of the use of these two methods:
use sidl_BaseClass use sidl_BaseInterface type(sidl_BaseClass_t) :: object type(sidl_BaseInterface_t) :: interface ! perhaps other code here call new(object) call cast(object, interface)
Here is an example call to the addSearchPath(), a static method, in the sidl.Loader class:
use sidl_Loader ! later call addSearchPath('/try/looking/here')
Your FORTRAN 90 must manage any object references created by the calls you make.