1 /*
2 Copyright (c) 1994 - 2010, Lawrence Livermore National Security, LLC.
3 LLNL-CODE-425250.
4 All rights reserved.
5
6 This file is part of Silo. For details, see silo.llnl.gov.
7
8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions
10 are met:
11
12 * Redistributions of source code must retain the above copyright
13 notice, this list of conditions and the disclaimer below.
14 * Redistributions in binary form must reproduce the above copyright
15 notice, this list of conditions and the disclaimer (as noted
16 below) in the documentation and/or other materials provided with
17 the distribution.
18 * Neither the name of the LLNS/LLNL nor the names of its
19 contributors may be used to endorse or promote products derived
20 from this software without specific prior written permission.
21
22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE
26 LIVERMORE NATIONAL SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR
27 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35 This work was produced at Lawrence Livermore National Laboratory under
36 Contract No. DE-AC52-07NA27344 with the DOE.
37
38 Neither the United States Government nor Lawrence Livermore National
39 Security, LLC nor any of their employees, makes any warranty, express
40 or implied, or assumes any liability or responsibility for the
41 accuracy, completeness, or usefulness of any information, apparatus,
42 product, or process disclosed, or represents that its use would not
43 infringe privately-owned rights.
44
45 Any reference herein to any specific commercial products, process, or
46 services by trade name, trademark, manufacturer or otherwise does not
47 necessarily constitute or imply its endorsement, recommendation, or
48 favoring by the United States Government or Lawrence Livermore
49 National Security, LLC. The views and opinions of authors expressed
50 herein do not necessarily state or reflect those of the United States
51 Government or Lawrence Livermore National Security, LLC, and shall not
52 be used for advertising or product endorsement purposes.
53 */
54 /*-------------------------------------------------------------------------
55 *
56 * Created: stc.c
57 * Dec 6 1996
58 * Robb Matzke <matzke@viper.llnl.gov>
59 *
60 * Purpose: The structure type class.
61 *
62 * Modifications:
63 *
64 *-------------------------------------------------------------------------
65 */
66 #include <assert.h>
67 #include <browser.h>
68 #define MYCLASS(X) ((obj_stc_t*)(X))
69
70 typedef struct obj_stc_t {
71 obj_pub_t pub;
72 char *name; /*name of structure or "" */
73 int ncomps; /*number of components used */
74 int acomps; /*number of components allocated*/
75 int *offset; /*offset for each component */
76 obj_t *sub; /*type of each component */
77 char **compname; /*name of each component */
78 void (*walk1)(obj_t,void*,int,walk_t*); /*walk1 override */
79 int (*walk2)(obj_t,void*,obj_t,void*,walk_t*);/*walk2 override*/
80 } obj_stc_t;
81
82 class_t C_STC;
83 static obj_t stc_new (va_list);
84 static obj_t stc_copy (obj_t, int);
85 static obj_t stc_dest (obj_t);
86 static obj_t stc_feval (obj_t);
87 static obj_t stc_apply (obj_t, obj_t);
88 static void stc_walk1 (obj_t, void*, int, walk_t*);
89 static int stc_walk2 (obj_t, void*, obj_t, void*, walk_t*);
90 static void stc_print (obj_t, out_t*);
91 static obj_t stc_deref (obj_t, int, obj_t*);
92 static char * stc_name (obj_t);
93 static obj_t stc_bind (obj_t, void*);
94
95 #define STRUCT(ST) STRUCT2(ST,#ST)
96
97 #define STRUCT2(ST_R,ST_F) { \
98 ST_R _tmp ; \
99 lex_t *_li=NULL ; \
100 obj_t _in=NIL, _out=NIL ; \
101 char *_tname = ST_F ; \
102 obj_t _t = obj_new (C_STC, ST_F, NULL); \
103 obj_stc_t *_tt = (obj_stc_t*)_t;
104
105 #define COMP(FIELD,TYPE) COMP2(FIELD,#FIELD,TYPE)
106
107 #define COMP2(FIELD_R,FIELD_F,TYPE) \
108 _li = lex_string (TYPE); \
109 _in = parse_stmt (_li, false); \
110 _li = lex_close (_li); \
111 _out = obj_eval (_in); \
112 _in = obj_dest (_in); \
113 assert (_out); \
114 COMP3 (FIELD_R, FIELD_F, _out);
115
116 #define COMP3(FIELD_R,FIELD_F,TYPE) \
117 stc_add (_t, TYPE, ((char*)(&(_tmp.FIELD_R))-(char*)(&_tmp)), FIELD_F); \
118 prim_set_io_assoc(_tt->sub[_tt->ncomps-1], NULL); /*for cc warning*/
119
120 #define IOASSOC(ASSOC) \
121 assert (_tt->ncomps-1>=0); \
122 assert (_tt->sub[_tt->ncomps-1]); \
123 _in = prim_set_io_assoc (_tt->sub[_tt->ncomps-1], ASSOC); \
124 assert (_in) ; \
125 _in = NIL;
126
127 #define WALK1(FUNC) \
128 assert (_tt); \
129 _tt->walk1 = FUNC
130
131 #define WALK2(FUNC) \
132 assert (_tt); \
133 _tt->walk2 = FUNC
134
135 #define ESTRUCT \
136 _in = obj_new (C_SYM, _tname); \
137 sym_vbind (_in, _t); \
138 obj_dest (_in) ; \
139 _tt=NULL; /*to prevent compiler warning*/ \
140 }
141
142
143
144
145 /*-------------------------------------------------------------------------
146 * Function: stc_class
147 *
148 * Purpose: Initializes the STRUCT class.
149 *
150 * Return: Success: Ptr to the class
151 *
152 * Failure: NULL
153 *
154 * Programmer: Robb Matzke
155 * matzke@viper.llnl.gov
156 * Dec 6 1996
157 *
158 * Modifications:
159 *
160 * Lisa J. Roberts, Mon Nov 22 17:27:53 PST 1999
161 * I changed strdup to safe_strdup.
162 *
163 *-------------------------------------------------------------------------
164 */
165 class_t
stc_class(void)166 stc_class (void) {
167
168 class_t cls = (class_t)calloc (1, sizeof(*cls));
169
170 cls->name = safe_strdup ("STRUCT");
171 cls->newobj = stc_new;
172 cls->copy = stc_copy;
173 cls->dest = stc_dest;
174 cls->feval = stc_feval;
175 cls->apply = stc_apply;
176 cls->print = stc_print;
177 cls->walk1 = stc_walk1;
178 cls->walk2 = stc_walk2;
179 cls->deref = stc_deref;
180 cls->objname = stc_name;
181 cls->bind = stc_bind;
182 return cls;
183 }
184
185
186 /*-------------------------------------------------------------------------
187 * Function: stc_new
188 *
189 * Purpose: Creates a new struct object with the specified components.
190 * Each following structure component consists of three values:
191 * the type of the component, a byte offset from the beginning
192 * of the structure, and the name of the component. All are
193 * required. The argument list must be terminated with a
194 * NULL pointer.
195 *
196 * The first argument is an optional structure name.
197 *
198 * Return: Success: Ptr to a new STRUCT object.
199 *
200 * Failure: NIL
201 *
202 * Programmer: Robb Matzke
203 * matzke@viper.llnl.gov
204 * Dec 6 1996
205 *
206 * Modifications:
207 *
208 * Lisa J. Roberts, Mon Nov 22 17:27:53 PST 1999
209 * I changed strdup to safe_strdup.
210 *
211 *-------------------------------------------------------------------------
212 */
213 static obj_t
stc_new(va_list ap)214 stc_new (va_list ap) {
215
216 obj_stc_t *self = (obj_stc_t *)calloc (1, sizeof(obj_stc_t));
217 obj_t _self = (obj_t)self;
218 obj_t sub;
219 int offset;
220 char *name;
221
222 name = va_arg (ap, char*);
223 self->name = safe_strdup (name?name:"");
224
225 for (;;) {
226 sub = va_arg (ap, obj_t);
227 if (!sub) break;
228 offset = va_arg (ap, int);
229 name = va_arg (ap, char*);
230
231 stc_add (_self, sub, offset, name);
232 }
233
234 return _self;
235 }
236
237
238 /*-------------------------------------------------------------------------
239 * Function: stc_add
240 *
241 * Purpose: Destructively adds another field to a structure.
242 *
243 * Return: Success: SELF
244 *
245 * Failure: NIL
246 *
247 * Programmer: Robb Matzke
248 * robb@maya.nuance.mdn.com
249 * Jan 31 1997
250 *
251 * Modifications:
252 *
253 * Lisa J. Roberts, Mon Nov 22 17:27:53 PST 1999
254 * I changed strdup to safe_strdup.
255 *
256 *-------------------------------------------------------------------------
257 */
258 obj_t
stc_add(obj_t _self,obj_t sub,int offset,const char * name)259 stc_add (obj_t _self, obj_t sub, int offset, const char *name) {
260
261 obj_stc_t *self = MYCLASS(_self);
262 int i;
263
264 /*
265 * Does the field already exist? If yes, replace it with the new
266 * definition.
267 */
268 for (i=0; i<self->ncomps; i++) {
269 if (!strcmp(self->compname[i], name)) {
270 obj_dest (self->sub[i]);
271 self->sub[i] = sub;
272 self->offset[i] = offset;
273 return _self;
274 }
275 }
276
277 /*
278 * (Re)allocate space for the new component (possibly with malloc
279 * for those non-posix systems.
280 */
281 if (self->ncomps>=self->acomps) {
282 self->acomps = MAX (2*self->acomps, 30);
283 if (self->sub) {
284 self->offset = (int *)realloc (self->offset, self->acomps*sizeof(int));
285 self->compname = (char **)realloc (self->compname, self->acomps*sizeof(char*));
286 self->sub = (obj_t *)realloc (self->sub, self->acomps*sizeof(obj_t));
287 } else {
288 self->offset = (int *)malloc (self->acomps*sizeof(int));
289 self->compname = (char **)malloc (self->acomps*sizeof(char*));
290 self->sub = (obj_t *)malloc (self->acomps*sizeof(obj_t));
291 }
292 assert (self->offset);
293 assert (self->compname);
294 assert (self->sub);
295 }
296
297
298 /*
299 * Create the new component
300 */
301 i = self->ncomps;
302 self->ncomps += 1;
303
304 self->offset[i] = offset;
305 self->sub[i] = sub;
306 self->compname[i] = safe_strdup (name);
307
308 return _self;
309 }
310
311
312 /*-------------------------------------------------------------------------
313 * Function: stc_copy
314 *
315 * Purpose: Copies a structure.
316 *
317 * Return: Success: Ptr to a copy of the structure.
318 *
319 * Failure: abort()
320 *
321 * Programmer: Robb Matzke
322 * robb@maya.nuance.mdn.com
323 * Jan 22 1997
324 *
325 * Modifications:
326 *
327 * Lisa J. Roberts, Mon Nov 22 17:27:53 PST 1999
328 * I changed strdup to safe_strdup.
329 *
330 *-------------------------------------------------------------------------
331 */
332 static obj_t
stc_copy(obj_t _self,int flag)333 stc_copy (obj_t _self, int flag) {
334
335 obj_stc_t *self = MYCLASS(_self);
336 obj_stc_t *retval = NULL;
337 obj_t x;
338 int i;
339
340 if (SHALLOW==flag) {
341 for (i=0; i<self->ncomps; i++) {
342 x = obj_copy (self->sub[i], SHALLOW);
343 assert (x==self->sub[i]);
344 }
345 retval = self;
346
347 } else {
348 retval = (obj_stc_t *)calloc (1, sizeof(obj_stc_t));
349 retval->walk1 = self->walk1;
350 retval->walk2 = self->walk2;
351 retval->name = safe_strdup (self->name);
352 retval->acomps = self->ncomps; /*save some memory*/
353 retval->sub = (obj_t *)malloc (retval->acomps * sizeof(obj_t));
354 retval->offset = (int *)malloc (retval->acomps * sizeof(int));
355 retval->compname = (char **)malloc (retval->acomps * sizeof(char*));
356 retval->ncomps = self->ncomps;
357
358 for (i=0; i<self->ncomps; i++) {
359 retval->sub[i] = obj_copy (self->sub[i], DEEP);
360 retval->offset[i] = self->offset[i];
361 retval->compname[i] = safe_strdup (self->compname[i]);
362 }
363 }
364
365 return (obj_t)retval;
366 }
367
368
369 /*-------------------------------------------------------------------------
370 * Function: stc_dest
371 *
372 * Purpose: Destroys a structure type object.
373 *
374 * Return: Success: NIL
375 *
376 * Failure: NIL
377 *
378 * Programmer: Robb Matzke
379 * matzke@viper.llnl.gov
380 * Dec 6 1996
381 *
382 * Modifications:
383 *
384 * Robb Matzke, 5 Feb 1997
385 * Frees memory associated with the structure.
386 *
387 *-------------------------------------------------------------------------
388 */
389 static obj_t
stc_dest(obj_t _self)390 stc_dest (obj_t _self) {
391
392 obj_stc_t *self = MYCLASS(_self);
393 int i;
394
395 for (i=0; i<self->ncomps; i++) {
396 obj_dest (self->sub[i]);
397 if (0==self->pub.ref) {
398 if (self->compname[i]) free (self->compname[i]);
399 }
400 }
401
402 if (0==self->pub.ref) {
403 free (self->name);
404 free (self->sub);
405 free (self->offset);
406 free (self->compname);
407 memset (self, 0, sizeof(obj_stc_t));
408 }
409 return NIL;
410 }
411
412
413 /*-------------------------------------------------------------------------
414 * Function: stc_feval
415 *
416 * Purpose: The functional value of a type is the type.
417 *
418 * Return: Success: Copy of SELF
419 *
420 * Failure: NIL
421 *
422 * Programmer: Robb Matzke
423 * matzke@viper.llnl.gov
424 * Dec 6 1996
425 *
426 * Modifications:
427 *
428 *-------------------------------------------------------------------------
429 */
430 static obj_t
stc_feval(obj_t _self)431 stc_feval (obj_t _self) {
432
433 return obj_copy (_self, SHALLOW);
434 }
435
436
437 /*-------------------------------------------------------------------------
438 * Function: stc_apply
439 *
440 * Purpose: Applying a structure type to an argument list consisting of
441 * a single SILO database object (SDO) causes the object to
442 * be cast to that type.
443 *
444 * Return: Success: Ptr to a new SDO object with the appropriate
445 * type.
446 *
447 * Failure: NIL
448 *
449 * Programmer: Robb Matzke
450 * matzke@viper.llnl.gov
451 * Dec 6 1996
452 *
453 * Modifications:
454 *
455 *-------------------------------------------------------------------------
456 */
457 static obj_t
stc_apply(obj_t _self,obj_t args)458 stc_apply (obj_t _self, obj_t args) {
459
460 obj_t sdo=NIL, retval=NIL;
461
462 if (1!=F_length(args)) {
463 out_errorn ("typecast: wrong number of arguments");
464 return NIL;
465 }
466
467 sdo = obj_eval (cons_head (args));
468 retval = sdo_cast (sdo, _self);
469 obj_dest (sdo);
470 return retval;
471 }
472
473
474 /*-------------------------------------------------------------------------
475 * Function: stc_print
476 *
477 * Purpose: Prints a structure type.
478 *
479 * Return: void
480 *
481 * Programmer: Robb Matzke
482 * matzke@viper.llnl.gov
483 * Dec 6 1996
484 *
485 * Modifications:
486 *
487 *-------------------------------------------------------------------------
488 */
489 static void
stc_print(obj_t _self,out_t * f)490 stc_print (obj_t _self, out_t *f) {
491
492 obj_stc_t *self = MYCLASS(_self);
493 int i;
494
495 if (self->name[0]) {
496 out_printf (f, "struct %s {\n", self->name);
497 } else {
498 out_printf (f, "struct {\n");
499 }
500
501 out_indent (f);
502 if (self->walk1) out_printf (f, "__OVERRIDE_PRINT_FUNCTION__\n");
503 if (self->walk2) out_printf (f, "__OVERRIDE_DIFF_FUNCTION__\n");
504 for (i=0; i<self->ncomps && !out_brokenpipe(f); i++) {
505 out_push (f, self->compname[i]);
506 out_printf (f, "+%d ", self->offset[i]);
507 obj_print (self->sub[i], f);
508 out_nl (f);
509 out_pop (f);
510 }
511 out_undent (f);
512 out_puts (f, "}");
513 }
514
515
516 /*-------------------------------------------------------------------------
517 * Function: stc_walk1_DBdirectory
518 *
519 * Purpose: Walks a directory to print the results in a nice format.
520 *
521 * Return: void
522 *
523 * Programmer: Robb Matzke
524 * matzke@viper.llnl.gov
525 * Jul 25 1997
526 *
527 * Modifications:
528 *
529 *-------------------------------------------------------------------------
530 */
531 /*ARGSUSED*/
532 static void
stc_walk1_DBdirectory(obj_t _self,void * mem,int operation,walk_t * wdata)533 stc_walk1_DBdirectory (obj_t _self, void *mem, int operation, walk_t *wdata)
534 {
535 DBdirectory *dir = (DBdirectory *)mem;
536 int width=0, i, old_type=-1, nprint;
537 char buf[64];
538
539 assert (WALK_PRINT==operation);
540
541 for (i=0; i<dir->nsyms; i++) {
542 width = MAX (width, (int) strlen(dir->toc[i].name));
543 }
544 if (0==width) {
545 out_errorn ("empty directory");
546 return;
547 }
548
549 for (i=nprint=0; i<dir->nsyms && !out_brokenpipe(OUT_STDOUT); i++) {
550 if (dir->toc[i].type!=old_type) {
551 if (nprint) {
552 out_nl (OUT_STDOUT);
553 out_nl (OUT_STDOUT);
554 }
555 sprintf (buf, "%s(s)", ObjTypeName[dir->toc[i].type]);
556 out_push (OUT_STDOUT, buf);
557 }
558 out_printf (OUT_STDOUT, " %-*s", width, dir->toc[i].name);
559 if (dir->toc[i].type!=old_type) {
560 out_pop (OUT_STDOUT);
561 old_type = dir->toc[i].type;
562 }
563 nprint++;
564 }
565 out_nl (OUT_STDOUT);
566 return;
567 }
568
569
570 /*-------------------------------------------------------------------------
571 * Function: stc_walk1
572 *
573 * Purpose: Print memory cast as a structure type.
574 *
575 * Return: void
576 *
577 * Programmer: Robb Matzke
578 * matzke@viper.llnl.gov
579 * Dec 6 1996
580 *
581 * Modifications:
582 * Robb Matzke, 2000-05-23
583 * Removed an extraneous out_pop() call.
584 *-------------------------------------------------------------------------
585 */
586 static void
stc_walk1(obj_t _self,void * mem,int operation,walk_t * wdata)587 stc_walk1 (obj_t _self, void *mem, int operation, walk_t *wdata) {
588
589 obj_stc_t *self = MYCLASS(_self);
590 int i;
591 out_t *f;
592
593 switch (operation) {
594 case WALK_PRINT:
595 f = wdata->f;
596
597 /*
598 * Walk each of the structure members.
599 */
600 if (self->walk1) {
601 (self->walk1)(_self, mem, operation, wdata);
602 } else {
603 if (self->name && self->name[0]) out_printf (f, "%s: ", self->name);
604 out_printf (f, "struct");
605 out_indent (f);
606 for (i=0; i<self->ncomps && !out_brokenpipe(f); i++) {
607 out_push (f, self->compname[i]);
608 out_nl (f);
609 obj_walk1 (self->sub[i], (char*)mem+self->offset[i], operation,
610 wdata);
611 out_pop (f);
612 }
613 out_undent (wdata->f);
614 }
615 break;
616
617 default:
618 abort();
619 }
620 }
621
622 static void
stc_walk1_outmrgtree(DBmrgtnode * tnode,int walk_order,void * data)623 stc_walk1_outmrgtree(DBmrgtnode *tnode, int walk_order, void *data)
624 {
625 walk_t *wdata = (walk_t*) data;
626 out_t *f = wdata->f;
627 int j, level = -1;
628 DBmrgtnode *tmp = tnode;
629
630 /* walk to top to determine level of indentation */
631 while (tmp != 0)
632 {
633 tmp = tmp->parent;
634 level++;
635 }
636 for (j = 0; j < level; j++)
637 out_indent(f);
638
639 /* print this node using special '*' field width specifier */
640 out_printf(f, "name = \"%s\" {", tnode->name);
641 out_nl(f);
642 out_printf(f, "....walk_order = %d", tnode->walk_order);
643 out_nl(f);
644 out_printf(f, "........parent = \"%s\"", tnode->parent?tnode->parent->name:"");
645 out_nl(f);
646 out_printf(f, "........narray = %d", tnode->narray);
647 out_nl(f);
648 if (tnode->narray > 0)
649 {
650 if (strchr(tnode->names[0], '%') == 0)
651 {
652 out_printf(f, ".........names = ...", "");
653 out_nl(f);
654 for (j = 0; j < tnode->narray; j++)
655 {
656 out_printf(f, "....................\"%s\"", tnode->names[j]);
657 out_nl(f);
658 }
659 }
660 else
661 {
662 out_printf(f, "....namescheme = \"%s\"", tnode->names[0]);
663 out_nl(f);
664 }
665 }
666 out_printf(f, "type_info_bits = %d", tnode->type_info_bits);
667 out_nl(f);
668 out_printf(f, "..max_children = %d", tnode->max_children);
669 out_nl(f);
670 out_printf(f, ".....maps_name = \"%s\"", tnode->maps_name?tnode->maps_name:"");
671 out_nl(f);
672 out_printf(f, ".........nsegs = %d", tnode->nsegs);
673 out_nl(f);
674 if (tnode->nsegs > 0)
675 {
676 out_printf(f, "......segments = ids | lens | types", "");
677 out_nl(f);
678 for (j = 0; j < tnode->nsegs*(tnode->narray?tnode->narray:1); j++)
679 {
680 out_printf(f, ".................%.10d|%.10d|%.10d",
681 tnode->seg_ids[j], tnode->seg_lens[j], tnode->seg_types[j]);
682 out_nl(f);
683 }
684 }
685 out_printf(f, "..num_children = %d", tnode->num_children);
686 out_nl(f);
687 if (tnode->num_children > 0)
688 {
689 for (j = 0; j < tnode->num_children && tnode->children[j] != 0; j++)
690 {
691 out_printf(f, ".................\"%s\"", tnode->children[j]->name);
692 out_nl(f);
693 }
694 }
695 out_printf(f, "} \"%s\"", tnode->name);
696 out_nl(f);
697
698 for (j = 0; j < level; j++)
699 out_undent(f);
700 }
701
702 /*ARGSUSED*/
703 static void
stc_walk1_DBmrgtree(obj_t _self,void * mem,int operation,walk_t * wdata)704 stc_walk1_DBmrgtree(obj_t _self, void *mem, int operation, walk_t *wdata)
705 {
706 DBmrgtree *tree = (DBmrgtree*)mem;
707 out_t *f = wdata->f;
708 char **p;
709
710
711 assert (WALK_PRINT==operation);
712
713 out_printf (f, "mrgtree: \"%s\"", tree->name);
714 out_nl(f);
715 out_printf (f, "src_mesh_name: \"%s\"", tree->src_mesh_name);
716 out_nl(f);
717 out_printf (f, "type_info_bits: %8X", tree->type_info_bits);
718 out_nl(f);
719 out_printf (f, "num_nodes: %d", tree->num_nodes);
720 out_nl(f);
721 p = tree->mrgvar_onames;
722 out_printf (f, "mrgvar_onames: \"%s\"", p ? "" : "none");
723 out_nl(f);
724 while (p && *p)
725 {
726 out_printf (f, "....\"%s\"", *p);
727 out_nl(f);
728 p++;
729 }
730 p = tree->mrgvar_rnames;
731 out_printf (f, "mrgvar_rnames: \"%s\"", p ? "" : "none");
732 out_nl(f);
733 while (p && *p)
734 {
735 out_printf (f, "....\"%s\"", *p);
736 out_nl(f);
737 p++;
738 }
739
740 DBWalkMrgtree(tree, (DBmrgwalkcb) stc_walk1_outmrgtree, wdata, DB_PREORDER);
741 return;
742 }
743
744
745 /*-------------------------------------------------------------------------
746 * Function: stc_walk2_DBdirectory
747 *
748 * Purpose: Diff's two directories.
749 *
750 * Return: Success:
751 * 0: A and B are identical, nothing has been printed.
752 * 1: A and B are paritally the same, a summary of the
753 * differences has been printed.
754 * 2: A and B are totally different, nothing has been
755 * printed yet.
756 *
757 * Failure: -1
758 *
759 * Programmer: Robb Matzke
760 * matzke@viper.llnl.gov
761 * Jul 25 1997
762 *
763 * Modifications:
764 * Robb Matzke, 2000-05-25
765 * If file A and file B are two different files then change
766 * current working directories in each and call file_diff(),
767 * which is probably faster.
768 *-------------------------------------------------------------------------
769 */
770 /*ARGSUSED*/
771 static int
stc_walk2_DBdirectory(obj_t _a,void * a_mem,obj_t _b,void * b_mem,walk_t * wdata)772 stc_walk2_DBdirectory (obj_t _a, void *a_mem, obj_t _b, void *b_mem,
773 walk_t *wdata)
774 {
775 obj_t a_file = sdo_file (wdata->a_sdo);
776 obj_t b_file = sdo_file (wdata->b_sdo);
777 DBdirectory *a_dir = (DBdirectory *)a_mem;
778 DBdirectory *b_dir = (DBdirectory *)b_mem;
779 toc_t *a_toc = a_dir->toc;
780 toc_t *b_toc = b_dir->toc;
781 obj_t a_subdir=NIL;
782 obj_t b_subdir=NIL;
783 obj_t aobj=NIL, bobj=NIL;
784 int an = a_dir->nsyms;
785 int bn = b_dir->nsyms;
786 char cwd[1024], buf[1024];
787 obj_t sym=NIL;
788
789 int i, j, ndiff=0;
790 int status, nonlya=0, nonlyb=0;
791 out_t *f = OUT_STDOUT;
792
793 while (file_file(a_file)!=file_file(b_file)) {
794 /* The file_diff() function is probably faster because it uses the
795 * current working directory (significantly faster for the
796 * Silo/PDB driver). However, we can only use it if we're
797 * differencing in two different files (because it needs to keep
798 * track of two different cwds). */
799 char a_cwd[1024], b_cwd[1024];
800 int retval;
801
802 /* Save current directories */
803 if (DBGetDir(file_file(a_file), a_cwd)<0) break;
804 if (DBGetDir(file_file(b_file), b_cwd)<0) break;
805
806 /* Set cwds */
807 if (DBSetDir(file_file(a_file), obj_name(wdata->a_sdo))<0) break;
808 if (DBSetDir(file_file(b_file), obj_name(wdata->b_sdo))<0) {
809 status = DBSetDir(file_file(a_file), a_cwd);
810 assert(status>=0);
811 break;
812 }
813
814 /* Diff the files */
815 retval = obj_diff(a_file, b_file);
816
817 DBFreeCompressionResources(file_file(a_file),0);
818 DBFreeCompressionResources(file_file(b_file),0);
819
820 /* Reset cwds */
821 status = DBSetDir(file_file(a_file), a_cwd);
822 assert(status>=0);
823 status = DBSetDir(file_file(b_file), b_cwd);
824 assert(status>=0);
825
826 /* Free resources */
827 obj_dest(a_file);
828 obj_dest(b_file);
829
830 return retval;
831 }
832
833
834 if (Verbosity>=1) {
835 out_info ("Differencing directories %s%s and %s%s",
836 obj_name (a_file), obj_name(wdata->a_sdo),
837 obj_name (b_file), obj_name(wdata->b_sdo));
838 }
839
840 /* Get the table of contents for each file. */
841 assert (a_file && b_file);
842 assert ((0==an || a_toc) && (0==bn || b_toc));
843
844 for (i=j=ndiff=0; i<an || j<bn; i++,j++) {
845 out_section(f);
846 if (out_brokenpipe(f)) break;
847
848 /* List the names of objects that appear only in A. */
849 nonlya = 0;
850 if (!DiffOpt.ignore_dels) {
851 while (i<an && (j>=bn || strcmp(a_toc[i].name, b_toc[j].name)<0)) {
852 out_section(f);
853 switch (DiffOpt.report) {
854 case DIFF_REP_ALL:
855 case DIFF_REP_BRIEF:
856 out_push (f, a_toc[i].name);
857 out_puts (f, "appears only in file A");
858 out_nl (f);
859 out_pop (f);
860 break;
861 case DIFF_REP_SUMMARY:
862 return 2;
863 }
864 nonlya++;
865 ndiff++;
866 i++;
867 }
868 }
869
870 /* List the names of objects that appear only in B. */
871 nonlyb = 0;
872 if (!DiffOpt.ignore_adds) {
873 while (j<bn && (i>=an || strcmp(b_toc[j].name, a_toc[i].name)<0)) {
874 out_section(f);
875 switch (DiffOpt.report) {
876 case DIFF_REP_ALL:
877 case DIFF_REP_BRIEF:
878 out_push (f, b_toc[j].name);
879 out_puts (f, "appears only in file B");
880 out_nl (f);
881 out_pop (f);
882 break;
883 case DIFF_REP_SUMMARY:
884 return 2;
885 }
886 nonlyb++;
887 ndiff++;
888 j++;
889 }
890 }
891
892 if (i<an && BROWSER_DB_DIR==a_toc[i].type &&
893 j<bn && BROWSER_DB_DIR==b_toc[j].type) {
894 /* Diff two subdirectories. */
895 out_section(f);
896 assert (0==strcmp (a_toc[i].name, b_toc[j].name));
897
898 sprintf (buf, "%s/%s", obj_name(wdata->a_sdo), a_toc[i].name);
899 sym = obj_new (C_SYM, buf);
900 a_subdir = obj_deref (a_file, 1, &sym);
901 sym = obj_dest (sym);
902
903 sprintf (buf, "%s/%s", obj_name(wdata->b_sdo), b_toc[j].name);
904 sym = obj_new (C_SYM, buf);
905 b_subdir = obj_deref (b_file, 1, &sym);
906 sym = obj_dest (sym);
907
908 out_push (f, a_toc[i].name);
909 obj_diff (a_subdir, b_subdir);
910 out_pop(f);
911 a_subdir = obj_dest (a_subdir);
912 b_subdir = obj_dest (b_subdir);
913
914 } else if (i<an && j<bn) {
915 /* Diff two objects. */
916 out_section(f);
917 if (Verbosity>=1) {
918 assert (0==strcmp (a_toc[i].name, b_toc[j].name));
919 strcpy (cwd, "Differencing: ");
920 DBGetDir (file_file(a_file), cwd+14);
921 if (strcmp(cwd+14,"/")) strcat (cwd, "/");
922 strcat (cwd, a_toc[i].name);
923 out_progress (cwd);
924 }
925
926 sprintf (buf, "%s/%s", obj_name(wdata->a_sdo), a_toc[i].name);
927 sym = obj_new (C_SYM, buf);
928 aobj = obj_deref (a_file, 1, &sym);
929 sym = obj_dest (sym);
930
931 sprintf (buf, "%s/%s", obj_name(wdata->b_sdo), b_toc[j].name);
932 sym = obj_new (C_SYM, buf);
933 bobj = obj_deref (b_file, 1, &sym);
934 sym = obj_dest (sym);
935
936 assert(aobj && bobj);
937 out_push (f, a_toc[i].name);
938 status = obj_diff (aobj, bobj);
939 if (status) ndiff++;
940
941 switch (DiffOpt.report) {
942 case DIFF_REP_ALL:
943 if (2==status) {
944 out_line (f, "***************");
945 obj_print (aobj, f);
946 out_line (f, "---------------");
947 obj_print (bobj, f);
948 out_line (f, "***************");
949 }
950 break;
951 case DIFF_REP_BRIEF:
952 if (2==status) {
953 out_puts(f, "different value(s)");
954 out_nl(f);
955 }
956 break;
957 case DIFF_REP_SUMMARY:
958 if (status) {
959 out_pop(f);
960 aobj = obj_dest(aobj);
961 bobj = obj_dest(bobj);
962 out_progress(NULL);
963 obj_dest(a_file);
964 obj_dest(b_file);
965 return 2;
966 }
967 }
968 out_pop (f);
969 aobj = obj_dest (aobj);
970 bobj = obj_dest (bobj);
971 }
972 }
973
974 out_progress (NULL);
975 obj_dest (a_file);
976 obj_dest (b_file);
977 return ndiff ? 1 : 0;
978 }
979
980
981 /*-------------------------------------------------------------------------
982 * Function: stc_walk2
983 *
984 * Purpose: Determines if two structured objects are the same.
985 *
986 * Return: Success:
987 * 0: A and B are identical, nothing has been printed.
988 * 1: A and B are partially the same, a summary of the
989 * differences has been printed.
990 * 2: A and B are totally different, nothing has been
991 * printed yet.
992 *
993 * Failure: -1
994 *
995 * Programmer: Robb Matzke
996 * robb@maya.nuance.mdn.com
997 * Jan 21 1997
998 *
999 * Modifications:
1000 * Robb Matzke, 2000-05-23
1001 * The output depends on the DiffOpt global variable. In fact,
1002 * with certain settings we can even short-circuit some of
1003 * the work.
1004 *-------------------------------------------------------------------------
1005 */
1006 static int
stc_walk2(obj_t _a,void * a_mem,obj_t _b,void * b_mem,walk_t * wdata)1007 stc_walk2 (obj_t _a, void *a_mem, obj_t _b, void *b_mem, walk_t *wdata) {
1008
1009 obj_stc_t *a = MYCLASS(_a);
1010 obj_stc_t *b = MYCLASS(_b);
1011 int i, j, status, na, nb;
1012 out_t *f = wdata->f;
1013 int *a_diff, *b_diff;
1014 int nsame=0, ndiffer=0, nonlya=0, nonlyb=0;
1015
1016 /*
1017 * If both types have localized their walk2 functions, then call that
1018 * function instead.
1019 */
1020 if (a->walk2 && a->walk2==b->walk2) {
1021 return (a->walk2)(_a, a_mem, _b, b_mem, wdata);
1022 }
1023
1024 /*
1025 * Clear the difference indicators by setting them each to -999.
1026 * When A differs from B, a_diff will contain the index of B and
1027 * b_diff will contain the index of A.
1028 */
1029 a_diff = (int *)calloc (a->ncomps, sizeof(int));
1030 for (i=0; i<a->ncomps; i++) a_diff[i] = -999;
1031 b_diff = (int *)calloc (b->ncomps, sizeof(int));
1032 for (i=0; i<b->ncomps; i++) b_diff[i] = -999;
1033
1034 /*
1035 * Figure out which fields appear only in A (a_diff[i]==b->ncomps),
1036 * which appear only in B (b_diff[i]==a->ncomps), which appear in both
1037 * but differ (a_diff[i]=j, b_diff[j]=i, i>=0, j>=0), and which are
1038 * the same in both.
1039 */
1040 for (i=0; i<a->ncomps; i++) {
1041 if (out_brokenpipe(f)) {
1042 free(a_diff);
1043 free(b_diff);
1044 return -1;
1045 }
1046 for (j=0; j<b->ncomps; j++) {
1047 if (!strcmp(a->compname[i], b->compname[j])) {
1048
1049 out_push (f, a->compname[i]);
1050 status = obj_walk2 (a->sub[i], (char*)a_mem+a->offset[i],
1051 b->sub[j], (char*)b_mem+b->offset[j], wdata);
1052 out_pop (f);
1053
1054 switch (DiffOpt.report) {
1055 case DIFF_REP_ALL:
1056 case DIFF_REP_BRIEF:
1057 if (status<0 || 1==status) {
1058 ndiffer++;
1059 } else if (0==status) {
1060 nsame++;
1061 } else {
1062 ndiffer++;
1063 a_diff[i] = j;
1064 b_diff[j] = i;
1065 }
1066 break;
1067 case DIFF_REP_SUMMARY:
1068 free(a_diff);
1069 free(b_diff);
1070 return 1;
1071 }
1072 break;
1073 }
1074 }
1075 if (j>=b->ncomps) {
1076 switch (DiffOpt.report) {
1077 case DIFF_REP_ALL:
1078 case DIFF_REP_BRIEF:
1079 if (!DiffOpt.ignore_dels) {
1080 ndiffer++;
1081 nonlya++;
1082 a_diff[i] = b->ncomps;
1083 } else {
1084 nsame++;
1085 }
1086 break;
1087 case DIFF_REP_SUMMARY:
1088 if (!DiffOpt.ignore_dels) {
1089 free(a_diff);
1090 free(b_diff);
1091 return 2;
1092 }
1093 nsame++;
1094 break;
1095 }
1096 }
1097 }
1098 for (j=0; j<b->ncomps; j++) {
1099 for (i=0; i<a->ncomps; i++) {
1100 if (!strcmp(a->compname[i], b->compname[j])) break;
1101 }
1102 if (i>=a->ncomps) {
1103 switch (DiffOpt.report) {
1104 case DIFF_REP_ALL:
1105 case DIFF_REP_BRIEF:
1106 if (!DiffOpt.ignore_adds) {
1107 ndiffer++;
1108 nonlyb++;
1109 b_diff[j] = a->ncomps;
1110 } else {
1111 nsame++;
1112 }
1113 break;
1114 case DIFF_REP_SUMMARY:
1115 if (!DiffOpt.ignore_adds) {
1116 free(a_diff);
1117 free(b_diff);
1118 return 2;
1119 }
1120 nsame++;
1121 break;
1122 }
1123 }
1124 }
1125
1126 /* Print the A side of things */
1127 for (i=na=0; i<a->ncomps; i++) {
1128 if (out_brokenpipe(f)) {
1129 free(a_diff);
1130 free(b_diff);
1131 return -1;
1132 }
1133 if (a_diff[i]==b->ncomps && !DiffOpt.ignore_dels) {
1134 switch (DiffOpt.report) {
1135 case DIFF_REP_ALL:
1136 out_push(f, a->compname[i]);
1137 if (DiffOpt.two_column) {
1138 obj_walk1(a->sub[i], (char*)a_mem+a->offset[i],
1139 WALK_PRINT, wdata);
1140 out_column(f, OUT_COL2, DIFF_SEPARATOR);
1141 out_puts(f, DIFF_NOTAPP);
1142 } else {
1143 if (0==na) out_line(f, "***************");
1144 obj_walk1(a->sub[i], (char*)a_mem+a->offset[i],
1145 WALK_PRINT, wdata);
1146 }
1147 out_pop(f);
1148 out_nl(f);
1149 break;
1150 case DIFF_REP_BRIEF:
1151 out_push(f, a->compname[i]);
1152 out_puts(f, "appears only in file A");
1153 out_nl(f);
1154 out_pop(f);
1155 break;
1156 case DIFF_REP_SUMMARY:
1157 free(a_diff);
1158 free(b_diff);
1159 return 2;
1160 }
1161 na++;
1162 } else if (a_diff[i]>=0 && a_diff[i]<b->ncomps) {
1163 switch (DiffOpt.report) {
1164 case DIFF_REP_ALL:
1165 out_push(f, a->compname[i]);
1166 if (DiffOpt.two_column) {
1167 obj_walk1(a->sub[i], (char*)a_mem+a->offset[i],
1168 WALK_PRINT, wdata);
1169 out_column(f, OUT_COL2, DIFF_SEPARATOR);
1170 obj_walk1(b->sub[a_diff[i]],
1171 (char*)b_mem+b->offset[a_diff[i]],
1172 WALK_PRINT, wdata);
1173 } else {
1174 if (0==na) out_line(f, "***************");
1175 obj_walk1(a->sub[i], (char*)a_mem+a->offset[i],
1176 WALK_PRINT, wdata);
1177 }
1178 out_nl(f);
1179 out_pop(f);
1180 break;
1181 case DIFF_REP_BRIEF:
1182 out_push(f, a->compname[i]);
1183 out_puts(f, "different value(s)");
1184 out_nl(f);
1185 out_pop(f);
1186 break;
1187 case DIFF_REP_SUMMARY:
1188 free(a_diff);
1189 free(b_diff);
1190 return 2;
1191 }
1192 na++;
1193 }
1194 }
1195
1196 /* Print the B side of things */
1197 for (i=nb=0; i<b->ncomps; i++) {
1198 if (out_brokenpipe(f)) {
1199 free(a_diff);
1200 free(b_diff);
1201 return -1;
1202 }
1203 if (b_diff[i]==a->ncomps && !DiffOpt.ignore_adds) {
1204 switch (DiffOpt.report) {
1205 case DIFF_REP_ALL:
1206 out_push(f, b->compname[i]);
1207 if (DiffOpt.two_column) {
1208 out_puts(f, DIFF_NOTAPP);
1209 out_column(f, OUT_COL2, DIFF_SEPARATOR);
1210 obj_walk1(b->sub[i], (char*)b_mem+b->offset[i],
1211 WALK_PRINT, wdata);
1212 } else {
1213 if (0==nb) {
1214 if (0==na) out_line(f, "***************");
1215 out_line(f, "---------------");
1216 }
1217 obj_walk1(b->sub[i], (char*)b_mem+b->offset[i],
1218 WALK_PRINT, wdata);
1219 }
1220 out_nl(f);
1221 out_pop(f);
1222 break;
1223 case DIFF_REP_BRIEF:
1224 out_push(f, b->compname[i]);
1225 out_puts(f, "appears only in file B");
1226 out_nl(f);
1227 out_pop(f);
1228 break;
1229 case DIFF_REP_SUMMARY:
1230 free(a_diff);
1231 free(b_diff);
1232 return 2;
1233 }
1234 nb++;
1235 } else if (b_diff[i]>=0 && b_diff[i]<a->ncomps) {
1236 switch (DiffOpt.report) {
1237 case DIFF_REP_ALL:
1238 if (DiffOpt.two_column) {
1239 /* already printed */
1240 } else {
1241 if (0==nb) {
1242 if (0==na) out_line(f, "***************");
1243 out_line(f, "---------------");
1244 }
1245 out_push (f, a->compname[i]);
1246 obj_walk1(b->sub[i], (char*)b_mem+b->offset[i],
1247 WALK_PRINT, wdata);
1248 out_nl(f);
1249 out_pop (f);
1250 }
1251 break;
1252 case DIFF_REP_BRIEF:
1253 break; /*already printed*/
1254 case DIFF_REP_SUMMARY:
1255 free(a_diff);
1256 free(b_diff);
1257 return 2;
1258 }
1259 nb++;
1260 }
1261 }
1262 if ((na || nb) && DIFF_REP_ALL==DiffOpt.report && !DiffOpt.two_column) {
1263 out_line (f, "***************");
1264 }
1265
1266 free(a_diff);
1267 free(b_diff);
1268
1269 /* Return */
1270 if (ndiffer) {
1271 if (DiffOpt.two_column) return 1;
1272 if (na || nb) return 1;
1273 return 2;
1274 }
1275 return 0;
1276 }
1277
1278
1279 /*-------------------------------------------------------------------------
1280 * Function: stc_deref
1281 *
1282 * Purpose: Given a structure type, return the subtype of the component
1283 * with name COMP. Call stc_offset with SELF and COMP to get
1284 * the byte offset for the specified component from the
1285 * beginning of the structure.
1286 *
1287 * Return: Success: Ptr to a copy of the subtype.
1288 *
1289 * Failure: NIL
1290 *
1291 * Programmer: Robb Matzke
1292 * robb@maya.nuance.mdn.com
1293 * Dec 10 1996
1294 *
1295 * Modifications:
1296 *
1297 * Robb Matzke, 4 Feb 1997
1298 * The prototype changed but the functionality remains the same.
1299 *
1300 *-------------------------------------------------------------------------
1301 */
1302 static obj_t
stc_deref(obj_t _self,int argc,obj_t argv[])1303 stc_deref (obj_t _self, int argc, obj_t argv[]) {
1304
1305 obj_stc_t *self = MYCLASS(_self);
1306 int i;
1307 char *compname;
1308
1309 if (1!=argc) {
1310 out_errorn ("stc_deref: wrong number of arguments");
1311 return NIL;
1312 }
1313 if (argv[0] && C_NUM==argv[0]->pub.cls) {
1314 out_errorn ("stc_deref: an array index cannot be applied to a "
1315 "structure");
1316 return NIL;
1317 }
1318
1319 compname = obj_name (argv[0]);
1320 assert (self && compname);
1321
1322 for (i=0; i<self->ncomps; i++) {
1323 if (!strcmp(self->compname[i], compname)) {
1324 return obj_copy (self->sub[i], SHALLOW);
1325 }
1326 }
1327
1328 out_errorn ("stc_deref: structure component doesn't exist: %s",
1329 compname);
1330 return NIL;
1331 }
1332
1333
1334 /*-------------------------------------------------------------------------
1335 * Function: stc_name
1336 *
1337 * Purpose: Returns a pointer to the structure name.
1338 *
1339 * Return: Success: Ptr to structure name
1340 *
1341 * Failure: NULL
1342 *
1343 * Programmer: Robb Matzke
1344 * robb@maya.nuance.mdn.com
1345 * Dec 17 1996
1346 *
1347 * Modifications:
1348 *
1349 *-------------------------------------------------------------------------
1350 */
1351 static char *
stc_name(obj_t _self)1352 stc_name (obj_t _self) {
1353
1354 obj_stc_t *self = MYCLASS(_self);
1355
1356 if (self->name && self->name[0]) return self->name;
1357 return NULL;
1358 }
1359
1360
1361 /*-------------------------------------------------------------------------
1362 * Function: stc_bind
1363 *
1364 * Purpose: Binds array dimensions to numeric values.
1365 *
1366 * Return: Success: SELF
1367 *
1368 * Failure: NIL
1369 *
1370 * Programmer: Robb Matzke
1371 * robb@maya.nuance.mdn.com
1372 * Jan 13 1997
1373 *
1374 * Modifications:
1375 *
1376 *-------------------------------------------------------------------------
1377 */
1378 static obj_t
stc_bind(obj_t _self,void * mem)1379 stc_bind (obj_t _self, void *mem) {
1380
1381 obj_stc_t *self = MYCLASS(_self);
1382 int i, nerrors=0;
1383 obj_t saved=NIL, sdo=NIL;
1384
1385 if (!mem) return _self;
1386
1387 /*
1388 * Save current value of variable `self' and set `self' to point
1389 * to an SDO with the MEM and type SELF.
1390 */
1391 sdo = obj_new (C_SDO, NIL, NULL, mem, self, mem, self, NULL, NULL, NULL);
1392 saved = sym_self_set (sdo);
1393 sdo=NIL;
1394
1395 /*
1396 * Bind each of the component types.
1397 */
1398 for (i=0; i<self->ncomps; i++) {
1399 if (NIL==obj_bind(self->sub[i], (char*)mem+self->offset[i])) {
1400 nerrors++;
1401 }
1402 }
1403
1404 /*
1405 * Restore the previous value of variable `self'.
1406 */
1407 obj_dest (sym_self_set (saved));
1408 saved = NIL;
1409
1410 return nerrors ? NIL : _self;
1411 }
1412
1413
1414 /*-------------------------------------------------------------------------
1415 * Function: stc_sort
1416 *
1417 * Purpose: Destructively sorts the fields of a structure.
1418 *
1419 * Return: void
1420 *
1421 * Programmer: Robb Matzke
1422 * robb@maya.nuance.mdn.com
1423 * Feb 5 1997
1424 *
1425 * Modifications:
1426 *
1427 *-------------------------------------------------------------------------
1428 */
1429 void
stc_sort(obj_t _self,int start_at)1430 stc_sort (obj_t _self, int start_at) {
1431
1432 obj_stc_t *self = MYCLASS(_self);
1433 int i, j, mini, tmp_off;
1434 char *tmp_str=NULL;
1435 obj_t tmp_sub=NIL;
1436
1437 for (i=start_at; i<self->ncomps-1; i++) {
1438 mini = i;
1439 for (j=i+1; j<self->ncomps; j++) {
1440 if (strcmp (self->compname[j], self->compname[mini])<0) {
1441 mini = j;
1442 }
1443 }
1444 if (mini!=i) {
1445 tmp_str = self->compname[i];
1446 self->compname[i] = self->compname[mini];
1447 self->compname[mini] = tmp_str;
1448
1449 tmp_sub = self->sub[i];
1450 self->sub[i] = self->sub[mini];
1451 self->sub[mini] = tmp_sub;
1452
1453 tmp_off = self->offset[i];
1454 self->offset[i] = self->offset[mini];
1455 self->offset[mini] = tmp_off;
1456 }
1457 }
1458 }
1459
1460
1461 /*-------------------------------------------------------------------------
1462 * Function: stc_offset
1463 *
1464 * Purpose: Given a structure and a component name, return the byte
1465 * offset of the subtype from the beginning of the structure.
1466 *
1467 * Return: Success: Byte offset to specified structure member.
1468 *
1469 * Failure: -1
1470 *
1471 * Programmer: Robb Matzke
1472 * robb@maya.nuance.mdn.com
1473 * Dec 10 1996
1474 *
1475 * Modifications:
1476 *
1477 *-------------------------------------------------------------------------
1478 */
1479 int
stc_offset(obj_t _self,obj_t comp)1480 stc_offset (obj_t _self, obj_t comp) {
1481
1482 obj_stc_t *self = MYCLASS(_self);
1483 int i;
1484 char *compname = obj_name (comp);
1485
1486 for (i=0; i<self->ncomps; i++) {
1487 if (!strcmp(self->compname[i], compname)) {
1488 return self->offset[i];
1489 }
1490 }
1491
1492 out_errorn ("stc_offset: no such structure component: %s", compname);
1493 return -1;
1494 }
1495
1496
1497 /*-------------------------------------------------------------------------
1498 * Function: stc_silo_types
1499 *
1500 * Purpose: Initializes the silo data types.
1501 *
1502 * Return: void
1503 *
1504 * Programmer: Robb Matzke
1505 * robb@maya.nuance.mdn.com
1506 * Jan 13 1997
1507 *
1508 * Modifications:
1509 *
1510 * Robb Matzke, 18 Feb 1997
1511 * Added limits to arrays based on `ndims'.
1512 *
1513 * Robb Matzke, 25 Mar 1997
1514 * Changed the `min_extents', `max_extents', and `align' fields to use
1515 * the value stored in the datatype field. See related comments in the
1516 * silo.h file.
1517 *
1518 * Robb Matzke, 29 Jul 1997
1519 * Array special handling flag `SH1' now takes an optional argument
1520 * which, if it evaluates to anything other than DB_COLLINEAR, the
1521 * special handling is ignored. If it isn't ignored, then the specified
1522 * array is really a 1-d array where the array size is one of the numbers
1523 * specified depending on the current index of the enclosing array.
1524 *
1525 * Robb Matzke, 2 Sep 1997
1526 * The `min_extents', `max_extents', and `align' fields are always
1527 * DB_FLOAT.
1528 *
1529 * Sean Ahern, Tue Mar 31 17:43:03 PST 1998
1530 * Changed the `min_extents', and `max_extents' fields in UCD meshes to use
1531 * the value stored in the datatype field.
1532 *
1533 * Jeremy Meredith, Sept 21 1998
1534 * Added multimatspecies object.
1535 *
1536 * Sean Ahern, Tue Oct 20 14:35:13 PDT 1998
1537 * Changed the `min_extents' and `max_extents' fields in Quadmeshes to use
1538 * the value stored in the datatype field.
1539 *
1540 * Jeremy Meredith, Wed Jul 7 12:15:31 PDT 1999
1541 * I removed the origin from the species object.
1542 *
1543 * Robb Matzke, Thu Jul 15 12:40:37 EDT 1999
1544 * Added `group_no' to DBpointmesh, DBquadmesh, and DBucdmesh.
1545 *
1546 * Robb Matzke, Thu Jul 15 12:40:37 EDT 1999
1547 * Added `ngroups', `blockorigin', and `grouporigin' to DBmultimesh,
1548 * DBmultivar, DBmultimat, and DBmultimatspecies.
1549 *
1550 * Robb Matzke, Thu Jul 15 12:40:37 EDT 1999
1551 * Added `min_index', `max_index', `zoneno', and `gzoneno' to the DBzonelist
1552 * type.
1553 *
1554 * Robb Matzke, Thu Jul 15 12:40:37 EDT 1999
1555 * Added `base_index[]' to the DBquadmesh type.
1556 *
1557 * Robb Matzke, Thu Jul 15 12:40:37 EDT 1999
1558 * Added `gnodeno' and `nodeno' properties to the DBucdmesh type.
1559 *
1560 * Thomas R. Treadway, Fri Jul 7 12:44:38 PDT 2006
1561 * Added support for DBOPT_REFERENCE in Curves
1562 *
1563 * Mark C. Miller, Wed Sep 2 16:48:37 PDT 2009
1564 * Added mixvals to ucdvar struct.
1565 *
1566 * Mark C. Miller, Thu Nov 5 16:32:45 PST 2009
1567 * Re-organized these structs so that problems-sized arrays are always at
1568 * the bottom. That way, browser will display them last and one doesn't
1569 * have to page through the problem-sized data to see tiny bits of
1570 * metadata at the end. Also added conserved/extensive properties to
1571 * all var objects and centering to quadvar.
1572 *
1573 * Mark C. Miller, Fri Nov 13 15:33:42 PST 2009
1574 * Added support for long long global node/zone numbers.
1575 *
1576 * Mark C. Miller, Sat Nov 14 20:28:34 PST 2009
1577 * Changed how long long global node/zone numbers are supported
1578 * from a int (bool), "llong_gnode|zoneno" to an int holding
1579 * the actual datatype. The type is assumed int if it its
1580 * value is zero or it does not exist. Otherwise, the type is
1581 * is whatever is stored in gnznodtype member. This makes it quite
1582 * easy for browser to handle variations in type of this data.
1583 *
1584 * Mark C. Miller, Mon Nov 23 11:18:25 PST 2009
1585 * Added missing 'topo_dim' member to multimesh object.
1586 *
1587 * Mark C. Miller, Wed Feb 24 16:39:21 PST 2010
1588 * Fixed a problem with display of extents in point meshes.
1589 *
1590 * Mark C. Miller, Wed Jul 14 21:06:27 PDT 2010
1591 * Added support for namescheme/emtpy_list options on multi-block objs.
1592 *-------------------------------------------------------------------------
1593 */
1594 void
stc_silo_types(void)1595 stc_silo_types (void) {
1596
1597 obj_t tmp=NIL;
1598
1599 STRUCT (DBobject) {
1600 COMP (name, "primitive 'string'");
1601 COMP (type, "primitive 'string'");
1602 COMP (ncomponents, "primitive 'int'");
1603 COMP (maxcomponents, "primitive 'int'");
1604 COMP (comp_names,
1605 "pointer (array 'self.ncomponents' (primitive 'string'))");
1606 COMP (pdb_names,
1607 "pointer (array 'self.ncomponents' (primitive 'string'))");
1608 } ESTRUCT;
1609
1610 STRUCT (DBcurve) {
1611 COMP (id, "primitive 'int'");
1612 COMP (datatype, "primitive 'int'");
1613 IOASSOC (PA_DATATYPE);
1614 COMP (origin, "primitive 'int'");
1615 COMP (title, "primitive 'string'");
1616 COMP (xvarname, "primitive 'string'");
1617 COMP (yvarname, "primitive 'string'");
1618 COMP (xlabel, "primitive 'string'");
1619 COMP (ylabel, "primitive 'string'");
1620 COMP (xunits, "primitive 'string'");
1621 COMP (yunits, "primitive 'string'");
1622 COMP (npts, "primitive 'int'");
1623 COMP (reference, "primitive 'string'");
1624 COMP (guihide, "primitive 'int'");
1625 IOASSOC (PA_BOOLEAN);
1626 COMP (coord_sys, "primitive 'int'");
1627 IOASSOC (PA_COORDSYS);
1628 COMP (missing_value, "primitive 'double'");
1629 IOASSOC (PA_MISSING_VALUE);
1630 COMP (x,
1631 "pointer (array 'self.npts' (primitive 'self.datatype'))");
1632 COMP (y,
1633 "pointer (array 'self.npts' (primitive 'self.datatype'))");
1634 } ESTRUCT;
1635
1636 STRUCT (DBdefvars) {
1637 COMP (ndefs, "primitive 'int'");
1638 COMP (names,
1639 "pointer (array 'self.ndefs' (primitive 'string'))");
1640
1641 tmp = obj_new (C_PRIM, "int");
1642 prim_set_io_assoc (tmp, PA_DEFVARTYPE);
1643 tmp = obj_new (C_PTR, obj_new (C_ARY, "self.ndefs", tmp));
1644 COMP3 (types, "types", tmp);
1645
1646 COMP (defns,
1647 "pointer (array 'self.ndefs' (primitive 'string'))");
1648 COMP (guihides,
1649 "pointer (array 'self.ndefs' (primitive 'int'))");
1650 } ESTRUCT;
1651
1652 STRUCT (DBmultimesh) {
1653 COMP (id, "primitive 'int'");
1654 COMP (nblocks, "primitive 'int'");
1655 COMP (ngroups, "primitive 'int'");
1656 COMP (guihide, "primitive 'int'"); IOASSOC (PA_BOOLEAN);
1657 COMP (blockorigin, "primitive 'int'");
1658 COMP (grouporigin, "primitive 'int'");
1659 COMP (extentssize, "primitive 'int'");
1660 COMP (mrgtree_name, "primitive 'string'");
1661 COMP (tv_connectivity, "primitive 'int'");
1662 COMP (disjoint_mode, "primitive 'int'");
1663 COMP (topo_dim, "primitive 'int'"); IOASSOC (PA_TOPODIM);
1664 COMP (file_ns, "primitive 'string'");
1665 COMP (block_ns, "primitive 'string'");
1666 COMP (block_type, "primitive 'int'");
1667 COMP (repr_block_idx, "primitive 'int'"); IOASSOC (PA_REPRBLOCK);
1668 COMP (alt_nodenum_vars, "pointer (array 'SH5 0, self.alt_nodenum_vars' (primitive 'string'))");
1669 COMP (alt_zonenum_vars, "pointer (array 'SH5 0, self.alt_zonenum_vars' (primitive 'string'))");
1670 COMP (empty_cnt, "primitive 'int'");
1671 COMP (empty_list, "pointer (array 'self.empty_cnt' (primitive 'int'))");
1672 COMP (meshids, "pointer (array 'self.nblocks' (primitive 'int'))");
1673 COMP (meshnames, "pointer (array 'self.nblocks' (primitive 'string'))");
1674
1675 tmp = obj_new (C_PRIM, "int");
1676 prim_set_io_assoc (tmp, PA_OBJTYPE);
1677 tmp = obj_new (C_PTR, obj_new (C_ARY, "self.nblocks", tmp));
1678 COMP3 (meshtypes, "meshtypes", tmp);
1679
1680 COMP (dirids, "pointer (array 'self.nblocks' (primitive 'int'))");
1681 COMP (extents, "pointer (array 'self.nblocks,self.extentssize' (primitive 'double'))");
1682 COMP (zonecounts, "pointer (array 'self.nblocks' (primitive 'int'))");
1683 COMP (has_external_zones, "pointer (array 'self.nblocks' (primitive 'int'))");
1684 COMP (lgroupings, "primitive 'int'");
1685 COMP (groupings, "pointer (array 'self.lgroupings' (primitive 'int'))");
1686 COMP (groupnames, "pointer (array 'self.lgroupings' (primitive 'string'))");
1687 } ESTRUCT;
1688
1689 /* ThDBmultimeshadj object is handled specially in browser using the
1690 browser_DBGetMultimesadj() function */
1691
1692 STRUCT (DBmultivar) {
1693 COMP (id, "primitive 'int'");
1694 COMP (nvars, "primitive 'int'");
1695 COMP (ngroups, "primitive 'int'");
1696 COMP (guihide, "primitive 'int'");
1697 IOASSOC (PA_BOOLEAN);
1698 COMP (extentssize, "primitive 'int'");
1699 COMP (blockorigin, "primitive 'int'");
1700 COMP (grouporigin, "primitive 'int'");
1701 COMP (tensor_rank, "primitive 'int'");
1702 IOASSOC (PA_DEFVARTYPE);
1703 COMP (mmesh_name, "primitive 'string'");
1704 COMP (conserved, "primitive 'int'");
1705 COMP (extensive, "primitive 'int'");
1706 COMP (file_ns, "primitive 'string'");
1707 COMP (block_ns, "primitive 'string'");
1708 COMP (block_type, "primitive 'int'");
1709 COMP (repr_block_idx, "primitive 'int'");
1710 IOASSOC (PA_REPRBLOCK);
1711 COMP (missing_value, "primitive 'double'");
1712 IOASSOC (PA_MISSING_VALUE);
1713 COMP (empty_cnt, "primitive 'int'");
1714 COMP (empty_list,
1715 "pointer (array 'self.empty_cnt' (primitive 'int'))");
1716 COMP (varnames,
1717 "pointer (array 'self.nvars' (primitive 'string'))");
1718
1719 tmp = obj_new (C_PRIM, "int");
1720 prim_set_io_assoc (tmp, PA_OBJTYPE);
1721 tmp = obj_new (C_PTR, obj_new (C_ARY, "self.nvars", tmp));
1722 COMP3 (vartypes, "vartypes", tmp);
1723 tmp = NIL;
1724
1725 COMP (extents,
1726 "pointer (array 'self.nvars,self.extentssize' (primitive 'double'))");
1727 } ESTRUCT;
1728
1729
1730 STRUCT (DBmultimat) {
1731 COMP (id, "primitive 'int'");
1732 COMP (nmats, "primitive 'int'");
1733 COMP (ngroups, "primitive 'int'");
1734 COMP (allowmat0, "primitive 'int'");
1735 IOASSOC (PA_BOOLEAN);
1736 COMP (guihide, "primitive 'int'");
1737 IOASSOC (PA_BOOLEAN);
1738 COMP (blockorigin, "primitive 'int'");
1739 COMP (grouporigin, "primitive 'int'");
1740 COMP (mmesh_name, "primitive 'string'");
1741 COMP (file_ns, "primitive 'string'");
1742 COMP (block_ns, "primitive 'string'");
1743 COMP (repr_block_idx, "primitive 'int'");
1744 IOASSOC (PA_REPRBLOCK);
1745 COMP (empty_cnt, "primitive 'int'");
1746 COMP (empty_list,
1747 "pointer (array 'self.empty_cnt' (primitive 'int'))");
1748 COMP (matnames,
1749 "pointer (array 'self.nmats' (primitive 'string'))");
1750 COMP (mixlens,
1751 "pointer (array 'self.nmats' (primitive 'int'))");
1752 COMP (matcounts,
1753 "pointer (array 'self.nmats' (primitive 'int'))");
1754 COMP (matlists,
1755 "pointer (array 'self.nmats' (primitive 'int'))");
1756 COMP (nmatnos, "primitive 'int'");
1757 COMP (matnos,
1758 "pointer (array 'self.nmatnos' (primitive 'int'))");
1759 COMP (material_names,
1760 "pointer (array 'self.nmatnos' (primitive 'string'))");
1761 COMP (matcolors,
1762 "pointer (array 'self.nmatnos' (primitive 'string'))");
1763 } ESTRUCT;
1764
1765 STRUCT (DBmultimatspecies) {
1766 COMP (id, "primitive 'int'");
1767 COMP (nspec, "primitive 'int'");
1768 COMP (ngroups, "primitive 'int'");
1769 COMP (guihide, "primitive 'int'");
1770 IOASSOC (PA_BOOLEAN);
1771 COMP (blockorigin, "primitive 'int'");
1772 COMP (grouporigin, "primitive 'int'");
1773 COMP (nmat, "primitive 'int'");
1774 COMP (file_ns, "primitive 'string'");
1775 COMP (block_ns, "primitive 'string'");
1776 COMP (repr_block_idx, "primitive 'int'");
1777 IOASSOC (PA_REPRBLOCK);
1778 COMP (empty_cnt, "primitive 'int'");
1779 COMP (empty_list,
1780 "pointer (array 'self.empty_cnt' (primitive 'int'))");
1781 COMP (specnames,
1782 "pointer (array 'self.nspec' (primitive 'string'))");
1783 COMP (nmatspec,
1784 "pointer (array 'self.nmat' (primitive 'int'))");
1785 COMP (species_names,
1786 "pointer (array 'SH4, self.nmatspec' (primitive 'string'))");
1787 COMP (speccolors,
1788 "pointer (array 'SH4, self.nmatspec' (primitive 'string'))");
1789 } ESTRUCT;
1790
1791 STRUCT (DBquadmesh) {
1792 COMP (id, "primitive 'int'");
1793 COMP (block_no, "primitive 'int'");
1794 COMP (group_no, "primitive 'int'");
1795 COMP (name, "primitive 'string'");
1796 COMP (cycle, "primitive 'int'");
1797 COMP (time, "primitive 'float'");
1798 COMP (dtime, "primitive 'double'");
1799 COMP (coord_sys, "primitive 'int'"); IOASSOC (PA_COORDSYS);
1800 COMP (major_order, "primitive 'int'"); IOASSOC (PA_ORDER);
1801 COMP (stride, "array 3 (primitive 'int')");
1802 COMP (coordtype, "primitive 'int'"); IOASSOC (PA_COORDTYPE);
1803 COMP (facetype, "primitive 'int'"); IOASSOC (PA_FACETYPE);
1804 COMP (planar, "primitive 'int'"); IOASSOC (PA_PLANAR);
1805 COMP (ndims, "primitive 'int'");
1806 COMP (nspace, "primitive 'int'");
1807 COMP (nnodes, "primitive 'int'");
1808 COMP (dims, "array 'SH3 3, self.ndims' (primitive 'int')");
1809 COMP (min_index, "array 'SH3 3, self.ndims' (primitive 'int')");
1810 COMP (max_index, "array 'SH3 3, self.ndims' (primitive 'int')");
1811 COMP (origin, "primitive 'int'");
1812 COMP (datatype, "primitive 'int'"); IOASSOC (PA_DATATYPE);
1813 COMP (min_extents, "array 'SH3 3, self.ndims' (primitive 'self.datatype')");
1814 COMP (max_extents, "array 'SH3 3, self.ndims' (primitive 'self.datatype')");
1815 COMP (labels, "array 'SH3 3, self.ndims' (primitive 'string')");
1816 COMP (units, "array 'SH3 3, self.ndims' (primitive 'string')");
1817 COMP (guihide, "primitive 'int'"); IOASSOC (PA_BOOLEAN);
1818 COMP (base_index, "array 3 (primitive 'int')");
1819 COMP (start_index, "array 3 (primitive 'int')");
1820 COMP (size_index, "array 3 (primitive 'int')");
1821 COMP (mrgtree_name, "primitive 'string'");
1822 COMP (alt_nodenum_vars, "pointer (array 'SH5 0, self.alt_nodenum_vars' (primitive 'string'))");
1823 COMP (alt_zonenum_vars, "pointer (array 'SH5 0, self.alt_zonenum_vars' (primitive 'string'))");
1824 COMP (coords, "array 'SH3 3, self.ndims' "
1825 "(pointer (array 'SH1 self.coordtype, self.dims' "
1826 "(primitive 'self.datatype')))");
1827 COMP (ghost_node_labels, "pointer (array 'self.dims' (primitive 'int8'))");
1828 COMP (ghost_zone_labels, "pointer (array 'SH6 -1, self.dims' (primitive 'int8'))");
1829 } ESTRUCT;
1830
1831 STRUCT (DBquadvar) {
1832 COMP (id, "primitive 'int'");
1833 COMP (name, "primitive 'string'");
1834 COMP (meshname, "primitive 'string'");
1835 COMP (units, "primitive 'string'");
1836 COMP (label, "primitive 'string'");
1837 COMP (cycle, "primitive 'int'");
1838 COMP (time, "primitive 'float'");
1839 COMP (dtime, "primitive 'double'");
1840 COMP (meshid, "primitive 'int'");
1841 COMP (datatype, "primitive 'int'"); IOASSOC (PA_DATATYPE);
1842 COMP (centering, "primitive 'int'"); IOASSOC (PA_CENTERING);
1843 COMP (nels, "primitive 'int'");
1844 COMP (nvals, "primitive 'int'");
1845 COMP (ndims, "primitive 'int'");
1846 COMP (dims, "array 'SH3 3, self.ndims' (primitive 'int')");
1847 COMP (major_order, "primitive 'int'"); IOASSOC (PA_ORDER);
1848 COMP (stride, "array 'SH3 3, self.ndims' (primitive 'int')");
1849 COMP (min_index, "array 'SH3 3, self.ndims' (primitive 'int')");
1850 COMP (max_index, "array 'SH3 3, self.ndims' (primitive 'int')");
1851 COMP (origin, "primitive 'int'");
1852 COMP (align, "array 'SH3 3, self.ndims' (primitive 'float')");
1853 COMP (mixlen, "primitive 'int'");
1854 COMP (use_specmf, "primitive 'int'"); IOASSOC (PA_ONOFF);
1855 COMP (ascii_labels, "primitive 'int'"); IOASSOC (PA_BOOLEAN);
1856 COMP (guihide, "primitive 'int'"); IOASSOC (PA_BOOLEAN);
1857 COMP (conserved, "primitive 'int'");
1858 COMP (extensive, "primitive 'int'");
1859 COMP (missing_value, "primitive 'double'"); IOASSOC (PA_MISSING_VALUE);
1860 COMP (region_pnames, "pointer (array 'SH5 0, self.region_pnames' (primitive 'string'))");
1861 COMP (mixvals, "pointer (array 'self.nvals' (pointer (array 'self.mixlen' "
1862 "(primitive 'self.datatype'))))");
1863 COMP (vals, "pointer (array 'self.nvals' (pointer (array 'self.nels' "
1864 "(primitive 'self.datatype'))))");
1865 } ESTRUCT;
1866
1867 STRUCT (DBzonelist) {
1868 COMP (ndims, "primitive 'int'");
1869 COMP (nzones, "primitive 'int'");
1870 COMP (nshapes, "primitive 'int'");
1871 COMP (origin, "primitive 'int'");
1872 COMP (min_index, "primitive 'int'");
1873 COMP (max_index, "primitive 'int'");
1874 COMP (gnznodtype, "primitive 'int'"); IOASSOC (PA_DATATYPE);
1875 COMP (lnodelist, "primitive 'int'");
1876 COMP (shapecnt, "pointer (array 'self.nshapes' (primitive 'int'))");
1877 COMP (shapesize, "pointer (array 'self.nshapes' (primitive 'int'))");
1878
1879 tmp = obj_new (C_PRIM, "int");
1880 prim_set_io_assoc (tmp, PA_ZONETYPE);
1881 tmp = obj_new (C_PTR, obj_new (C_ARY, "self.nshapes", tmp));
1882 COMP3 (shapetype, "shapetype", tmp);
1883
1884 COMP (nodelist, "pointer (array 'self.lnodelist' (primitive 'int'))");
1885 COMP (zoneno, "pointer (array 'self.nzones' (primitive 'int'))");
1886 COMP (gzoneno, "pointer (array 'self.nzones' (primitive 'self.gnznodtype'))");
1887 COMP (ghost_zone_labels, "pointer (array 'self.nzones' (primitive 'int8'))");
1888 } ESTRUCT;
1889
1890 STRUCT (DBphzonelist) {
1891 COMP (nzones, "primitive 'int'");
1892 COMP (nfaces, "primitive 'int'");
1893 COMP (origin, "primitive 'int'");
1894 COMP (lo_offset, "primitive 'int'");
1895 COMP (hi_offset, "primitive 'int'");
1896 COMP (lnodelist, "primitive 'int'");
1897 COMP (lfacelist, "primitive 'int'");
1898 COMP (gnznodtype, "primitive 'int'"); IOASSOC (PA_DATATYPE);
1899 COMP (alt_zonenum_vars, "pointer (array 'SH5 0, self.alt_zonenum_vars' (primitive 'string'))");
1900 COMP (nodecnt, "pointer (array 'self.nfaces' (primitive 'int'))");
1901 COMP (nodelist, "pointer (array 'self.lnodelist' (primitive 'int'))");
1902 COMP (extface, "pointer (array 'self.nfaces' (primitive 'int8'))");
1903 COMP (facecnt, "pointer (array 'self.nzones' (primitive 'int'))");
1904 COMP (facelist, "pointer (array 'self.lfacelist' (primitive 'int'))");
1905 COMP (zoneno, "pointer (array 'self.nzones' (primitive 'int'))");
1906 COMP (gzoneno, "pointer (array 'self.nzones' (primitive 'self.gnznodtype'))");
1907 COMP (ghost_zone_labels, "pointer (array 'self.nzones' (primitive 'int8'))");
1908 } ESTRUCT;
1909
1910 STRUCT (DBcsgzonelist) {
1911 COMP (nregs, "primitive 'int'");
1912 COMP (nzones, "primitive 'int'");
1913 COMP (origin, "primitive 'int'");
1914 COMP (lxform, "primitive 'int'");
1915 COMP (datatype, "primitive 'int'");
1916 COMP (min_index, "primitive 'int'");
1917 COMP (max_index, "primitive 'int'");
1918 COMP (alt_zonenum_vars, "pointer (array 'SH5 0, self.alt_zonenum_vars' (primitive 'string'))");
1919
1920 tmp = obj_new (C_PRIM, "int");
1921 prim_set_io_assoc (tmp, PA_REGIONOP);
1922 tmp = obj_new (C_PTR, obj_new (C_ARY, "self.nregs", tmp));
1923 COMP3 (typeflags, "typeflags", tmp);
1924
1925 COMP (leftids,
1926 "pointer (array 'self.nregs' (primitive 'int'))");
1927 COMP (rightids,
1928 "pointer (array 'self.nregs' (primitive 'int'))");
1929 COMP (xform,
1930 "pointer (array 'self.lxform' (primitive 'self.datatype'))");
1931 COMP (zonelist,
1932 "pointer (array 'self.nzones' (primitive 'int'))");
1933 COMP (regnames,
1934 "pointer (array 'self.nregs' (primitive 'string'))");
1935 COMP (zonenames,
1936 "pointer (array 'self.nzones' (primitive 'string'))");
1937 } ESTRUCT;
1938
1939 STRUCT (DBfacelist) {
1940 COMP (ndims, "primitive 'int'");
1941 COMP (nfaces, "primitive 'int'");
1942 COMP (origin, "primitive 'int'");
1943 COMP (lnodelist, "primitive 'int'");
1944 COMP (nshapes, "primitive 'int'");
1945 COMP (ntypes, "primitive 'int'");
1946 COMP (nodelist,
1947 "pointer (array 'self.lnodelist' (primitive 'int'))");
1948 COMP (shapecnt,
1949 "pointer (array 'self.nshapes' (primitive 'int'))");
1950 COMP (shapesize,
1951 "pointer (array 'self.nshapes' (primitive 'int'))");
1952 COMP (typelist,
1953 "pointer (array 'self.ntypes' (primitive 'int'))");
1954 COMP (types,
1955 "pointer (array 'self.nfaces' (primitive 'int'))");
1956 COMP (nodeno,
1957 "pointer (array 'self.lnodelist' (primitive 'int'))");
1958 COMP (zoneno,
1959 "pointer (array 'self.nfaces' (primitive 'int'))");
1960 } ESTRUCT;
1961
1962 STRUCT (DBedgelist) {
1963 COMP (ndims, "primitive 'int'");
1964 COMP (nedges, "primitive 'int'");
1965 COMP (origin, "primitive 'int'");
1966 COMP (edge_beg,
1967 "pointer (array 'self.nedges' (primitive 'int'))");
1968 COMP (edge_end,
1969 "pointer (array 'self.nedges' (primitive 'int'))");
1970 } ESTRUCT;
1971
1972 STRUCT (DBcsgmesh) {
1973 COMP (block_no, "primitive 'int'");
1974 COMP (group_no, "primitive 'int'");
1975 COMP (name, "primitive 'string'");
1976 COMP (cycle, "primitive 'int'");
1977 COMP (ndims, "primitive 'int'");
1978 COMP (units,
1979 "array 'SH3 3, self.ndims' (primitive 'string')");
1980 COMP (labels,
1981 "array 'SH3 3, self.ndims' (primitive 'string')");
1982 COMP (guihide, "primitive 'int'");
1983 IOASSOC (PA_BOOLEAN);
1984 COMP (nbounds, "primitive 'int'");
1985 COMP (time, "primitive 'float'");
1986 COMP (dtime, "primitive 'double'");
1987 COMP (min_extents,
1988 "array 'SH3 3, self.ndims' (primitive 'double')");
1989 COMP (max_extents,
1990 "array 'SH3 3, self.ndims' (primitive 'double')");
1991 COMP (origin, "primitive 'int'");
1992 COMP (mrgtree_name, "primitive 'string'");
1993 COMP (tv_connectivity, "primitive 'int'");
1994 COMP (disjoint_mode, "primitive 'int'");
1995 COMP (lcoeffs, "primitive 'int'");
1996 COMP (datatype, "primitive 'int'");
1997 COMP (alt_nodenum_vars, "pointer (array 'SH5 0, self.alt_nodenum_vars' (primitive 'string'))");
1998
1999 tmp = obj_new (C_PRIM, "int");
2000 prim_set_io_assoc (tmp, PA_BOUNDARYTYPE);
2001 tmp = obj_new (C_PTR, obj_new (C_ARY, "self.nbounds", tmp));
2002 COMP3 (typeflags, "typeflags", tmp);
2003
2004 COMP (bndids,
2005 "pointer (array 'self.nbounds' (primitive 'int'))");
2006 COMP (coeffs,
2007 "pointer (array 'self.lcoeffs' (primitive 'self.datatype'))");
2008 COMP (bndnames,
2009 "pointer (array 'self.nbounds' (primitive 'string'))");
2010 COMP (zones, "pointer 'DBcsgzonelist'");
2011 } ESTRUCT;
2012
2013 STRUCT (DBcsgvar) {
2014 COMP (name, "primitive 'string'");
2015 COMP (meshname, "primitive 'string'");
2016 COMP (cycle, "primitive 'int'");
2017 COMP (units, "primitive 'string'");
2018 COMP (label, "primitive 'string'");
2019 COMP (time, "primitive 'float'");
2020 COMP (dtime, "primitive 'double'");
2021 COMP (datatype, "primitive 'int'");
2022 IOASSOC (PA_DATATYPE);
2023 COMP (nels, "primitive 'int'");
2024 COMP (nvals, "primitive 'int'");
2025 COMP (centering, "primitive 'int'");
2026 IOASSOC (PA_CENTERING);
2027 COMP (use_specmf, "primitive 'int'");
2028 IOASSOC (PA_ONOFF);
2029 COMP (ascii_labels, "primitive 'int'");
2030 IOASSOC (PA_BOOLEAN);
2031 COMP (guihide, "primitive 'int'");
2032 IOASSOC (PA_BOOLEAN);
2033 COMP (conserved, "primitive 'int'");
2034 COMP (extensive, "primitive 'int'");
2035 COMP (missing_value, "primitive 'double'");
2036 IOASSOC (PA_MISSING_VALUE);
2037 COMP (region_pnames, "pointer (array 'SH5 0, self.region_pnames' (primitive 'string'))");
2038 COMP (vals,
2039 "pointer (array 'self.nvals' (pointer "
2040 "(array 'self.nels' (primitive 'self.datatype'))))");
2041 } ESTRUCT;
2042
2043 STRUCT (DBucdmesh) {
2044 COMP (id, "primitive 'int'");
2045 COMP (block_no, "primitive 'int'");
2046 COMP (group_no, "primitive 'int'");
2047 COMP (name, "primitive 'string'");
2048 COMP (cycle, "primitive 'int'");
2049 COMP (time, "primitive 'float'");
2050 COMP (dtime, "primitive 'double'");
2051 COMP (coord_sys, "primitive 'int'"); IOASSOC (PA_COORDSYS);
2052 COMP (topo_dim, "primitive 'int'"); IOASSOC (PA_TOPODIM);
2053 COMP (ndims, "primitive 'int'");
2054 COMP (nnodes, "primitive 'int'");
2055 COMP (origin, "primitive 'int'");
2056 COMP (datatype, "primitive 'int'"); IOASSOC (PA_DATATYPE);
2057 COMP (units, "array 'SH3 3, self.ndims' (primitive 'string')");
2058 COMP (labels, "array 'SH3 3, self.ndims' (primitive 'string')");
2059 COMP (guihide, "primitive 'int'"); IOASSOC (PA_BOOLEAN);
2060 COMP (mrgtree_name, "primitive 'string'");
2061 COMP (tv_connectivity, "primitive 'int'");
2062 COMP (disjoint_mode, "primitive 'int'");
2063 COMP (gnznodtype, "primitive 'int'"); IOASSOC (PA_DATATYPE);
2064 COMP (min_extents, "array 'SH3 3, self.ndims' (primitive 'self.datatype')");
2065 COMP (max_extents, "array 'SH3 3, self.ndims' (primitive 'self.datatype')");
2066 COMP (alt_nodenum_vars, "pointer (array 'SH5 0, self.alt_nodenum_vars' (primitive 'string'))");
2067 COMP (coords, "array 'SH3 3, self.ndims' (pointer (array 'self.nnodes' "
2068 "(primitive 'self.datatype')))");
2069 COMP (gnodeno, "pointer (array 'self.nnodes' (primitive 'self.gnznodtype'))");
2070 COMP (nodeno, "pointer (array 'self.nnodes' (primitive 'int'))");
2071 COMP (ghost_node_labels, "pointer (array 'self.nnodes' (primitive 'int8'))");
2072 COMP (faces, "pointer 'DBfacelist'");
2073 COMP (zones, "pointer 'DBzonelist'");
2074 COMP (edges, "pointer 'DBedgelist'");
2075 COMP (phzones, "pointer 'DBphzonelist'");
2076 } ESTRUCT;
2077
2078 STRUCT (DBucdvar) {
2079 COMP (id, "primitive 'int'");
2080 COMP (name, "primitive 'string'");
2081 COMP (meshname, "primitive 'string'");
2082 COMP (cycle, "primitive 'int'");
2083 COMP (units, "primitive 'string'");
2084 COMP (label, "primitive 'string'");
2085 COMP (time, "primitive 'float'");
2086 COMP (dtime, "primitive 'double'");
2087 COMP (meshid, "primitive 'int'");
2088 COMP (datatype, "primitive 'int'");
2089 IOASSOC (PA_DATATYPE);
2090 COMP (nels, "primitive 'int'");
2091 COMP (nvals, "primitive 'int'");
2092 COMP (ndims, "primitive 'int'");
2093 COMP (origin, "primitive 'int'");
2094 COMP (centering, "primitive 'int'");
2095 IOASSOC (PA_CENTERING);
2096 COMP (mixlen, "primitive 'int'");
2097 COMP (use_specmf, "primitive 'int'");
2098 IOASSOC (PA_ONOFF);
2099 COMP (ascii_labels, "primitive 'int'");
2100 IOASSOC (PA_BOOLEAN);
2101 COMP (guihide, "primitive 'int'");
2102 IOASSOC (PA_BOOLEAN);
2103 COMP (conserved, "primitive 'int'");
2104 COMP (extensive, "primitive 'int'");
2105 COMP (missing_value, "primitive 'double'");
2106 IOASSOC (PA_MISSING_VALUE);
2107 COMP (region_pnames, "pointer (array 'SH5 0, self.region_pnames' (primitive 'string'))");
2108 COMP (vals,
2109 "pointer (array 'self.nvals' (pointer "
2110 "(array 'self.nels' (primitive 'self.datatype'))))");
2111 COMP (mixvals,
2112 "pointer (array 'self.nvals' (pointer (array 'self.mixlen' "
2113 "(primitive 'self.datatype'))))");
2114 } ESTRUCT;
2115
2116 STRUCT (DBpointmesh) {
2117 COMP (id, "primitive 'int'");
2118 COMP (block_no, "primitive 'int'");
2119 COMP (group_no, "primitive 'int'");
2120 COMP (name, "primitive 'string'");
2121 COMP (cycle, "primitive 'int'");
2122 COMP (time, "primitive 'float'");
2123 COMP (dtime, "primitive 'double'");
2124 COMP (title, "primitive 'string'");
2125 COMP (datatype, "primitive 'int'");
2126 IOASSOC (PA_DATATYPE);
2127 COMP (ndims, "primitive 'int'");
2128 COMP (nels, "primitive 'int'");
2129 COMP (origin, "primitive 'int'");
2130 COMP (units, "array 'SH3 3, self.ndims' (primitive 'string')");
2131 COMP (labels, "array 'SH3 3, self.ndims' (primitive 'string')");
2132 COMP (guihide, "primitive 'int'");
2133 IOASSOC (PA_BOOLEAN);
2134 COMP (mrgtree_name, "primitive 'string'");
2135 COMP (gnznodtype, "primitive 'int'");
2136 IOASSOC (PA_DATATYPE);
2137 COMP (min_extents, "array 'SH3 3, self.ndims' (primitive 'self.datatype')");
2138 COMP (max_extents, "array 'SH3 3, self.ndims' (primitive 'self.datatype')");
2139 COMP (alt_nodenum_vars, "pointer (array 'SH5 0, self.alt_nodenum_vars' (primitive 'string'))");
2140 COMP (coords, "array 'self.ndims' (pointer (array 'self.nels' "
2141 "(primitive 'self.datatype')))");
2142 COMP (gnodeno, "pointer (array 'self.nels' (primitive 'self.gnznodtype'))");
2143 COMP (ghost_node_labels, "pointer (array 'self.nels' (primitive 'int8'))");
2144 } ESTRUCT;
2145
2146 STRUCT (DBmeshvar) {
2147 COMP (id, "primitive 'int'");
2148 COMP (name, "primitive 'string'");
2149 COMP (meshname, "primitive 'string'");
2150 COMP (units, "primitive 'string'");
2151 COMP (label, "primitive 'string'");
2152 COMP (cycle, "primitive 'int'");
2153 COMP (time, "primitive 'float'");
2154 COMP (dtime, "primitive 'double'");
2155 COMP (meshid, "primitive 'int'");
2156 COMP (datatype, "primitive 'int'");
2157 IOASSOC (PA_DATATYPE);
2158 COMP (nels, "primitive 'int'");
2159 COMP (nvals, "primitive 'int'");
2160 COMP (nspace, "primitive 'int'");
2161 COMP (ndims, "primitive 'int'");
2162 COMP (origin, "primitive 'int'");
2163 COMP (centering, "primitive 'int'");
2164 IOASSOC (PA_CENTERING);
2165 COMP (align, "array 'SH3 3, self.ndims' (primitive 'float')");
2166 COMP (dims, "array 'SH3 3, self.ndims' (primitive 'int')");
2167 COMP (major_order, "primitive 'int'");
2168 IOASSOC (PA_ORDER);
2169 COMP (stride, "array 'SH3 3, self.ndims' (primitive 'int')");
2170 COMP (min_index, "array 'SH3 3, self.ndims' (primitive 'int')");
2171 COMP (max_index, "array 'SH3 3, self.ndims' (primitive 'int')");
2172 COMP (guihide, "primitive 'int'");
2173 IOASSOC (PA_BOOLEAN);
2174 COMP (ascii_labels, "primitive 'int'");
2175 IOASSOC (PA_BOOLEAN);
2176 COMP (conserved, "primitive 'int'");
2177 COMP (extensive, "primitive 'int'");
2178 COMP (missing_value, "primitive 'double'");
2179 IOASSOC (PA_MISSING_VALUE);
2180 COMP (region_pnames, "pointer (array 'SH5 0, self.region_pnames' (primitive 'string'))");
2181 COMP (vals, "pointer (array 'self.nvals' (pointer "
2182 "(array 'self.nels' (primitive 'self.datatype'))))");
2183 } ESTRUCT;
2184
2185 STRUCT (DBmaterial) {
2186 COMP (id, "primitive 'int'");
2187 COMP (name, "primitive 'string'");
2188 COMP (meshname, "primitive 'string'");
2189 COMP (ndims, "primitive 'int'");
2190 COMP (origin, "primitive 'int'");
2191 COMP (dims, "array 'SH3 3, self.ndims' (primitive 'int')");
2192 COMP (major_order, "primitive 'int'");
2193 IOASSOC (PA_ORDER);
2194 COMP (stride, "array 'SH3 3, self.ndims' (primitive 'int')");
2195 COMP (nmat, "primitive 'int'");
2196 COMP (matnos, "pointer (array 'self.nmat' (primitive 'int'))");
2197 COMP (matnames, "pointer (array 'self.nmat' (primitive 'string'))");
2198 COMP (matcolors, "pointer (array 'self.nmat' (primitive 'string'))");
2199 COMP (allowmat0, "primitive 'int'");
2200 IOASSOC (PA_BOOLEAN);
2201 COMP (guihide, "primitive 'int'");
2202 IOASSOC (PA_BOOLEAN);
2203 COMP (mixlen, "primitive 'int'");
2204 COMP (datatype, "primitive 'int'");
2205 IOASSOC (PA_DATATYPE);
2206 COMP (matlist, "pointer (array 'SH2, self.dims' (primitive 'int'))");
2207 COMP (mix_vf, "pointer (array 'self.mixlen' (primitive 'self.datatype'))");
2208 COMP (mix_next, "pointer (array 'self.mixlen' (primitive 'int'))");
2209 COMP (mix_mat, "pointer (array 'self.mixlen' (primitive 'int'))");
2210 COMP (mix_zone, "pointer (array 'self.mixlen' (primitive 'int'))");
2211 } ESTRUCT;
2212
2213 STRUCT (DBmatspecies) {
2214 COMP (id, "primitive 'int'");
2215 COMP (name, "primitive 'string'");
2216 COMP (matname, "primitive 'string'");
2217 COMP (nmat, "primitive 'int'");
2218 COMP (nmatspec,
2219 "pointer (array 'self.nmat' (primitive 'int'))");
2220 COMP (ndims, "primitive 'int'");
2221 COMP (dims,
2222 "array 'SH3 3, self.ndims' (primitive 'int')");
2223 COMP (major_order, "primitive 'int'");
2224 IOASSOC (PA_ORDER);
2225 COMP (datatype, "primitive 'int'");
2226 IOASSOC (PA_DATATYPE);
2227 COMP (stride,
2228 "array 'SH3 3, self.ndims' (primitive 'int')");
2229 COMP (nspecies_mf, "primitive 'int'");
2230 COMP (guihide, "primitive 'int'");
2231 IOASSOC (PA_BOOLEAN);
2232 COMP (mixlen, "primitive 'int'");
2233 COMP (speclist,
2234 "pointer (array 'self.dims' (primitive 'int'))");
2235 COMP (specnames,
2236 "pointer (array 'SH4, self.nmatspec' (primitive 'string'))");
2237 COMP (speccolors,
2238 "pointer (array 'SH4, self.nmatspec' (primitive 'string'))");
2239 COMP (species_mf,
2240 "pointer (array 'self.nspecies_mf' (primitive 'self.datatype'))");
2241 COMP (mix_speclist,
2242 "pointer (array 'self.mixlen' (primitive 'int'))");
2243 } ESTRUCT;
2244
2245 /* The DBcompoundarray object is handled specially in browser using the
2246 browser_DBGetCompoundarray() function */
2247
2248 STRUCT (DBmrgtree) {
2249 WALK1 (stc_walk1_DBmrgtree);
2250 COMP (name, "primitive 'string'");
2251 COMP (src_mesh_name, "primitive 'string'");
2252 COMP (src_mesh_type, "primitive 'int'");
2253 COMP (type_info_bits, "primitive 'int'");
2254 COMP (num_nodes, "primitive 'int'");
2255 } ESTRUCT;
2256
2257 /* The DBgroupelmap object is handled specially in browser using the
2258 browser_DBGroupelmap() function */
2259
2260 STRUCT (DBmrgvar) {
2261 COMP (name, "primitive 'string'");
2262 COMP (mrgt_name, "primitive 'string'");
2263 COMP (ncomps, "primitive 'int'");
2264 COMP (nregns, "primitive 'int'");
2265 COMP (datatype, "primitive 'int'");
2266 IOASSOC (PA_DATATYPE);
2267 COMP (compnames, "pointer (array 'self.ncomps' (primitive 'string'))");
2268 COMP (reg_pnames, "pointer (array 'SH5 0, self.reg_pnames' (primitive 'string'))");
2269 COMP (data, "pointer (array 'self.ncomps' (pointer "
2270 "(array 'self.nregns' (primitive 'self.datatype'))))");
2271 } ESTRUCT;
2272
2273 STRUCT (toc_t) {
2274 COMP (type, "primitive 'int'");
2275 IOASSOC (PA_BR_OBJTYPE);
2276 COMP (name, "primitive 'string'");
2277 } ESTRUCT;
2278
2279 STRUCT (DBdirectory) {
2280 WALK1 (stc_walk1_DBdirectory);
2281 WALK2 (stc_walk2_DBdirectory);
2282 COMP (nsyms, "primitive 'int'");
2283 COMP (entry_ptr, "pointer (array 'self.nsyms' (pointer 'toc_t'))");
2284 } ESTRUCT;
2285
2286 STRUCT (DBtoc) {
2287 COMP (ncurve, "primitive 'int'");
2288 COMP (curve_names, "pointer (array 'self.ncurve' (primitive 'string'))");
2289 COMP (ndefvars, "primitive 'int'");
2290 COMP (defvars_names,
2291 "pointer (array 'self.ndefvars' (primitive 'string'))");
2292 COMP (nmultimesh, "primitive 'int'");
2293 COMP (multimesh_names,
2294 "pointer (array 'self.nmultimesh' (primitive 'string'))");
2295 COMP (nmultimeshadj, "primitive 'int'");
2296 COMP (multimeshadj_names,
2297 "pointer (array 'self.nmultimeshadj' (primitive 'string'))");
2298 COMP (nmultimat, "primitive 'int'");
2299 COMP (multimat_names,
2300 "pointer (array 'self.nmultimat' (primitive 'string'))");
2301 COMP (nmultimatspecies, "primitive 'int'");
2302 COMP (multimatspecies_names,
2303 "pointer (array 'self.nmultimatspecies' (primitive 'string'))");
2304 COMP (ncsgmesh, "primitive 'int'");
2305 COMP (csgmesh_names,
2306 "pointer (array 'self.ncsgmesh' (primitive 'string'))");
2307 COMP (ncsgvar, "primitive 'int'");
2308 COMP (csgvar_names,
2309 "pointer (array 'self.ncsgvar' (primitive 'string'))");
2310 COMP (nqmesh, "primitive 'int'");
2311 COMP (qmesh_names,
2312 "pointer (array 'self.nqmesh' (primitive 'string'))");
2313 COMP (nqvar, "primitive 'int'");
2314 COMP (qvar_names,
2315 "pointer (array 'self.nqvar' (primitive 'string'))");
2316 COMP (nucdmesh, "primitive 'int'");
2317 COMP (ucdmesh_names,
2318 "pointer (array 'self.nucdmesh' (primitive 'string'))");
2319 COMP (nucdvar, "primitive 'int'");
2320 COMP (ucdvar_names,
2321 "pointer (array 'self.nucdvar' (primitive 'string'))");
2322 COMP (nptmesh, "primitive 'int'");
2323 COMP (ptmesh_names,
2324 "pointer (array 'self.nptmesh' (primitive 'string'))");
2325 COMP (nptvar, "primitive 'int'");
2326 COMP (ptvar_names,
2327 "pointer (array 'self.nptmesh' (primitive 'string'))");
2328 COMP (nmat, "primitive 'int'");
2329 COMP (mat_names,
2330 "pointer (array 'self.nmat' (primitive 'string'))");
2331 COMP (nmatspecies, "primitive 'int'");
2332 COMP (matspecies_names,
2333 "pointer (array 'self.nmatspecies' (primitive 'string'))");
2334 COMP (nvar, "primitive 'int'");
2335 COMP (var_names,
2336 "pointer (array 'self.nvar' (primitive 'string'))");
2337 COMP (nobj, "primitive 'int'");
2338 COMP (obj_names,
2339 "pointer (array 'self.nobj' (primitive 'string'))");
2340 COMP (ndir, "primitive 'int'");
2341 COMP (dir_names,
2342 "pointer (array 'self.ndir' (primitive 'string'))");
2343 COMP (narray, "primitive 'int'");
2344 COMP (array_names,
2345 "pointer (array 'self.narray' (primitive 'string'))");
2346 COMP (nmrgtree, "primitive 'int'");
2347 COMP (mrgtree_names,
2348 "pointer (array 'self.nmrgtree' (primitive 'string'))");
2349 COMP (ngroupelmap, "primitive 'int'");
2350 COMP (groupelmap_names,
2351 "pointer (array 'self.ngroupelmap' (primitive 'string'))");
2352 COMP (nmrgvar, "primitive 'int'");
2353 COMP (mrgvar_names,
2354 "pointer (array 'self.nmrgvar' (primitive 'string'))");
2355 } ESTRUCT;
2356 }
2357