Back to index

plt-scheme  4.2.1
declarefunc.c
Go to the documentation of this file.
00001 /*   wbuild
00002      Copyright (C) 1996  Joel N. Weber II <nemo@koa.iolani.honolulu.hi.us>
00003      
00004      This program is free software; you can redistribute it and/or
00005      modify it under the terms of the GNU General Public License
00006      as published by the Free Software Foundation; either version 2
00007      of the License, or (at your option) any later version.
00008      
00009      This program is distributed in the hope that it will be useful,
00010      but WITHOUT ANY WARRANTY; without even the implied warranty of
00011      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012      GNU General Public License for more details.
00013      
00014      You should have received a copy of the GNU General Public License
00015      along with this program; if not, write to the Free Software
00016      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017  */
00018 
00019 #define fputS(s, f) fputs(get(s), f)
00020 
00021 #include <config.h>
00022 #include <stdio.h>
00023 
00024 #include <libit/unistd.h>
00025 
00026 #include <libit/string.h>
00027 
00028 #include <libit/ctype.h>
00029 #include <wbuild.h>
00030 #include <wsym.h>
00031 
00032 #include <libintl.h>
00033 #define _(String) gettext(String)
00034 
00035 #include <libit/malloc.h>
00036 
00037 /* |declare_function| creates a prototype for a function |d|. If
00038  * |export| is |False|, the prototype will be preceded by
00039  * |"static"|.\mkref{declare-function}
00040  */
00041 
00042 void declare_function(int export, STRING name, Decl d, FILE *f)
00043 {
00044        Decl d1;
00045 
00046        if (!export)
00047               fputs("static ", f);
00048 
00049        if (d->type)
00050               fputS(d->type, f);
00051        else
00052               fputs("void", f);
00053 
00054        putc(' ', f);
00055        fputS(name, f);
00056        fputs("(\n#if NeedFunctionPrototypes\n", f);
00057        if (!d->params) {
00058               fputs("void", f);
00059        } else {
00060               for (d1 = d->params; d1; d1 = d1->next) {
00061                      if (d1->name == DOLLAR)
00062                             fputs("Widget", f);
00063                      else
00064                             fputS(d1->type, f);
00065                      if (d1->suffix)
00066                             fprintf(f, " %s%s", get(d1->name),
00067                                    get(d1->suffix));
00068                      if (d1->next) (void) putc(',', f);
00069               }
00070        }
00071        fputs("\n#endif\n);\n", f);
00072 }