diff options
Diffstat (limited to 'templates/data.swift.ede')
-rw-r--r-- | templates/data.swift.ede | 43 |
1 files changed, 38 insertions, 5 deletions
diff --git a/templates/data.swift.ede b/templates/data.swift.ede index d10c865..f2a9039 100644 --- a/templates/data.swift.ede +++ b/templates/data.swift.ede | |||
@@ -1,11 +1,6 @@ | |||
1 | // generated file, do not modify! | 1 | // generated file, do not modify! |
2 | // {{ dateTime }} | 2 | // {{ dateTime }} |
3 | 3 | ||
4 | enum Maybe<T> { | ||
5 | case Nothing | ||
6 | case Just(T) | ||
7 | } | ||
8 | |||
9 | {% for t in dataAndType %} | 4 | {% for t in dataAndType %} |
10 | {% case t.value | constType %} | 5 | {% case t.value | constType %} |
11 | {% when "DataDef" %} | 6 | {% when "DataDef" %} |
@@ -106,3 +101,41 @@ extension {{ t.value.dataName }} { | |||
106 | } | 101 | } |
107 | } | 102 | } |
108 | {% endfor %} | 103 | {% endfor %} |
104 | |||
105 | enum Maybe<T> { | ||
106 | case Nothing | ||
107 | case Just(T) | ||
108 | } | ||
109 | |||
110 | enum Type { | ||
111 | case Int | ||
112 | case Int32 | ||
113 | case Word | ||
114 | case Word32 | ||
115 | case Float | ||
116 | case Bool | ||
117 | case String | ||
118 | case Array(Type) | ||
119 | case List(Type) | ||
120 | case Maybe(Type) | ||
121 | case Map(Type,Type) | ||
122 | {% for t in definitions %} | ||
123 | case {{ t.value.dataName }} | ||
124 | {% endfor %} | ||
125 | } | ||
126 | |||
127 | func fromJSON(type: Type, personName: String) -> Any { | ||
128 | switch type { | ||
129 | case .Int: return 0 | ||
130 | case .Int32: return 0 | ||
131 | case .Word: return 0 | ||
132 | case .Word32: return 0 | ||
133 | case .Float: return 0.0 | ||
134 | case .Bool: return false | ||
135 | case .String: return "" | ||
136 | case .Array(let a): return fromJSON(a,personName) | ||
137 | case .List(let a): return fromJSON(a,personName) | ||
138 | case .Maybe(let a): return fromJSON(a,personName) | ||
139 | } | ||
140 | return 0; | ||
141 | } \ No newline at end of file | ||