2 * This file is part of gtkD.
4 * gtkD 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 * gtkD 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 gtkD; 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
.GtkDClass
;
27 private import std
.stdio
;
30 public char[] outPack
;
31 public char[] bindDir
;
32 public char[] outFile
;
34 public char[] realStrct
;
35 public char[] ctorStrct
; /// the ToolItem derivates all retrun GtkToolItem
38 public char[][] templ
;
41 public char[][] prefixes
;
42 public bool strictPrefix
; /// include only function that match the prefix
43 public char[][] imprts
;
44 public char[][char[]] structWrap
;
45 public char[][] noStructs
;
46 public char[][] noPrefixes
;
47 public char[][] noCode
; /// insert the external declaration but not the wrapping code
48 public char[][char[]] aliases
;
49 public char[][char[]] mAliases
;
50 public char[] classCode
; /// any valid D code to be copied to the final GtkD class
51 public char[] interfaceCode
; /// any valid D code to be copied to the final GtkD interface
52 public char[][] text
; /// text to be added to the text read from the file
54 public void clearAll()
56 char[][char[]] clear(){char[][char[]] cc
;return cc
;};
74 noPrefixes
.length
= 0;
80 interfaceCode
.length
= 0;
85 public char[] toString()
89 text
~= "\n * Conversion parameters:";
90 text
~= "\n * inFile = "~inFile
;
91 text
~= "\n * outPack = "~outPack
;
92 text
~= "\n * outFile = "~outFile
;
93 text
~= "\n * strct = "~strct
;
94 text
~= "\n * realStrct="~realStrct
;
95 text
~= "\n * ctorStrct="~ctorStrct
;
96 text
~= "\n * clss = "~clss
;
97 text
~= "\n * interf = "~interf
;
98 text
~= "\n * class Code: " ~ (classCode
.length
>0 ?
"Yes" : "No");
99 text
~= "\n * interface Code: " ~ (interfaceCode
.length
>0 ?
"Yes" : "No");
100 text
~= "\n * template for:";
101 foreach ( char[] tp
; templ
)
103 text
~= "\n * \t- "~tp
;
106 text
~= "\n * extend = "~extend
;
108 text
~= "\n * implements:";
109 foreach ( char[] ip
; impl
)
111 text
~= "\n * \t- "~ip
;
114 text
~= "\n * prefixes:";
115 foreach ( char[] prefix
; prefixes
)
117 text
~= "\n * \t- "~prefix
;
120 text
~= "\n * omit structs:";
121 foreach ( char[] noStruct
; noStructs
)
123 text
~= "\n * \t- "~noStruct
;
126 text
~= "\n * omit prefixes:";
127 foreach ( char[] noPrefix
; noPrefixes
)
129 text
~= "\n * \t- "~noPrefix
;
132 text
~= "\n * omit code:";
133 foreach ( char[] ncode
; noCode
)
135 text
~= "\n * \t- "~ncode
;
138 text
~= "\n * imports:";
139 foreach ( char[] imp
; imprts
)
141 text
~= "\n * \t- "~imp
;
144 text
~= "\n * structWrap:";
145 foreach ( char[] key
; structWrap
.keys
.sort
)
147 text
~= "\n * \t- "~key
~" -> "~structWrap
[key
];
150 text
~= "\n * module aliases:";
151 foreach ( char[] key
; mAliases
.keys
.sort
)
153 text
~= "\n * \t- "~key
~" -> "~mAliases
[key
];
155 text
~= "\n * local aliases:";
156 foreach ( char[] key
; aliases
.keys
.sort
)
158 text
~= "\n * \t- "~key
~" -> "~aliases
[key
];
166 public void appendAsComment(inout char[] text
)
171 public bool containsPrefix(char[] prefix
)
173 bool contains
= false;
175 while ( !contains
&& i
<prefixes
.length
)
177 contains
= GtkDClass
.startsWith(prefix
, prefixes
[i
]);
183 public char[] getPrefix(char[] prefix
)
186 bool contains
= false;
188 while ( !contains
&& i
<prefixes
.length
)
190 if ( GtkDClass
.startsWith(prefix
, prefixes
[i
]) )
193 fundPrefix
= prefixes
[i
];
200 public bool omitCode(char[] codeName
)
204 while ( !omit
&& i
<noCode
.length
)
206 omit
= codeName
== noCode
[i
];
207 debug(omitCode
)writefln("\t (%s) %s ?= %s", omit
, codeName
, noCode
[i
]);
210 debug(omitCode
)writefln("\t (%s) %s %s", i
, (omit?
"omited >>>>>>>":"included <<<<<"), codeName
);