Initial import of the CDE 2.1.30 sources from the Open Group.
[oweals/cde.git] / cde / osf / wml / wmlouth.c
1 /* 
2  *  @OSF_COPYRIGHT@
3  *  COPYRIGHT NOTICE
4  *  Copyright (c) 1990, 1991, 1992, 1993 Open Software Foundation, Inc.
5  *  ALL RIGHTS RESERVED (MOTIF). See the file named COPYRIGHT.MOTIF for
6  *  the full copyright text.
7 */ 
8 /* 
9  * HISTORY
10 */ 
11 #ifdef REV_INFO
12 #ifndef lint
13 static char rcsid[] = "$XConsortium: wmlouth.c /main/8 1995/08/29 11:10:46 drk $"
14 #endif
15 #endif
16 /*
17 *  (c) Copyright 1989, 1990, DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS. */
18
19 /*
20  * This module contains routines responsible for writing the .h files
21  * produced by WML. All files are written into the current directory.
22  *
23  * Input:
24  *      The resolved objects
25  *
26  * Output:
27  *      UilSymGen.h
28  *      UilSymArTy.h
29  *      UilSymChCl.h
30  *      UilSymRArg.h
31  *      UilUrmClas.h
32  *      UilConst.h
33  *      UilSymReas.h
34  *      UilSymArTa.h
35  *      UilSymChTa.h
36  *      UilSymCtl.h
37  *      UilSymNam.h
38  *      UilSymEnum.h
39  *      UilSymCSet.h
40  */
41
42
43 #include "wml.h"
44
45 #if defined(__STDC__)
46 #include <string.h>
47 #endif
48 #include <stdio.h>
49
50
51 /*
52  * Routines used only in this module
53  */
54 void wmlOutputUilSymGen ();
55 void wmlOutputUilSymArTy ();
56 void wmlOutputUilSymChCl ();
57 void wmlOutputUilSymRArg ();
58 void wmlOutputUilUrmClas ();
59 void wmlOutputUilConst ();
60 void wmlOutputUilSymReas ();
61 void wmlOutputUilSymArTa ();
62 void wmlOutputUilSymChTa ();
63 void wmlOutputUilSymCtl ();
64 void wmlOutputUilSymNam ();
65 void wmlOutputUilSymEnum ();
66 void wmlOutputUilSymCSet ();
67
68 /*
69  * globals
70  */
71
72 static char             *canned_warn =
73 "/*\n\
74 **\tThis file is automatically generated.  Do not edit it by hand.\n\
75 **/\n";
76
77 /*
78  * Used to create masks for bytes in bit vectors. Accessed by bit numbers
79  * from 1 - 8.
80  */
81 static char             *bit_masks[] =  {""
82                                         ," | 1"         /* bit 1 */
83                                         ," | 2"         /* bit 2 */
84                                         ," | 4"         /* bit 3 */
85                                         ," | 8"         /* bit 4 */
86                                         ," | 16"        /* bit 5 */
87                                         ," | 32"        /* bit 6 */
88                                         ," | 64"        /* bit 7 */
89                                         ," | 128"};     /* bit 8 */
90
91 /*
92  * To pick up maximum code values
93  */
94 static int              max_object_code = 0;
95 static int              max_reason_code = 0;
96 static int              max_arg_code = 0;
97 static int              max_enumset_code = 0;
98 static int              max_enumval_code = 0;
99 static int              max_charset_code = 0;
100 static int              max_child_code = 0;
101
102
103 \f
104 /*
105  * Output control routine, which simply outputs each .h file in turn.
106  */
107
108 void wmlOutputHFiles ()
109
110 {
111
112 wmlOutputUilSymGen ();
113 wmlOutputUilSymArTy ();
114 wmlOutputUilSymChCl ();
115 wmlOutputUilSymRArg ();
116 wmlOutputUilUrmClas ();
117 wmlOutputUilConst ();
118 wmlOutputUilSymReas ();
119 wmlOutputUilSymArTa ();
120 wmlOutputUilSymChTa ();
121 wmlOutputUilSymCtl ();
122 wmlOutputUilSymNam ();
123 wmlOutputUilSymEnum ();
124 wmlOutputUilSymCSet ();
125
126 }
127
128
129 \f
130 /*
131  * Routine to write out UilSymGen.h
132  *
133  * This file defines the sym_k... literals for UIL. Each set of literals
134  * typiclly increases monotonically from 1, with 0 used as en error value.
135  *
136  *      sym_k_<class>_object
137  *              <class> is widget class name in lexicographic order
138  *              gadgets are not include.
139  *
140  *      bit masks for table access
141  *
142  *      sym_k_<reason>_reason
143  *              literals specifying all reasons, lexicographically ordered 
144  *
145  *      sym_k_<argument>_arg
146  *              literals for all arguments, lexicographically ordered.
147  *              Constraints are included, and ordered with the arguments.
148  *
149  *      sym_k_<child>_child
150  *              literals for all automatic children, lexicographically ordered.
151  *
152  *      sym_k_<enumset>_enumset
153  *              literals naming each enumeration set, lexicographically ordered
154  *
155  *      Fixed literals naming character set character sizes
156  *      sym_k_<charset>_charset
157  *              literals naming each character set, lexicographically ordered
158  */
159
160 void wmlOutputUilSymGen ()
161
162 {
163
164 char            *canned1 =
165 "\n/*  Define literals for objects */\n";
166
167
168 char            *canned3 =
169 "\n/*  Define literals for reasons */\n\n";
170
171
172 char            *canned4 =
173 "\n/*  Define literals for arguments */\n\n";
174
175 char            *canned5 =
176 "\n/*  Define literals for enumeration sets */\n\n";
177
178 char            *canned6 =
179 "\n/*  Define literals for enumeration values */\n\n";
180
181 char            *canned7 =
182 "\n/*  Define literals for character sets */\n\n";
183
184 char            *canned8 =
185 "\n/*  Define literals for automatic children */\n\n";
186
187 FILE                    *outfil;        /* output file */
188 int                     ndx;            /* loop index */
189 WmlClassDefPtr          clsobj;         /* class object */
190 WmlDataTypeDefPtr       datobj;         /* data type object */
191 WmlResourceDefPtr       resobj;         /* resource object */
192 WmlEnumSetDefPtr        enumsetobj;     /* enumeration set object */
193 WmlEnumValueDefPtr      enumvalobj;     /* enumeration value object */
194 WmlCharSetDefPtr        charsetobj;     /* character set object */
195 WmlChildDefPtr          childobj;       /* child object */
196
197 /*
198  * Open the output file. Write the canned header stuff
199  */
200 outfil = fopen ("UilSymGen.h", "w");
201 if ( outfil == (FILE *) NULL )
202     {
203     printf ("\nCouldn't open UilSymGen.h");
204     return;
205     }
206 fprintf (outfil, canned_warn);
207
208 /*
209  * Write the sym_k..._object literals
210  */
211 fprintf (outfil, canned1);
212 for ( ndx=0 ; ndx<wml_obj_class_ptr->cnt ; ndx++ )
213     {
214     clsobj = (WmlClassDefPtr) wml_obj_class_ptr->hvec[ndx].objptr;
215     fprintf (outfil, "#define sym_k_%s_object\t%d\n",
216              clsobj->tkname,
217              clsobj->sym_code);
218     if ( clsobj->sym_code > max_object_code )
219         max_object_code = clsobj->sym_code;
220     }
221
222 /*
223  * Define the sym_k_..._reason literals
224  */
225 fprintf (outfil, canned3);
226 for ( ndx=0 ; ndx<wml_obj_reason_ptr->cnt ; ndx++ )
227     {
228     resobj = (WmlResourceDefPtr) wml_obj_reason_ptr->hvec[ndx].objptr;
229     fprintf (outfil, "#define sym_k_%s_reason\t%d\n",
230              resobj->tkname,
231              resobj->sym_code);
232     if ( resobj->sym_code > max_reason_code )
233         max_reason_code = resobj->sym_code;
234     }
235
236 /*
237  * Define the sym_k_..._arg literals
238  */
239 fprintf (outfil, canned4);
240 for ( ndx=0 ; ndx<wml_obj_arg_ptr->cnt ; ndx++ )
241     {
242     resobj = (WmlResourceDefPtr) wml_obj_arg_ptr->hvec[ndx].objptr;
243     fprintf (outfil, "#define sym_k_%s_arg\t%d\n",
244              resobj->tkname,
245              resobj->sym_code);
246     if ( resobj->sym_code > max_arg_code )
247         max_arg_code = resobj->sym_code;
248     }
249
250 /*
251  * Define the sym_k_..._enumset structs and literals
252  */
253 fprintf (outfil, canned5);
254 for ( ndx=0 ; ndx<wml_obj_enumset_ptr->cnt ; ndx++ )
255     {
256     enumsetobj = (WmlEnumSetDefPtr) wml_obj_enumset_ptr->hvec[ndx].objptr;
257     fprintf (outfil, "#define sym_k_%s_enumset\t%d\n",
258              enumsetobj->tkname,
259              enumsetobj->sym_code);
260     if ( enumsetobj->sym_code > max_enumset_code )
261         max_enumset_code = enumsetobj->sym_code;
262     }
263
264 /*
265  * Define the sym_k_..._enumval literals
266  */
267 fprintf (outfil, canned6);
268 for ( ndx=0 ; ndx<wml_obj_enumval_ptr->cnt ; ndx++ )
269     {
270     enumvalobj = (WmlEnumValueDefPtr) wml_obj_enumval_ptr->hvec[ndx].objptr;
271     fprintf (outfil, "#define sym_k_%s_enumval\t%d\n",
272              enumvalobj->syndef->name,
273              enumvalobj->sym_code);
274     if ( enumvalobj->sym_code > max_enumval_code )
275         max_enumval_code = enumvalobj->sym_code;
276     }
277
278 /*
279  * Define the sym_k_..._charsize literals
280  * Define the sym_k_..._charset literals
281  */
282 fprintf (outfil, canned7);
283 for ( ndx=0 ; ndx<wml_obj_charset_ptr->cnt ; ndx++ )
284     {
285     charsetobj = (WmlCharSetDefPtr) wml_obj_charset_ptr->hvec[ndx].objptr;
286     fprintf (outfil, "#define sym_k_%s_charset\t%d\n",
287              charsetobj->syndef->name,
288              charsetobj->sym_code);
289     if ( charsetobj->sym_code > max_charset_code )
290         max_charset_code = charsetobj->sym_code;
291     }
292
293 /*
294  * Define the sym_k_..._child literals
295  */
296 fprintf (outfil, canned8);
297 for ( ndx=0 ; ndx<wml_obj_child_ptr->cnt ; ndx++ )
298     {
299     childobj = (WmlChildDefPtr) wml_obj_child_ptr->hvec[ndx].objptr;
300     fprintf (outfil, "#define sym_k_%s_child\t%d\n",
301              childobj->syndef->name,
302              childobj->sym_code);
303     if ( childobj->sym_code > max_child_code )
304         max_child_code = childobj->sym_code;
305     }
306
307 /*
308  * close the output file
309  */
310 printf ("\nCreated UilSymGen.h");
311 fclose (outfil);
312
313 }
314
315
316 \f
317 /*
318  * Routine to write out UilSymChCl.h
319  *
320  * A table of classes accessed by child type (sym_k_<child>_child, in
321  * the form
322  *      ...
323  *      sym_k_<class>_class,
324  */
325
326 void wmlOutputUilSymChCl ()
327
328 {
329
330 char                    *canned1 =
331 "/*  Table of the class type of children\n\
332     The table is indexed by child with each entry the\n\
333     permitted class for that child.\n\
334 */\n\
335 \n\
336 static unsigned char child_class_table_vec[] =\n\
337   {\n\
338     0,\n";
339
340 char                    *canned1a =
341 "  };\n\
342 externaldef(uil_sym_glbl) unsigned char *child_class_table =\n\
343 \t child_class_table_vec;\n";
344
345 FILE                    *outfil;        /* output file */
346 int                     ndx;            /* loop index */
347 WmlClassDefPtr          classobj;       /* data type object */
348 WmlChildDefPtr          childobj;       /* resource object */
349
350
351 /*
352  * Open the output file. Write canned header.
353  */
354 outfil = fopen ( "UilSymChCl.h", "w");
355 if ( outfil == (FILE *) NULL )
356     {
357     printf ("\nCouldn't open UilSymChCL.h");
358     return;
359     }
360 fprintf (outfil, canned_warn);
361
362 /*
363  * Create table entries, similar to writing sym_k...
364  */
365 fprintf (outfil, canned1);
366 for ( ndx=0 ; ndx<wml_obj_child_ptr->cnt ; ndx++ )
367     {
368     childobj = (WmlChildDefPtr) wml_obj_child_ptr->hvec[ndx].objptr;
369     classobj = childobj->class;
370     fprintf (outfil, "    sym_k_%s_object,\n",
371              classobj->tkname);
372     }
373 fprintf (outfil, canned1a);
374
375 /*
376  * close the output file
377  */
378 printf ("\nCreated UilSymChCl.h");
379 fclose (outfil);
380
381 }
382
383 \f
384 /*
385  * Routine to write out UilSymArTy.h
386  *
387  * A table of data types accessed by argument type (sym_k_<arg>_arg, in
388  * the form
389  *      ...
390  *      sym_k_<data_type>_value,
391  */
392
393 void wmlOutputUilSymArTy ()
394
395 {
396
397 char                    *canned1 =
398 "/*  Table of the types of arguments\n\
399     The table is indexed by argument with each entry the\n\
400     permitted type for that argument.\n\
401 */\n\
402 \n\
403 static unsigned char argument_type_table_vec[] =\n\
404   {\n\
405     0,\n";
406
407 char                    *canned1a =
408 "  };\n\
409 externaldef(uil_sym_glbl) unsigned char *argument_type_table =\n\
410 \t argument_type_table_vec;\n";
411
412 FILE                    *outfil;        /* output file */
413 int                     ndx;            /* loop index */
414 WmlDataTypeDefPtr       datobj;         /* data type object */
415 WmlResourceDefPtr       resobj;         /* resource object */
416
417
418 /*
419  * Open the output file. Write canned header.
420  */
421 outfil = fopen ( "UilSymArTy.h", "w");
422 if ( outfil == (FILE *) NULL )
423     {
424     printf ("\nCouldn't open UilSymArTy.h");
425     return;
426     }
427 fprintf (outfil, canned_warn);
428
429 /*
430  * Create table entries, similar to writing sym_k...
431  */
432 fprintf (outfil, canned1);
433 for ( ndx=0 ; ndx<wml_obj_arg_ptr->cnt ; ndx++ )
434     {
435     resobj = (WmlResourceDefPtr) wml_obj_arg_ptr->hvec[ndx].objptr;
436     datobj = resobj->dtype_def;
437     fprintf (outfil, "    sym_k_%s_value,\n",
438              datobj->tkname);
439     }
440 fprintf (outfil, canned1a);
441
442 /*
443  * close the output file
444  */
445 printf ("\nCreated UilSymArTy.h");
446 fclose (outfil);
447
448 }
449
450
451 \f
452 /*
453  * Routine to write out UilSymRArg.h
454  *
455  * Related argument table
456  */
457
458 void wmlOutputUilSymRArg ()
459
460 {
461
462 char                    *canned1 =
463 "/*     Related argument table. Each non-zero entry is the code\n\
464         of the related argument.\n\
465  */\n\
466 \n\
467 static unsigned short int related_argument_table_vec[] =\n\
468   {\n\
469     0,\n";
470
471 char                    *canned1a =
472 "  };\n\
473 externaldef(uil_sym_glbl) unsigned short int *related_argument_table =\n\
474 \t\trelated_argument_table_vec;\n";
475
476 FILE                    *outfil;        /* output file */
477 int                     ndx;            /* loop index */
478 WmlResourceDefPtr       resobj;         /* resource object */
479
480
481 /*
482  * Open the output file. Write canned header.
483  */
484 outfil = fopen ( "UilSymRArg.h", "w");
485 if ( outfil == (FILE *) NULL )
486     {
487     printf ("\nCouldn't open UilSymRArg.h");
488     return;
489     }
490 fprintf (outfil, canned_warn);
491
492 /*
493  * Create table entries, similar to writing sym_k...
494  */
495 fprintf (outfil, canned1);
496 for ( ndx=0 ; ndx<wml_obj_arg_ptr->cnt ; ndx++ )
497     {
498     resobj = (WmlResourceDefPtr) wml_obj_arg_ptr->hvec[ndx].objptr;
499     fprintf (outfil, "    %d,\n",
500              resobj->related_code);
501     }
502 fprintf (outfil, canned1a);
503
504 /*
505  * close the output file
506  */
507 printf ("\nCreated UilSymRArg.h");
508 fclose (outfil);
509
510 }
511
512
513 \f
514 /*
515  * Routine to write out UilUrmClas.h
516  *
517  * Table of convenience function names indexed by the sym_k_<class> literal
518  *      for both widgets and gadgets
519  * Table of resource names indexed by the sym_k_<argument>_arg and
520  *      sym_k_<reason>_reason codes.
521  */
522
523 void wmlOutputUilUrmClas ()
524
525 {
526
527 char                    *canned1 =
528 "\n/*  Define mapping of UIL widget types to convenience functions.  */\n\
529 static char *uil_widget_funcs_vec[] = {\n\
530   \"\",\t  /* NOT USED */\n";
531
532 char                    *canned2 =
533 "};\n\
534 externaldef(uil_sym_glbl) char **uil_widget_funcs = uil_widget_funcs_vec;\n\
535 \n\
536 /*  Define mapping of UIL widget classes to matching gadget class.  */\n\
537 static unsigned short int uil_gadget_variants_vec[] = {\n\
538   0,\t  /* NOT USED */\n";
539
540 char                    *canned3 =
541 "};\n\
542 externaldef(uil_sym_glbl) unsigned short int *uil_gadget_variants =\n\
543 \t\tuil_gadget_variants_vec;\n\
544 \n\
545 /*  Define mapping of dialog types to non-dialog URM widget classes.  */\n\
546 static unsigned short int uil_urm_nondialog_class_vec[] = {\n\
547   0,\t/* NOT USED */\n";
548
549 char                    *canned4 =
550 "};\n\
551 externaldef(uil_sym_glbl) unsigned short int *uil_urm_nondialog_class =\n\
552 \t\tuil_urm_nondialog_class_vec;\n\
553 \n\
554 /*  Define mapping of widget controls to a (subtree) resource.  */\n\
555 static unsigned short int uil_urm_subtree_resource_vec[] = {\n\
556   0,\t/* NOT USED */\n";
557
558 char                    *canned5 =
559 "};\n\
560 externaldef(uil_sym_glbl) unsigned short int *uil_urm_subtree_resource =\n\
561 \t\tuil_urm_subtree_resource_vec;\n\
562 \n\
563 /*  Define mapping of arguments to toolkit names.  */\n\
564 static char *uil_argument_toolkit_names_vec[] = {\n\
565   \"\",\t  /* NOT USED */\n";
566
567 char                    *canned6 =
568 "};\n\
569 externaldef(uil_sym_glbl) char **uil_argument_toolkit_names =\n\
570 \t\tuil_argument_toolkit_names_vec;\n\
571 \n\
572 /*  Define mapping of reasons to toolkit names.  */\n\
573 static char *uil_reason_toolkit_names_vec[] = {\n\
574   \"\",\t/* NOT USED */\n";
575
576 char                    *canned7 =
577 "};\n\
578 externaldef(uil_sym_glbl) char **uil_reason_toolkit_names =\n\
579 \t\tuil_reason_toolkit_names_vec;\n";
580
581
582
583 FILE                    *outfil;        /* output file */
584 int                     ndx;            /* loop index */
585 WmlClassDefPtr          clsobj;         /* class object */
586 WmlSynClassDefPtr       synobj;         /* syntactic object */
587 WmlClassDefPtr          varobj;         /* variant (widget) class object */
588 WmlResourceDefPtr       resobj;         /* argument/reason object */
589 WmlSynResourceDefPtr    synres;         /* arg/reason syntactic object */
590 WmlResourceDefPtr       mapresobj;      /* controls map to resource object */
591
592
593 /*
594  * Open the output file. Write canned header.
595  */
596 outfil = fopen ( "UilUrmClas.h", "w");
597 if ( outfil == (FILE *) NULL )
598     {
599     printf ("\nCouldn't open UilUrmClas.h");
600     return;
601     }
602 fprintf (outfil, canned_warn);
603
604 /*
605  * Write entries for widgets
606  */
607 fprintf (outfil, canned1);
608 for ( ndx=0 ; ndx<wml_obj_class_ptr->cnt ; ndx++ )
609     {
610     clsobj = (WmlClassDefPtr) wml_obj_class_ptr->hvec[ndx].objptr;
611     if ( clsobj->sym_code == 0 ) continue;
612     synobj = clsobj->syndef;
613     if ( synobj->int_lit != NULL )
614         fprintf (outfil, "  \"%s\",\n", synobj->convfunc);
615     else 
616         fprintf (outfil, "  \"%s\",\t\n", synobj->convfunc);
617     }
618 fprintf (outfil, canned2);
619
620 /*
621  * Write entries for gadget variants of widget classes
622  */
623 for ( ndx=0 ; ndx<wml_obj_class_ptr->cnt ; ndx++ )
624     {
625     clsobj = (WmlClassDefPtr) wml_obj_class_ptr->hvec[ndx].objptr;
626     if ( clsobj->sym_code == 0 ) continue;
627     varobj = clsobj->variant;
628     synobj = clsobj->syndef;
629     if ( varobj==NULL || synobj->type==WmlClassTypeGadget )
630         fprintf (outfil, "  0,\n");
631     else 
632         {
633         synobj = varobj->syndef;
634         if ( synobj->int_lit != NULL )
635             fprintf (outfil, "  sym_k_%s_object,\n",
636                      synobj->int_lit);
637         else 
638             fprintf (outfil, "  sym_k_%s_object,\n",
639                      synobj->name);
640         }
641     }
642 fprintf (outfil, canned3);
643
644 /*
645  * Write entries for non-dialog widgets
646  */
647 for ( ndx=0 ; ndx<wml_obj_class_ptr->cnt ; ndx++ )
648     {
649     clsobj = (WmlClassDefPtr) wml_obj_class_ptr->hvec[ndx].objptr;
650     if ( clsobj->sym_code == 0 ) continue;
651     varobj = clsobj->nondialog;
652     synobj = clsobj->syndef;
653     if ( varobj == NULL )
654         fprintf (outfil, "  0,\n");
655     else
656         {
657         synobj = varobj->syndef;
658         if ( synobj->int_lit != NULL )
659             fprintf (outfil, "  sym_k_%s_object,\n",
660                      synobj->int_lit);
661         else 
662             fprintf (outfil, "  sym_k_%s_object,\n",
663                      synobj->name);
664         }
665     }
666 fprintf (outfil, canned4);
667
668 /*
669  * Write entries for the resource a widget's controls map to
670  */
671 for ( ndx=0 ; ndx<wml_obj_class_ptr->cnt ; ndx++ )
672     {
673     clsobj = (WmlClassDefPtr) wml_obj_class_ptr->hvec[ndx].objptr;
674     if ( clsobj->sym_code == 0 ) continue;
675     synobj = clsobj->syndef;
676     mapresobj = clsobj->ctrlmapto;
677     if ( mapresobj == NULL )
678         fprintf (outfil, "  0,\n");
679     else
680         fprintf (outfil, "  sym_k_%s_arg,\n", mapresobj->tkname);
681     }
682 fprintf (outfil, canned5);
683
684 /*
685  * Write entries for arguments
686  */
687 for ( ndx=0 ; ndx<wml_obj_arg_ptr->cnt ; ndx++ )
688     {
689     resobj = (WmlResourceDefPtr) wml_obj_arg_ptr->hvec[ndx].objptr;
690     synres = resobj->syndef;
691     if ( resobj->sym_code == 0 ) continue;
692     fprintf (outfil, "  %s,\n",
693              synres->resliteral);
694     }
695 fprintf (outfil, canned6);
696
697 /*
698  * Write entries for reasons
699  */
700 for ( ndx=0 ; ndx<wml_obj_reason_ptr->cnt ; ndx++ )
701     {
702     resobj = (WmlResourceDefPtr) wml_obj_reason_ptr->hvec[ndx].objptr;
703     synres = resobj->syndef;
704     if ( resobj->sym_code == 0 ) continue;
705     fprintf (outfil, "  %s,\n",
706              synres->resliteral);
707     }
708 fprintf (outfil, canned7);
709
710 /*
711  * close the output file
712  */
713 printf ("\nCreated UilUrmClas.h");
714 fclose (outfil);
715
716 }
717
718
719 \f
720 /*
721  * Routine to write out UilConst.h
722  *
723  * A bit vector showing which arguments are constraints.
724  */
725
726 void wmlOutputUilConst ()
727
728 {
729
730 char                    *canned1 =
731 "/* Table indexed by argument indicating whether\n\
732    argument is a constraint (TRUE) or a regular\n\
733    argument (FALSE).  Each entry is one bit.\n\
734    Index and mask macros are defined to simplify\n\
735    access to the table\n\
736 */\n\
737 \n\
738 static unsigned char constraint_tab_vec[] = {\n";
739
740 char                    *canned1a =
741 "};\n\
742 externaldef(uil_sym_glbl) unsigned char *constraint_tab =\n\
743 \t\tconstraint_tab_vec;\n";
744
745
746 FILE                    *outfil;        /* output file */
747 int                     ndx;            /* loop index */
748 WmlResourceDefPtr       resobj;         /* resource object */
749 WmlSynResourceDefPtr    synobj;         /* syntactic object */
750 char                    maskbuf[100];   /* to constuct each mask */
751 int                     bitno;          /* current bit number, from code */
752
753 /*
754  * Open the output file. Write canned header.
755  */
756 outfil = fopen ( "UilConst.h", "w");
757 if ( outfil == (FILE *) NULL )
758     {
759     printf ("\nCouldn't open UilConst.h");
760     return;
761     }
762 fprintf (outfil, canned_warn);
763
764 /*
765  * Process the arguments in code order. We start with 1, and write out
766  * the mask after processing 8 codes.
767  */
768 fprintf (outfil, canned1);
769 strcpy (maskbuf, "0");
770 for ( ndx=0 ; ndx<wml_obj_arg_ptr->cnt ; ndx++ )
771     {
772     resobj = (WmlResourceDefPtr) wml_obj_arg_ptr->hvec[ndx].objptr;
773     synobj = resobj->syndef;
774     bitno = resobj->sym_code % 8;
775     if ( bitno == 0 ) bitno = 8;
776     if ( synobj->type == WmlResourceTypeConstraint )
777         strcat (maskbuf, bit_masks[bitno]);
778     if ( bitno == 8 )
779         {
780         fprintf (outfil, "%s,\n", maskbuf);
781         strcpy (maskbuf, "0");
782         }
783     }
784 if ( bitno != 8 )
785     fprintf (outfil, "%s", maskbuf);
786 fprintf (outfil, canned1a);
787
788 /*
789  * close the output file
790  */
791 printf ("\nCreated UilConst.h");
792 fclose (outfil);
793
794 }
795
796
797 \f
798 /*
799  * Routine to write out UilSymReas.h
800  *
801  * This file defines the reasons supported by each class. For each
802  * reason, there is a bit vector with the bit for each supporting class
803  * turned on if the reason is supported. There is then a vector pointing
804  * to these bit vectors for all reasons. This vector is accessed by
805  * sym_k_..._reason to find the reasons bit vector, then by sym_k_..._object
806  * to check the bit.
807  */
808
809 void wmlOutputUilSymReas ()
810
811 {
812
813 char                    *canned1 =
814 "\n/*\n\
815  * Bit vectors for each reason. The entries in the vector correspond\n\
816  * to each class.\n\
817  */\n";
818
819 char                    *bvechdr =
820 "\n\
821 /* sym_k_%s_reason */\n\
822 static unsigned char reason_class_vec%d[] =\n\
823   {\n";
824
825 char                    *canned2 =
826 "\n/*\n\
827  * Table of bit vectors accessed by sym_k_..._reason\n\
828  */\n\
829 static unsigned char *allowed_reason_table_vec[] =\n\
830   {\n\
831   NULL,\t/* UNUSED */\n";
832
833 char                    *canned3 =
834 "  };\n\
835 externaldef(uil_sym_glbl) unsigned char **allowed_reason_table =\n\
836 \t\tallowed_reason_table_vec;\n";
837
838 FILE                    *outfil;        /* output file */
839 int                     resndx;         /* outer loop index */
840 WmlResourceDefPtr       resobj;         /* current reason */
841 int                     clsndx;         /* inner loop index */
842 WmlClassDefPtr          clsobj;         /* current class object */
843 WmlClassResDefPtr       resref;         /* class' resource reference */
844 int                     itemno;         /* item in bye */
845 char                    maskbuf[500];   /* current mask buffer */
846 char                    itembuf[100];   /* for current item */
847 int                     donl;           /* TRUE if append \n to mask */
848
849
850 /*
851  * Open the output file. Write canned header.
852  */
853 outfil = fopen ( "UilSymReas.h", "w");
854 if ( outfil == (FILE *) NULL )
855     {
856     printf ("\nCouldn't open UilSymReas.h");
857     return;
858     }
859 fprintf (outfil, canned_warn);
860 fprintf (outfil, canned1);
861
862 /*
863  * Generate the bit vectors for each class. Outer loop on the reason code,
864  * inner loop on the class code.
865  */
866 for ( resndx=0 ; resndx<wml_obj_reason_ptr->cnt ; resndx++ )
867     {
868     resobj = (WmlResourceDefPtr) wml_obj_reason_ptr->hvec[resndx].objptr;
869     fprintf (outfil, bvechdr, resobj->tkname, resobj->sym_code);
870
871     /*
872      * inner loop on widget class.
873      */
874     strcpy (maskbuf, " ");
875     for ( clsndx=0 ; clsndx<wml_obj_class_ptr->cnt ; clsndx++ )
876         {
877         clsobj = (WmlClassDefPtr) wml_obj_class_ptr->hvec[clsndx].objptr;
878         itemno = (clsobj->sym_code+1) % 8;
879         donl = FALSE;
880         resref = wmlResolveResIsMember (resobj, clsobj->reasons);
881         if ( resref != NULL )
882             if ( resref->exclude != WmlAttributeTrue )
883                 {
884                 sprintf (itembuf, " _BIT_MASK(sym_k_%s_object) |",
885                          clsobj->tkname);
886                 strcat (maskbuf, itembuf);
887                 donl = TRUE;
888                 }
889         if ( donl )
890             strcat (maskbuf, "\n ");
891         if ( itemno == 0 )
892             {
893             fprintf (outfil, "%s 0", maskbuf);
894             strcpy (maskbuf, ",");
895             }
896         }
897     if ( itemno != 0 )
898         fprintf (outfil, "%s 0};\n", maskbuf);
899     else
900         fprintf (outfil, "};\n");
901     }
902
903 /*
904  * Write the vector of vectors.
905  */
906 fprintf (outfil, canned2);
907 for ( resndx=0 ; resndx<wml_obj_reason_ptr->cnt ; resndx++ )
908     {
909     resobj = (WmlResourceDefPtr) wml_obj_reason_ptr->hvec[resndx].objptr;
910     fprintf (outfil, "  reason_class_vec%d,\n", resobj->sym_code);
911     }
912 fprintf (outfil, canned3);
913
914 /*
915  * close the output file
916  */
917 printf ("\nCreated UilSymReas.h");
918 fclose (outfil);
919
920 }
921
922
923 \f
924 /*
925  * Routine to write out UilSymArTa.h
926  *
927  * This file defines the arguments supported by each class. For each
928  * argument, there is a bit vector with the bit for each supporting class
929  * turned on if the argument is supported. There is then a vector pointing
930  * to these bit vectors for all arguments. This vector is accessed by
931  * sym_k_..._arg to find the arguments bit vector, then by sym_k_..._object
932  * to check the bit.
933  */
934
935 void wmlOutputUilSymArTa ()
936
937 {
938
939 char                    *canned1 =
940 "\n/*\n\
941  * Bit vectors for each argument. The entries in the vector correspond\n\
942  * to each class.\n\
943  */\n";
944
945 char                    *bvechdr =
946 "\n\
947 /* sym_k_%s_arg */\n\
948 static unsigned char arg_class_vec%d[] =\n\
949   {\n";
950
951 char                    *canned2 =
952 "\n/*\n\
953  * Table of bit vectors accessed by sym_k_..._arg\n\
954  */\n\
955 static unsigned char *allowed_argument_table_vec[] =\n\
956   {\n\
957   NULL,\t/* UNUSED */\n";
958
959 char                    *canned3 =
960 "  };\n\
961 externaldef(uil_sym_glbl) unsigned char **allowed_argument_table =\n\
962 \t\tallowed_argument_table_vec;\n";
963
964 FILE                    *outfil;        /* output file */
965 int                     resndx;         /* outer loop index */
966 WmlResourceDefPtr       resobj;         /* current argument */
967 int                     clsndx;         /* inner loop index */
968 WmlClassDefPtr          clsobj;         /* current class object */
969 WmlClassResDefPtr       resref;         /* class' resource reference */
970 int                     itemno;         /* item in bye */
971 char                    maskbuf[500];   /* current mask buffer */
972 char                    itembuf[100];   /* for current item */
973 int                     donl;           /* TRUE if append \n to mask */
974
975
976 /*
977  * Open the output file. Write canned header.
978  */
979 outfil = fopen ( "UilSymArTa.h", "w");
980 if ( outfil == (FILE *) NULL )
981     {
982     printf ("\nCouldn't open UilSymArTa.h");
983     return;
984     }
985 fprintf (outfil, canned_warn);
986 fprintf (outfil, canned1);
987
988 /*
989  * Generate the bit vectors for each class. Outer loop on the argument code,
990  * inner loop on the class code.
991  */
992 for ( resndx=0 ; resndx<wml_obj_arg_ptr->cnt ; resndx++ )
993     {
994     resobj = (WmlResourceDefPtr) wml_obj_arg_ptr->hvec[resndx].objptr;
995     fprintf (outfil, bvechdr, resobj->tkname, resobj->sym_code);
996
997     /*
998      * inner loop on widget class.
999      */
1000     strcpy (maskbuf, " ");
1001     for ( clsndx=0 ; clsndx<wml_obj_class_ptr->cnt ; clsndx++ )
1002         {
1003         clsobj = (WmlClassDefPtr) wml_obj_class_ptr->hvec[clsndx].objptr;
1004         itemno = (clsobj->sym_code+1) % 8;
1005         donl = FALSE;
1006         resref = wmlResolveResIsMember (resobj, clsobj->arguments);
1007         if ( resref != NULL )
1008             if ( resref->exclude != WmlAttributeTrue )
1009                 {
1010                 sprintf (itembuf, " _BIT_MASK(sym_k_%s_object) |",
1011                          clsobj->tkname);
1012                 strcat (maskbuf, itembuf);
1013                 donl = TRUE;
1014                 }
1015         if ( donl )
1016             strcat (maskbuf, "\n ");
1017         if ( itemno == 0 )
1018             {
1019             fprintf (outfil, "%s 0", maskbuf);
1020             strcpy (maskbuf, ",");
1021             }
1022         }
1023     if ( itemno != 0 )
1024         fprintf (outfil, "%s 0};\n", maskbuf);
1025     else
1026         fprintf (outfil, "};\n");
1027     }
1028
1029 /*
1030  * Write the vector of vectors.
1031  */
1032 fprintf (outfil, canned2);
1033 for ( resndx=0 ; resndx<wml_obj_arg_ptr->cnt ; resndx++ )
1034     {
1035     resobj = (WmlResourceDefPtr) wml_obj_arg_ptr->hvec[resndx].objptr;
1036     fprintf (outfil, "  arg_class_vec%d,\n", resobj->sym_code);
1037     }
1038 fprintf (outfil, canned3);
1039
1040 /*
1041  * close the output file
1042  */
1043 printf ("\nCreated UilSymArTa.h");
1044 fclose (outfil);
1045
1046 }
1047
1048 \f
1049 /*
1050  * Routine to write out UilSymChTa.h
1051  *
1052  * This file defines the automatic children supported by each class. For each
1053  * child, there is a bit vector with the bit for each supporting class
1054  * turned on if the child is supported. There is then a vector pointing
1055  * to these bit vectors for all children. This vector is accessed by
1056  * sym_k_..._child to find the child's bit vector, then by sym_k_..._object
1057  * to check the bit.
1058  */
1059
1060 void wmlOutputUilSymChTa ()
1061
1062 {
1063
1064 char                    *canned1 =
1065 "\n/*\n\
1066  * Bit vectors for each child. The entries in the vector correspond\n\
1067  * to each class.\n\
1068  */\n";
1069
1070 char                    *bvechdr =
1071 "\n\
1072 /* sym_k_%s_child */\n\
1073 static unsigned char child_class_vec%d[] =\n\
1074   {\n";
1075
1076 char                    *canned2 =
1077 "\n/*\n\
1078  * Table of bit vectors accessed by sym_k_..._child\n\
1079  */\n\
1080 static unsigned char *allowed_child_table_vec[] =\n\
1081   {\n\
1082   NULL,\t/* UNUSED */\n";
1083
1084 char                    *canned3 =
1085 "  };\n\
1086 externaldef(uil_sym_glbl) unsigned char **allowed_child_table =\n\
1087 \t\tallowed_child_table_vec;\n";
1088
1089 FILE                    *outfil;        /* output file */
1090 int                     childndx;       /* outer loop index */
1091 WmlChildDefPtr          childobj;       /* current argument */
1092 int                     clsndx;         /* inner loop index */
1093 WmlClassDefPtr          clsobj;         /* current class object */
1094 WmlClassChildDefPtr     childref;       /* class' child reference */
1095 int                     itemno;         /* item in byte */
1096 char                    maskbuf[500];   /* current mask buffer */
1097 char                    itembuf[100];   /* for current item */
1098 int                     donl;           /* TRUE if append \n to mask */
1099
1100
1101 /*
1102  * Open the output file. Write canned header.
1103  */
1104 outfil = fopen ( "UilSymChTa.h", "w");
1105 if ( outfil == (FILE *) NULL )
1106     {
1107     printf ("\nCouldn't open UilSymChTa.h");
1108     return;
1109     }
1110 fprintf (outfil, canned_warn);
1111 fprintf (outfil, canned1);
1112
1113 /*
1114  * Generate the bit vectors for each class. Outer loop on the child code,
1115  * inner loop on the class code.
1116  */
1117 for ( childndx=0 ; childndx<wml_obj_child_ptr->cnt ; childndx++ )
1118     {
1119     childobj = (WmlChildDefPtr) wml_obj_child_ptr->hvec[childndx].objptr;
1120     fprintf (outfil, bvechdr, childobj->tkname, childobj->sym_code);
1121
1122     /*
1123      * inner loop on widget class.
1124      */
1125     strcpy (maskbuf, " ");
1126     for ( clsndx=0 ; clsndx<wml_obj_class_ptr->cnt ; clsndx++ )
1127         {
1128         clsobj = (WmlClassDefPtr) wml_obj_class_ptr->hvec[clsndx].objptr;
1129         itemno = (clsobj->sym_code+1) % 8;
1130         donl = FALSE;
1131         childref = wmlResolveChildIsMember (childobj, clsobj->children);
1132         if ( childref != NULL )
1133           {
1134             sprintf (itembuf, " _BIT_MASK(sym_k_%s_object) |", clsobj->tkname);
1135             strcat (maskbuf, itembuf);
1136             donl = TRUE;
1137           }
1138         if ( donl )
1139             strcat (maskbuf, "\n ");
1140         if ( itemno == 0 )
1141             {
1142             fprintf (outfil, "%s 0", maskbuf);
1143             strcpy (maskbuf, ",");
1144             }
1145         }
1146     if ( itemno != 0 )
1147         fprintf (outfil, "%s 0};\n", maskbuf);
1148     else
1149         fprintf (outfil, "};\n");
1150     }
1151
1152 /*
1153  * Write the vector of vectors.
1154  */
1155 fprintf (outfil, canned2);
1156 for ( childndx=0 ; childndx<wml_obj_child_ptr->cnt ; childndx++ )
1157     {
1158     childobj = (WmlChildDefPtr) wml_obj_child_ptr->hvec[childndx].objptr;
1159     fprintf (outfil, "  child_class_vec%d,\n", childobj->sym_code);
1160     }
1161 fprintf (outfil, canned3);
1162
1163 /*
1164  * close the output file
1165  */
1166 printf ("\nCreated UilSymChTa.h");
1167 fclose (outfil);
1168
1169 }
1170
1171 \f
1172 /*
1173  * Routine to write out UilSymCtl.h
1174  *
1175  * This file defines the controls supported by each class. For each
1176  * object, there is a bit vector with the bit for each supporting class
1177  * turned on if the object is supported. There is then a vector pointing
1178  * to these bit vectors for all objects. This vector is accessed by
1179  * sym_k_..._object to find the objects bit vector, then by sym_k_..._object
1180  * to check the bit.
1181  */
1182
1183 void wmlOutputUilSymCtl ()
1184
1185 {
1186
1187 char                    *canned1 =
1188 "\n/*\n\
1189  * Bit vectors for each control. The entries in the vector correspond\n\
1190  * to each class.\n\
1191  */\n";
1192
1193 char                    *bvechdr =
1194 "\n\
1195 /* sym_k_%s_object */\n\
1196 static unsigned char object_class_vec%d[] =\n\
1197   {\n";
1198
1199 char                    *canned2 =
1200 "\n/*\n\
1201  * Table of bit vectors accessed by sym_k_..._object\n\
1202  */\n\
1203 static unsigned char *allowed_control_table_vec[] =\n\
1204   {\n\
1205   NULL,\t/* UNUSED */\n";
1206
1207 char                    *canned3 =
1208 "  };\n\
1209 externaldef(uil_sym_glbl) unsigned char **allowed_control_table =\n\
1210 \t\tallowed_control_table_vec;\n";
1211
1212 FILE                    *outfil;        /* output file */
1213 int                     ctlndx;         /* outer loop index */
1214 WmlClassDefPtr          ctlobj;         /* current class allowing controls */
1215 int                     clsndx;         /* inner loop index */
1216 WmlClassDefPtr          clsobj;         /* current class object */
1217 int                     itemno;         /* item in bye */
1218 char                    maskbuf[500];   /* current mask buffer */
1219 char                    itembuf[100];   /* for current item */
1220 int                     donl;           /* TRUE if append \n to mask */
1221
1222
1223 /*
1224  * Open the output file. Write canned header.
1225  */
1226 outfil = fopen ( "UilSymCtl.h", "w");
1227 if ( outfil == (FILE *) NULL )
1228     {
1229     printf ("\nCouldn't open UilSymCtl.h");
1230     return;
1231     }
1232 fprintf (outfil, canned_warn);
1233 fprintf (outfil, canned1);
1234
1235 /*
1236  * Generate the bit vectors for each class. Outer loop on the class code,
1237  * inner loop on the class code.
1238  */
1239 for ( ctlndx=0 ; ctlndx<wml_obj_class_ptr->cnt ; ctlndx++ )
1240     {
1241     clsobj = (WmlClassDefPtr) wml_obj_class_ptr->hvec[ctlndx].objptr;
1242     fprintf (outfil, bvechdr, clsobj->tkname, clsobj->sym_code);
1243
1244     /*
1245      * inner loop on widget class.
1246      */
1247     strcpy (maskbuf, " ");
1248     for ( clsndx=0 ; clsndx<wml_obj_class_ptr->cnt ; clsndx++ )
1249         {
1250         ctlobj = (WmlClassDefPtr) wml_obj_class_ptr->hvec[clsndx].objptr;
1251         itemno = (ctlobj->sym_code+1) % 8;
1252         donl = FALSE;
1253         if ( wmlResolveCtlIsMember(clsobj,ctlobj->controls) == TRUE)
1254             {
1255             sprintf (itembuf, " _BIT_MASK(sym_k_%s_object) |",
1256                      ctlobj->tkname);
1257             strcat (maskbuf, itembuf);
1258             donl = TRUE;
1259             }
1260         if ( donl )
1261             strcat (maskbuf, "\n ");
1262         if ( itemno == 0 )
1263             {
1264             fprintf (outfil, "%s 0", maskbuf);
1265             strcpy (maskbuf, ",");
1266             }
1267         }
1268     if ( itemno != 0 )
1269         fprintf (outfil, "%s 0};\n", maskbuf);
1270     else
1271         fprintf (outfil, "};\n");
1272     }
1273
1274 /*
1275  * Write the vector of vectors.
1276  */
1277 fprintf (outfil, canned2);
1278 for ( ctlndx=0 ; ctlndx<wml_obj_class_ptr->cnt ; ctlndx++ )
1279     {
1280     clsobj = (WmlClassDefPtr) wml_obj_class_ptr->hvec[ctlndx].objptr;
1281     fprintf (outfil, "  object_class_vec%d,\n", clsobj->sym_code);
1282     }
1283 fprintf (outfil, canned3);
1284
1285 /*
1286  * close the output file
1287  */
1288 printf ("\nCreated UilSymCtl.h");
1289 fclose (outfil);
1290
1291 }
1292
1293
1294 \f
1295 /*
1296  * Predicate to indicate if a class object is in a controls list.
1297  */
1298
1299 int wmlResolveCtlIsMember (ctlobj, ctlref)
1300     WmlClassDefPtr              ctlobj;
1301     WmlClassCtrlDefPtr          ctlref;
1302
1303 {
1304
1305 while ( ctlref != NULL )
1306     {
1307     if ( ctlref->ctrl == ctlobj ) return TRUE;
1308     ctlref = ctlref->next;
1309     }
1310 return FALSE;
1311
1312 }
1313
1314
1315 \f
1316 /*
1317  * Routine to write out UilSymNam.h
1318  *
1319  * Tables of names of object indexed by their various sym_k_ literals.
1320  */
1321
1322 void wmlOutputUilSymNam ()
1323
1324 {
1325
1326 char                    *canned1 =
1327 "/*  Define mapping of sym_k_..._object codes to widget names.  */\n\
1328 \n\
1329 externaldef(uil_sym_glbl) int uil_max_object = %d;\n\
1330 static char *uil_widget_names_vec[] = {\n\
1331     \"\",\t/* NOT USED */\n";
1332
1333 char                    *canned2 =
1334 "};\n\
1335 externaldef(uil_sym_glbl) char **uil_widget_names =\n\
1336 \t\tuil_widget_names_vec;\n\
1337 \n\n\
1338 /*  Define mapping of sym_k_..._arg codes to argument names.  */\n\
1339 \n\
1340 externaldef(uil_sym_glbl) int uil_max_arg = %d;\n\
1341 static char *uil_argument_names_vec[] = {\n\
1342     \"\",\t/* NOT USED */\n";
1343
1344 char                    *canned3 =
1345 "};\n\
1346 externaldef(uil_sym_glbl) char **uil_argument_names =\n\
1347 \t\tuil_argument_names_vec;\n\
1348 \n\n\
1349 /*  Define mapping of sym_k_..._reason to reason names.  */\n\
1350 \n\
1351 externaldef(uil_sym_glbl) int uil_max_reason = %d;\n\
1352 static char *uil_reason_names_vec[] = {\n\
1353     \"\",\t/* NOT USED */\n";
1354
1355 char                    *canned4 =
1356 "};\n\
1357 externaldef(uil_sym_glbl) char **uil_reason_names =\n\
1358 \t\tuil_reason_names_vec;\n\
1359 \n\n\
1360 /*  Define mapping of sym_k_..._enumval to enumeration value names.  */\n\
1361 \n\
1362 externaldef(uil_sym_glbl) int uil_max_enumset = %d;\n\
1363 externaldef(uil_sym_glbl) int uil_max_enumval = %d;\n\
1364 static char *uil_enumval_names_vec[] = {\n\
1365     \"\",\t/* NOT USED */\n";
1366
1367 char                    *canned5 =
1368 "};\n\
1369 externaldef(uil_sym_glbl) char **uil_enumval_names =\n\
1370 \t\tuil_enumval_names_vec;\n\
1371 \n\n\
1372 /*  Define mapping of sym_k_..._charset to enumeration value names.  */\n\
1373 \n\
1374 externaldef(uil_sym_glbl) int uil_max_charset = %d;\n\
1375 static char *uil_charset_names_vec[] = {\n\
1376     \"\",\t/* NOT USED */\n\
1377     \"<userdefined>\",\n";
1378
1379 char                    *canned6 =
1380 "};\n\
1381 externaldef(uil_sym_glbl) char **uil_charset_names =\n\
1382 \t\tuil_charset_names_vec;\n\
1383 \n\n\
1384 /*  Define mapping of sym_k_..._child codes to child names.  */\n\
1385 \n\
1386 externaldef(uil_sym_glbl) int uil_max_child = %d;\n\
1387 static char *uil_child_names_vec[] = {\n\
1388     \"\",\t/* NOT USED */\n";
1389
1390 char                    *canned7 =
1391 "};\n\
1392 externaldef(uil_sym_glbl) char **uil_child_names =\n\
1393 \t\tuil_child_names_vec;\n";
1394
1395
1396 FILE                    *outfil;        /* output file */
1397 int                     ndx;            /* loop index */
1398 WmlClassDefPtr          clsobj;         /* class object */
1399 WmlClassDefPtr          varobj;         /* gadget class object */
1400 WmlSynClassDefPtr       synobj;         /* syntactic object */
1401 WmlResourceDefPtr       resobj;         /* argument/reason object */
1402 WmlSynResourceDefPtr    synres;         /* arg/reason syntactic object */
1403 WmlEnumValueDefPtr      evobj;          /* enumeration value object */
1404 WmlSynEnumValueDefPtr   synev;          /* enumeration value syntactic obj */
1405 WmlCharSetDefPtr        csobj;          /* character set object */
1406 WmlSynCharSetDefPtr     syncs;          /* character set syntactic obj */
1407 WmlChildDefPtr          chobj;          /* child object */
1408 WmlSynChildDefPtr       synch;          /* child syntactic object */
1409
1410 /*
1411  * Open the output file. Write canned header.
1412  */
1413 outfil = fopen ( "UilSymNam.h", "w");
1414 if ( outfil == (FILE *) NULL )
1415     {
1416     printf ("\nCouldn't open UilSymNam.h");
1417     return;
1418     }
1419 fprintf (outfil, canned_warn);
1420
1421 /*
1422  * Write entries for widgets
1423  */
1424 fprintf (outfil, canned1, max_object_code);
1425 for ( ndx=0 ; ndx<wml_obj_class_ptr->cnt ; ndx++ )
1426     {
1427     clsobj = (WmlClassDefPtr) wml_obj_class_ptr->hvec[ndx].objptr;
1428     if ( clsobj->sym_code == 0 ) continue;
1429     synobj = clsobj->syndef;
1430     fprintf (outfil, "    \"%s\",\n",
1431              synobj->name);
1432     }
1433
1434 /*
1435  * Write entries for arguments
1436  */
1437 fprintf (outfil, canned2, max_arg_code);
1438 for ( ndx=0 ; ndx<wml_obj_arg_ptr->cnt ; ndx++ )
1439     {
1440     resobj = (WmlResourceDefPtr) wml_obj_arg_ptr->hvec[ndx].objptr;
1441     synres = resobj->syndef;
1442     if ( resobj->sym_code == 0 ) continue;
1443     fprintf (outfil, "    \"%s\",\n",
1444              synres->name);
1445     }
1446
1447 /*
1448  * Write entries for reasons
1449  */
1450 fprintf (outfil, canned3, max_reason_code);
1451 for ( ndx=0 ; ndx<wml_obj_reason_ptr->cnt ; ndx++ )
1452     {
1453     resobj = (WmlResourceDefPtr) wml_obj_reason_ptr->hvec[ndx].objptr;
1454     synres = resobj->syndef;
1455     if ( resobj->sym_code == 0 ) continue;
1456     fprintf (outfil, "    \"%s\",\n",
1457              synres->name);
1458     }
1459
1460 /*
1461  * Write entries for enumeration values
1462  */
1463 fprintf (outfil, canned4, max_enumset_code, max_enumval_code);
1464 for ( ndx=0 ; ndx<wml_obj_enumval_ptr->cnt ; ndx++ )
1465     {
1466     evobj = (WmlEnumValueDefPtr) wml_obj_enumval_ptr->hvec[ndx].objptr;
1467     synev = evobj->syndef;
1468     if ( evobj->sym_code == 0 ) continue;
1469     fprintf (outfil, "    \"%s\",\n",
1470              synev->name);
1471     }
1472
1473 /*
1474  * Write entries for character sets
1475  */
1476 fprintf (outfil, canned5, max_charset_code);
1477 for ( ndx=0 ; ndx<wml_obj_charset_ptr->cnt ; ndx++ )
1478     {
1479     csobj = (WmlCharSetDefPtr) wml_obj_charset_ptr->hvec[ndx].objptr;
1480     syncs = csobj->syndef;
1481     if ( csobj->sym_code == 0 ) continue;
1482     fprintf (outfil, "    \"%s\",\n",
1483              syncs->name);
1484     }
1485
1486 /*
1487  * Write entries for children
1488  */
1489 fprintf (outfil, canned6, max_child_code);
1490 for ( ndx=0 ; ndx<wml_obj_child_ptr->cnt ; ndx++ )
1491     {
1492     chobj = (WmlChildDefPtr) wml_obj_child_ptr->hvec[ndx].objptr;
1493     synch = chobj->syndef;
1494     if ( chobj->sym_code == 0 ) continue;
1495     fprintf (outfil, "    \"%s\",\n",
1496              synch->name);
1497     }
1498 fprintf (outfil, canned7);
1499
1500 /*
1501  * close the output file
1502  */
1503 printf ("\nCreated UilSymNam.h");
1504 fclose (outfil);
1505
1506 }
1507
1508
1509 \f
1510 /*
1511  * Routine to write out UilSymEnum.h
1512  *
1513  * This file defines the enumeration sets recognized by UIL. There is an
1514  * entry in this file for each enumeration set. The definitions are accessed
1515  * by the sym_k_..._enumset code. Each consists of a structure containing
1516  * a vector of enumeration value descriptors, each of which is the name
1517  * of the value and its value.
1518  *
1519  * UilSymEnum.h contains:
1520  *      - Vectors of value descriptors for each table entry
1521  *      - The table itself.
1522  *      - A table given the sym_k_..._enumset code for each argument which
1523  *        has an enumeration set.
1524  *      - A table accessed by sym_k_..._enumval code giving the actual value
1525  *        for each enumeration value.
1526  *
1527  * The typedefs for the tables are in UilSymGen.h
1528  */
1529
1530 void wmlOutputUilSymEnum ()
1531
1532 {
1533
1534 char                    *canned1 =
1535 "\n\
1536 /*\n\
1537  * Enumeration value vectors for each enumeration set\n\
1538  */\n\
1539 \n";
1540
1541 char                    *valhdr =
1542 "\n\
1543 static unsigned short int enum_value_vec%d[] =\n\
1544   {\n";
1545
1546 char                    *canned3 =
1547 "\n\
1548 /*\n\
1549  * Enumeration set descriptor table\n\
1550  */\n\
1551 static UilEnumSetDescDef enum_set_table_vec[] =\n\
1552   {\n\
1553     {0,NULL},\n";
1554
1555 char                    *canned4 =
1556 "  };\n\
1557 externaldef(uil_sym_glbl) UilEnumSetDescDef *enum_set_table =\n\
1558 \t\tenum_set_table_vec;\n\
1559 /*\n\
1560  * Enumeration set table, accessed by sym_k_..._arg code. Each non-zero entry\n\
1561  * is the sym_k_..._enumset code for the argument's enumeration set.\n\
1562  */\n\
1563 static unsigned short int argument_enumset_table_vec[] =\n\
1564   {\n\
1565     0,\n";
1566
1567 char                    *canned5 =
1568 "  };\n\
1569 externaldef(uil_sym_glbl) unsigned short int *argument_enumset_table =\n\
1570 \t\targument_enumset_table_vec;\n\
1571 /*\n\
1572  * Enumeration value table, accessed by sym_k_..._enumval code. Each entry is\n\
1573  * the actual value associated with the code.\n\
1574  */\n\
1575 static int enumval_values_table_vec[] =\n\
1576   {\n\
1577   0,\n";
1578
1579 char                    *canned5a =
1580 "  };\n\
1581 externaldef(uil_sym_glbl) int *enumval_values_table =\n\
1582 \t\tenumval_values_table_vec;\n";
1583
1584
1585 FILE                    *outfil;        /* output file */
1586 int                     ndx;            /* loop index */
1587 WmlEnumSetDefPtr        enumsetobj;     /* enumeration set object */
1588 WmlEnumSetValDefPtr     esvobj;         /* current enum set value list element */
1589 WmlEnumValueDefPtr      evobj;          /* current enumeration value object */
1590 WmlResourceDefPtr       resobj;         /* resource object */
1591
1592
1593 /*
1594  * Open the output file. Write the canned header stuff
1595  */
1596 outfil = fopen ("UilSymEnum.h", "w");
1597 if ( outfil == (FILE *) NULL )
1598     {
1599     printf ("\nCouldn't open UilSymEnum.h");
1600     return;
1601     }
1602 fprintf (outfil, canned_warn);
1603
1604 /*
1605  * Generate the enumeration value vectors for each enumeration set.
1606  */
1607 fprintf (outfil, canned1);
1608 for ( ndx=0 ; ndx<wml_obj_enumset_ptr->cnt ; ndx++ )
1609     {
1610     enumsetobj = (WmlEnumSetDefPtr) wml_obj_enumset_ptr->hvec[ndx].objptr;
1611     fprintf (outfil, valhdr, enumsetobj->sym_code);
1612     for ( esvobj=enumsetobj->values ; esvobj!=NULL ; esvobj=esvobj->next )
1613         {
1614         evobj = esvobj->value;
1615         fprintf (outfil, "    %d,\n",
1616                  evobj->sym_code);
1617         }
1618     fprintf (outfil, "  };\n");
1619     }
1620
1621 /*
1622  * Generate the enumeration set tables
1623  */
1624 fprintf (outfil, canned3);
1625 for ( ndx=0 ; ndx<wml_obj_enumset_ptr->cnt ; ndx++ )
1626     {
1627     enumsetobj = (WmlEnumSetDefPtr) wml_obj_enumset_ptr->hvec[ndx].objptr;
1628     fprintf (outfil, "    {%d,enum_value_vec%d},\n",
1629              enumsetobj->values_cnt,
1630              enumsetobj->sym_code);
1631     }
1632
1633 /*
1634  * Create enumset table entries for arguments, similar to writing sym_k...
1635  */
1636 fprintf (outfil, canned4);
1637 for ( ndx=0 ; ndx<wml_obj_arg_ptr->cnt ; ndx++ )
1638     {
1639     resobj = (WmlResourceDefPtr) wml_obj_arg_ptr->hvec[ndx].objptr;
1640     if ( resobj->enumset_def == NULL )
1641         fprintf (outfil, "    0,\n");
1642     else
1643         fprintf (outfil, "    %d,\n",
1644                  resobj->enumset_def->sym_code);
1645     }
1646
1647 /*
1648  * Create the enumval values table.
1649  */
1650 fprintf (outfil, canned5);
1651 for ( ndx=0 ; ndx<wml_obj_enumval_ptr->cnt ; ndx++ )
1652     {
1653     evobj = (WmlEnumValueDefPtr) wml_obj_enumval_ptr->hvec[ndx].objptr;
1654     fprintf (outfil, "  %s,\n", evobj->syndef->enumlit);
1655     }
1656 fprintf (outfil, canned5a);
1657
1658 /*
1659  * close the output file
1660  */
1661 printf ("\nCreated UilSymEnum.h");
1662 fclose (outfil);
1663
1664 }
1665
1666
1667 \f
1668 /*
1669  * Routine to write out UilSymCSet.h
1670  *
1671  * This file specifies the various attributes for the character sets
1672  * recognized by UIL. There is a table for each of the following
1673  * attributes:
1674  *      - Standards name associated with the character set
1675  *      - Writing direction, from XmSTRING_DIRECTION_...
1676  *      - Parsing direction, from XmSTRING_DIRECTION_...
1677  *      - Bytes per character, from sym_k_..._charsize (in UilSymGen.h)
1678  *      - A pair of tables for recognizing $LANG settings:
1679  *              o a table of all names under which a character set might
1680  *                be legally recognized (upper case).
1681  *              o the sym_k_..._charset code for each entry
1682  *              o a variable giving the number of entries in the table
1683  *
1684  * All tables are accessed by the sym_k_..._charset 
1685  *
1686  */
1687
1688 void wmlOutputUilSymCSet ()
1689
1690 {
1691
1692 char                    *canned1 =
1693 "\n\
1694 /*\n\
1695  * Character set XmString name table, accessed by sym_k_..._charset code.\n\
1696  * Each entry is the name which identifies the character set in a XmString.\n\
1697  */\n\
1698 static char *charset_xmstring_names_table_vec[] =\n\
1699   {\n\
1700     0,\n\
1701     \"<userdefined>\",\n";
1702
1703 char                    *canned2 =
1704 "};\n\
1705 externaldef(uil_sym_glbl) char **charset_xmstring_names_table =\n\
1706 \t\tcharset_xmstring_names_table_vec;\n\
1707 /*\n\
1708  * Character set writing direction table, accessed by sym_k_..._charset code.\n\
1709  * Each entry is the XmSTRING_DIRECTION_... code which identifies the\n\
1710  * writing direction for the character set in a XmString.\n\
1711  */\n\
1712 static unsigned char charset_wrdirection_table_vec[] =\n\
1713   {\n\
1714     0,\n\
1715     0,\t/* userdefined */\n";
1716
1717 char                    *canned3 =
1718 "};\n\
1719 externaldef(uil_sym_glbl) unsigned char *charset_writing_direction_table =\n\
1720 \t\tcharset_wrdirection_table_vec;\n\
1721 /*\n\
1722  * Character set parsing direction table, accessed by sym_k_..._charset code.\n\
1723  * Each entry is the XmSTRING_DIRECTION_... code which identifies the\n\
1724  * parsing direction for the character set in a XmString.\n\
1725  */\n\
1726 static unsigned char charset_parsdirection_table_vec[] =\n\
1727   {\n\
1728     0,\n\
1729     0,\t/* userdefined */\n";
1730
1731 char                    *canned4 =
1732 "};\n\
1733 externaldef(uil_sym_glbl) unsigned char *charset_parsing_direction_table =\n\
1734 \t\tcharset_parsdirection_table_vec;\n\
1735 /*\n\
1736  * Character set character size table, accessed by sym_k_..._charset code.\n\
1737  * Each entry is the sym_k_..._charsize literal which names the character\n\
1738  * size for the character set in a XmString.\n\
1739  */\n\
1740 static unsigned char charset_charsize_table_vec[] =\n\
1741   {\n\
1742     0,\n\
1743     0,\t/* userdefined */\n";
1744
1745 char                    *canned5 =
1746 "};\n\
1747 externaldef(uil_sym_glbl) unsigned char *charset_character_size_table =\n\
1748 \t\tcharset_charsize_table_vec;\n\
1749 /*\n\
1750  * All the names under which a character set may be legally named in a \n\
1751  * $LANG variable (upper case).\n\
1752  */\n\
1753 static char *charset_lang_names_table_vec[] =\n\
1754   {\n";
1755
1756 char                    *canned6 =
1757 "};\n\
1758 externaldef(uil_sym_glbl) char **charset_lang_names_table =\n\
1759 \t\tcharset_lang_names_table_vec;\n\
1760 /*\n\
1761  * The sym_k_..._charset codes for charset_lang_names\n\
1762  */\n\
1763 static unsigned short int charset_lang_codes_table_vec[] =\n\
1764   {\n";
1765
1766 char                    *canned7 =
1767 "};\n\
1768 externaldef(uil_sym_glbl) unsigned short int *charset_lang_codes_table =\n\
1769 \t\tcharset_lang_codes_table_vec;\n\
1770 /*\n\
1771  * The number of entries in charset_lang_..._table tables\n\
1772  */\n\
1773 externaldef(uil_sym_glbl) unsigned short int charset_lang_table_max = %d;\n";
1774
1775
1776 FILE                    *outfil;        /* output file */
1777 int                     ndx;            /* loop index */
1778 WmlCharSetDefPtr        csobj;          /* character set object */
1779 WmlSynCharSetDefPtr     syncs;          /* character set syntactic obj */
1780 int                     lang_max;       /* max value for $LANG tables */
1781 int                     alias_ndx;      /* alias loop index */
1782 char                    uname[200];     /* name converted to upper case */
1783
1784
1785 /*
1786  * Open the output file. Write the canned header stuff
1787  */
1788 outfil = fopen ("UilSymCSet.h", "w");
1789 if ( outfil == (FILE *) NULL )
1790     {
1791     printf ("\nCouldn't open UilSymCSet.h");
1792     return;
1793     }
1794 fprintf (outfil, canned_warn);
1795
1796 /*
1797  * Generate the standards name table
1798  */
1799 fprintf (outfil, canned1);
1800 for ( ndx=0 ; ndx<wml_obj_charset_ptr->cnt ; ndx++ )
1801     {
1802     csobj = (WmlCharSetDefPtr) wml_obj_charset_ptr->hvec[ndx].objptr;
1803     syncs = csobj->syndef;
1804     if ( csobj->sym_code == 0 ) continue;
1805     if ((strcmp(syncs->xms_name, "XmFONTLIST_DEFAULT_TAG") == 0) ||
1806         (strcmp(syncs->xms_name, "_MOTIF_DEFAULT_LOCALE") == 0))
1807       fprintf (outfil, "    %s,\t/* %s */\n",
1808                syncs->xms_name, syncs->name);
1809     else
1810       fprintf (outfil, "    \"%s\",\t/* %s */\n",
1811                syncs->xms_name, syncs->name);
1812     }
1813
1814 /*
1815  * Generate the writing direction table
1816  */
1817 fprintf (outfil, canned2);
1818 for ( ndx=0 ; ndx<wml_obj_charset_ptr->cnt ; ndx++ )
1819     {
1820     csobj = (WmlCharSetDefPtr) wml_obj_charset_ptr->hvec[ndx].objptr;
1821     syncs = csobj->syndef;
1822     if ( csobj->sym_code == 0 ) continue;
1823     switch ( syncs->direction )
1824         {
1825         case WmlCharSetDirectionLtoR:
1826             fprintf (outfil, "    XmSTRING_DIRECTION_L_TO_R,\t/* %s */\n",
1827                      syncs->name);
1828             break;
1829         case WmlCharSetDirectionRtoL:
1830             fprintf (outfil, "    XmSTRING_DIRECTION_R_TO_L,\t/* %s */\n",
1831                      syncs->name);
1832             break;
1833         }
1834     }
1835
1836 /*
1837  * Generate the parsing direction table
1838  */
1839 fprintf (outfil, canned3);
1840 for ( ndx=0 ; ndx<wml_obj_charset_ptr->cnt ; ndx++ )
1841     {
1842     csobj = (WmlCharSetDefPtr) wml_obj_charset_ptr->hvec[ndx].objptr;
1843     syncs = csobj->syndef;
1844     if ( csobj->sym_code == 0 ) continue;
1845     switch ( syncs->parsedirection )
1846         {
1847         case WmlCharSetDirectionLtoR:
1848             fprintf (outfil, "    XmSTRING_DIRECTION_L_TO_R,\t/* %s */\n",
1849                      syncs->name);
1850             break;
1851         case WmlCharSetDirectionRtoL:
1852             fprintf (outfil, "    XmSTRING_DIRECTION_R_TO_L,\t/* %s */\n",
1853                      syncs->name);
1854             break;
1855         }
1856     }
1857
1858 /*
1859  * Generate the character size table
1860  */
1861 fprintf (outfil, canned4);
1862 for ( ndx=0 ; ndx<wml_obj_charset_ptr->cnt ; ndx++ )
1863     {
1864     csobj = (WmlCharSetDefPtr) wml_obj_charset_ptr->hvec[ndx].objptr;
1865     syncs = csobj->syndef;
1866     if ( csobj->sym_code == 0 ) continue;
1867     switch ( syncs->charsize )
1868         {
1869         case WmlCharSizeOneByte:
1870             fprintf (outfil, "    sym_k_onebyte_charsize,\t/* %s */\n",
1871                      syncs->name);
1872             break;
1873         case WmlCharSizeTwoByte:
1874             fprintf (outfil, "    sym_k_twobyte_charsize,\t/* %s */\n",
1875                      syncs->name);
1876             break;
1877         case WmlCharSizeMixed1_2Byte:
1878             fprintf (outfil, "    sym_k_mixed1_2byte_charsize,\t/* %s */\n",
1879                      syncs->name);
1880             break;
1881         }
1882     }
1883
1884 /*
1885  * Generate the $LANG name recognition table
1886  */
1887 fprintf (outfil, canned5);
1888 lang_max = 0;
1889 for ( ndx=0 ; ndx<wml_obj_charset_ptr->cnt ; ndx++ )
1890     {
1891     csobj = (WmlCharSetDefPtr) wml_obj_charset_ptr->hvec[ndx].objptr;
1892     syncs = csobj->syndef;
1893     if ( csobj->sym_code == 0 ) continue;
1894     strcpy (uname, syncs->name);
1895     wmlUpperCaseString (uname);
1896     fprintf (outfil, "    \"%s\",\t/* %s */\n",
1897              uname, syncs->name);
1898     lang_max += 1;
1899     strcpy (uname, syncs->xms_name);
1900     wmlUpperCaseString (uname);
1901     fprintf (outfil, "    \"%s\",\t/* %s */\n",
1902              uname, syncs->name);
1903     lang_max += 1;
1904     for ( alias_ndx=0 ; alias_ndx<syncs->alias_cnt ; alias_ndx++ )
1905         {
1906         strcpy (uname, syncs->alias_list[alias_ndx]);
1907         wmlUpperCaseString (uname);
1908         fprintf (outfil, "    \"%s\",\t/* %s */\n",
1909                  uname, syncs->name);
1910         lang_max += 1;
1911         }
1912     }
1913
1914 /*
1915  * Generate the $LANG code lookup table, in upper case
1916  */
1917 fprintf (outfil, canned6);
1918 for ( ndx=0 ; ndx<wml_obj_charset_ptr->cnt ; ndx++ )
1919     {
1920     csobj = (WmlCharSetDefPtr) wml_obj_charset_ptr->hvec[ndx].objptr;
1921     syncs = csobj->syndef;
1922     if ( csobj->sym_code == 0 ) continue;
1923     fprintf (outfil, "    sym_k_%s_charset,\n", syncs->name);
1924     fprintf (outfil, "    sym_k_%s_charset,\n", syncs->name);
1925     for ( alias_ndx=0 ; alias_ndx<syncs->alias_cnt ; alias_ndx++ )
1926         fprintf (outfil, "    sym_k_%s_charset,\n", syncs->name);
1927     }
1928
1929 /*
1930  * Generate the number of entries in the previous two tables
1931  */
1932 fprintf (outfil, canned7, lang_max);
1933
1934 /*
1935  * close the output file
1936  */
1937 printf ("\nCreated UilSymCSet.h");
1938 fclose (outfil);
1939
1940 }
1941
1942