/* %Z%%M% %I% %E% */ /* * Copyright (c) 1990, 1991, 1993, 1994, 1995 by Wayne C. Gramlich. * All rights reserved. * * Permission to use, copy, modify, distribute, and sell this software * for any purpose is hereby granted without fee provided that the above * copyright notice and this permission are retained. The author makes * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. */ /* This file contains code generation routines: */ #ifndef GEN_DEFS_H #include "gen_defs.h" #endif #ifndef OUT_EXPORTS_H #include "out_exports.h" #endif #ifndef UNIX_CTYPE_H #include "unix_ctype.h" #endif #ifndef UNIX_STDARG_H #include "unix_stdarg.h" #endif #ifndef VECTOR_DEFS_H #include "vector_defs.h" #endif /* * gen_comment(gen, comment) * This routine will print "comment" to "gen" (provided that "comment" * is not equal to (Str)0. If "prefix" is 1, the comment will be * preceeded by a tab; otherwise it won't. */ void gen_comment( Gen gen, Str comment, int prefix) { if (comment == (Str)0) { gen_out(gen, "\n"); } else { if (prefix) { gen_out(gen, "\t"); } gen_out(gen, "/* %s */\n", comment + 1); } } /* * gen_comments(gen, comments, prefix) * This routine will print "comments" to "gen". If "prefix" is 1, * the comment will be preceeded by a tab; otherwise it won't. */ void gen_comments( Gen gen, Vec(Str) comments, int prefix) { Str comment; VEC_LOOP(Str, comments, comment) { if (comment != (Str)0) { gen_comment(gen, comment, prefix); } } } /* * gen_indented_list(gen, list, routine, indent) * This routine will print each item in "list" to "gen" using * "routine(item, gen, indent)". */ void gen_indented_list( Gen gen, Vec(Pointer) list, Gen_routine routine, int indent) { Pointer item; VEC_LOOP(Pointer, list, item) { (*routine)(item, gen, indent); } } /* * gen_out(gen, format, arg1, ..., argN) * This routine will print "arg1" through "argN" to "gen"->out_file * using "format". See out_format() for more details. */ void gen_out( Gen gen, Str format, ...) { va_list args; Stdio out_file; va_start(args, format); out_file = gen->out_file; out_format(out_file, format, args); va_end(args); }