1 | |
---|
2 | #include "RpLibrary.h" |
---|
3 | #include "RpDict.h" |
---|
4 | #include <string.h> |
---|
5 | #include <fstream> |
---|
6 | #include "RpFortranCommon.h" |
---|
7 | |
---|
8 | /* |
---|
9 | // rappture-fortran api |
---|
10 | */ |
---|
11 | |
---|
12 | #ifdef __cplusplus |
---|
13 | extern "C" { |
---|
14 | #endif |
---|
15 | |
---|
16 | #ifdef COMPNAME_ADD1UNDERSCORE |
---|
17 | # define rp_init rp_init_ |
---|
18 | # define rp_lib rp_lib_ |
---|
19 | # define rp_lib_element_comp rp_lib_element_comp_ |
---|
20 | # define rp_lib_element_id rp_lib_element_id_ |
---|
21 | # define rp_lib_element_type rp_lib_element_type_ |
---|
22 | # define rp_lib_element_obj rp_lib_element_obj_ |
---|
23 | # define rp_lib_child_num rp_lib_child_num_ |
---|
24 | # define rp_lib_child_comp rp_lib_child_comp_ |
---|
25 | # define rp_lib_child_id rp_lib_child_id_ |
---|
26 | # define rp_lib_child_type rp_lib_child_type_ |
---|
27 | # define rp_lib_child_obj rp_lib_child_obj_ |
---|
28 | # define rp_lib_get rp_lib_get_ |
---|
29 | # define rp_lib_get_double rp_lib_get_double_ |
---|
30 | # define rp_lib_put_str rp_lib_put_str_ |
---|
31 | # define rp_lib_put_id_str rp_lib_put_id_str_ |
---|
32 | # define rp_lib_put_obj rp_lib_put_obj_ |
---|
33 | # define rp_lib_put_id_obj rp_lib_put_id_obj_ |
---|
34 | # define rp_lib_remove rp_lib_remove_ |
---|
35 | # define rp_lib_xml_len rp_lib_xml_len_ |
---|
36 | # define rp_lib_write_xml rp_lib_write_xml_ |
---|
37 | # define rp_lib_xml rp_lib_xml_ |
---|
38 | # define rp_quit rp_quit_ |
---|
39 | #elif defined(COMPNAME_ADD2UNDERSCORE) |
---|
40 | # define rp_init rp_init__ |
---|
41 | # define rp_lib rp_lib__ |
---|
42 | # define rp_lib_element_comp rp_lib_element_comp__ |
---|
43 | # define rp_lib_element_id rp_lib_element_id__ |
---|
44 | # define rp_lib_element_type rp_lib_element_type__ |
---|
45 | # define rp_lib_element_obj rp_lib_element_obj__ |
---|
46 | # define rp_lib_child_num rp_lib_child_num__ |
---|
47 | # define rp_lib_child_comp rp_lib_child_comp__ |
---|
48 | # define rp_lib_child_id rp_lib_child_id__ |
---|
49 | # define rp_lib_child_type rp_lib_child_type__ |
---|
50 | # define rp_lib_child_obj rp_lib_child_obj__ |
---|
51 | # define rp_lib_get rp_lib_get__ |
---|
52 | # define rp_lib_get_double rp_lib_get_double__ |
---|
53 | # define rp_lib_put_str rp_lib_put_str__ |
---|
54 | # define rp_lib_put_id_str rp_lib_put_id_str__ |
---|
55 | # define rp_lib_put_obj rp_lib_put_obj__ |
---|
56 | # define rp_lib_put_id_obj rp_lib_put_id_obj__ |
---|
57 | # define rp_lib_remove rp_lib_remove__ |
---|
58 | # define rp_lib_xml_len rp_lib_xml_len__ |
---|
59 | # define rp_lib_write_xml rp_lib_write_xml__ |
---|
60 | # define rp_lib_xml rp_lib_xml__ |
---|
61 | # define rp_quit rp_quit__ |
---|
62 | #elif defined(COMPNAME_NOCHANGE) |
---|
63 | # define rp_init rp_init |
---|
64 | # define rp_lib rp_lib |
---|
65 | # define rp_lib_element_comp rp_lib_element_comp |
---|
66 | # define rp_lib_element_id rp_lib_element_id |
---|
67 | # define rp_lib_element_type rp_lib_element_type |
---|
68 | # define rp_lib_element_obj rp_lib_element_obj |
---|
69 | # define rp_lib_child_num rp_lib_child_num |
---|
70 | # define rp_lib_child_comp rp_lib_child_comp |
---|
71 | # define rp_lib_child_id rp_lib_child_id |
---|
72 | # define rp_lib_child_type rp_lib_child_type |
---|
73 | # define rp_lib_child_obj rp_lib_child_obj |
---|
74 | # define rp_lib_get rp_lib_get |
---|
75 | # define rp_lib_get_double rp_lib_get_double |
---|
76 | # define rp_lib_put_str rp_lib_put_str |
---|
77 | # define rp_lib_put_id_str rp_lib_put_id_str |
---|
78 | # define rp_lib_put_obj rp_lib_put_obj |
---|
79 | # define rp_lib_put_id_obj rp_lib_put_id_obj |
---|
80 | # define rp_lib_remove rp_lib_remove |
---|
81 | # define rp_lib_xml_len rp_lib_xml_len |
---|
82 | # define rp_lib_write_xml rp_lib_write_xml |
---|
83 | # define rp_lib_xml rp_lib_xml |
---|
84 | # define rp_quit rp_quit |
---|
85 | #elif defined(COMPNAME_UPPERCASE) |
---|
86 | # define rp_init RP_INIT |
---|
87 | # define rp_lib RP_LIB |
---|
88 | # define rp_lib_element_comp RP_LIB_ELEMENT_COMP |
---|
89 | # define rp_lib_element_id RP_LIB_ELEMENT_ID |
---|
90 | # define rp_lib_element_type RP_LIB_ELEMENT_TYPE |
---|
91 | # define rp_lib_element_obj RP_LIB_ELEMENT_OBJ |
---|
92 | # define rp_lib_child_num RP_LIB_CHILD_NUM |
---|
93 | # define rp_lib_child_comp RP_LIB_CHILD_COMP |
---|
94 | # define rp_lib_child_id RP_LIB_CHILD_ID |
---|
95 | # define rp_lib_child_type RP_LIB_CHILD_TYPE |
---|
96 | # define rp_lib_child_obj RP_LIB_CHILD_OBJ |
---|
97 | # define rp_lib_get RP_LIB_GET |
---|
98 | # define rp_lib_get_double RP_LIB_GET_DOUBLE |
---|
99 | # define rp_lib_put_str RP_LIB_PUT_STR |
---|
100 | # define rp_lib_put_id_str RP_LIB_PUT_ID_STR |
---|
101 | # define rp_lib_put_obj RP_LIB_PUT_OBJ |
---|
102 | # define rp_lib_put_id_obj RP_LIB_PUT_ID_OBJ |
---|
103 | # define rp_lib_remove RP_LIB_REMOVE |
---|
104 | # define rp_lib_xml_len RP_LIB_XML_LEN |
---|
105 | # define rp_lib_write_xml RP_LIB_WRITE_XML |
---|
106 | # define rp_lib_xml RP_LIB_XML |
---|
107 | # define rp_quit RP_QUIT |
---|
108 | #endif |
---|
109 | |
---|
110 | |
---|
111 | void rp_init(); |
---|
112 | |
---|
113 | int rp_lib(const char* filePath, int filePath_len); |
---|
114 | |
---|
115 | void rp_lib_element_comp( int* handle, |
---|
116 | char* path, |
---|
117 | char* retText, |
---|
118 | int path_len, |
---|
119 | int retText_len ); |
---|
120 | |
---|
121 | void rp_lib_element_id( int* handle, |
---|
122 | char* path, |
---|
123 | char* retText, |
---|
124 | int path_len, |
---|
125 | int retText_len ); |
---|
126 | |
---|
127 | void rp_lib_element_type( int* handle, |
---|
128 | char* path, |
---|
129 | char* retText, |
---|
130 | int path_len, |
---|
131 | int retText_len ); |
---|
132 | |
---|
133 | int rp_lib_element_obj( int* handle, |
---|
134 | char* path, |
---|
135 | int path_len ); |
---|
136 | |
---|
137 | int rp_lib_child_num( int* handle, |
---|
138 | char* path, |
---|
139 | int path_len); |
---|
140 | |
---|
141 | int rp_lib_child_comp( int* handle, /* integer handle of library */ |
---|
142 | char* path, /* DOM path of requested object */ |
---|
143 | char* type, /* specific name of element */ |
---|
144 | int* childNum, /* child number for iteration */ |
---|
145 | char* retText, /* buffer to store return text */ |
---|
146 | int path_len, /* length of path */ |
---|
147 | int type_len, /* length of type */ |
---|
148 | int retText_len /* length of return text buffer */ |
---|
149 | ); |
---|
150 | |
---|
151 | int rp_lib_child_id( int* handle, /* integer handle of library */ |
---|
152 | char* path, /* DOM path of requested object */ |
---|
153 | char* type, /* specific name of element */ |
---|
154 | int* childNum, /* child number for iteration */ |
---|
155 | char* retText, /* buffer to store return text */ |
---|
156 | int path_len, /* length of path */ |
---|
157 | int type_len, /* length of type */ |
---|
158 | int retText_len /* length of return text buffer */ |
---|
159 | ); |
---|
160 | |
---|
161 | int rp_lib_child_type( int* handle, /* integer handle of library */ |
---|
162 | char* path, /* DOM path of requested object */ |
---|
163 | char* type, /* specific name of element */ |
---|
164 | int* childNum, /* child number for iteration */ |
---|
165 | char* retText, /* buffer to store return text */ |
---|
166 | int path_len, /* length of path */ |
---|
167 | int type_len, /* length of type */ |
---|
168 | int retText_len /* length of return text buffer */ |
---|
169 | ); |
---|
170 | |
---|
171 | int rp_lib_child_obj( int* handle, |
---|
172 | char* path, |
---|
173 | char* type, |
---|
174 | int path_len, |
---|
175 | int type_len |
---|
176 | ); |
---|
177 | |
---|
178 | void rp_lib_get( int* handle, |
---|
179 | char* path, |
---|
180 | char* retText, |
---|
181 | int path_len, |
---|
182 | int retText_len ); |
---|
183 | |
---|
184 | double rp_lib_get_double( int* handle, |
---|
185 | char* path, |
---|
186 | int path_len); |
---|
187 | |
---|
188 | void rp_lib_put_str( int* handle, |
---|
189 | char* path, |
---|
190 | char* value, |
---|
191 | int* append, |
---|
192 | int path_len, |
---|
193 | int value_len ); |
---|
194 | |
---|
195 | void rp_lib_put_id_str( int* handle, |
---|
196 | char* path, |
---|
197 | char* value, |
---|
198 | char* id, |
---|
199 | int* append, |
---|
200 | int path_len, |
---|
201 | int value_len, |
---|
202 | int id_len ); |
---|
203 | |
---|
204 | void rp_lib_put_obj( int* handle, |
---|
205 | char* path, |
---|
206 | int* valHandle, |
---|
207 | int* append, |
---|
208 | int path_len ); |
---|
209 | |
---|
210 | void rp_lib_put_id_obj( int* handle, |
---|
211 | char* path, |
---|
212 | int* valHandle, |
---|
213 | char* id, |
---|
214 | int* append, |
---|
215 | int path_len, |
---|
216 | int id_len ); |
---|
217 | |
---|
218 | int rp_lib_remove( int* handle, |
---|
219 | char* path, |
---|
220 | int path_len); |
---|
221 | |
---|
222 | int rp_lib_xml_len( int* handle); |
---|
223 | |
---|
224 | void rp_lib_xml( int* handle, |
---|
225 | char* retText, |
---|
226 | int retText_len); |
---|
227 | |
---|
228 | int rp_lib_write_xml( int* handle, |
---|
229 | char* outFile, |
---|
230 | int outFile_len); |
---|
231 | void rp_quit(); |
---|
232 | |
---|
233 | |
---|
234 | /**********************************************************/ |
---|
235 | |
---|
236 | /**********************************************************/ |
---|
237 | |
---|
238 | // private member functions |
---|
239 | int objType( char* flavor); |
---|
240 | |
---|
241 | int storeObject_Lib(RpLibrary* objectName); |
---|
242 | RpLibrary* getObject_Lib(int objKey); |
---|
243 | |
---|
244 | // global vars |
---|
245 | // dictionary to hold the python objects that |
---|
246 | // cannot be sent to fortran |
---|
247 | |
---|
248 | #define DICT_TEMPLATE <int,RpLibrary*> |
---|
249 | RpDict DICT_TEMPLATE fortObjDict_Lib; |
---|
250 | |
---|
251 | #ifdef __cplusplus |
---|
252 | } |
---|
253 | #endif |
---|