Skip to content

Commit e558943

Browse files
committed
Swift Dictionary Added
1 parent 4c15618 commit e558943

File tree

2 files changed

+161
-0
lines changed

2 files changed

+161
-0
lines changed

languages/SwiftDictionary.json

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
{
2+
"modelStart": "{\n",
3+
"reservedKeywords": [
4+
"associatedtype",
5+
"class",
6+
"deinit",
7+
"enum",
8+
"extension",
9+
"fileprivate",
10+
"func",
11+
"import",
12+
"init",
13+
"inout",
14+
"internal",
15+
"let",
16+
"open",
17+
"operator",
18+
"private",
19+
"protocol",
20+
"public",
21+
"static",
22+
"struct",
23+
"subscript",
24+
"typealias",
25+
"var",
26+
"break",
27+
"case",
28+
"continue",
29+
"default",
30+
"defer",
31+
"do",
32+
"else",
33+
"fallthrough",
34+
"for",
35+
"guard",
36+
"if",
37+
"in",
38+
"repeat",
39+
"return",
40+
"switch",
41+
"where",
42+
"while",
43+
"as",
44+
"Any",
45+
"catch",
46+
"false",
47+
"is",
48+
"nil",
49+
"rethrows",
50+
"super",
51+
"self",
52+
"Self",
53+
"throw",
54+
"throws",
55+
"true",
56+
"try",
57+
"associativity",
58+
"convenience",
59+
"dynamic",
60+
"didSet",
61+
"final",
62+
"get",
63+
"infix",
64+
"indirect",
65+
"lazy",
66+
"left",
67+
"mutating",
68+
"none",
69+
"nonmutating",
70+
"optional",
71+
"override",
72+
"postfix",
73+
"precedence",
74+
"prefix",
75+
"Protocol",
76+
"required",
77+
"right",
78+
"set",
79+
"Type",
80+
"unowned",
81+
"weak",
82+
"willSet"
83+
],
84+
85+
"dataTypes": {
86+
"arrayType": "[<!ElementType!>]",
87+
"generic": "Any",
88+
"string": "String",
89+
"boolean": "Bool",
90+
"float": "Double",
91+
"doubleType": "Double",
92+
"characterType": "Character",
93+
"longType": "Double",
94+
"int": "Int"
95+
},
96+
97+
"typesWithCustomFetchMethod": [
98+
"String",
99+
"Bool",
100+
"Double",
101+
"Int",
102+
"Any"
103+
],
104+
105+
"customFetchTypeReplacement": [
106+
".stringValue",
107+
".boolValue",
108+
".doubleValue",
109+
".intValue",
110+
""
111+
],
112+
113+
"modelDefinition": "\n<!ModelIdentifier!> <!ModelName!> ",
114+
"getter": "",
115+
"setter": "",
116+
"fileExtension": "swift",
117+
"instanceVarDefinition": "\tlet <!VarName!>: <!VarType!>?\n",
118+
"modelEnd": "\n}",
119+
"staticImports": "import Foundation",
120+
"supportsCamelcasing": true,
121+
"methods": {
122+
"constructorName": "Initializer",
123+
"constructorChecked": "checked",
124+
"constructors": [{
125+
"signature": "\tinit(_ dict: [String: Any]) ",
126+
"bodyStart": "{\n",
127+
"bodyEnd": "\t}\n",
128+
"codeForEachProperty": "\t\t<!VarName!> = dict[\"<!JsonKeyName!>\"] as? <!VarType!>\n",
129+
"codeForEachCustomProperty": "\n\t\tif let <!VarName!>Dict = dict[\"<!JsonKeyName!>\"] as? [String: Any] {\n\t\t\t<!VarName!> = <!VarType!>(<!VarName!>Dict)\n\t\t}\n",
130+
"codeForEachCustomArrayProperty": "\n\t\tif let <!VarName!>DictArray = dict[\"<!JsonKeyName!>\"] as? [[String: Any]] {\n\t\t\t<!VarName!> = <!VarName!>DictArray.map { <!ElementType!>($0) }\n\t\t}\n",
131+
"comment": ""
132+
}],
133+
"others": {
134+
"dictionaryMethod": {
135+
"name": "toDictionary",
136+
"signature": "\tfunc toDictionary() -> [String: Any] ",
137+
"bodyStart": "{\n\t\tvar jsonDict = [String: Any]()\n",
138+
"bodyEnd": "\t\treturn jsonDict\n\t}\n",
139+
"codeForEachProperty": "\t\tjsonDict[\"<!JsonKeyName!>\"] = <!VarName!>\n",
140+
"codeForEachCustomProperty": "\t\tjsonDict[\"<!JsonKeyName!>\"] = <!VarName!>?.toDictionary()\n",
141+
"codeForEachCustomArrayProperty": "\t\tjsonDict[\"<!JsonKeyName!>\"] = <!VarName!>?.map { $0.toDictionary() }\n",
142+
"comment": "",
143+
"checked": "checked"
144+
}
145+
}
146+
}
147+
}

script/script.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,20 @@ let languages = {
2929
value: "Class",
3030
checked: ""
3131
}]
32+
},
33+
dictionary: {
34+
mode: "text/x-swift",
35+
name: "Dictionary",
36+
file: "SwiftDictionary.json",
37+
identifiers: [{
38+
key: "struct",
39+
value: "Struct",
40+
checked: "checked"
41+
},{
42+
key: "class",
43+
value: "Class",
44+
checked: ""
45+
}]
3246
}
3347
}
3448
},

0 commit comments

Comments
 (0)