2 * This file is part of duit.
4 * duit is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * duit is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with duit; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 module utils
.convparms
;
23 public struct ConvParms
26 private import utils
.DuitClass
;
27 private import std
.stdio
;
30 public char[] outPack
;
31 public char[] outFile
;
33 public char[] realStrct
;
34 public char[] ctorStrct
; /// the ToolItem derivates all retrun GtkToolItem
37 public char[][] templ
;
40 public char[][] prefixes
;
41 public bit strictPrefix
; /// include only function that match the prefix
42 public char[][] imprts
;
43 public char[][char[]] structWrap
;
44 public char[][] noStructs
;
45 public char[][] noPrefixes
;
46 public char[][] noCode
; /// insert the external declaration but not the wrapping code
47 public char[][char[]] aliases
;
48 public char[] classCode
; /// any valid D code to be copied to the final Duit class
49 public char[] interfaceCode
; /// any valid D code to be copied to the final Duit interface
50 public char[][] text
; /// text to be added to the text read from the file
52 public void clearAll()
54 char[][char[]] clear(){char[][char[]] cc
;return cc
;};
71 noPrefixes
.length
= 0;
76 interfaceCode
.length
= 0;
81 public char[] toString()
85 text
~= "\n * Conversion parameters:";
86 text
~= "\n * inFile = "~inFile
;
87 text
~= "\n * outPack = "~outPack
;
88 text
~= "\n * outFile = "~outFile
;
89 text
~= "\n * strct = "~strct
;
90 text
~= "\n * realStrct="~realStrct
;
91 text
~= "\n * ctorStrct="~ctorStrct
;
92 text
~= "\n * clss = "~clss
;
93 text
~= "\n * interf = "~interf
;
94 text
~= "\n * class Code: " ~ (classCode
.length
>0 ?
"Yes" : "No");
95 text
~= "\n * interface Code: " ~ (interfaceCode
.length
>0 ?
"Yes" : "No");
96 text
~= "\n * template for:";
97 foreach ( char[] tp
; templ
)
99 text
~= "\n * \t- "~tp
;
102 text
~= "\n * extend = "~extend
;
104 text
~= "\n * implements:";
105 foreach ( char[] ip
; impl
)
107 text
~= "\n * \t- "~ip
;
110 text
~= "\n * prefixes:";
111 foreach ( char[] prefix
; prefixes
)
113 text
~= "\n * \t- "~prefix
;
116 text
~= "\n * omit structs:";
117 foreach ( char[] noStruct
; noStructs
)
119 text
~= "\n * \t- "~noStruct
;
122 text
~= "\n * omit prefixes:";
123 foreach ( char[] noPrefix
; noPrefixes
)
125 text
~= "\n * \t- "~noPrefix
;
128 text
~= "\n * omit code:";
129 foreach ( char[] ncode
; noCode
)
131 text
~= "\n * \t- "~ncode
;
134 text
~= "\n * imports:";
135 foreach ( char[] imp
; imprts
)
137 text
~= "\n * \t- "~imp
;
140 text
~= "\n * structWrap:";
141 foreach ( char[] key
; structWrap
.keys
.sort
)
143 text
~= "\n * \t- "~key
~" -> "~structWrap
[key
];
146 text
~= "\n * local aliases:";
147 foreach ( char[] key
; aliases
.keys
.sort
)
149 text
~= "\n * \t- "~key
~" -> "~aliases
[key
];
157 public void appendAsComment(inout char[] text
)
162 public bit
containsPrefix(char[] prefix
)
164 bit contains
= false;
166 while ( !contains
&& i
<prefixes
.length
)
168 contains
= DuitClass
.startsWith(prefix
, prefixes
[i
]);
174 public char[] getPrefix(char[] prefix
)
177 bit contains
= false;
179 while ( !contains
&& i
<prefixes
.length
)
181 if ( DuitClass
.startsWith(prefix
, prefixes
[i
]) )
184 fundPrefix
= prefixes
[i
];
191 public bit
omitCode(char[] codeName
)
195 while ( !omit
&& i
<noCode
.length
)
197 omit
= codeName
== noCode
[i
];
198 debug(omitCode
)writefln("\t (%s) %s ?= %s", omit
, codeName
, noCode
[i
]);
201 debug(omitCode
)writefln("\t (%s) %s %s", i
, (omit?
"omited >>>>>>>":"included <<<<<"), codeName
);