Update upstream source from tag 'upstream/0.22.0'
Update to upstream version '0.22.0'
with Debian dir 2aaf2c207ed65d31c3c3911325da063f2e3b43be
Matthias Klumpp
3 years ago
66 | 66 | reader.skipTag(); |
67 | 67 | break; |
68 | 68 | default: |
69 | error("Unexpected tag: ", reader.front.value, " in GirAlias: ", name, reader); | |
69 | warning("Unexpected tag: ", reader.front.value, " in GirAlias: ", name, reader); | |
70 | 70 | } |
71 | 71 | reader.popFront(); |
72 | 72 | } |
77 | 77 | reader.skipTag(); |
78 | 78 | break; |
79 | 79 | default: |
80 | error("Unexpected tag: ", reader.front.value, " in GirConstant: ", name, reader); | |
80 | warning("Unexpected tag: ", reader.front.value, " in GirConstant: ", name, reader); | |
81 | 81 | } |
82 | 82 | reader.popFront(); |
83 | 83 | } |
88 | 88 | reader.skipTag(); |
89 | 89 | break; |
90 | 90 | default: |
91 | error("Unexpected tag: ", reader.front.value, " in GirEnum: ", name, reader); | |
91 | warning("Unexpected tag: ", reader.front.value, " in GirEnum: ", name, reader); | |
92 | 92 | } |
93 | 93 | reader.popFront(); |
94 | 94 | } |
180 | 180 | value = "\""~ value ~"\""; |
181 | 181 | break; |
182 | 182 | default: |
183 | error("Unexpected tag: ", reader.front.value, " in GirEnumMember: ", name, reader); | |
183 | warning("Unexpected tag: ", reader.front.value, " in GirEnumMember: ", name, reader); | |
184 | 184 | } |
185 | 185 | reader.popFront(); |
186 | 186 | } |
97 | 97 | reader.skipTag(); |
98 | 98 | break; |
99 | 99 | default: |
100 | error("Unexpected tag: ", reader.front.value, " in GirField: ", name, reader); | |
100 | warning("Unexpected tag: ", reader.front.value, " in GirField: ", name, reader); | |
101 | 101 | } |
102 | 102 | reader.popFront(); |
103 | 103 | } |
143 | 143 | { |
144 | 144 | switch ( reader.front.value ) |
145 | 145 | { |
146 | case "attribute": | |
147 | //TODO: Do we need these attibutes? | |
148 | //dbus.name ccode.ordering deprecated replacement. | |
149 | reader.skipTag(); | |
150 | break; | |
146 | 151 | case "doc": |
147 | 152 | reader.popFront(); |
148 | 153 | returnType.doc ~= reader.front.value; |
153 | 158 | returnType.parse(reader); |
154 | 159 | break; |
155 | 160 | default: |
156 | error("Unexpected tag: ", reader.front.value, " in GirFunction: ", name, reader); | |
161 | warning("Unexpected tag: ", reader.front.value, " in GirFunction: ", name, reader); | |
157 | 162 | } |
158 | 163 | reader.popFront(); |
159 | 164 | } |
174 | 179 | params ~= param; |
175 | 180 | break; |
176 | 181 | default: |
177 | error("Unexpected tag: ", reader.front.value, " in GirFunction: ", name, reader); | |
182 | warning("Unexpected tag: ", reader.front.value, " in GirFunction: ", name, reader); | |
178 | 183 | } |
179 | 184 | reader.popFront(); |
180 | 185 | } |
183 | 188 | reader.skipTag(); |
184 | 189 | break; |
185 | 190 | default: |
186 | error("Unexpected tag: ", reader.front.value, " in GirFunction: ", name, reader); | |
191 | warning("Unexpected tag: ", reader.front.value, " in GirFunction: ", name, reader); | |
187 | 192 | } |
188 | 193 | reader.popFront(); |
189 | 194 | } |
582 | 587 | { |
583 | 588 | if ( param.type.size > 0 ) |
584 | 589 | buff ~= elementType.cType ~"* out"~ id ~" = cast("~ elementType.cType ~"*)sliceAlloc0("~ elementType.cType ~".sizeof * "~ to!string(param.type.size) ~");"; |
590 | else if ( !elementType.cType.endsWith("*") ) | |
591 | buff ~= elementType.cType ~"* out"~ id ~" = null;"; | |
585 | 592 | else |
586 | 593 | buff ~= elementType.cType ~" out"~ id ~" = null;"; |
587 | 594 | } |
783 | 790 | else if ( param.type.isArray() && param.type.size > 0) |
784 | 791 | outType = param.type.elementType.name ~ "[" ~ to!string(param.type.size) ~ "]"; |
785 | 792 | |
786 | buff ~= stringToGtkD(outType, wrapper.aliasses, localAliases) ~ " " ~ outName ~" = "; | |
793 | buff ~= stringToGtkD(outType, wrapper.aliasses, localAliases) ~" " ~ outName; | |
787 | 794 | |
788 | 795 | if ( param.direction == GirParamDirection.Out ) |
789 | buff[$-1] ~= "null;"; | |
796 | buff[$-1] ~= ";"; | |
790 | 797 | else |
791 | buff[$-1] ~= id ~".ptr"; | |
798 | buff[$-1] ~=" = "~ id ~".ptr"; | |
792 | 799 | |
793 | 800 | if ( param.type.elementType.cType.empty ) |
794 | 801 | gtkCall ~= "cast("~stringToGtkD(param.type.cType, wrapper.aliasses, localAliases) ~")&" ~ outName; |
903 | 910 | } |
904 | 911 | else if ( returnType.isString() ) |
905 | 912 | { |
906 | if ( outToD.empty && !throws && !(returnOwnership == GirTransferOwnership.Full) ) | |
913 | if ( outToD.empty && !throws && | |
914 | !(returnOwnership == GirTransferOwnership.Full || returnOwnership == GirTransferOwnership.Container) ) | |
907 | 915 | { |
908 | 916 | if ( isStringArray(returnType) ) |
909 | 917 | buff ~= "return Str.toStringArray(" ~ gtkCall ~");"; |
934 | 942 | buff ~= "scope(exit) Str.freeStringArray(retStr);"; |
935 | 943 | else |
936 | 944 | buff ~= "scope(exit) Str.freeString(retStr);"; |
945 | } else if ( returnOwnership == GirTransferOwnership.Container ) | |
946 | { | |
947 | if ( isStringArray(returnType) ) | |
948 | buff ~= "scope(exit) g_free(retStr);"; | |
937 | 949 | } |
938 | 950 | |
939 | 951 | string len = lenId(returnType); |
1504 | 1516 | reader.skipTag(); |
1505 | 1517 | break; |
1506 | 1518 | default: |
1507 | error("Unexpected tag: ", reader.front.value, " in GirParam: ", name, reader); | |
1519 | warning("Unexpected tag: ", reader.front.value, " in GirParam: ", name, reader); | |
1508 | 1520 | } |
1509 | 1521 | |
1510 | 1522 | reader.popFront(); |
206 | 206 | // We are not able to wrap these. |
207 | 207 | reader.skipTag(); |
208 | 208 | break; |
209 | case "docsection": | |
210 | // General documentation. | |
211 | reader.skipTag(); | |
212 | break; | |
209 | 213 | default: |
210 | error("Unexpected tag: ", reader.front.value, " in GirPackage: ", name, reader); | |
214 | warning("Unexpected tag: ", reader.front.value, " in GirPackage: ", name, reader); | |
211 | 215 | } |
212 | 216 | reader.popFront(); |
213 | 217 | } |
214 | 214 | reader.skipTag(); |
215 | 215 | break; |
216 | 216 | default: |
217 | error("Unexpected tag: ", reader.front.value, " in GirStruct: ", name, reader); | |
217 | warning("Unexpected tag: ", reader.front.value, " in GirStruct: ", name, reader); | |
218 | 218 | } |
219 | 219 | |
220 | 220 | reader.popFront(); |
929 | 929 | else |
930 | 930 | imports ~= dType.pack.name ~"."~ dType.name; |
931 | 931 | } |
932 | else if ( field.type.isString() || (field.type.isArray() && field.type.elementType.isString()) ) | |
932 | else if ( field.type.isString() || (field.type.isArray() && field.type.elementType.isString()) ) { | |
933 | 933 | imports ~= "glib.Str"; |
934 | imports ~= "glib.c.functions"; | |
935 | } | |
934 | 936 | } |
935 | 937 | } |
936 | 938 | |
968 | 970 | else |
969 | 971 | imports ~= dType.pack.name ~"."~ dType.name; |
970 | 972 | } |
971 | else if ( type.name.among("utf8", "filename") || type.cType.among("guchar**") ) | |
973 | else if ( type.name.among("utf8", "filename") || type.cType.among("guchar**") ) { | |
972 | 974 | imports ~= "glib.Str"; |
975 | imports ~= "glib.c.functions"; | |
976 | } | |
973 | 977 | } |
974 | 978 | |
975 | 979 | if ( func.returnType && func.returnType.cType !in structWrap ) |
1022 | 1026 | && pack.getStruct(param.type.name) !is null |
1023 | 1027 | && pack.getStruct(param.type.name).isDClass() ) |
1024 | 1028 | imports ~= "glib.MemorySlice"; |
1029 | ||
1030 | if ( param.direction == GirParamDirection.Out | |
1031 | && param.type.elementType | |
1032 | && pack.getStruct(param.type.elementType.name) !is null | |
1033 | && pack.getStruct(param.type.elementType.name).isDClass() | |
1034 | && param.type.size > 0 ) | |
1035 | imports ~= "glib.MemorySlice"; | |
1025 | 1036 | } |
1026 | 1037 | |
1027 | 1038 | if ( func.type == GirFunctionType.Signal ) |
1187 | 1198 | reader.skipTag(); |
1188 | 1199 | break; |
1189 | 1200 | default: |
1190 | error("Unexpected tag: ", reader.front.value, " in GirUnion: ", name, reader); | |
1201 | warning("Unexpected tag: ", reader.front.value, " in GirUnion: ", name, reader); | |
1191 | 1202 | } |
1192 | 1203 | reader.popFront(); |
1193 | 1204 | } |
145 | 145 | error("No version specified.", defReader); |
146 | 146 | |
147 | 147 | bool parseVersion = checkOsVersion(defReader.subKey); |
148 | bool smalerThen = false; | |
149 | ||
150 | if ( defReader.subKey.length > 1 && defReader.subKey[0] == '<' && defReader.subKey[1].isNumber() ) | |
151 | { | |
152 | smalerThen = true; | |
153 | defReader.subKey.popFront(); | |
154 | } | |
148 | 155 | |
149 | 156 | if ( !parseVersion && defReader.subKey[0].isNumber() ) |
150 | 157 | { |
151 | 158 | if ( !currentPackage ) |
152 | 159 | error("Only use OS versions before wrap.", defReader); |
153 | 160 | parseVersion = defReader.subKey <= currentPackage._version; |
161 | ||
162 | if ( smalerThen ) | |
163 | parseVersion = !parseVersion; | |
154 | 164 | } |
155 | 165 | |
156 | 166 | if ( defReader.value == "start" ) |
306 | 316 | GirParam param = findParam(currentStruct, vals[0], vals[1]); |
307 | 317 | GirType elementType = new GirType(this); |
308 | 318 | |
319 | if ( !param ) | |
320 | error("Unknown parameter ", vals[1], " in function ", vals[0]); | |
321 | ||
309 | 322 | elementType.name = param.type.name; |
310 | 323 | elementType.cType = param.type.cType[0..$-1]; |
311 | 324 | param.type.elementType = elementType; |
460 | 473 | string[] vals = defReader.value.split(); |
461 | 474 | if ( vals[0] !in currentStruct.functions ) |
462 | 475 | error("Unknown function ", vals[0], ". Possible values: ", currentStruct.functions, defReader); |
463 | findParam(currentStruct, vals[0], vals[1]).direction = GirParamDirection.Default; | |
476 | GirParam param = findParam(currentStruct, vals[0], vals[1]); | |
477 | if ( !param ) | |
478 | error("Unknown parameter ", vals[1], " in function ", vals[0]); | |
479 | param.direction = GirParamDirection.Default; | |
464 | 480 | break; |
465 | 481 | case "out": |
466 | 482 | string[] vals = defReader.value.split(); |
467 | 483 | if ( vals[0] !in currentStruct.functions ) |
468 | 484 | error("Unknown function ", vals[0], ". Possible values: ", currentStruct.functions, defReader); |
469 | findParam(currentStruct, vals[0], vals[1]).direction = GirParamDirection.Out; | |
485 | GirParam param = findParam(currentStruct, vals[0], vals[1]); | |
486 | if ( !param ) | |
487 | error("Unknown parameter ", vals[1], " in function ", vals[0]); | |
488 | param.direction = GirParamDirection.Out; | |
470 | 489 | break; |
471 | 490 | case "override": |
472 | 491 | currentStruct.functions[defReader.value].lookupOverride = true; |
476 | 495 | string[] vals = defReader.value.split(); |
477 | 496 | if ( vals[0] !in currentStruct.functions ) |
478 | 497 | error("Unknown function ", vals[0], ". Possible values: ", currentStruct.functions, defReader); |
479 | findParam(currentStruct, vals[0], vals[1]).direction = GirParamDirection.InOut; | |
498 | GirParam param = findParam(currentStruct, vals[0], vals[1]); | |
499 | if ( !param ) | |
500 | error("Unknown parameter ", vals[1], " in function ", vals[0]); | |
501 | param.direction = GirParamDirection.InOut; | |
480 | 502 | break; |
481 | 503 | |
482 | 504 | default: |
22 | 22 | "gint": "int", |
23 | 23 | "guint": "uint", |
24 | 24 | "gboolean": "bool", |
25 | "_Bool": "bool", | |
25 | 26 | "gpointer": "void*", |
26 | 27 | "gconstpointer": "void*", |
27 | 28 | "gchar": "char", |
80 | 81 | "scope": "scope_", |
81 | 82 | "string": "string_", |
82 | 83 | "switch": "switch_", |
84 | "this": "this_", | |
83 | 85 | "union": "union_", |
84 | 86 | "version": "version_", |
85 | 87 | "byte": "byte_", |