1 | /****************************************************************** |
---|
2 | * |
---|
3 | * File: MPT.h |
---|
4 | * Purpose: Main Header file for MP Tree routines |
---|
5 | * Author: Olaf Bachmann (obachman@mathematik.uni-kl.de) |
---|
6 | * Created: 11/96 |
---|
7 | * |
---|
8 | * Change History (most recent first): |
---|
9 | * |
---|
10 | ******************************************************************/ |
---|
11 | #ifndef _MPT_H_ |
---|
12 | #define _MPT_H_ |
---|
13 | |
---|
14 | #include "MP.h" |
---|
15 | |
---|
16 | /*************************************************************** |
---|
17 | * |
---|
18 | * Declare all names of types that we use |
---|
19 | * |
---|
20 | ***************************************************************/ |
---|
21 | struct MPT_Tree_t; |
---|
22 | typedef MPT_Tree_t * MPT_Tree_pt; |
---|
23 | |
---|
24 | struct MPT_Node_t; |
---|
25 | typedef MPT_Node_t * MPT_Node_pt; |
---|
26 | |
---|
27 | struct MPT_Annot_t; |
---|
28 | typedef MPT_Annot_t * MPT_Annot_pt; |
---|
29 | |
---|
30 | typedef void * MPT_Arg_t; |
---|
31 | typedef MPT_Arg_t * MPT_Arg_pt; |
---|
32 | |
---|
33 | struct MPT_Union_t; |
---|
34 | typedef MPT_Union_t * MPT_Union_pt; |
---|
35 | |
---|
36 | struct MPT_DynArgs_t; |
---|
37 | typedef MPT_DynArgs_t * MPT_DynArgs_pt; |
---|
38 | |
---|
39 | typedef void * MPT_ExternalData_t; |
---|
40 | |
---|
41 | /*************************************************************** |
---|
42 | * |
---|
43 | * Tree declarations |
---|
44 | * |
---|
45 | ***************************************************************/ |
---|
46 | |
---|
47 | /* A Tree consists of */ |
---|
48 | struct MPT_Tree_t |
---|
49 | { |
---|
50 | MPT_Node_pt node; /* a node */ |
---|
51 | MPT_Arg_pt args; /* and possibly of arguments */ |
---|
52 | }; |
---|
53 | |
---|
54 | /*************************************************************** |
---|
55 | * |
---|
56 | * Node declaration |
---|
57 | * |
---|
58 | ***************************************************************/ |
---|
59 | /* A node has a */ |
---|
60 | struct MPT_Node_t |
---|
61 | { |
---|
62 | MP_NodeType_t type; |
---|
63 | MP_DictTag_t dict; /* may have a defined semantics in a dictionary */ |
---|
64 | MPT_Arg_t nvalue; /* always has a (node) value */ |
---|
65 | MP_NumChild_t numchild; /* may specify that numchild args follow */ |
---|
66 | MP_NumAnnot_t numannot; /* always may have 0 or more annots */ |
---|
67 | MPT_Annot_pt *annots; /* which are stored here */ |
---|
68 | }; |
---|
69 | |
---|
70 | /*************************************************************** |
---|
71 | * |
---|
72 | * Annotation declaration |
---|
73 | * |
---|
74 | ***************************************************************/ |
---|
75 | /* An annot has */ |
---|
76 | struct MPT_Annot_t |
---|
77 | { |
---|
78 | MP_AnnotFlags_t flags; /* as defined in the MP spec */ |
---|
79 | MP_AnnotType_t type; /* as defined in some dict*/ |
---|
80 | MP_DictTag_t dict; /* always need to be defined in a dict */ |
---|
81 | MPT_Tree_pt value; /* and may have a tree as value */ |
---|
82 | }; |
---|
83 | |
---|
84 | /*************************************************************** |
---|
85 | * |
---|
86 | * Argument declaration |
---|
87 | * |
---|
88 | * The problem is that we need to compactly represent (arrays and |
---|
89 | * 8, 16, 32, and 64 bit (numeric) quantities. Hence, we can not |
---|
90 | * just do |
---|
91 | * |
---|
92 | * union MPT_Arg_t { ... all types ... }; |
---|
93 | * typedef MPT_Arg_t * MPT_Args_pt; |
---|
94 | * |
---|
95 | * since in this case sizeof(MPT_Arg_t) == sizeof(type_with_max_size); |
---|
96 | * |
---|
97 | * Hence, we need to let MPT_Arg_t be (void *) and cast it to whatever |
---|
98 | * it is supposed to be (which is determined from the context) |
---|
99 | * |
---|
100 | * We provide Macros for doing that |
---|
101 | ***************************************************************/ |
---|
102 | /* First of all, an argument may have one of the basic types */ |
---|
103 | /* For the following, we assume that sizeof(void *) >= sizeof(type) */ |
---|
104 | #define MP_BOOLEAN_T(arg) ((MP_Boolean_t) (MP_UINT32_T(arg))) |
---|
105 | #define MP_ARG_BOOLEAN_T(arg) ((MPT_Arg_t)((MP_Boolean_t) (MP_UINT32_T(arg)))) |
---|
106 | #define MP_COMMON_T(arg) ((MP_Common_t) (MP_UINT32_T(arg))) |
---|
107 | #define MP_ARG_COMMON_T(arg) ((MPT_Arg_t)((MP_Common_t) (MP_UINT32_T(arg)))) |
---|
108 | #define MP_SINT8_T(arg) ((MP_Sint8_t) (MP_SINT32_T(arg))) |
---|
109 | #define MP_ARG_SINT8_T(arg) ((MPT_Arg_t)((MP_Sint8_t) (MP_SINT32_T(arg)))) |
---|
110 | #define MP_UINT8_T(arg) ((MP_Uint8_t) (MP_UINT32_T(arg))) |
---|
111 | #define MP_ARG_UINT8_T(arg) ((MPT_Arg_t)((MP_Uint8_t) (MP_UINT32_T(arg)))) |
---|
112 | #define MP_SINT32_T(arg) ((MP_Sint32_t) (arg)) |
---|
113 | #define MP_ARG_SINT32_T(arg) ((MPT_Arg_t)((MP_Sint32_t) (arg))) |
---|
114 | #define MP_UINT32_T(arg) ((MP_Uint32_t) (arg)) |
---|
115 | #define MP_ARG_UINT32_T(arg) ((MPT_Arg_t)((MP_Uint32_t) (arg))) |
---|
116 | #define MP_REAL32_T(arg) ((MP_Real32_t) (arg)) |
---|
117 | #define MP_ARG_REAL32_T(arg) ((MPT_Arg_t)((MP_Real32_t) (arg))) |
---|
118 | #ifndef __64_BIT__ |
---|
119 | /* sizeof(void *) < sizeof(MP_Real64_t) */ |
---|
120 | #define MP_REAL64_T(arg) (*((MP_Real64_t *) (arg))) |
---|
121 | #else |
---|
122 | /* sizeof(void *) >= sizeof(MP_Real64_t) */ |
---|
123 | #define MP_REAL64_T(arg) ((MP_Real64_t) (arg)) |
---|
124 | #endif |
---|
125 | #define MP_ARG_REAL64_T(arg) ((MPT_Arg_t)MP_REAL64_T(arg)) |
---|
126 | #define MP_APINT_T(arg) ((MP_ApInt_t) (arg)) |
---|
127 | #define MP_ARG_APINT_T(arg) ((MPT_Arg_t)((MP_ApInt_t) (arg))) |
---|
128 | #define MP_APREAL_T(arg) ((MP_ApReal_t) (arg)) |
---|
129 | #define MP_ARG_APREAL_T(arg) ((MPT_Arg_t)((MP_ApReal_t) (arg))) |
---|
130 | #define MP_STRING_T(arg) ((char *) (arg)) |
---|
131 | #define MP_ARG_STRING_T(arg) ((MPT_Arg_t)((char *) (arg))) |
---|
132 | #define MPT_ARG_T(arg) ((MPT_Arg_t) (arg)) |
---|
133 | |
---|
134 | /* Now we come to "structured" or composite types */ |
---|
135 | /* For ProtoD:Union */ |
---|
136 | #define MPT_UNION_PT(arg) ((MPT_Union_pt) (arg)) |
---|
137 | /* for MetaOps with numchild == 0 */ |
---|
138 | #define MPT_DYNARGS_PT(arg) ((MPT_DynArgs_pt) (arg)) |
---|
139 | /* For ProtoD:Struct, and ProtoD:Ptr, and MetaOps with numchild > 0 */ |
---|
140 | #define MPT_ARG_PT(arg) ((MPT_Arg_pt) arg) |
---|
141 | /* For user defined Meta types or unspecified types */ |
---|
142 | #define MPT_TREE_PT(arg) ((MPT_Tree_pt) arg) |
---|
143 | |
---|
144 | /* And here are Macros tofor dealing with MPT_Arg_pt's */ |
---|
145 | |
---|
146 | #define MP_BOOLEAN_PT(arg_pt) ((MP_Boolean_t *) (arg_pt)) |
---|
147 | #define MP_COMMON_PT(arg_pt) ((MP_Common_t *) (arg_pt)) |
---|
148 | #define MP_SINT8_PT(arg_pt) ((MP_Sint8_t *) (arg_pt)) |
---|
149 | #define MP_UINT8_PT(arg_pt) ((MP_Uint8_t *) (arg_pt)) |
---|
150 | #define MP_SINT32_PT(arg_pt) ((MP_Sint32_t *) (arg_pt)) |
---|
151 | #define MP_UINT32_PT(arg_pt) ((MP_Uint32_t *) (arg_pt)) |
---|
152 | #define MP_REAL32_PT(arg_pt) ((MP_Real32_t *) (arg_pt)) |
---|
153 | #define MP_REAL64_PT(arg_pt) ((MP_Real64_t *) (arg_pt)) |
---|
154 | |
---|
155 | |
---|
156 | /* Argument of Dynamic length -- used for MetaOperators with numchil == 0 */ |
---|
157 | struct MPT_DynArgs_t |
---|
158 | { |
---|
159 | MP_Uint32_t length; /* Length of array pointed to by */ |
---|
160 | MPT_Arg_pt args; |
---|
161 | }; |
---|
162 | |
---|
163 | /* Union -- for ProtoD:Union data*/ |
---|
164 | struct MPT_Union_t |
---|
165 | { |
---|
166 | MP_Uint32_t tag; /* Identifying type of the arg */ |
---|
167 | MPT_Arg_t arg; /* different typespecs */ |
---|
168 | }; |
---|
169 | |
---|
170 | |
---|
171 | /* Furthermore, we need a numeric value which identifies external data in |
---|
172 | node->type */ |
---|
173 | #define MPT_ExternalDataType 255 |
---|
174 | |
---|
175 | /*************************************************************** |
---|
176 | * |
---|
177 | * From MPT_Error.c |
---|
178 | * |
---|
179 | ***************************************************************/ |
---|
180 | |
---|
181 | /* Enumeration of MPT specific errors */ |
---|
182 | typedef enum MPT_Errors |
---|
183 | { |
---|
184 | MPT_Failure, |
---|
185 | MPT_Success, |
---|
186 | MPT_MP_Failure, |
---|
187 | MPT_UnknownType, |
---|
188 | MPT_OutOfMemory, |
---|
189 | MPT_WrongNodeType, |
---|
190 | MPT_WrongTreeSyntax, |
---|
191 | MPT_NoPointerTypespec, |
---|
192 | MPT_WrongUnionDiscriminator, |
---|
193 | MPT_ViolatedAssumption, |
---|
194 | MPT_NotExternalData, |
---|
195 | MPT_WrongApIntFormat, |
---|
196 | MPT_MaxError |
---|
197 | } MPT_Errors; |
---|
198 | |
---|
199 | typedef MPT_Errors MPT_Status_t; |
---|
200 | |
---|
201 | /* global MPT error variable */ |
---|
202 | extern MPT_Status_t MPT_errno; |
---|
203 | |
---|
204 | /* defined in MPT_Error.c */ |
---|
205 | extern const char *MPT_errlist[]; |
---|
206 | |
---|
207 | extern MPT_Status_t MPT_CheckStatus(); |
---|
208 | extern const char* MPT_ErrorStr(MPT_Status_t error); |
---|
209 | extern const char* MPT_LinkErrorStr(MP_Link_pt link, MPT_Status_t error); |
---|
210 | |
---|
211 | /* #define MPT_DEBUG 1 */ |
---|
212 | #ifdef MPT_DEBUG |
---|
213 | /* For Debugging, it is more convenient to have the following defined |
---|
214 | as functions. This way, we can easily set a breakpoints there. */ |
---|
215 | extern MPT_Status_t MPT_SetError(MPT_Status_t error); |
---|
216 | extern MPT_Status_t MPT_ClearError(); |
---|
217 | extern void MPT_Assume(MP_Boolean_t value); |
---|
218 | #else |
---|
219 | #define MPT_SetError(error) MPT_errno = (error) |
---|
220 | #define MPT_ClearError() MPT_errno = MPT_Success |
---|
221 | #define MPT_Assume(x) ((void)0) |
---|
222 | #endif |
---|
223 | |
---|
224 | /*************************************************************** |
---|
225 | * |
---|
226 | * From MPT_Tree.c Copying/Deleting a tree |
---|
227 | * |
---|
228 | ***************************************************************/ |
---|
229 | extern void MPT_DeleteTree(MPT_Tree_pt tree); |
---|
230 | extern void MPT_DeleteNode(MPT_Node_pt node); |
---|
231 | extern void MPT_DeleteArgs(MPT_Arg_pt args, MP_NumChild_t nc, |
---|
232 | MPT_Tree_pt typespec); |
---|
233 | extern void MPT_DeleteTypespecedArg(MPT_Arg_t arg, MPT_Tree_pt typespec); |
---|
234 | |
---|
235 | extern void MPT_CpyTree(MPT_Tree_pt *dest, MPT_Tree_pt src); |
---|
236 | extern void MPT_CpyNode(MPT_Node_pt *odest, MPT_Node_pt src); |
---|
237 | extern void MPT_CpyArgs(MPT_Arg_pt *oargs, MPT_Arg_pt args, |
---|
238 | MP_NumChild_t nc, MPT_Tree_pt typespec); |
---|
239 | extern void MPT_CpyTypespecedArg(MPT_Arg_t *oarg, MPT_Arg_t arg, |
---|
240 | MPT_Tree_pt typespec); |
---|
241 | |
---|
242 | /*************************************************************** |
---|
243 | * |
---|
244 | * From MPT_Get.c |
---|
245 | * |
---|
246 | ***************************************************************/ |
---|
247 | |
---|
248 | extern MPT_Status_t MPT_GetTree(MP_Link_pt link, MPT_Tree_pt *otree); |
---|
249 | extern MPT_Status_t MPT_GetNode(MP_Link_pt link, MPT_Node_pt *onode); |
---|
250 | extern MPT_Status_t MPT_GetAnnot(MP_Link_pt link, MPT_Annot_pt *oanot); |
---|
251 | extern MPT_Status_t MPT_GetArgs(MP_Link_pt link, MPT_Arg_pt *oargs, |
---|
252 | MP_NumChild_t nc, MPT_Tree_pt typespec); |
---|
253 | extern MPT_Status_t MPT_GetTypespecedArg(MP_Link_pt link, MPT_Arg_t *oarg, |
---|
254 | MPT_Tree_pt typespec); |
---|
255 | extern MPT_Status_t MPT_SkipTree(MP_Link_pt link); |
---|
256 | extern MPT_Status_t MPT_SkipArgs(MP_Link_pt link, MPT_Node_pt node); |
---|
257 | extern MPT_Status_t MPT_SkipAnnot(MP_Link_pt link, MP_Boolean_t *req); |
---|
258 | extern MPT_Status_t MPT_SkipAnnots(MP_Link_pt link, MP_NumAnnot_t na, |
---|
259 | MP_Boolean_t *req); |
---|
260 | |
---|
261 | /*************************************************************** |
---|
262 | * |
---|
263 | * From MPT_Put.c |
---|
264 | * |
---|
265 | ***************************************************************/ |
---|
266 | extern MPT_Status_t MPT_PutTree(MP_Link_pt link, MPT_Tree_pt tree); |
---|
267 | extern MPT_Status_t MPT_PutNode(MP_Link_pt link, MPT_Node_pt node); |
---|
268 | extern MPT_Status_t MPT_PutArgs(MP_Link_pt link, MPT_Arg_pt args, |
---|
269 | MP_NumChild_t nc, |
---|
270 | MPT_Tree_pt typespec); |
---|
271 | extern MPT_Status_t MPT_PutTypespecedArg(MP_Link_pt link, MPT_Arg_t arg, |
---|
272 | MPT_Tree_pt typespec); |
---|
273 | |
---|
274 | /*************************************************************** |
---|
275 | * |
---|
276 | * From MPT_ApNumber.c |
---|
277 | * |
---|
278 | ***************************************************************/ |
---|
279 | |
---|
280 | extern MPT_Status_t MPT_Init(MP_Env_pt env); |
---|
281 | extern int MPT_GetApIntFormat(); |
---|
282 | extern void (*MPT_InitCopyApInt)(MPT_Arg_t *dest, MPT_Arg_t src); |
---|
283 | extern void (*MPT_DeleteApInt)(MPT_Arg_t apint); |
---|
284 | extern void MPT_InitCopyApReal(MPT_Arg_t *dest, MPT_Arg_t src); |
---|
285 | extern void MPT_DeleteApReal(MPT_Arg_t apreal); |
---|
286 | MPT_Status_t MPT_GetApInt(MP_Link_pt link, MPT_Arg_t *arg); |
---|
287 | MPT_Status_t MPT_PutApInt(MP_Link_pt link, MPT_Arg_t arg); |
---|
288 | MPT_Status_t MPT_GetApReal(MP_Link_pt link, MPT_Arg_t *apreal); |
---|
289 | MPT_Status_t MPT_PutApReal(MP_Link_pt link, MPT_Arg_t arg); |
---|
290 | |
---|
291 | /*************************************************************** |
---|
292 | * |
---|
293 | * From MPT_Misc.c |
---|
294 | * |
---|
295 | ***************************************************************/ |
---|
296 | inline MP_Boolean_t MPT_IsNode(MPT_Node_pt node, |
---|
297 | MP_NodeType_t type, |
---|
298 | MP_DictTag_t dict) |
---|
299 | { |
---|
300 | return (node->type == type && node->dict == dict); |
---|
301 | } |
---|
302 | |
---|
303 | inline MP_Boolean_t MPT_IsNode(MPT_Node_pt node, |
---|
304 | MP_NodeType_t type, |
---|
305 | MP_DictTag_t dict, |
---|
306 | MP_Common_t cvalue) |
---|
307 | { |
---|
308 | return (node->type == type && node->dict == dict && |
---|
309 | MP_COMMON_T(node->nvalue) == cvalue); |
---|
310 | } |
---|
311 | |
---|
312 | inline MP_Boolean_t MPT_IsNode(MPT_Node_pt node, |
---|
313 | MP_NodeType_t type, |
---|
314 | MP_DictTag_t dict, |
---|
315 | MP_Common_t cvalue, |
---|
316 | MP_NumChild_t nc) |
---|
317 | { |
---|
318 | return (node->type == type && node->dict == dict && |
---|
319 | MP_COMMON_T(node->nvalue) == cvalue && node->numchild == nc); |
---|
320 | } |
---|
321 | |
---|
322 | inline MPT_Annot_pt MPT_Annot(MPT_Node_pt node, MP_DictTag_t dict, |
---|
323 | MP_AnnotType_t atype) |
---|
324 | /* Searches for annot of type atype and dicionary tag dict in annots |
---|
325 | attached to node. If one is found, then the first one is |
---|
326 | returned, otherwise, NULL is returned */ |
---|
327 | { |
---|
328 | MP_NumAnnot_t numannot; |
---|
329 | MP_Uint32_t i; |
---|
330 | MPT_Annot_pt *annots, an; |
---|
331 | |
---|
332 | MPT_Assume(node != NULL); |
---|
333 | |
---|
334 | numannot = node->numannot; |
---|
335 | if (numannot == 0) return NULL; |
---|
336 | |
---|
337 | annots = node->annots; |
---|
338 | MPT_Assume(annots != NULL); |
---|
339 | |
---|
340 | for (i=0; i<numannot; i++) |
---|
341 | { |
---|
342 | an = annots[i]; |
---|
343 | if (an->type == atype && an->dict == dict) return an; |
---|
344 | } |
---|
345 | |
---|
346 | return NULL; |
---|
347 | } |
---|
348 | |
---|
349 | inline MPT_Tree_pt MPT_AnnotValue(MPT_Node_pt node, MP_DictTag_t dict, |
---|
350 | MP_AnnotType_t atype) |
---|
351 | { |
---|
352 | MPT_Annot_pt annot = MPT_Annot(node, dict, atype); |
---|
353 | if (annot != NULL && annot->value != NULL) |
---|
354 | return annot->value; |
---|
355 | return NULL; |
---|
356 | } |
---|
357 | |
---|
358 | #define MPT_ProtoAnnotValue(node) \ |
---|
359 | MPT_AnnotValue(node, MP_ProtoDict, MP_AnnotProtoPrototype) |
---|
360 | |
---|
361 | extern void MPT_MoveAnnots(MPT_Node_pt from, MPT_Node_pt to); |
---|
362 | extern void MPT_RemoveAnnot(MPT_Node_pt node, |
---|
363 | MP_DictTag_t dict, |
---|
364 | MP_AnnotType_t type); |
---|
365 | #define MPT_RemoveProtoAnnot(node) \ |
---|
366 | MPT_RemoveAnnot(node, MP_ProtoDict, MP_AnnotProtoPrototype) |
---|
367 | |
---|
368 | extern MP_Boolean_t MPT_IsTrueProtoTypeSpec(MPT_Tree_pt typespec); |
---|
369 | inline MPT_Tree_pt MPT_TrueProtoAnnotValue(MPT_Node_pt node) |
---|
370 | { |
---|
371 | MPT_Tree_pt ptree = MPT_ProtoAnnotValue(node); |
---|
372 | if (ptree != NULL && MPT_IsTrueProtoTypeSpec(ptree)) |
---|
373 | return ptree; |
---|
374 | |
---|
375 | return NULL; |
---|
376 | } |
---|
377 | |
---|
378 | extern void* IMP_MemAlloc0Fnc(size_t size); |
---|
379 | extern MPT_Tree_pt MPT_InitTree(MP_Common_t type, |
---|
380 | MP_DictTag_t dict, |
---|
381 | MPT_Arg_t nvalue, |
---|
382 | MP_NumAnnot_t num_annot, |
---|
383 | MP_NumChild_t num_child); |
---|
384 | #define MPT_InitBasicTree(type, arg) MPT_InitTree(type, 0, arg, 0, 0) |
---|
385 | |
---|
386 | extern void MPT_PushRecStruct(MPT_Tree_pt tree); |
---|
387 | extern void MPT_PopRecStruct(); |
---|
388 | extern void MPT_PushRecUnion(MPT_Tree_pt tree); |
---|
389 | extern void MPT_PopRecUnion(); |
---|
390 | extern MPT_Tree_pt MPT_RecStructTree; |
---|
391 | extern MPT_Tree_pt MPT_RecUnionTree; |
---|
392 | |
---|
393 | /*************************************************************** |
---|
394 | * |
---|
395 | * From MPT_TreeManips.c |
---|
396 | * |
---|
397 | ***************************************************************/ |
---|
398 | extern MPT_Tree_pt MPT_UntypespecTree(MPT_Tree_pt tree); |
---|
399 | extern MPT_Arg_pt MPT_UntypespecArgs(MPT_Arg_pt args, |
---|
400 | MP_NumChild_t nc, |
---|
401 | MPT_Tree_pt typespec); |
---|
402 | extern MPT_Tree_pt MPT_UntypespecArg(MPT_Arg_t arg, MPT_Tree_pt typespec); |
---|
403 | |
---|
404 | /*************************************************************** |
---|
405 | * |
---|
406 | * From MPT_PolyManips.c |
---|
407 | * |
---|
408 | ***************************************************************/ |
---|
409 | extern MPT_Tree_pt MPT_DDP_2_ExpTree(MPT_Tree_pt tree); |
---|
410 | extern MP_Boolean_t MPT_IsExpVectorTypespec(MPT_Tree_pt typespec, |
---|
411 | MP_NumChild_t *num_vars); |
---|
412 | |
---|
413 | /*************************************************************** |
---|
414 | * |
---|
415 | * From MPT_ExternalData.c |
---|
416 | * |
---|
417 | ***************************************************************/ |
---|
418 | |
---|
419 | extern void (*MPT_DeleteExternalData)(MPT_Arg_t edata); |
---|
420 | extern void (*MPT_CpyExternalData)(MPT_Arg_t *src, |
---|
421 | MPT_Arg_t dest); |
---|
422 | extern MPT_Status_t (*MPT_GetExternalData)(MP_Link_pt link, |
---|
423 | MPT_Arg_t *data, |
---|
424 | MPT_Node_pt node); |
---|
425 | extern MPT_Status_t (*MPT_PutExternalData)(MP_Link_pt link, |
---|
426 | MPT_Arg_t data); |
---|
427 | extern void MPT_DefaultDeleteExternalData(MPT_Arg_t edata); |
---|
428 | extern void MPT_DefaultCpyExternalData(MPT_Arg_t *src, |
---|
429 | MPT_Arg_t dest); |
---|
430 | extern MPT_Status_t MPT_DefaultGetExternalData(MP_Link_pt link, |
---|
431 | MPT_Arg_t *data, |
---|
432 | MPT_Node_pt node); |
---|
433 | extern MPT_Status_t MPT_DefaultPutExternalData(MP_Link_pt link, |
---|
434 | MPT_Arg_t data); |
---|
435 | |
---|
436 | /*************************************************************** |
---|
437 | * |
---|
438 | * from MPT_PutPoly.c |
---|
439 | * |
---|
440 | ***************************************************************/ |
---|
441 | typedef void* MPT_ExternalPoly_t; |
---|
442 | typedef void* MPT_ExternalMonomial_t; |
---|
443 | typedef void* MPT_ExternalCoeff_t; |
---|
444 | typedef void* MPT_ExternalIdeal_t; |
---|
445 | typedef void* MPT_External2DMatrix_t; |
---|
446 | typedef void* MPT_External2DPolyMatrix_t; |
---|
447 | |
---|
448 | |
---|
449 | typedef struct MPT_PutPolyFncs_t |
---|
450 | { |
---|
451 | MP_Sint32_t (*GetCharacteristic) (MPT_ExternalPoly_t poly); |
---|
452 | MP_Uint32_t (*GetNumberOfVariables) (MPT_ExternalPoly_t poly); |
---|
453 | char * (*GetVarName) (MPT_ExternalPoly_t poly, MP_Uint32_t varnumber); |
---|
454 | MP_Common_t (*GetMonomialOrdering) (MPT_ExternalPoly_t poly); |
---|
455 | MP_Uint32_t (*GetNumberOfMonomials) (MPT_ExternalPoly_t poly); |
---|
456 | MP_Status_t (*PutCoeffFillExpVector) (MP_Link_pt link, |
---|
457 | MPT_ExternalPoly_t poly, |
---|
458 | MP_Uint32_t monomial, |
---|
459 | MP_Uint32_t varnumber, |
---|
460 | MP_Sint32_t *ex_pvector); |
---|
461 | } MPT_PutPolyFncs_t; |
---|
462 | typedef MPT_PutPolyFncs_t* MPT_PutPolyFncs_pt; |
---|
463 | |
---|
464 | typedef struct MPT_PutIdealFncs_t |
---|
465 | { |
---|
466 | MP_Uint32_t (*GetNumberOfPolys) (MPT_ExternalIdeal_t ideal); |
---|
467 | MPT_ExternalPoly_t (*GetPoly) (MPT_ExternalIdeal_t ideal, |
---|
468 | MP_Uint32_t polynumber); |
---|
469 | MPT_PutPolyFncs_pt polyfncs; |
---|
470 | } MPT_PutIdealFncs_t; |
---|
471 | typedef MPT_PutIdealFncs_t * MPT_PutIdealFncs_pt; |
---|
472 | |
---|
473 | typedef struct MPT_Put2DMatrixFncs_t |
---|
474 | { |
---|
475 | void (*GetDimension) (MPT_External2DMatrix_t matrix, |
---|
476 | MP_Uint32_t *m, |
---|
477 | MP_Uint32_t *n); |
---|
478 | MP_Status_t (*PutElType) (MP_Link_pt link, MPT_External2DMatrix_t matrix); |
---|
479 | MP_Status_t (*PutEl) (MP_Link_pt link, |
---|
480 | MPT_External2DMatrix_t matrix, |
---|
481 | MP_Uint32_t m, |
---|
482 | MP_Uint32_t n); |
---|
483 | } MPT_Put2DMatrixFncs_t; |
---|
484 | typedef MPT_Put2DMatrixFncs_t* MPT_Put2DMatrixFncs_pt; |
---|
485 | |
---|
486 | typedef struct MPT_Put2DPolyMatrixFncs_t |
---|
487 | { |
---|
488 | void (*GetDimension) (MPT_External2DPolyMatrix_t matrix, |
---|
489 | MP_Uint32_t *m, |
---|
490 | MP_Uint32_t *n); |
---|
491 | MPT_ExternalPoly_t (*GetPoly) (MPT_External2DPolyMatrix_t matrix, |
---|
492 | MP_Uint32_t m, |
---|
493 | MP_Uint32_t n); |
---|
494 | MPT_PutPolyFncs_pt polyfncs; |
---|
495 | } MPT_Put2DPolyMatrixFncs_t; |
---|
496 | typedef MPT_Put2DPolyMatrixFncs_t* MPT_Put2DPolyMatrixFncs_pt; |
---|
497 | |
---|
498 | |
---|
499 | |
---|
500 | extern MP_Status_t MPT_PutDDPoly(MP_Link_pt link, |
---|
501 | MPT_ExternalPoly_t poly, |
---|
502 | MPT_PutPolyFncs_pt polyfncs); |
---|
503 | extern MP_Status_t MPT_PutPolyAnnots(MP_Link_pt link, |
---|
504 | MPT_ExternalPoly_t poly, |
---|
505 | MPT_PutPolyFncs_pt polyfncs); |
---|
506 | extern MP_Status_t MPT_PutPolyData(MP_Link_pt link, |
---|
507 | MPT_ExternalPoly_t poly, |
---|
508 | MP_Uint32_t nummonimials, |
---|
509 | MPT_PutPolyFncs_pt polyfncs); |
---|
510 | extern MP_Status_t MPT_PutDDPIdeal(MP_Link_pt link, |
---|
511 | MPT_ExternalIdeal_t ideal, |
---|
512 | MPT_PutIdealFncs_pt polyfncs); |
---|
513 | extern MP_Status_t MPT_PutDense2DMatrix(MP_Link_pt link, |
---|
514 | MPT_External2DMatrix_t matrix, |
---|
515 | MPT_Put2DMatrixFncs_pt matrixfncs); |
---|
516 | extern MP_Status_t MPT_Put2DPolyMatrix(MP_Link_pt link, |
---|
517 | MPT_External2DPolyMatrix_t matrix, |
---|
518 | MPT_Put2DPolyMatrixFncs_pt mfncts); |
---|
519 | |
---|
520 | /*************************************************************** |
---|
521 | * |
---|
522 | * from MPT_GetPoly.c |
---|
523 | * |
---|
524 | ***************************************************************/ |
---|
525 | extern MP_Boolean_t MPT_IsDDPTree(MPT_Tree_pt tree, |
---|
526 | MP_Sint32_t *characteristic, |
---|
527 | MPT_Tree_pt *var_tree, |
---|
528 | MP_Common_t *ordering); |
---|
529 | extern MPT_Tree_pt MPT_GetVarNamesTree(MPT_Node_pt node, |
---|
530 | MP_NumChild_t num_vars); |
---|
531 | extern MP_Boolean_t MPT_IsIdealTree(MPT_Tree_pt tree, |
---|
532 | MP_Sint32_t *characteristic, |
---|
533 | MPT_Tree_pt *var_tree, |
---|
534 | MP_Common_t *ordering); |
---|
535 | |
---|
536 | /*************************************************************** |
---|
537 | * |
---|
538 | * Useful Macros |
---|
539 | * |
---|
540 | ***************************************************************/ |
---|
541 | #define mpt_failr(cond) \ |
---|
542 | do { \ |
---|
543 | MPT_Status_t _mpt_status = cond; \ |
---|
544 | if (_mpt_status != MPT_Success) return _mpt_status;\ |
---|
545 | } while (0) |
---|
546 | |
---|
547 | #define mp_failr(cond) \ |
---|
548 | do \ |
---|
549 | { \ |
---|
550 | if (((MP_Status_t) (cond)) != MP_Success) return MPT_SetError(MPT_MP_Failure); \ |
---|
551 | } while (0) |
---|
552 | |
---|
553 | |
---|
554 | #define mp_return(stmnt) \ |
---|
555 | do \ |
---|
556 | { \ |
---|
557 | if ((stmnt) != MP_Success) return MPT_SetError(MPT_MP_Failure); \ |
---|
558 | else return MPT_Success; \ |
---|
559 | } \ |
---|
560 | while (0) |
---|
561 | |
---|
562 | #define failr(cond) \ |
---|
563 | do \ |
---|
564 | { \ |
---|
565 | if ((cond) != MP_Success) return MP_Failure; \ |
---|
566 | } while (0) |
---|
567 | |
---|
568 | /****************************************************************** |
---|
569 | * |
---|
570 | * some handy defines |
---|
571 | * |
---|
572 | ******************************************************************/ |
---|
573 | #define MP_AnnotReqValTree (MP_AnnotRequired | MP_AnnotValuated | MP_AnnotTreeScope) |
---|
574 | |
---|
575 | #define MP_AnnotReqValNode (MP_AnnotRequired | MP_AnnotValuated) |
---|
576 | |
---|
577 | #endif /* _MPT_H_ */ |
---|
578 | |
---|