Codebase list gir-to-d / b04f55a
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
9 changed file(s) with 72 addition(s) and 21 deletion(s). Raw diff Collapse all Expand all
6666 reader.skipTag();
6767 break;
6868 default:
69 error("Unexpected tag: ", reader.front.value, " in GirAlias: ", name, reader);
69 warning("Unexpected tag: ", reader.front.value, " in GirAlias: ", name, reader);
7070 }
7171 reader.popFront();
7272 }
7777 reader.skipTag();
7878 break;
7979 default:
80 error("Unexpected tag: ", reader.front.value, " in GirConstant: ", name, reader);
80 warning("Unexpected tag: ", reader.front.value, " in GirConstant: ", name, reader);
8181 }
8282 reader.popFront();
8383 }
8888 reader.skipTag();
8989 break;
9090 default:
91 error("Unexpected tag: ", reader.front.value, " in GirEnum: ", name, reader);
91 warning("Unexpected tag: ", reader.front.value, " in GirEnum: ", name, reader);
9292 }
9393 reader.popFront();
9494 }
180180 value = "\""~ value ~"\"";
181181 break;
182182 default:
183 error("Unexpected tag: ", reader.front.value, " in GirEnumMember: ", name, reader);
183 warning("Unexpected tag: ", reader.front.value, " in GirEnumMember: ", name, reader);
184184 }
185185 reader.popFront();
186186 }
9797 reader.skipTag();
9898 break;
9999 default:
100 error("Unexpected tag: ", reader.front.value, " in GirField: ", name, reader);
100 warning("Unexpected tag: ", reader.front.value, " in GirField: ", name, reader);
101101 }
102102 reader.popFront();
103103 }
143143 {
144144 switch ( reader.front.value )
145145 {
146 case "attribute":
147 //TODO: Do we need these attibutes?
148 //dbus.name ccode.ordering deprecated replacement.
149 reader.skipTag();
150 break;
146151 case "doc":
147152 reader.popFront();
148153 returnType.doc ~= reader.front.value;
153158 returnType.parse(reader);
154159 break;
155160 default:
156 error("Unexpected tag: ", reader.front.value, " in GirFunction: ", name, reader);
161 warning("Unexpected tag: ", reader.front.value, " in GirFunction: ", name, reader);
157162 }
158163 reader.popFront();
159164 }
174179 params ~= param;
175180 break;
176181 default:
177 error("Unexpected tag: ", reader.front.value, " in GirFunction: ", name, reader);
182 warning("Unexpected tag: ", reader.front.value, " in GirFunction: ", name, reader);
178183 }
179184 reader.popFront();
180185 }
183188 reader.skipTag();
184189 break;
185190 default:
186 error("Unexpected tag: ", reader.front.value, " in GirFunction: ", name, reader);
191 warning("Unexpected tag: ", reader.front.value, " in GirFunction: ", name, reader);
187192 }
188193 reader.popFront();
189194 }
582587 {
583588 if ( param.type.size > 0 )
584589 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;";
585592 else
586593 buff ~= elementType.cType ~" out"~ id ~" = null;";
587594 }
783790 else if ( param.type.isArray() && param.type.size > 0)
784791 outType = param.type.elementType.name ~ "[" ~ to!string(param.type.size) ~ "]";
785792
786 buff ~= stringToGtkD(outType, wrapper.aliasses, localAliases) ~ " " ~ outName ~" = ";
793 buff ~= stringToGtkD(outType, wrapper.aliasses, localAliases) ~" " ~ outName;
787794
788795 if ( param.direction == GirParamDirection.Out )
789 buff[$-1] ~= "null;";
796 buff[$-1] ~= ";";
790797 else
791 buff[$-1] ~= id ~".ptr";
798 buff[$-1] ~=" = "~ id ~".ptr";
792799
793800 if ( param.type.elementType.cType.empty )
794801 gtkCall ~= "cast("~stringToGtkD(param.type.cType, wrapper.aliasses, localAliases) ~")&" ~ outName;
903910 }
904911 else if ( returnType.isString() )
905912 {
906 if ( outToD.empty && !throws && !(returnOwnership == GirTransferOwnership.Full) )
913 if ( outToD.empty && !throws &&
914 !(returnOwnership == GirTransferOwnership.Full || returnOwnership == GirTransferOwnership.Container) )
907915 {
908916 if ( isStringArray(returnType) )
909917 buff ~= "return Str.toStringArray(" ~ gtkCall ~");";
934942 buff ~= "scope(exit) Str.freeStringArray(retStr);";
935943 else
936944 buff ~= "scope(exit) Str.freeString(retStr);";
945 } else if ( returnOwnership == GirTransferOwnership.Container )
946 {
947 if ( isStringArray(returnType) )
948 buff ~= "scope(exit) g_free(retStr);";
937949 }
938950
939951 string len = lenId(returnType);
15041516 reader.skipTag();
15051517 break;
15061518 default:
1507 error("Unexpected tag: ", reader.front.value, " in GirParam: ", name, reader);
1519 warning("Unexpected tag: ", reader.front.value, " in GirParam: ", name, reader);
15081520 }
15091521
15101522 reader.popFront();
206206 // We are not able to wrap these.
207207 reader.skipTag();
208208 break;
209 case "docsection":
210 // General documentation.
211 reader.skipTag();
212 break;
209213 default:
210 error("Unexpected tag: ", reader.front.value, " in GirPackage: ", name, reader);
214 warning("Unexpected tag: ", reader.front.value, " in GirPackage: ", name, reader);
211215 }
212216 reader.popFront();
213217 }
214214 reader.skipTag();
215215 break;
216216 default:
217 error("Unexpected tag: ", reader.front.value, " in GirStruct: ", name, reader);
217 warning("Unexpected tag: ", reader.front.value, " in GirStruct: ", name, reader);
218218 }
219219
220220 reader.popFront();
929929 else
930930 imports ~= dType.pack.name ~"."~ dType.name;
931931 }
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()) ) {
933933 imports ~= "glib.Str";
934 imports ~= "glib.c.functions";
935 }
934936 }
935937 }
936938
968970 else
969971 imports ~= dType.pack.name ~"."~ dType.name;
970972 }
971 else if ( type.name.among("utf8", "filename") || type.cType.among("guchar**") )
973 else if ( type.name.among("utf8", "filename") || type.cType.among("guchar**") ) {
972974 imports ~= "glib.Str";
975 imports ~= "glib.c.functions";
976 }
973977 }
974978
975979 if ( func.returnType && func.returnType.cType !in structWrap )
10221026 && pack.getStruct(param.type.name) !is null
10231027 && pack.getStruct(param.type.name).isDClass() )
10241028 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";
10251036 }
10261037
10271038 if ( func.type == GirFunctionType.Signal )
11871198 reader.skipTag();
11881199 break;
11891200 default:
1190 error("Unexpected tag: ", reader.front.value, " in GirUnion: ", name, reader);
1201 warning("Unexpected tag: ", reader.front.value, " in GirUnion: ", name, reader);
11911202 }
11921203 reader.popFront();
11931204 }
145145 error("No version specified.", defReader);
146146
147147 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 }
148155
149156 if ( !parseVersion && defReader.subKey[0].isNumber() )
150157 {
151158 if ( !currentPackage )
152159 error("Only use OS versions before wrap.", defReader);
153160 parseVersion = defReader.subKey <= currentPackage._version;
161
162 if ( smalerThen )
163 parseVersion = !parseVersion;
154164 }
155165
156166 if ( defReader.value == "start" )
306316 GirParam param = findParam(currentStruct, vals[0], vals[1]);
307317 GirType elementType = new GirType(this);
308318
319 if ( !param )
320 error("Unknown parameter ", vals[1], " in function ", vals[0]);
321
309322 elementType.name = param.type.name;
310323 elementType.cType = param.type.cType[0..$-1];
311324 param.type.elementType = elementType;
460473 string[] vals = defReader.value.split();
461474 if ( vals[0] !in currentStruct.functions )
462475 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;
464480 break;
465481 case "out":
466482 string[] vals = defReader.value.split();
467483 if ( vals[0] !in currentStruct.functions )
468484 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;
470489 break;
471490 case "override":
472491 currentStruct.functions[defReader.value].lookupOverride = true;
476495 string[] vals = defReader.value.split();
477496 if ( vals[0] !in currentStruct.functions )
478497 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;
480502 break;
481503
482504 default:
2222 "gint": "int",
2323 "guint": "uint",
2424 "gboolean": "bool",
25 "_Bool": "bool",
2526 "gpointer": "void*",
2627 "gconstpointer": "void*",
2728 "gchar": "char",
8081 "scope": "scope_",
8182 "string": "string_",
8283 "switch": "switch_",
84 "this": "this_",
8385 "union": "union_",
8486 "version": "version_",
8587 "byte": "byte_",