Mercurial > projects > mde
annotate mde/file/mergetag/DefaultData.d @ 88:01f4f5f1acc9
Changes to init and to allow compiling with gdc.
Tweaked init code to allow using circular iterators (disabled until my patch makes it into tango).
Changes to allow compiling with gdc. Building is successful and unittests complete, but in my experience a SIGSEGV occurs within SDL.
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Mon, 29 Sep 2008 12:09:44 +0100 |
parents | d8fccaa45d5f |
children |
rev | line source |
---|---|
17
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
14
diff
changeset
|
1 /* LICENSE BLOCK |
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
14
diff
changeset
|
2 Part of mde: a Modular D game-oriented Engine |
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
14
diff
changeset
|
3 Copyright © 2007-2008 Diggory Hardy |
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
14
diff
changeset
|
4 |
26
611f7b9063c6
Changed the licensing and removed a few dead files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
17
diff
changeset
|
5 This program is free software: you can redistribute it and/or modify it under the terms |
611f7b9063c6
Changed the licensing and removed a few dead files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
17
diff
changeset
|
6 of the GNU General Public License as published by the Free Software Foundation, either |
611f7b9063c6
Changed the licensing and removed a few dead files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
17
diff
changeset
|
7 version 2 of the License, or (at your option) any later version. |
17
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
14
diff
changeset
|
8 |
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
14
diff
changeset
|
9 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
14
diff
changeset
|
10 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
14
diff
changeset
|
11 See the GNU General Public License for more details. |
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
14
diff
changeset
|
12 |
26
611f7b9063c6
Changed the licensing and removed a few dead files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
17
diff
changeset
|
13 You should have received a copy of the GNU General Public License |
611f7b9063c6
Changed the licensing and removed a few dead files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
17
diff
changeset
|
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
17
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
14
diff
changeset
|
15 |
14
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
16 /** This module contains the DefaultData class, and some notes possibly useful for implementing |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
17 * other types of DataSection. |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
18 */ |
81
d8fccaa45d5f
Moved file IO code from mde/mergetag to mde/file[/mergetag] and changed how some errors are caught.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
79
diff
changeset
|
19 module mde.file.mergetag.DefaultData; |
14
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
20 |
81
d8fccaa45d5f
Moved file IO code from mde/mergetag to mde/file[/mergetag] and changed how some errors are caught.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
79
diff
changeset
|
21 public import mde.file.mergetag.iface.IDataSection; |
d8fccaa45d5f
Moved file IO code from mde/mergetag to mde/file[/mergetag] and changed how some errors are caught.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
79
diff
changeset
|
22 import mde.file.serialize; |
14
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
23 |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
24 |
75
25cb7420dc91
A massive overhaul/rewrite for the gui's data management and setup code. Currently much that was working is broken.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
74
diff
changeset
|
25 /************************************************************************************************* |
25cb7420dc91
A massive overhaul/rewrite for the gui's data management and setup code. Currently much that was working is broken.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
74
diff
changeset
|
26 * Default DataSection class. |
25cb7420dc91
A massive overhaul/rewrite for the gui's data management and setup code. Currently much that was working is broken.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
74
diff
changeset
|
27 * |
79
61ea26abe4dd
Moved mde/mergetag/parse/parse(To/From) to mde/mergetag/(de)serialize. Implemented (de)serialization of structs.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
75
diff
changeset
|
28 * Supported types are given by dataTypes. |
61ea26abe4dd
Moved mde/mergetag/parse/parse(To/From) to mde/mergetag/(de)serialize. Implemented (de)serialization of structs.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
75
diff
changeset
|
29 * |
61ea26abe4dd
Moved mde/mergetag/parse/parse(To/From) to mde/mergetag/(de)serialize. Implemented (de)serialization of structs.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
75
diff
changeset
|
30 * Currently DefaultData is only used for headers, and thus the list of supported types has been |
75
25cb7420dc91
A massive overhaul/rewrite for the gui's data management and setup code. Currently much that was working is broken.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
74
diff
changeset
|
31 * reduced to just those used in headers. Load order is HIGH_LOW, i.e. existing entries aren't |
25cb7420dc91
A massive overhaul/rewrite for the gui's data management and setup code. Currently much that was working is broken.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
74
diff
changeset
|
32 * overwritten. |
25cb7420dc91
A massive overhaul/rewrite for the gui's data management and setup code. Currently much that was working is broken.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
74
diff
changeset
|
33 *************************************************************************************************/ |
14
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
34 /* The implementation now uses a fair bit of generic programming. Adjusting the types supported |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
35 * should be as simple as adjusting the list dataTypes, and possibly implemting new conversions in |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
36 * parseFrom and parseTo if you add new types (e.g. for cent or imaginary/complex types, or user types). |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
37 * |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
38 * There shouldn't really be any need to adjust the implementation, except perhaps to add new |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
39 * functions to the class (such as another type of output where the delegate used in writeAll isn't |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
40 * enough). |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
41 */ |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
42 class DefaultData : IDataSection |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
43 { |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
44 //BEGIN META |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
45 /* These functions are used to generate code. Compile-time functions rather than templates are |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
46 * used because they are easier to write and understand. Mixins are used to compile the resultant |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
47 * code. Must be declared before used since forward references aren't supported for compile-time |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
48 * functions. */ |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
49 |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
50 // Generate the correct name for each variable type. |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
51 static char[] varName (char[] type) { |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
52 char[] append = ""; |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
53 while (type.length >= 2 && type[$-2..$] == "[]") { |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
54 type = type[0..$-2]; |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
55 append ~= "A"; |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
56 } |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
57 return "_" ~ type ~ append; |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
58 } |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
59 |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
60 // Int-to-string converter, which may not be efficient but will run at compile time. |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
61 static char[] int2str (uint i) { |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
62 char[] ret; |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
63 const digits = "0123456789"; |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
64 if (i == 0) ret = "0"; |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
65 else for (; i > 0; i /= 10) ret = digits[i%10] ~ ret; |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
66 return ret; |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
67 } |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
68 |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
69 // Generate the code for variable declarations. |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
70 static char[] declerations (char[][] types) { |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
71 char[] ret = ""; |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
72 foreach (char[] type; types) ret ~= type ~ "[ID]\t" ~ varName(type) ~ ";\n"; |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
73 return ret; |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
74 } |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
75 |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
76 // Purely to add indentation. Could just return "" without affecting functionality. |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
77 static char[] indent (uint i) { |
75
25cb7420dc91
A massive overhaul/rewrite for the gui's data management and setup code. Currently much that was working is broken.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
74
diff
changeset
|
78 char[] ret = ""; |
14
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
79 for (; i > 0; --i) ret ~= " "; |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
80 // This is not executable at compile time: |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
81 //ret.length = i * 4; // number of characters for each indentation |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
82 //ret[] = ' '; // character to indent with |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
83 return ret; |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
84 } |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
85 |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
86 /* Generates a binary search algorithm. |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
87 * |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
88 * Currently this is tailored to it's particular use (addTag). */ |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
89 static char[] binarySearch (char[] var, char[][] consts, int indents = 0) { |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
90 if (consts.length > 3) { |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
91 return indent(indents) ~ "if (" ~ var ~ " <= \"" ~ consts[$/2 - 1] ~ "\") {\n" ~ |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
92 binarySearch (var, consts[0 .. $/2], indents + 1) ~ |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
93 indent(indents) ~ "} else {\n" ~ |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
94 binarySearch (var, consts[$/2 .. $], indents + 1) ~ |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
95 indent(indents) ~ "}\n"; |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
96 } else { |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
97 char[] ret; |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
98 ret ~= indent(indents); |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
99 foreach (c; consts) { |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
100 ret ~= "if (" ~ var ~ " == \"" ~ c ~ "\") {\n" ~ |
75
25cb7420dc91
A massive overhaul/rewrite for the gui's data management and setup code. Currently much that was working is broken.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
74
diff
changeset
|
101 //indent(indents+1) ~ varName(c) ~ "[id] = parseTo!(" ~ c ~ ") (dt);\n" ~ |
25cb7420dc91
A massive overhaul/rewrite for the gui's data management and setup code. Currently much that was working is broken.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
74
diff
changeset
|
102 indent(indents+1) ~ "if ((id in "~varName(c)~") is null)\n" ~ |
25cb7420dc91
A massive overhaul/rewrite for the gui's data management and setup code. Currently much that was working is broken.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
74
diff
changeset
|
103 indent(indents+2) ~ varName(c)~"[id] = parseTo!(" ~ c ~ ") (dt);\n" ~ |
14
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
104 indent(indents) ~ "} else "; |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
105 } |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
106 ret = ret[0..$-6] ~ '\n'; // remove last else |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
107 return ret; |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
108 } |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
109 } |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
110 |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
111 // Generates the code to write data members (writeAll). |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
112 static char[] writeVars () { |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
113 char[] code = ""; |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
114 foreach (i,type; dataTypes) { |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
115 code ~= "foreach (id, dt; " ~ varName(type) ~ ") itemdlg (dataTypes[" ~ int2str(i) ~ "], id, parseFrom!(" ~ type ~ ")(dt));\n"; |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
116 } |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
117 return code; |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
118 } |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
119 //END META |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
120 |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
121 /** Data Members |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
122 * |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
123 * These types are all stored directly, as below, are available for direct access. The variable |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
124 * names are created dynamically at compile-time based on the dataTypes list. |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
125 * ------------------ |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
126 * int[ID] _int; // name is type prefixed by _ |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
127 * char[][ID] _charA; // [] is replaced by A |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
128 * ------------------ |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
129 */ |
75
25cb7420dc91
A massive overhaul/rewrite for the gui's data management and setup code. Currently much that was working is broken.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
74
diff
changeset
|
130 /+ All types previously supported. Most of these weren't used. |
14
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
131 const char[][] dataTypes = ["bool","bool[]", |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
132 "byte","byte[]", |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
133 "char","char[]","char[][]", |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
134 "double","double[]", |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
135 "float","float[]", |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
136 "int","int[]", |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
137 "long","long[]", |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
138 "real","real[]", |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
139 "short","short[]", |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
140 "ubyte","ubyte[]", |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
141 "uint","uint[]", |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
142 "ulong","ulong[]", |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
143 "ushort","ushort[]"]; |
75
25cb7420dc91
A massive overhaul/rewrite for the gui's data management and setup code. Currently much that was working is broken.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
74
diff
changeset
|
144 +/ |
25cb7420dc91
A massive overhaul/rewrite for the gui's data management and setup code. Currently much that was working is broken.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
74
diff
changeset
|
145 const char[][] dataTypes = ["char[]", "char[][]"]; |
14
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
146 |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
147 mixin (declerations (dataTypes)); // Declare all the variables. |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
148 |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
149 void addTag (char[] type, ID id, char[] dt) { /// Supports all types listed in dataTypes. |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
150 mixin (binarySearch ("type", dataTypes)); |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
151 } |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
152 |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
153 void writeAll (ItemDelg itemdlg) { /// Supports all types listed in dataTypes. |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
154 mixin (writeVars ()); |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
155 } |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
156 } |