File: node134.html

package info (click to toggle)
babel 0.10.2-1
  • links: PTS
  • area: contrib
  • in suites: sarge
  • size: 43,932 kB
  • ctags: 29,707
  • sloc: java: 74,695; ansic: 73,142; cpp: 40,649; sh: 18,411; f90: 10,062; fortran: 6,727; python: 6,406; makefile: 3,866; xml: 118; perl: 48
file content (228 lines) | stat: -rw-r--r-- 8,768 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<!--Converted with LaTeX2HTML 2002-2-1 (1.70)
original version by:  Nikos Drakos, CBLU, University of Leeds
* revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
  Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<TITLE>Calling Methods From FORTRAN 77</TITLE>
<META NAME="description" CONTENT="Calling Methods From FORTRAN 77">
<META NAME="keywords" CONTENT="users_guide">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">

<META NAME="Generator" CONTENT="LaTeX2HTML v2002-2-1">
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">

<LINK REL="STYLESHEET" HREF="users_guide.css">

<LINK REL="next" HREF="node135.html">
<LINK REL="previous" HREF="node133.html">
<LINK REL="up" HREF="node131.html">
<LINK REL="next" HREF="node135.html">
</HEAD>

<BODY >

<DIV CLASS="navigation"><!--Navigation Panel-->
<A NAME="tex2html2715"
  HREF="node135.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> 
<A NAME="tex2html2709"
  HREF="node131.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> 
<A NAME="tex2html2703"
  HREF="node133.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> 
<A NAME="tex2html2711"
  HREF="node14.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A> 
<A NAME="tex2html2713"
  HREF="node317.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A> 
<BR>
<B> Next:</B> <A NAME="tex2html2716"
  HREF="node135.html">Catching and Throwing Exceptions</A>
<B> Up:</B> <A NAME="tex2html2710"
  HREF="node131.html">FORTRAN 77 Bindings</A>
<B> Previous:</B> <A NAME="tex2html2704"
  HREF="node133.html">Basic Types</A>
 &nbsp; <B>  <A NAME="tex2html2712"
  HREF="node14.html">Contents</A></B> 
 &nbsp; <B>  <A NAME="tex2html2714"
  HREF="node317.html">Index</A></B> 
<BR>
<BR></DIV>
<!--End of Navigation Panel-->

<H1><A NAME="SECTION03330000000000000000"></A>
<A NAME="7244"></A>
<BR>
Calling Methods From FORTRAN 77
</H1>

<P>
All SIDL methods are implemented as FORTRAN 77
subroutines<A NAME="7245"></A>  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.

<P>
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 <TT>out</TT> parameter.

<P>
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".

<P>
For example, to call the <TT>deleteRef()</TT> method on a 
<TT><I CLASS="slanted">sidl.BaseInterface</I></TT> interface, you would write:

<P>
<BR>
<PRE  CLASS="verbatim">       integer*8 interface1, interface2
       logical areSame
C      code to initialize interface1 &amp; interface 2 here
       call sidl_BaseInterface_deleteRef_f(interface1)
</PRE></td></tr></table></blockquote>
<P>
To call the isSame method on a sidl.BaseInterface , you would write:

<P>
<BR>
<PRE  CLASS="verbatim">       call sidl_BaseInterface_queryInt_f(interface1, 'My.Interface.Name', interface2)
</PRE></td></tr></table></blockquote>
<P>
To call the queryInt method on a sidl.BaseInterface, you would write:

<P>
<BR>
<PRE  CLASS="verbatim">      call sidl_BaseInterface_queryInt_f(interface1, 'My.Interface.Name', interface2)
</PRE></td></tr></table></blockquote>
<P>
Examples of calls to SIDL overloaded methods are based on the 
<TT>overload_sample.sidl</TT> file shown in Section&nbsp;<A HREF="node107.html#sec:overloading">5.6</A>.  
Recall that the file describes three versions of the <TT>getValue</TT> 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:

<P>
<BR>
<PRE  CLASS="verbatim">
      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)
</PRE></td></tr></table></blockquote>
<P>
For interfaces and classes, there are two implicit methods called
<TT>_cast()</TT> and <TT>_cast2()</TT>. 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.

<P>
<TT>_cast()</TT> is a static
method. It tries to convert its opaque argument to the type of the
class indicated by the method name. For example,
<TT>x_y_z__cast(obj, xyz)</TT> will try to convert <TT>obj</TT> to
type <TT><I CLASS="slanted">x.y.z</I></TT>. If <TT>xyz</TT> is nonzero, the cast was successful.

<P>
<TT>_cast2()</TT> 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 <TT>_cast()</TT> method attempts to
cast the object/interface to the named type.  It is similar to the
queryInt method in <TT><I CLASS="slanted">sidl.BaseInterface</I></TT> 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
<TT>queryInt()</TT> method always returns an interface pointer.

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

<P>
Here are examples of the use of these two methods:

<P>
<BR>
<PRE  CLASS="verbatim">      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)
      </PRE></td></tr></table></blockquote>
<P>
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.

<P>
Here is an example call to the <TT>addSearchPath()</TT> in the <TT><I CLASS="slanted">sidl.Loader</I></TT> class:

<P>
<BR>
<PRE  CLASS="verbatim">      call sidl_Loader_addSearchPath_f('/try/looking/here')
      </PRE></td></tr></table></blockquote>
<P>
Your FORTRAN 77 must manage any object references created by the calls
you make.

<P>

<DIV CLASS="navigation"><HR>
<!--Navigation Panel-->
<A NAME="tex2html2715"
  HREF="node135.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> 
<A NAME="tex2html2709"
  HREF="node131.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> 
<A NAME="tex2html2703"
  HREF="node133.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> 
<A NAME="tex2html2711"
  HREF="node14.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A> 
<A NAME="tex2html2713"
  HREF="node317.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A> 
<BR>
<B> Next:</B> <A NAME="tex2html2716"
  HREF="node135.html">Catching and Throwing Exceptions</A>
<B> Up:</B> <A NAME="tex2html2710"
  HREF="node131.html">FORTRAN 77 Bindings</A>
<B> Previous:</B> <A NAME="tex2html2704"
  HREF="node133.html">Basic Types</A>
 &nbsp; <B>  <A NAME="tex2html2712"
  HREF="node14.html">Contents</A></B> 
 &nbsp; <B>  <A NAME="tex2html2714"
  HREF="node317.html">Index</A></B> </DIV>
<!--End of Navigation Panel-->
<ADDRESS>
<br><br>babel-0.10.2<br>users_guide Last Modified 2005-03-23<br><br><a href="http://www.llnl.gov/CASC/components">http://www.llnl.gov/CASC/components</a><br><a href="mailto:components@llnl.gov">components@llnl.gov</a>
</ADDRESS>
</BODY>
</HTML>