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