Mercurial > projects > ldc
annotate dmd/hdrgen.c @ 828:03b0c817a1a3
added install target and possibility to pre- and suffix ldc's executable name to cmake scripts
author | elrood |
---|---|
date | Thu, 04 Dec 2008 22:09:24 +0100 |
parents | cbd6c8073a32 |
children | b30fe7e1dbb9 |
rev | line source |
---|---|
1 | 1 |
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. | |
10 | |
11 // Routines to emit header files | |
12 | |
13 #ifdef _DH | |
14 | |
15 #define PRETTY_PRINT | |
16 #define TEST_EMIT_ALL 0 // For Testing | |
17 | |
18 #define LOG 0 | |
19 | |
20 #include <stdio.h> | |
21 #include <stdlib.h> | |
22 #include <assert.h> | |
23 #if __DMC__ | |
24 #include <complex.h> | |
25 #endif | |
26 | |
27 #if IN_GCC || IN_LLVM | |
28 #include "mem.h" | |
29 #else | |
30 #if _WIN32 | |
31 #include "..\root\mem.h" | |
571
cbd6c8073a32
Changed all '#if linux || __APPLE__' to '#if POSIX' so we can support other platforms too, thanx for the suggestion anders.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
535
diff
changeset
|
32 #elif POSIX |
1 | 33 #include "../root/mem.h" |
34 #else | |
35 #error "fix this" | |
36 #endif | |
37 #endif | |
38 | |
39 #include "id.h" | |
40 #include "init.h" | |
41 | |
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" | |
53 | |
54 #include "declaration.h" | |
55 #include "aggregate.h" | |
56 #include "expression.h" | |
57 #include "statement.h" | |
58 #include "mtype.h" | |
59 #include "hdrgen.h" | |
60 | |
61 void argsToCBuffer(OutBuffer *buf, Array *arguments, HdrGenState *hgs); | |
62 | |
63 void Module::genhdrfile() | |
64 { | |
65 OutBuffer hdrbufr; | |
66 | |
67 hdrbufr.printf("// D import file generated from '%s'", srcfile->toChars()); | |
68 hdrbufr.writenl(); | |
69 | |
70 HdrGenState hgs; | |
71 memset(&hgs, 0, sizeof(hgs)); | |
72 hgs.hdrgen = 1; | |
73 | |
74 toCBuffer(&hdrbufr, &hgs); | |
75 | |
76 // Transfer image to file | |
77 hdrfile->setbuffer(hdrbufr.data, hdrbufr.offset); | |
78 hdrbufr.data = NULL; | |
79 | |
80 char *pt = FileName::path(hdrfile->toChars()); | |
81 if (*pt) | |
82 FileName::ensurePathExists(pt); | |
83 mem.free(pt); | |
84 hdrfile->writev(); | |
85 } | |
86 | |
87 | |
88 void Module::toCBuffer(OutBuffer *buf, HdrGenState *hgs) | |
89 { | |
90 if (md) | |
91 { | |
92 buf->writestring("module "); | |
93 buf->writestring(md->toChars()); | |
94 buf->writebyte(';'); | |
95 buf->writenl(); | |
96 } | |
97 | |
98 for (int i = 0; i < members->dim; i++) | |
99 { Dsymbol *s = (Dsymbol *)members->data[i]; | |
100 | |
101 s->toHBuffer(buf, hgs); | |
102 } | |
103 } | |
104 | |
105 | |
106 void Dsymbol::toHBuffer(OutBuffer *buf, HdrGenState *hgs) | |
107 { | |
108 toCBuffer(buf, hgs); | |
109 } | |
110 | |
111 | |
112 /*************************************/ | |
113 | |
114 #endif // #ifdef _DH |