[pkg-d-commits] [gir-to-d] 01/06: New upstream version 0.13.0
Matthias Klumpp
mak at moszumanska.debian.org
Thu Nov 9 02:16:19 UTC 2017
This is an automated email from the git hooks/post-receive script.
mak pushed a commit to branch master
in repository gir-to-d.
commit 98796c1a8b36134d48f4add47bf2ab7799b88901
Author: Matthias Klumpp <mak at debian.org>
Date: Thu Nov 9 03:10:01 2017 +0100
New upstream version 0.13.0
---
source/girtod.d | 4 +-
source/gtd/DefReader.d | 31 +++++++--
source/gtd/GirEnum.d | 6 +-
source/gtd/GirField.d | 130 +++++++++++++++++++++++++++----------
source/gtd/GirFunction.d | 48 +++++++++++---
source/gtd/GirStruct.d | 45 +++++--------
source/gtd/GirWrapper.d | 4 +-
source/gtd/GlibTypes.d | 1 +
source/gtd/IndentedStringBuilder.d | 4 ++
9 files changed, 194 insertions(+), 79 deletions(-)
diff --git a/source/girtod.d b/source/girtod.d
index e803386..0bebb8c 100644
--- a/source/girtod.d
+++ b/source/girtod.d
@@ -20,7 +20,7 @@
module girtod;
import std.array;
-import std.file : isFile;
+import std.file : isFile, exists;
import std.getopt;
import std.path;
import std.stdio;
@@ -69,7 +69,7 @@ void main(string[] args)
{
input = "./";
}
- else if ( input.isFile() )
+ else if ( input.exists && input.isFile() )
{
lookupFile = input.baseName();
input = input.dirName();
diff --git a/source/gtd/DefReader.d b/source/gtd/DefReader.d
index 075421d..9acf2e5 100644
--- a/source/gtd/DefReader.d
+++ b/source/gtd/DefReader.d
@@ -80,10 +80,11 @@ public final class DefReader
if ( !line.empty && !line.startsWith("#") )
{
- size_t index = line.indexOf(':');
+ ptrdiff_t index = line.indexOf(':');
- key = line[0 .. max(index, 0)].strip();
- value = line[index +1 .. $].strip();
+ key = line[0 .. max(index, 0)].strip();
+ value = line[index +1 .. $].strip();
+ subKey = "";
index = key.indexOf(' ');
if ( index != -1 )
@@ -96,11 +97,12 @@ public final class DefReader
{
key.length = 0;
value.length = 0;
+ subKey.length = 0;
}
}
/**
- * Gets the contends of a block value
+ * Gets the content of a block value
*/
public string[] readBlock(string key = "")
{
@@ -127,6 +129,27 @@ public final class DefReader
}
/**
+ * Skip the content of a block. Supports nested blocks.
+ */
+ public void skipBlock(string key = "")
+ {
+ if ( key.empty )
+ key = this.key;
+
+ size_t nestedBlocks = 1;
+ do
+ {
+ do lines.popFront; while ( !lines.front.strip().startsWith(key) );
+
+ if ( lines.front.strip().endsWith("start") )
+ nestedBlocks++;
+ else
+ nestedBlocks--;
+ }
+ while ( nestedBlocks > 0 );
+ }
+
+ /**
* Gets the current value as a bool
*/
public @property bool valueBool() const
diff --git a/source/gtd/GirEnum.d b/source/gtd/GirEnum.d
index 0e42785..2a180ea 100644
--- a/source/gtd/GirEnum.d
+++ b/source/gtd/GirEnum.d
@@ -21,6 +21,7 @@ module gtd.GirEnum;
import std.algorithm;
import std.string : splitLines, strip, toUpper;
+import std.uni : isNumber;
import gtd.GirPackage;
import gtd.GirWrapper;
@@ -188,7 +189,10 @@ struct GirEnumMember
buff ~= " */";
}
- buff ~= tokenToGtkD(name.toUpper(), wrapper.aliasses, false) ~" = "~ value ~",";
+ if ( name[0].isNumber && name !in wrapper.aliasses )
+ buff ~= "_"~ name.toUpper() ~" = "~ value ~",";
+ else
+ buff ~= tokenToGtkD(name.toUpper(), wrapper.aliasses, false) ~" = "~ value ~",";
return buff;
}
diff --git a/source/gtd/GirField.d b/source/gtd/GirField.d
index 663c4bc..17bb09d 100644
--- a/source/gtd/GirField.d
+++ b/source/gtd/GirField.d
@@ -249,13 +249,22 @@ final class GirField
if ( type.isString() )
{
- if ( type.isArray() )
+ if ( type.isArray() && type.elementType.isString() )
{
- buff ~= "public @property string[] "~ tokenToGtkD(name, wrapper.aliasses, parent.aliases) ~"()";
+ buff ~= "public @property string["~ ((type.size > 0)?type.size.to!string:"") ~"] "~ tokenToGtkD(name, wrapper.aliasses, parent.aliases) ~"()";
buff ~= "{";
if ( type.length > -1 )
buff ~= "return Str.toStringArray("~ parent.getHandleVar() ~"."~ tokenToGtkD(name, wrapper.aliasses) ~", "~ getLengthID(parent) ~");";
+ else if ( type.size > 0 )
+ {
+ buff ~= "string["~ type.size.to!string ~"] arr;";
+ buff ~= "foreach( i, str; "~ parent.getHandleVar() ~"."~ tokenToGtkD(name, wrapper.aliasses) ~" )";
+ buff ~= "{";
+ buff ~= "arr[i] = Str.toString(str);";
+ buff ~= "}";
+ buff ~= "return arr;";
+ }
else
buff ~= "return Str.toStringArray("~ parent.getHandleVar() ~"."~ tokenToGtkD(name, wrapper.aliasses) ~");";
@@ -263,10 +272,20 @@ final class GirField
}
else
{
- buff ~= "public @property string "~ tokenToGtkD(name, wrapper.aliasses, parent.aliases) ~"()";
- buff ~= "{";
- buff ~= "return Str.toString("~ parent.getHandleVar() ~"."~ tokenToGtkD(name, wrapper.aliasses) ~");";
- buff ~= "}";
+ if ( type.size > 0 )
+ {
+ buff ~= "public @property char["~ type.size.to!string ~"] "~ tokenToGtkD(name, wrapper.aliasses, parent.aliases) ~"()";
+ buff ~= "{";
+ buff ~= "return "~ parent.getHandleVar() ~"."~ tokenToGtkD(name, wrapper.aliasses) ~";";
+ buff ~= "}";
+ }
+ else
+ {
+ buff ~= "public @property string "~ tokenToGtkD(name, wrapper.aliasses, parent.aliases) ~"()";
+ buff ~= "{";
+ buff ~= "return Str.toString("~ parent.getHandleVar() ~"."~ tokenToGtkD(name, wrapper.aliasses) ~");";
+ buff ~= "}";
+ }
}
}
else if ( dType && dType.isDClass() && type.cType.endsWith("*") )
@@ -282,11 +301,13 @@ final class GirField
if ( type.isArray() )
{
- buff ~= "public @property "~ dTypeName ~"[] "~ tokenToGtkD(name, wrapper.aliasses, parent.aliases) ~"()";
+ buff ~= "public @property "~ dTypeName ~"["~ ((type.size > 0)?type.size.to!string:"") ~"] "~ tokenToGtkD(name, wrapper.aliasses, parent.aliases) ~"()";
buff ~= "{";
if ( type.length > -1 )
buff ~= dTypeName ~"[] arr = new "~ dTypeName ~"["~ getLengthID(parent) ~"];";
+ else if ( type.size > 0 )
+ buff ~= dTypeName ~"["~ type.size.to!string ~"] arr;";
else
buff ~= dTypeName ~"[] arr = new "~ dTypeName ~"[getArrayLength("~ parent.getHandleVar() ~"."~ tokenToGtkD(name, wrapper.aliasses) ~")];";
@@ -296,7 +317,7 @@ final class GirField
if ( dType.pack.name.among("cairo", "glib", "gthread") )
buff ~= "arr[i] = new "~ dTypeName ~"("~ parent.getHandleVar() ~"."~ tokenToGtkD(name, wrapper.aliasses) ~"[i], false);";
else if( dType.type == GirStructType.Interface )
- buff ~= "arr[i] = ObjectG.getDObject!("~ dTypeName ~", "~ dTypeName ~"IF)("~ parent.getHandleVar() ~"."~ tokenToGtkD(name, wrapper.aliasses) ~"[i], false);";
+ buff ~= "arr[i] = ObjectG.getDObject!("~ dTypeName ~"IF)("~ parent.getHandleVar() ~"."~ tokenToGtkD(name, wrapper.aliasses) ~"[i], false);";
else
buff ~= "arr[i] = ObjectG.getDObject!("~ dTypeName ~")("~ parent.getHandleVar() ~"."~ tokenToGtkD(name, wrapper.aliasses) ~"[i], false);";
@@ -313,7 +334,7 @@ final class GirField
if ( dType.pack.name.among("cairo", "glib", "gthread") )
buff ~= "return new "~ dTypeName ~"("~ parent.getHandleVar() ~"."~ tokenToGtkD(name, wrapper.aliasses) ~", false);";
else if( dType.type == GirStructType.Interface )
- buff ~= "return ObjectG.getDObject!("~ dTypeName ~", "~ dTypeName ~"IF)("~ parent.getHandleVar() ~"."~ tokenToGtkD(name, wrapper.aliasses) ~", false);";
+ buff ~= "return ObjectG.getDObject!("~ dTypeName ~"IF)("~ parent.getHandleVar() ~"."~ tokenToGtkD(name, wrapper.aliasses) ~", false);";
else
buff ~= "return ObjectG.getDObject!("~ dTypeName ~")("~ parent.getHandleVar() ~"."~ tokenToGtkD(name, wrapper.aliasses) ~", false);";
@@ -324,11 +345,13 @@ final class GirField
{
if ( type.isArray() )
{
- buff ~= "public @property bool[] "~ tokenToGtkD(name, wrapper.aliasses, parent.aliases) ~"()";
+ buff ~= "public @property bool["~ ((type.size > 0)?type.size.to!string:"") ~"] "~ tokenToGtkD(name, wrapper.aliasses, parent.aliases) ~"()";
buff ~= "{";
if ( type.length > -1 )
buff ~= "return "~ parent.getHandleVar ~"."~ tokenToGtkD(name, wrapper.aliasses) ~"[0.."~ getLengthID(parent) ~"];";
+ else if ( type.size > 0 )
+ buff ~= "return "~ parent.getHandleVar ~"."~ tokenToGtkD(name, wrapper.aliasses) ~";";
else
error("Is boolean[] field: ", parent.name, ".", name, " really zero terminated?");
@@ -346,11 +369,13 @@ final class GirField
{
if ( type.isArray() )
{
- buff ~= "public @property "~ stringToGtkD(type.cType[0..$-1], wrapper.aliasses, parent.aliases) ~"[] "~ tokenToGtkD(name, wrapper.aliasses, parent.aliases) ~"()";
+ buff ~= "public @property "~ stringToGtkD(type.cType[0..$-1], wrapper.aliasses, parent.aliases) ~"["~ ((type.size > 0)?type.size.to!string:"") ~"] "~ tokenToGtkD(name, wrapper.aliasses, parent.aliases) ~"()";
buff ~= "{";
if ( type.length > -1 )
buff ~= "return "~ parent.getHandleVar() ~"."~ tokenToGtkD(name, wrapper.aliasses) ~"[0.."~ getLengthID(parent) ~"];";
+ else if ( type.size > 0 )
+ buff ~= "return "~ parent.getHandleVar() ~"."~ tokenToGtkD(name, wrapper.aliasses) ~";";
else
buff ~= "return "~ parent.getHandleVar() ~"."~ tokenToGtkD(name, wrapper.aliasses) ~"[0..getArrayLength("~ parent.getHandleVar() ~"."~ tokenToGtkD(name, wrapper.aliasses) ~")];";
@@ -379,23 +404,44 @@ final class GirField
if ( type.isString() )
{
- if ( type.isArray() )
+ if ( type.isArray() && type.elementType.isString() )
{
- buff ~= "public @property void "~ tokenToGtkD(name, wrapper.aliasses, parent.aliases) ~"(string[] value)";
+ buff ~= "public @property void "~ tokenToGtkD(name, wrapper.aliasses, parent.aliases) ~"(string["~ ((type.size > 0)?type.size.to!string:"") ~"] value)";
buff ~= "{";
- buff ~= parent.getHandleVar() ~"."~ tokenToGtkD(name, wrapper.aliasses) ~" = Str.toStringzArray(value);";
-
- if ( type.length > -1 )
- buff ~= parent.getHandleVar() ~"."~ tokenToGtkD(parent.fields[type.length].name, wrapper.aliasses) ~" = cast("~ stringToGtkD(parent.fields[type.length].type.cType, wrapper.aliasses) ~")value.length;";
+ if ( type.size > 0 )
+ {
+ buff ~= stringToGtkD(type.elementType.cType, wrapper.aliasses) ~"["~ type.size.to!string ~"] arr;";
+ buff ~= "foreach( i, str; value )";
+ buff ~= "{";
+ buff ~= "arr[i] = Str.toStringz(str);";
+ buff ~= "}";
+ buff ~= parent.getHandleVar() ~"."~ tokenToGtkD(name, wrapper.aliasses) ~" = arr;";
+ }
+ else
+ {
+ buff ~= parent.getHandleVar() ~"."~ tokenToGtkD(name, wrapper.aliasses) ~" = Str.toStringzArray(value);";
+ if ( type.length > -1 )
+ buff ~= parent.getHandleVar() ~"."~ tokenToGtkD(parent.fields[type.length].name, wrapper.aliasses) ~" = cast("~ stringToGtkD(parent.fields[type.length].type.cType, wrapper.aliasses) ~")value.length;";
+ }
buff ~= "}";
}
else
{
- buff ~= "public @property void "~ tokenToGtkD(name, wrapper.aliasses, parent.aliases) ~"(string value)";
- buff ~= "{";
- buff ~= parent.getHandleVar() ~"."~ tokenToGtkD(name, wrapper.aliasses) ~" = Str.toStringz(value);";
- buff ~= "}";
+ if ( type.size > 0 )
+ {
+ buff ~= "public @property void "~ tokenToGtkD(name, wrapper.aliasses, parent.aliases) ~"(char["~ type.size.to!string ~"] value)";
+ buff ~= "{";
+ buff ~= parent.getHandleVar() ~"."~ tokenToGtkD(name, wrapper.aliasses) ~" = value;";
+ buff ~= "}";
+ }
+ else
+ {
+ buff ~= "public @property void "~ tokenToGtkD(name, wrapper.aliasses, parent.aliases) ~"(string value)";
+ buff ~= "{";
+ buff ~= parent.getHandleVar() ~"."~ tokenToGtkD(name, wrapper.aliasses) ~" = Str.toStringz(value);";
+ buff ~= "}";
+ }
}
}
else if ( dType && dType.isDClass() && type.cType.endsWith("*") )
@@ -411,9 +457,12 @@ final class GirField
if ( type.isArray() )
{
- buff ~= "public @property void "~ tokenToGtkD(name, wrapper.aliasses, parent.aliases) ~"("~ dTypeName ~"[] value)";
+ buff ~= "public @property void "~ tokenToGtkD(name, wrapper.aliasses, parent.aliases) ~"("~ dTypeName ~"["~ ((type.size > 0)?type.size.to!string:"") ~"] value)";
buff ~= "{";
- buff ~= dType.cType ~"*[] arr = new "~ dType.cType ~"*[value.length+1];";
+ if ( type.size > 0 )
+ buff ~= dType.cType ~"*["~ type.size.to!string ~"] arr;";
+ else
+ buff ~= dType.cType ~"*[] arr = new "~ dType.cType ~"*[value.length+1];";
buff ~= "for ( int i = 0; i < value.length; i++ )";
buff ~= "{";
buff ~= "arr[i] = value[i]."~ dType.getHandleFunc() ~"();";
@@ -439,13 +488,18 @@ final class GirField
{
if ( type.isArray() )
{
- buff ~= "public @property void "~ tokenToGtkD(name, wrapper.aliasses, parent.aliases) ~"(bool[] value)";
+ buff ~= "public @property void "~ tokenToGtkD(name, wrapper.aliasses, parent.aliases) ~"(bool["~ ((type.size > 0)?type.size.to!string:"") ~"] value)";
buff ~= "{";
- buff ~= parent.getHandleVar() ~"."~ tokenToGtkD(name, wrapper.aliasses) ~" = value.ptr;";
-
- if ( type.length > -1 )
- buff ~= parent.getHandleVar() ~"."~ tokenToGtkD(parent.fields[type.length].name, wrapper.aliasses) ~" = cast("~ stringToGtkD(parent.fields[type.length].type.cType, wrapper.aliasses) ~")value.length;";
-
+ if ( type.size > 0 )
+ {
+ buff ~= parent.getHandleVar() ~"."~ tokenToGtkD(name, wrapper.aliasses) ~" = value;";
+ }
+ else
+ {
+ buff ~= parent.getHandleVar() ~"."~ tokenToGtkD(name, wrapper.aliasses) ~" = value.ptr;";
+ if ( type.length > -1 )
+ buff ~= parent.getHandleVar() ~"."~ tokenToGtkD(parent.fields[type.length].name, wrapper.aliasses) ~" = cast("~ stringToGtkD(parent.fields[type.length].type.cType, wrapper.aliasses) ~")value.length;";
+ }
buff ~= "}";
}
else
@@ -460,13 +514,19 @@ final class GirField
{
if ( type.isArray() )
{
- buff ~= "public @property void "~ tokenToGtkD(name, wrapper.aliasses, parent.aliases) ~"("~ stringToGtkD(type.cType[0..$-1], wrapper.aliasses, parent.aliases) ~"[] value)";
+ buff ~= "public @property void "~ tokenToGtkD(name, wrapper.aliasses, parent.aliases) ~"("~ stringToGtkD(type.cType[0..$-1], wrapper.aliasses, parent.aliases) ~"["~ ((type.size > 0)?type.size.to!string:"") ~"] value)";
buff ~= "{";
- buff ~= parent.getHandleVar() ~"."~ tokenToGtkD(name, wrapper.aliasses) ~" = value.ptr;";
-
- if ( type.length > -1 )
- buff ~= parent.getHandleVar() ~"."~ tokenToGtkD(parent.fields[type.length].name, wrapper.aliasses) ~" = cast("~ stringToGtkD(parent.fields[type.length].type.cType, wrapper.aliasses) ~")value.length;";
+ if ( type.size > 0 )
+ {
+ buff ~= parent.getHandleVar() ~"."~ tokenToGtkD(name, wrapper.aliasses) ~" = value;";
+ }
+ else
+ {
+ buff ~= parent.getHandleVar() ~"."~ tokenToGtkD(name, wrapper.aliasses) ~" = value.ptr;";
+ if ( type.length > -1 )
+ buff ~= parent.getHandleVar() ~"."~ tokenToGtkD(parent.fields[type.length].name, wrapper.aliasses) ~" = cast("~ stringToGtkD(parent.fields[type.length].type.cType, wrapper.aliasses) ~")value.length;";
+ }
buff ~= "}";
}
else
@@ -499,7 +559,7 @@ final class GirField
{
if ( type.length > -1 )
return parent.getHandleVar() ~"."~ tokenToGtkD(parent.fields[type.length].name, wrapper.aliasses);
- else if ( type.size > -1 )
+ else if ( type.size > 0 )
return to!string(type.size);
return null;
diff --git a/source/gtd/GirFunction.d b/source/gtd/GirFunction.d
index 3369dd4..f96a300 100644
--- a/source/gtd/GirFunction.d
+++ b/source/gtd/GirFunction.d
@@ -191,10 +191,34 @@ final class GirFunction
if ( type == GirFunctionType.Function && name.startsWith("new") && returnType.cType != "void" )
type = GirFunctionType.Constructor;
- if ( cType.among("gst_init", "gst_init_check") )
+ // For the case where a param is `const gchar* name[]` whitch ends up in the gir files
+ // as an array with elementType name=utf8 c:type=gchar, missing the [].
+ switch ( cType )
{
- params[1].type.cType = "char***";
- params[1].type.elementType.cType = "char**";
+ case "gtk_icon_theme_choose_icon":
+ case "gtk_icon_theme_choose_icon_for_scale":
+ params[0].type.cType = "char**";
+ params[0].type.elementType.cType = "char*";
+ break;
+ case "g_object_getv":
+ case "g_object_setv":
+ params[1].type.cType = "char**";
+ params[1].type.elementType.cType = "char*";
+ break;
+ case "gst_init":
+ case "gst_init_check":
+ params[1].type.cType = "char***";
+ params[1].type.elementType.cType = "char**";
+ break;
+ case "g_object_new_with_properties":
+ params[2].type.cType = "char**";
+ params[2].type.elementType.cType = "char*";
+ break;
+ case "g_key_file_set_locale_string_list":
+ params[3].type.cType = "char**";
+ params[3].type.elementType.cType = "char*";
+ break;
+ default: break;
}
}
@@ -344,7 +368,7 @@ final class GirFunction
if ( param.lengthFor )
continue;
- if ( returnType.length > -1 && param == params[returnType.length] )
+ if ( returnType.length > -1 && param == params[returnType.length] && params[returnType.length].direction != GirParamDirection.Default )
continue;
if ( paramCount == 0 && strct.type == GirStructType.Record && isInstanceParam(param) )
@@ -620,7 +644,7 @@ final class GirFunction
}
}
}
- else if ( param.lengthFor || returnType.length == i )
+ else if ( param.lengthFor || (returnType.length == i && param.direction != GirParamDirection.Default ) )
{
string arrId;
string lenType = tokenToGtkD(param.type.cType.removePtr(), wrapper.aliasses, localAliases());
@@ -1213,7 +1237,10 @@ final class GirFunction
if ( param.doc.empty )
continue;
- if ( returnType.length > -1 && param == params[returnType.length] )
+ if ( param.lengthFor )
+ continue;
+
+ if ( returnType.length > -1 && param == params[returnType.length] && params[returnType.length].direction != GirParamDirection.Default )
continue;
if ( isInstanceParam(param) )
@@ -1391,7 +1418,9 @@ final class GirFunction
private string lenId(GirType type, string paramName = "p")
{
- if ( type.length > -1 )
+ if ( type.length > -1 && params[type.length].direction == GirParamDirection.Default && paramName != "p" )
+ return "cast("~ tokenToGtkD(params[type.length].type.cType.removePtr(), wrapper.aliasses, localAliases()) ~")"~ paramName.replaceFirst("out", "") ~".length";
+ else if ( type.length > -1 )
return tokenToGtkD(params[type.length].name, wrapper.aliasses, localAliases());
//The c function returns the length.
else if ( type.length == -2 )
@@ -1479,7 +1508,7 @@ final class GirFunction
if ( dType.pack.name.among("cairo", "glib", "gthread") )
return "new "~name;
else if( dType.type == GirStructType.Interface )
- return "ObjectG.getDObject!("~ name ~", "~ name ~"IF)";
+ return "ObjectG.getDObject!("~ name ~"IF)";
else
return "ObjectG.getDObject!("~ name ~")";
}
@@ -1610,6 +1639,9 @@ final class GirParam
reader.popFront();
}
+
+ if ( direction != GirParamDirection.Default && !type.cType.endsWith("*") )
+ direction = GirParamDirection.Default;
}
}
diff --git a/source/gtd/GirStruct.d b/source/gtd/GirStruct.d
index dcd0f7b..18a186e 100644
--- a/source/gtd/GirStruct.d
+++ b/source/gtd/GirStruct.d
@@ -408,16 +408,6 @@ final class GirStruct
if ( !isInterface() && cType != "GObject" && cType != "cairo_t" )
{
- if ( parentStruct && pack.name != "cairo" )
- {
- buff ~= indenter.format("protected override void setStruct(GObject* obj)");
- buff ~= indenter.format("{");
- buff ~= indenter.format(getHandleVar ~" = cast("~ cType ~"*)obj;");
- buff ~= indenter.format("super.setStruct(obj);");
- buff ~= indenter.format("}");
- buff ~= "\n";
- }
-
buff ~= indenter.format("/**");
buff ~= indenter.format(" * Sets our main struct and passes it to the parent class.");
buff ~= indenter.format(" */");
@@ -440,7 +430,7 @@ final class GirStruct
buff ~= indenter.format("{");
if ( wrapper.useRuntimeLinker )
- buff ~= indenter.format("if ( Linker.isLoaded(LIBRARY_"~ pack.name.toUpper() ~") && ownedRef )");
+ buff ~= indenter.format("if ( Linker.isLoaded(LIBRARY_"~ pack.name.replace(".","").toUpper() ~") && ownedRef )");
else
buff ~= indenter.format("if ( ownedRef )");
@@ -458,7 +448,7 @@ final class GirStruct
buff ~= indenter.format("{");
if ( wrapper.useRuntimeLinker )
- buff ~= indenter.format("if ( Linker.isLoaded(LIBRARY_"~ pack.name.toUpper() ~") && ownedRef )");
+ buff ~= indenter.format("if ( Linker.isLoaded(LIBRARY_"~ pack.name.replace(".","").toUpper() ~") && ownedRef )");
else
buff ~= indenter.format("if ( ownedRef )");
@@ -518,6 +508,9 @@ final class GirStruct
if ( isInterface() && func.type == GirFunctionType.Constructor )
continue;
+ if ( isInterface() && func.name == "get_type" )
+ continue;
+
if ( func.type == GirFunctionType.Signal )
{
buff ~= "\n";
@@ -603,7 +596,7 @@ final class GirStruct
buff ~= "\n";
buff ~= indenter.format(dec);
}
- else
+ else if ( func.name != "get_type" )
{
string[] dec = func.getDeclaration();
dec[$-1] = dec[$-1].replace("override ", "");
@@ -612,6 +605,14 @@ final class GirStruct
buff ~= "\n";
buff ~= indenter.format(dec);
}
+ else
+ {
+ buff ~= "\n";
+ buff ~= indenter.format(func.getDeclaration());
+ buff ~= indenter.format("{");
+ buff ~= indenter.format(func.getBody());
+ buff ~= indenter.format("}");
+ }
}
buff ~= indenter.format("}");
@@ -900,7 +901,7 @@ final class GirStruct
else
imports ~= dType.pack.name ~"."~ dType.name;
}
- else if ( field.type.name.among("utf8", "filename") || field.type.cType.among("guchar**") )
+ else if ( field.type.isString() || (field.type.isArray() && field.type.elementType.isString()) )
imports ~= "glib.Str";
}
}
@@ -934,10 +935,10 @@ final class GirStruct
if ( dType is this && dType.type != GirStructType.Interface )
return;
- imports ~= dType.pack.name ~"."~ dType.name;
-
if ( dType.type == GirStructType.Interface || dType.lookupInterface )
imports ~= dType.pack.name ~"."~ dType.name ~"IF";
+ else
+ imports ~= dType.pack.name ~"."~ dType.name;
}
else if ( type.name.among("utf8", "filename") || type.cType.among("guchar**") )
imports ~= "glib.Str";
@@ -967,18 +968,11 @@ final class GirStruct
if ( dType && dType.isDClass() )
{
if ( dType.type == GirStructType.Interface || dType.lookupInterface )
- {
imports ~= dType.pack.name ~"."~ dType.name ~"IF";
-
- if ( func.type == GirFunctionType.Signal )
- imports ~= dType.pack.name ~"."~ dType.name;
- }
else
- {
imports ~= dType.pack.name ~"."~ dType.name;
- }
}
- else if ( type.name.among("utf8", "filename") || type.cType.among("guchar**") )
+ else if ( type.isString() || (type.isArray() && type.elementType.isString()) )
imports ~= "glib.Str";
}
@@ -1069,9 +1063,6 @@ final class GirStruct
func.cType = cIdentifier;
func.returnType = returnType;
- if ( type == GirStructType.Interface )
- func.noCode = true;
-
return func;
}
diff --git a/source/gtd/GirWrapper.d b/source/gtd/GirWrapper.d
index 906f375..1e37000 100644
--- a/source/gtd/GirWrapper.d
+++ b/source/gtd/GirWrapper.d
@@ -150,8 +150,8 @@ class GirWrapper
{
if ( parseVersion )
break;
- else
- defReader.readBlock();
+
+ defReader.skipBlock();
}
if ( !parseVersion )
diff --git a/source/gtd/GlibTypes.d b/source/gtd/GlibTypes.d
index ff3c5e8..a2e60d8 100644
--- a/source/gtd/GlibTypes.d
+++ b/source/gtd/GlibTypes.d
@@ -80,6 +80,7 @@ enum string[string] glibTypes = [
"switch": "switc",
"union": "unio",
"version": "versio",
+ "byte": "_byte",
"GLIB_SYSDEF_POLLIN": "=1",
"GLIB_SYSDEF_POLLOUT": "=4",
diff --git a/source/gtd/IndentedStringBuilder.d b/source/gtd/IndentedStringBuilder.d
index 2d52456..c9422e5 100644
--- a/source/gtd/IndentedStringBuilder.d
+++ b/source/gtd/IndentedStringBuilder.d
@@ -79,6 +79,10 @@ public class IndentedStringBuilder
{
return "\n";
}
+ else if ( startsWith(line, "&&", "||") )
+ {
+ text = tabs ~"\t"~ line ~"\n";
+ }
else if ( statement )
{
text = tabs ~"\t"~ line ~"\n";
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-d/gir-to-d.git
More information about the pkg-d-commits
mailing list