1 /***********************************************************************/
2 /* Open Visualization Data Explorer                                    */
3 /* (C) Copyright IBM Corp. 1989,1999                                   */
4 /* ALL RIGHTS RESERVED                                                 */
5 /* This code licensed under the                                        */
6 /*    "IBM PUBLIC LICENSE - Open Visualization Data Explorer"          */
7 /***********************************************************************/
8 
9 #include <dxconfig.h>
10 
11 #ifndef __COMPUTE_H_
12 #define __COMPUTE_H_
13 
14 #define NT_ERROR	(-1)
15 #define NT_INPUT	0
16 #define NT_CONSTANT	1
17 #define NT_CONSTRUCT	2
18 #define NT_COND		4
19 #define NT_TOP		5
20 
21 #define OPER_PLUS	6
22 #define OPER_MINUS	7
23 #define OPER_MUL	8
24 #define OPER_DIV	9
25 #define OPER_MOD	10
26 #define OPER_CROSS	11
27 #define OPER_DOT	12
28 #define OPER_LT		13
29 #define OPER_LE		14
30 #define OPER_GT		15
31 #define OPER_GE		16
32 #define OPER_EQ		17
33 #define OPER_NE		18
34 #define OPER_AND	19
35 #define OPER_OR		20
36 #define OPER_EXP	21
37 #define OPER_PERIOD	22
38 #define OPER_NOT	23
39 #define OPER_ASSIGNMENT	24
40 #define OPER_VARIABLE	25
41 
42 #define LAST_OPER	25
43 /* _compoper.c defines other operators starting at LAST_OPER+1 */
44 
45 
46 typedef struct {
47     int  	items;
48     Type 	type;
49     Category 	category;
50     int 	rank;
51     int 	shape[32];
52     int		id;
53 } MetaType;
54 
55 typedef struct PTreeNode PTreeNode;
56 typedef struct ObjStruct ObjStruct;
57 typedef int (*CompFuncV)(PTreeNode*, ObjStruct*,
58 			 int, Pointer*, Pointer,
59 			 InvalidComponentHandle*, InvalidComponentHandle);
60 
61 struct PTreeNode {
62     struct PTreeNode 	*next;		/* Parent's List */
63     int  		oper;		/* Type of this node */
64     char 		*operName;	/* Name of this function */
65     CompFuncV 		impl;		/* Routine to implement this node */
66     struct PTreeNode 	*args;		/* My arguments (NULL if none) */
67     MetaType		metaType;
68     union {
69 	float	f;
70 	int	i;
71 	double	d;
72 #define MAX_CA_STRING 512
73 	char	s[MAX_CA_STRING];
74     } 			u;		/* Constant data */
75 };
76 
77 #define MAX_INPUTS	21
78 
79 typedef struct {
80     int used;
81     Class class;
82     Object object;
83 } CompInput;
84 
85 
86 /* ObjStruct holds the definition of the input structures.
87  * If the class is CLASS_GROUP, members contains a list of
88  * group members (linked by next).  Objects contains a list of
89  * elements paired up for processing.  If GetObjectClass(output) ==
90  * CLASS_ARRAY, then output isn't a copy, and when we know the type
91  * (shape, ...) then we should create a new one of the appropriate type.
92  */
93 struct ObjStruct {
94     Class	 class;
95     Class	 subClass;
96     Object 	 output;
97     Object 	 inputs[MAX_INPUTS];
98     PTreeNode	 *parseTree;
99     MetaType 	 metaType;
100     struct ObjStruct *members;
101     struct ObjStruct *next;
102 };
103 
104 
105 #define OPRL_INIT(node, v)   ((node)->args = (v))
106 #define OPRL_INSERT(node, v) ((v)->next = (node)->args, (node)->args = (v))
107 
108 extern PTreeNode   *_dxdcomputeTree;
109 extern CompInput  _dxdcomputeInput[];
110 
111 
112 /* from _compinput.c */
113 void	  _dxfComputeInitInputs(CompInput *);
114 ObjStruct *_dxfComputeGetInputs(Object *, CompInput *);
115 void	  _dxfComputeDumpInputs(CompInput *, ObjStruct *);
116 void      _dxfComputeFreeObjStruct (ObjStruct *);
117 
118 
119 /* from _compexec.c */
120 int	_dxfComputeExecute (PTreeNode *, ObjStruct *);
121 
122 /* from compute.c */
123 int m_Compute(Object *, Object *);
124 
125 
126 
127 /* #define COMP_DEBUG 1 */
128 
129 #endif /* __COMPUTE_H_ */
130