/[ascend]/trunk/base/generic/compiler/extcall.h
ViewVC logotype

Contents of /trunk/base/generic/compiler/extcall.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 203 - (show annotations) (download) (as text)
Mon Jan 23 04:13:17 2006 UTC (18 years, 5 months ago) by johnpye
File MIME type: text/x-chdr
File size: 7240 byte(s)
Documentation changes; making 'FIX' statement less verbose;
Commenting out ununsed 'CreateExternalFunction' function
1 /*
2 * External functions (ie blackbox relations) Module
3 * by Kirk Andre Abbott
4 * Created: Jun 1, 1995.
5 * Version: $Revision: 1.6 $
6 * Version control file: $RCSfile: extcall.h,v $
7 * Date last modified: $Date: 1997/07/18 12:29:27 $
8 * Last modified by: $Author: mthomas $
9 *
10 * This file is part of the Ascend Language Interpreter.
11 *
12 * Copyright (C) 1990, 1993, 1994 Thomas Guthrie Epperly, Kirk Andre Abbott
13 *
14 * The Ascend Language Interpreter is free software; you can redistribute
15 * it and/or modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of the
17 * License, or (at your option) any later version.
18 *
19 * The Ascend Language Interpreter is distributed in hope that it will be
20 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License along
25 * with the program; if not, write to the Free Software Foundation, Inc., 675
26 * Mass Ave, Cambridge, MA 02139 USA. Check the file named COPYING.
27 */
28
29 /** @file
30 * External functions (ie blackbox relations) Module
31
32 @todo Complete documentation of compiler/extcall.h.
33 */
34
35 /** @file
36 Requires:
37 #include <stdio.h>
38 #include <stdlib.h>
39 #include "utilities/ascConfig.h"
40 #include "compiler.h"
41 #include "ascmalloc.h"
42 #include "list.h"
43 #include "extfunc.h"
44 #include "instance_enum.h"
45 */
46
47 #ifndef ASC_EXTCALL_H
48 #define ASC_EXTCALL_H
49
50 /** External call data structure. */
51 struct ExtCallNode{
52 struct ExternalFunc *efunc; /**< Pointer to external function. */
53 struct gl_list_t *arglist; /**< List of Instance pointers. */
54 struct Instance **data; /**< A handle to additional user data. */
55 unsigned long subject; /**< Index into the arglist. */
56 int nodestamp; /**< A unique id for each call node. */
57 };
58
59 extern struct ExtCallNode *CreateExtCall(struct ExternalFunc *efunc,
60 struct gl_list_t *args,
61 struct Instance *subject,
62 struct Instance *data);
63 /**<
64 Create ExtCall
65 */
66
67 extern void DestroyExtCall(struct ExtCallNode *ext,
68 struct Instance *relinst);
69 /**<
70 Destroy ExtCall
71 */
72
73 extern struct Instance *GetSubjectInstance(struct gl_list_t *arglist,
74 unsigned long varndx);
75
76 extern unsigned long GetSubjectIndex(struct gl_list_t *arglist,
77 struct Instance *subject);
78
79 extern unsigned long CountNumberOfArgs(struct gl_list_t *arglist,
80 unsigned long start,
81 unsigned long end);
82
83 extern struct gl_list_t *LinearizeArgList(struct gl_list_t *arglist,
84 unsigned long start,
85 unsigned long end);
86 /**<
87 Given a list of gl_list_t's this function will create a new list which
88 is a linearized representation,i.e, each of the lists is spliced into
89 the original list, to create one long list. The user now owns the
90 new list structure, although the data in the original list is shared
91 with the new list.
92 */
93
94 extern struct gl_list_t *CopySpecialList(struct gl_list_t *list);
95
96 extern void DestroySpecialList(struct gl_list_t *list);
97 /**<
98 Given a list of gl_list_t's, this function will destroy the lists
99 structures associated with this complex list. It *will* not destroy
100 the *leaf* data, but it will destroy all the list structures.
101 */
102
103 #ifdef NDEBUG
104 #define ExternalCallExtFunc(ext) ((ext)->efunc)
105 #else
106 #define ExternalCallExtFunc(ext) ExternalCallExtFuncF(ext)
107 #endif
108 /**<
109 Return the external function pointer of an external call.
110 @param ext <code>struct ExtCallNode*</code>, node to query.
111 @return Returns the external function as a <code>struct ExternalFunc*</code>.
112 @see ExternalCallExtFuncF()
113 */
114 extern struct ExternalFunc *ExternalCallExtFuncF(struct ExtCallNode *ext);
115 /**<
116 Return the external function pointer of an external call;
117 Implementation function for ExternalCallExtFunc(). Do not call this
118 function directly - call ExternalCallExtFunc() instead.
119 */
120
121 #ifdef NDEBUG
122 #define ExternalCallArgList(ext) ((ext)->arglist)
123 #else
124 #define ExternalCallArgList(ext) ExternalCallArgListF(ext)
125 #endif
126 /**<
127 Return the argument list. This is a List of Lists of struct
128 Instances, for an external call.
129 @param ext <code>struct ExtCallNode*</code>, node to query.
130 @return Returns the arguments as a <code>struct gl_list_t*</code>.
131 @see ExternalCallArgListF()
132 */
133 extern struct gl_list_t *ExternalCallArgListF(struct ExtCallNode *ext);
134 /**<
135 Return the arguement list, which is a List of Lists of struct
136 Instances, for an external call;
137
138 Implementation function for ExternalCallArgList(). Do not call this
139 function directly - call ExternalCallArgList() instead.
140 */
141
142 extern struct Instance *ExternalCallDataInstance(struct ExtCallNode *ext);
143 /**<
144 Return the 'data' instance for an external call. This 'data'
145 instance can has to be a MODEL_INST. It is used to convey additional
146 information to a client who may need it. A NULL result means that no
147 additional information was requested and is a valid result.
148 */
149
150 #ifdef NDEBUG
151 #define ExternalCallVarIndex(ext) ((ext)->subject)
152 #else
153 #define ExternalCallVarIndex(ext) ExternalCallVarIndexF(ext)
154 #endif
155 /**<
156 Return the index in the argument list of the subject variable.
157 @param ext <code>struct ExtCallNode*</code>, node to query.
158 @return Returns the index as an <code>unsigned long</code>.
159 @see ExternalCallVarIndexF()
160 */
161 extern unsigned long ExternalCallVarIndexF(struct ExtCallNode *ext);
162 /**<
163 @return the index in the argument list of the subject variable.
164 This function uses the primitives GetWhichVar etc.
165 Implementation function for ExternalCallVarIndex(). Do not call this
166 function directly - call ExternalCallVarIndex() instead.
167 */
168
169 extern struct Instance *ExternalCallVarInstance(struct ExtCallNode *ext);
170 /**<
171 Return the "subject" variable instance of the external call. This is
172 the variable that relation was constructed wrt. If NULL, then a user
173 should consider this as an error.
174 */
175
176 #ifdef NDEBUG
177 #define ExternalCallNodeStamp(ext) ((ext)->nodestamp)
178 #else
179 #define ExternalCallNodeStamp(ext) ExternalCallNodeStampF(ext)
180 #endif
181 /**<
182 Return the nodestamp for the given external node.
183 Valid results are >= 0.
184
185 @param ext <code>struct ExtCallNode*</code>, node to query.
186 @return Returns the node stamp as an <code>int</code>.
187 @see ExternalCallNodeStampF()
188 */
189
190 extern int ExternalCallNodeStampF(struct ExtCallNode *ext);
191 /**<
192 Return the nodestamp for the given external node. Valid results
193 are >= 0.
194
195 Implementation function for ExternalCallNodeStamp(). Do not call this
196 function directly - call ExternalCallNodeStamp() instead.
197 */
198
199 extern void SetExternalCallNodeStamp(struct ExtCallNode *ext,
200 int nodestamp);
201 /**<
202 Set the nodestamp for the given external node.
203 */
204
205 #endif /* ASC_EXTCALL_H */
206

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22