Accept "in" instance variables
[delight/core.git] / dmd / hdrgen.c
bloba00c9680317f0282c3ed06f21cd64986de1922ce
2 // Compiler implementation of the D programming language
3 // Copyright (c) 1999-2006 by Digital Mars
4 // All Rights Reserved
5 // Initial header generation implementation by Dave Fladebo
6 // http://www.digitalmars.com
7 // License for redistribution is by either the Artistic License
8 // in artistic.txt, or the GNU General Public License in gnu.txt.
9 // See the included readme.txt for details.
11 // Routines to emit header files
13 #ifdef _DH
15 #define PRETTY_PRINT
16 #define TEST_EMIT_ALL 0 // For Testing
18 #define LOG 0
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <assert.h>
23 #if __DMC__
24 #include <complex.h>
25 #endif
27 #ifdef IN_GCC
28 #include "mem.h"
29 #else
30 #if _WIN32
31 #include "..\root\mem.h"
32 #elif linux
33 #include "../root/mem.h"
34 #else
35 #error "fix this"
36 #endif
37 #endif
39 #include "id.h"
40 #include "init.h"
42 #include "attrib.h"
43 #include "cond.h"
44 #include "enum.h"
45 #include "import.h"
46 #include "module.h"
47 #include "mtype.h"
48 #include "scope.h"
49 #include "staticassert.h"
50 #include "template.h"
51 #include "utf.h"
52 #include "version.h"
54 #include "declaration.h"
55 #include "aggregate.h"
56 #include "expression.h"
57 #include "statement.h"
58 #include "mtype.h"
59 #include "hdrgen.h"
61 void argsToCBuffer(OutBuffer *buf, Array *arguments, HdrGenState *hgs);
63 void Module::genhdrfile()
65 OutBuffer hdrbufr;
67 hdrbufr.printf("// D import file generated from '%s'", srcfile->toChars());
68 hdrbufr.writenl();
70 HdrGenState hgs;
71 memset(&hgs, 0, sizeof(hgs));
72 hgs.hdrgen = 1;
74 toCBuffer(&hdrbufr, &hgs);
76 // Transfer image to file
77 hdrfile->setbuffer(hdrbufr.data, hdrbufr.offset);
78 hdrbufr.data = NULL;
80 char *pt = FileName::path(hdrfile->toChars());
81 if (*pt)
82 FileName::ensurePathExists(pt);
83 mem.free(pt);
84 hdrfile->writev();
88 void Module::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
90 if (md)
92 buf->writestring("module ");
93 buf->writestring(md->toChars());
94 buf->writebyte(';');
95 buf->writenl();
98 for (int i = 0; i < members->dim; i++)
99 { Dsymbol *s = (Dsymbol *)members->data[i];
101 s->toHBuffer(buf, hgs);
106 void Dsymbol::toHBuffer(OutBuffer *buf, HdrGenState *hgs)
108 toCBuffer(buf, hgs);
112 /*************************************/
114 #endif // #ifdef _DH