Browse files

* Fix API calls that have been deprecated or changed

* Use string rather than char[] as far as possible
  • Loading branch information...
1 parent dea7576 commit edd54ebc0fc606775ea49f48cd2186a2982ade8c @martindemello committed May 9, 2012
View
2 wrap/Makefile
@@ -1,6 +1,6 @@
VPATH = utils
OBJS = HTODConvert.o WrapperIF.o funct.o DefReader.o \
- GtkWrapper.o HtmlStrip.o convparms.o GtkDClass.o
+ GtkWrapper.o HtmlStrip.o IndentedStringBuilder.o convparms.o GtkDClass.o
DSRC := $(OBJS:%.o=%.d)
DTARG = gtkwrap
CC = gcc
View
49 wrap/utils/DefReader.d
@@ -33,17 +33,18 @@ public class DefReader
private import std.file;
private import std.string;
+ private import std.conv;
private import std.stdio;
private import utils.GtkDClass;
- char[] fileName;
- char[][] lines;
+ string fileName;
+ string[] lines;
- char[] fullLine;
- char[] key;
- char[] value;
+ string fullLine;
+ string key;
+ string value;
int currLine = 0;
@@ -53,27 +54,27 @@ public class DefReader
* Params:
* fileName = The file name of the file containing the conversion definition
*/
- this ( char[] fileName )
+ this ( string fileName )
{
this.fileName = fileName;
debug(file)writefln("DefReader.ctor fileName = %s", fileName);
- lines = std.string.splitlines(cast(char[]) std.file.read(fileName));
+ lines = std.string.splitLines(cast(string) std.file.read(fileName));
}
- public char[] toString()
+ public string toString()
{
- char[] str;
+ string str;
str ~= "\n[DefReader]"
- ~ "\nfileName = "~fileName
- ~ "\ncurrLine = "~std.string.toString(currLine)
- ~ "\nfullLine = "~fullLine
- ~ "\nkey = "~key
- ~ "\nvalue + "~value
+ ~ "\nfileName = " ~ fileName
+ ~ "\ncurrLine = " ~ to!(string)(currLine)
+ ~ "\nfullLine = " ~ fullLine
+ ~ "\nkey = " ~ key
+ ~ "\nvalue + " ~ value
;
return str;
}
- char[] getFileName()
+ string getFileName()
{
return fileName;
}
@@ -83,15 +84,15 @@ public class DefReader
* both key and value a stripped of non visible start and ending chars
* Returns: The key after read the next key/value pair
*/
- char[] next(bool skipEmpty = true)
+ string next(bool skipEmpty = true)
{
key.length = 0;
value.length = 0;
- char[] line;
+ string line;
if ( currLine < lines.length )
{
fullLine = lines[currLine++];
- line = std.string.strip(fullLine.dup);
+ line = std.string.strip(fullLine);
int commentCount = 0;
while ( skipEmpty
&& (commentCount > 0 || line.length ==0 || line[0] == '#' || GtkDClass.startsWith(line, "#*") )
@@ -108,13 +109,13 @@ public class DefReader
}
fullLine = lines[currLine++];
- line = std.string.strip(fullLine.dup);
+ line = std.string.strip(fullLine);
}
}
if ( line.length > 0 )
{
- int pos = std.string.find(line, ':');
+ int pos = std.string.indexOf(line, ':');
if ( pos > 0 )
{
key = std.string.strip(line[0 .. pos]);
@@ -136,7 +137,7 @@ public class DefReader
* Gets the key of the current key/value pair
* Returns: The current key
*/
- char[] getKey()
+ string getKey()
{
return key;
}
@@ -145,18 +146,18 @@ public class DefReader
* Gets the value of the current key/value pair
* Returns: The current value
*/
- char[] getValue()
+ string getValue()
{
return value;
}
bool getValueBit()
{
- return std.string.find(" 1 ok OK Ok true TRUE True Y y yes YES Yes ", value) > 0;
+ return std.string.indexOf(" 1 ok OK Ok true TRUE True Y y yes YES Yes ", value) > 0;
}
- char[] getFullLine()
+ string getFullLine()
{
return fullLine;
}
View
908 wrap/utils/GtkDClass.d
@@ -54,116 +54,122 @@ module utils.GtkDClass;
//Moved here because of dsss:
private import utils.HtmlStrip;
private import utils.WrapperIF;
+private import utils.IndentedStringBuilder;
private import utils.convparms;
private import utils.funct;
-private import std.ctype;
+private import std.ascii;
private import std.path;
private import std.stdio;
+private import std.array;
private import std.string;
+private import std.conv;
public class GtkDClass
{
private WrapperIF wrapper;
- private char[] inAPI;
- private char[][] inLines;
+ private string inAPI;
+ private string[] inLines;
int currLine;
private int status = 0;
private int countBlock = 0;
ConvParms* convParms;
- char[] iFaceChar = "";
+ string iFaceChar = "";
- private char[] parentName; /// gtk parent struct
- private char[] gtkDParentName; /// gtkD parent name
- private char[] gtkDParentNamePrefix; /// gtkD parent name package
+ private string parentName; /// gtk parent struct
+ private string gtkDParentName; /// gtkD parent name
+ private string gtkDParentNamePrefix; /// gtkD parent name package
- private char[][] externalDeclarations; /// the external definition to pass to the wrapper
+ private string[] externalDeclarations; /// the external definition to pass to the wrapper
- private char[][] collectedAliases; /// public, module level type aliases
- private char[][] collectedEnums; /// public, module level definitions of enums
- private char[][] stockEnums; /// special enums for the SotckID
- private char[][] gTypes; /// special enums for G_TYPE_*
- private char[][] stockChars; /// the char[] value for the stockIDs
- private char[][] collectedStructs; /// public, module level definitions of structs
- private char[][] collectedTypes; /// public, module level definitions of other types
- private char[][] collectedFuncts; /// public, module level definitions of functions
- private char[][] collectedUnions; /// public, module level definitions of unions
- private char[][] collectedConstants;/// public, module level constants
+ private string[] collectedAliases; /// public, module level type aliases
+ private string[] collectedEnums; /// public, module level definitions of enums
+ private string[] stockEnums; /// special enums for the SotckID
+ private string[] gTypes; /// special enums for G_TYPE_*
+ private string[] stockChars; /// the string value for the stockIDs
+ private string[] collectedStructs; /// public, module level definitions of structs
+ private string[] collectedTypes; /// public, module level definitions of other types
+ private string[] collectedFuncts; /// public, module level definitions of functions
+ private string[] collectedUnions; /// public, module level definitions of unions
+ private string[] collectedConstants;/// public, module level constants
- private char[] gtkDText;
+ private string gtkDText;
- private char[][] properties;
- private char[][] styleProperties;
- private char[][] signals;
- private char[][] description;
- char[][] members;
+ private string[] properties;
+ private string[] styleProperties;
+ private string[] signals;
+ private string[] description;
+ private IndentedStringBuilder indenter;
- int[char[]] functionSignatures;
- int[char[]] gtkStructs;
+ string[] members;
+
+ int[string] functionSignatures;
+ int[string] gtkStructs;
private bool needSignalImports;
- private char[] tabs; /// used for simple indentation
+ private string tabs; /// used for simple indentation
public this (WrapperIF wrapper )
{
this.wrapper = wrapper;
+ indenter = new IndentedStringBuilder();
}
- public char[][] getExternalDeclarations()
+ public string[] getExternalDeclarations()
{
return externalDeclarations;
}
- public char[][] getAliases()
+ public string[] getAliases()
{
return collectedAliases;
}
- public char[][] getConstants()
+ public string[] getConstants()
{
return collectedConstants;
}
- public char[][] getEnums()
+ public string[] getEnums()
{
return collectedEnums;
}
- public char[][] getStockEnums()
+ public string[] getStockEnums()
{
return stockEnums;
}
- public char[][] getStockChars()
+ public string[] getStockChars()
{
return stockChars;
}
- public char[][] getGTypes()
+ public string[] getGTypes()
{
return gTypes;
}
- public char[][] getStructs()
+ public string[] getStructs()
{
return collectedStructs;
}
- public char[][] getTypes()
+ public string[] getTypes()
{
return collectedTypes;
}
- public char[][] getFuncts()
+ public string[] getFuncts()
{
return collectedFuncts;
}
- public char[][] getUnions()
+ public string[] getUnions()
{
return collectedUnions;
}
@@ -173,23 +179,23 @@ public class GtkDClass
return status;
}
- private int[char[]] getCleanSigns()
+ private int[string] getCleanSigns()
{
- int[char[]] cleanSignature;
+ int[string] cleanSignature;
return cleanSignature;
}
/** Construct the wrapped class according to all the collected
* information.
*/
- public void openGtkDClass(char[] inAPI, ConvParms* convParms)
+ public void openGtkDClass(string inAPI, ConvParms* convParms)
{
//writefln("collectStructs %s", std.string.strip(inLines[currLine]));
this.inAPI = inAPI;
if ( convParms.isInterface ) iFaceChar = ";";
else iFaceChar = "";
HtmlStrip stripper = new HtmlStrip();
- inLines = std.string.splitlines(stripper.strip(inAPI));
+ inLines = std.string.splitLines(stripper.strip(inAPI));
//writefln("new API\n%s",inAPI);
functionSignatures = getCleanSigns();
@@ -210,15 +216,15 @@ public class GtkDClass
needSignalImports = true;
- char[] privPub = ( convParms.templ.length > 0 ) ? "public" : "private";
+ string privPub = ( convParms.templ.length > 0 ) ? "public" : "private";
externalDeclarations ~= "";
externalDeclarations ~= "// " ~ convParms.outPack ~ '.' ~ convParms.clss;
externalDeclarations ~= "";
gtkDText = wrapper.getLicense();
- convParms.appendAsComment(gtkDText);
+ gtkDText ~= convParms.toString();
gtkDText ~= "module "~convParms.outPack~".";
if ( convParms.clss.length > 0 )
@@ -251,7 +257,7 @@ public class GtkDClass
// the use of phobs is limited, maybe we can get by with this...
- char[][][char[]] tangoImportConvs;
+ string[][string] tangoImportConvs;
tangoImportConvs["std.stdio"] = ["tango.io.Stdout"];
tangoImportConvs["std.thread"] = ["tango.core.Thread"];
tangoImportConvs["std.string"] = ["tango.text.Util", "tango.text.Unicode"];
@@ -261,39 +267,39 @@ public class GtkDClass
tangoImportConvs["std.stdarg"] = ["tango.core.Vararg"];
tangoImportConvs["std.conv"] = ["tango.text.convert.Integer"];
- char[][][char[]] druntimeImportConvs;
+ string[][string] druntimeImportConvs;
druntimeImportConvs["std.thread"] = ["core.thread"];
druntimeImportConvs["std.c.string"] = ["core.stdc.string"];
druntimeImportConvs["std.gc"] = ["core.memory"];
druntimeImportConvs["std.stdarg"] = ["core.vararg"];
- char[][][char[]] phobos2ImportConvs;
+ string[][string] phobos2ImportConvs;
phobos2ImportConvs["std.stdio"] = ["std.stdio"];
phobos2ImportConvs["std.c.stdio"] = ["std.c.stdio"];
phobos2ImportConvs["std.string"] = ["std.string"];
phobos2ImportConvs["std.conv"] = ["std.conv"];
- char[] importTango = "\nversion(Tango) {\n";
- char[] importDruntime = "} else version(D_Version2) {\n";
- char[] importElse = "} else {\n";
- char[] importCommon = "\n";
+ string importTango = "\nversion(Tango) {\n";
+ string importDruntime = "} else version(D_Version2) {\n";
+ string importElse = "} else {\n";
+ string importCommon = "\n";
int countTango;
int countDruntime;
- foreach( char[] imprt ; convParms.imprts )
+ foreach( string imprt ; convParms.imprts )
{
if ( imprt in druntimeImportConvs )
{
++countDruntime;
- foreach ( char[] d2Imp ; druntimeImportConvs[imprt] )
+ foreach ( string d2Imp ; druntimeImportConvs[imprt] )
{
importDruntime ~= "\t"~ privPub ~" import "~d2Imp~";\n";
}
}
if ( imprt in phobos2ImportConvs )
{
- foreach ( char[] phobos2Imp ; phobos2ImportConvs[imprt] )
+ foreach ( string phobos2Imp ; phobos2ImportConvs[imprt] )
{
importDruntime ~= "\t"~ privPub ~" import "~phobos2Imp~";\n";
}
@@ -302,7 +308,7 @@ public class GtkDClass
if ( imprt in tangoImportConvs )
{
++countTango;
- foreach ( char[] tangoImp ; tangoImportConvs[imprt] )
+ foreach ( string tangoImp ; tangoImportConvs[imprt] )
{
importTango ~= "\t"~ privPub ~" import "~tangoImp~";\n";
}
@@ -335,19 +341,9 @@ public class GtkDClass
readGtkDClass(convParms);
- /*
- // moved to GdkWrapper.d
- append(text, collectedAliases, tabs);
- append(text, collectedEnums, tabs);
- append(text, collectedStructs, tabs);
- append(text, collectedTypes, tabs);
- append(text, collectedFuncts, tabs);
- append(text, collectedUnions, tabs);
- */
-
gtkDText ~= "\n";
- foreach ( char[] key ; convParms.mAliases.keys.sort )
+ foreach ( string key ; convParms.mAliases.keys.sort )
{
gtkDText ~= "public alias "~key~" "~convParms.mAliases[key]~";";
}
@@ -357,9 +353,8 @@ public class GtkDClass
parentName = null;
gtkDParentName = "";
- char[][] classHead = openClass(convParms);
- append(gtkDText, classHead, tabs);
-
+ string[] classHead = openClass(convParms);
+ gtkDText ~= indenter.format(classHead);
}
private void readGtkDClass(ConvParms* convParms)
@@ -373,11 +368,11 @@ public class GtkDClass
}
- public void mergeGtkDClass(char[] inAPI, ConvParms* convParms)
+ public void mergeGtkDClass(string inAPI, ConvParms* convParms)
{
this.inAPI = inAPI;
HtmlStrip stripper = new HtmlStrip();
- inLines = std.string.splitlines(stripper.strip(inAPI));
+ inLines = std.string.splitLines(stripper.strip(inAPI));
//writefln("new API\n%s",inAPI);
this.convParms = convParms;
@@ -386,21 +381,19 @@ public class GtkDClass
if ( wrapper.includeComments() )
{
- append(gtkDText, description, tabs);
+ gtkDText ~= indenter.format(description);
}
}
- public char[] closeGtkDClass(char[] inAPI, ConvParms* convParms)
+ public string closeGtkDClass(string inAPI, ConvParms* convParms)
{
mergeGtkDClass(inAPI, convParms);
- append(gtkDText, properties, tabs);
- append(gtkDText, styleProperties, tabs);
- append(gtkDText, signals, tabs);
-
- append(gtkDText, members, tabs);
-
+ gtkDText ~= indenter.format(properties);
+ gtkDText ~= indenter.format(styleProperties);
+ gtkDText ~= indenter.format(signals);
+ gtkDText ~= indenter.format(members);
gtkDText ~= closeClass(convParms);
return gtkDText;
@@ -412,59 +405,24 @@ public class GtkDClass
* outputRoot =
* Returns:
*/
- public char[] getOutFile(char[] outputRoot, char[] srcOut)
+ public string getOutFile(string outputRoot, string srcOut)
{
- char[] outF = std.path.join(outputRoot, srcOut);
- outF = std.path.join(outF, convParms.outPack);
- outF = std.path.join(outF, (convParms.clss.length>0 ? convParms.outFile : convParms.outFile));
+ string outF = std.path.buildPath(outputRoot, srcOut);
+ outF = std.path.buildPath(outF, convParms.outPack);
+ outF = std.path.buildPath(outF, (convParms.clss.length>0 ? convParms.outFile : convParms.outFile));
return outF~".d";
}
- /**
- * Appends to the main text with the correct indentation
- * Params:
- * text = The main text
- * lines = The lines to append
- * tabs = The indentation to use
- */
- public static void append(inout char[] text, char[][] lines, inout char[] tabs)
- {
- foreach(char[] line ; lines )
- {
- char[] ln = std.string.strip(line);
- if ( endsWith(ln, '}')
- || endsWith(ln, "};")
- || startsWith(ln, "}")
- || startsWith(ln, "* }")
- || startsWith(ln, "// }")
- )
- {
- if ( tabs.length > 0 ) tabs.length = tabs.length -1;
- }
- if ( startsWith(ln, '*') )
- {
- text ~= tabs ~" "~ ln ~ "\n";
- }
- else
- {
- text ~= tabs ~ ln ~ "\n";
- }
- if ( endsWith(ln,'{') )//&& !startsWith(line, " *") )
- {
- tabs ~= '\t';
- }
- }
- }
/**
* Checks if we are a template and if the parent name
* Params:
* parentName =
* Returns:
*/
- private char[] getClassHeader(ConvParms* convParms, char[] parentName)
+ private string getClassHeader(ConvParms* convParms, string parentName)
{
- char[] h;
+ string h;
if ( convParms.isInterface )
{
h = "public interface "~convParms.interf;
@@ -477,7 +435,7 @@ public class GtkDClass
{
h = "public template "~convParms.clss~"(";
- foreach ( int count, char[] tp ; convParms.templ )
+ foreach ( int count, string tp ; convParms.templ )
{
if ( count > 0 )
{
@@ -501,9 +459,9 @@ public class GtkDClass
* clss = The class Name
* Returns:
*/
- private char[][] openClass(ConvParms* convParms)
+ private string[] openClass(ConvParms* convParms)
{
- char[][] text;
+ string[] text;
if ( convParms.clss.length > 0 )
{
@@ -517,13 +475,13 @@ public class GtkDClass
if ( wrapper.includeComments() )
{
- foreach(char[] line; description)
+ foreach(string line; description)
text ~= line;
}
text ~= getClassHeader(convParms, gtkDParentName)
~ getImplements(convParms, gtkDParentName);
-// char[] implements = getImplements(convParms, gtkDParentName);
+// string implements = getImplements(convParms, gtkDParentName);
// if ( implements.length > 0 )
// {
// text ~= implements;
@@ -536,12 +494,12 @@ public class GtkDClass
//text ~= "private import lib."~convParms.outPack ~ ";\n\n";
// moved to module level - AND BACK AGAIN
- //foreach( char[] imprt ; convParms.imprts )
+ //foreach( string imprt ; convParms.imprts )
//{
// text ~= "private import "~imprt~";";
//}
- char[] flipG(char[] inStr)
+ string flipG(string inStr)
{
char[] flipped = inStr.dup;
@@ -550,15 +508,15 @@ public class GtkDClass
flipped = flipped[1..flipped.length] ~ 'G';
}
- return flipped;
+ return to!(string)(flipped);
@MikeWey
MikeWey added a note May 10, 2012

Since we are using string now we don't need to make a copy, or the to!(string)().

@martindemello
Owner

good catch, i missed that one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
}
if ( convParms.strct.length > 0 )
{
- char[] gtkStruct = convParms.realStrct.length > 0
+ string gtkStruct = convParms.realStrct.length > 0
? convParms.realStrct
: convParms.strct;
- char[] var = toVar(gtkStruct.dup);
+ string var = toVar(gtkStruct);
text ~= "";
if ( !convParms.isInterface )
{
@@ -619,14 +577,14 @@ public class GtkDClass
text ~= "public this ("~gtkStruct~"* "~var~")"~iFaceChar;
text ~= "{";
- char[][] checkIfNull = [
+ string[] checkIfNull = [
"if("~var~" is null)",
"{",
" this = null;",
" return;",
"}" ];
- char[][] checkObject = [
+ string[] checkObject = [
""
"//Check if there already is a D object for this gtk struct",
"void* ptr = getDObject(cast(GObject*)"~var~");",
@@ -669,12 +627,12 @@ public class GtkDClass
}
/* Deprecated */ /*
- char[][] assertStructNotNull = [
+ string[] assertStructNotNull = [
];
- private char[][] getAssertStructNotNull(char[] var)
+ private string[] getAssertStructNotNull(string var)
{
- char[][] lines = [
+ string[] lines = [
"version(noAssert)",
"{",
" if ( "~var~" is null )",
@@ -709,24 +667,24 @@ public class GtkDClass
* Params:
* convParms =
*/
- private void addStaticClassCode(ConvParms* convParms, inout char[][] text)
+ private void addStaticClassCode(ConvParms* convParms, ref string[] text)
{
- char[] code;
+ string code;
if ( convParms.isInterface ) code = convParms.interfaceCode;
else code = convParms.classCode;
if ( code.length > 0 )
{
text ~= "";
- foreach ( char[] line ; std.string.splitlines(code))
+ foreach ( string line ; std.string.splitLines(code))
{
text ~= std.string.strip(line);
}
}
}
- private char[] castToParent(char[] var)
+ private string castToParent(string var)
{
return "cast("~parentName~"*)"~var;
}
@@ -738,17 +696,18 @@ public class GtkDClass
* type =
* Returns:
*/
- public static char[] toVar(char[] type)
+ public static string toVar(string type)
{
- if ( type.length > 0 )
- {
- type[0] = std.ctype.tolower(type[0]);
- }
+ if (type.length == 0)
+ return "";
+
+ string p = to!string(toLower(type[0]));
if ( type.endsWith("_t") )
{
- type = type[0..type.length-2];
+ return p ~ type[1 .. $ - 2];
+ } else {
+ return p ~ type[1 .. $];
}
- return type;
}
/**
@@ -758,7 +717,7 @@ public class GtkDClass
* clss = The class name
* Returns:
*/
- private char[] closeClass(ConvParms* convParms)
+ private string closeClass(ConvParms* convParms)
{
if ( tabs.length > 0 )
{
@@ -774,16 +733,16 @@ public class GtkDClass
* clss =
* Returns:
*/
- private char[] getParent()
+ private string getParent()
{
debug(getParent) writefln("getParent for %s ", convParms.outFile);
if ( parentName is null )
{
if ( convParms.extend.length > 0 )
{
- parentName = convParms.extend.dup;
- gtkDParentName = convertClassName(convParms.extend, gtkDParentNamePrefix);
+ parentName = convParms.extend;
+ gtkDParentName = convertClassName(convParms.extend);
}
else
{
@@ -803,9 +762,9 @@ public class GtkDClass
}
if ( i<inLines.length ) writefln("\t getParent first line = %s", inLines[i]);
}
- char[] parent;
- char[] current;
- char[] next;
+ string parent;
+ string current;
+ string next;
if ( i < inLines.length )
{
@@ -815,7 +774,7 @@ public class GtkDClass
current = next;
}
}
- char[] gtkStruct = convParms.strct;
+ string gtkStruct = convParms.strct;
if ( convParms.realStrct.length > 0 )
{
gtkStruct = convParms.realStrct;
@@ -829,24 +788,26 @@ public class GtkDClass
next = inLines[i][6..inLines[i].length];
if ( "GInitiallyUnowned" != next )
{
- current = next.dup;
+ current = next;
debug(getParent) writefln("\t current = %s", current);
}
++i;
}
if ( gtkStruct == current && parent.length>0 )
{
- parentName = parent.dup;
- gtkDParentName = convertClassName(parentName, gtkDParentNamePrefix);
+ parentName = parent;
+ gtkDParentName = convertClassName(parentName);
}
}
}
return parentName;
}
- private char[] convertClassName(char[] gName, inout char[] prefix)
+ private string convertClassName(string gName)
{
- char[] conv;
+ string conv;
+ string prefix;
+
if ( startsWith(gName, "Gtk") ) prefix = "Gtk";
else if ( startsWith(gName, "Gio") ) prefix = "";
else if ( startsWith(gName, "Gdk") ) prefix = "Gdk";
@@ -861,10 +822,10 @@ public class GtkDClass
if ( conv == "Object" ) conv ~= prefix;
if ( prefix == "Pg" ) conv = "Pg" ~ gName[5..gName.length];
- if ( prefix == "cairo") conv = std.string.toupper(gName[6..7]) ~ gName[7..gName.length - 2];
+ if ( prefix == "cairo") conv = std.string.toUpper(gName[6..7]) ~ gName[7..gName.length - 2];
debug(getParent)writefln("convertClassName %s >>> %s", gName, conv);
- prefix = std.string.tolower(prefix);
+ prefix = std.string.toLower(prefix);
//TODO: better way to covert Gio names.
if( prefix == "g" && convParms.outPack == "gio" && conv != "ObjectG" && conv != "TypeModule" && conv != "Boxed" )
@@ -875,6 +836,7 @@ public class GtkDClass
if( prefix == "pg" ) prefix = "pango";
if ( startsWith(gName, "Gio") ) parentName = "G"~ gName[3 .. $];
+ gtkDParentNamePrefix = prefix;
return conv;
}
@@ -884,10 +846,10 @@ public class GtkDClass
* clss =
* Returns:
*/
- private char[] getImplements(ConvParms* convParms, char[] parentName)
+ private string getImplements(ConvParms* convParms, string parentName)
{
- char[] impls;
- foreach ( int count, char[] impl ; convParms.impl )
+ string impls;
+ foreach ( int count, string impl ; convParms.impl )
{
if ( count > 0 || parentName.length > 0)
{
@@ -903,17 +865,17 @@ public class GtkDClass
}
/* TODO */
- private char[][] getProperties()
+ private string[] getProperties()
{
- char[][] text;
+ string[] text;
return text;
}
/* TODO */
- private char[][] getStyleProperties()
+ private string[] getStyleProperties()
{
- char[][] text;
+ string[] text;
return text;
}
@@ -923,9 +885,9 @@ public class GtkDClass
* All the signals
* Returns:
*/
- private char[][] getSignals()
+ private string[] getSignals()
{
- char[][] text;
+ string[] text;
debug(getSignal) writefln("\tgetSignals");
int i = moveToBlockStart("Signal Details", inLines);
@@ -947,21 +909,21 @@ public class GtkDClass
return text;
}
- private char[][] getSignal(inout int i, char[][] lines)
+ private string[] getSignal(ref int i, string[] lines)
{
debug(getSignal) writefln("\tgetSignal %s", lines[i]);
- char[][] text;
- int endPos = std.string.rfind(lines[i], '"');
+ string[] text;
+ int endPos = std.string.lastIndexOf(lines[i], '"');
if ( endPos > 5 )
{
- char[] signalName = lines[i][5..endPos];
+ string signalName = lines[i][5..endPos];
++i;
- char[] funct = getSignalFunctionDeclaration(i, lines);
+ string funct = getSignalFunctionDeclaration(i, lines);
if(!convParms.omitSignal(signalName))
{
- char[][] comments;
+ string[] comments;
if ( wrapper.includeComments )
{
comments ~= "/**";
@@ -974,7 +936,7 @@ public class GtkDClass
//Skip empty lines.
++i;
}
- else if(find(lines[i], ":") == lines[i].length-1)
+ else if(indexOf(lines[i], ":") == lines[i].length-1)
{
//Skip the parameters.
++i;
@@ -994,8 +956,8 @@ public class GtkDClass
Funct fun;
fun.init(funct, convParms);
- char[] gtkDSignal = signalNameToGtkD(signalName);
- char[] delegateDeclaration = fun.getDelegateDeclaration(convParms, 1);
+ string gtkDSignal = signalNameToGtkD(signalName);
+ string delegateDeclaration = fun.getDelegateDeclaration(convParms, 1);
// Removed function "addSignalImports" and replaced it
// with simple "if" block to make sure class local imports
@@ -1005,7 +967,7 @@ public class GtkDClass
{
if ( !convParms.isInterface )
{
- text ~= "int[char[]] connectedSignals;";
+ text ~= "int[string] connectedSignals;";
}
text ~= "";
@@ -1041,12 +1003,12 @@ public class GtkDClass
/*
* Params:
- * text = the char[][] to append the function to.
+ * text = the string[] to append the function to.
* funct = the signal function
* gtkDSignal = the GtkD name for the signal
* dlg = the delegale for this signal
*/
- void addExternCallback(inout char[][] text, Funct fun, char[] gtkDSignal, char[] dlg)
+ void addExternCallback(ref string[] text, Funct fun, string gtkDSignal, string dlg)
{
if ( !convParms.isInterface )
{
@@ -1059,7 +1021,7 @@ public class GtkDClass
else
{
text ~= "extern(C) static void callBack"~gtkDSignal~"("
- ~fun.getCallbackParameters(0, convParms, wrapper.getAliases()).replace("string", "str")
+ ~ std.array.replace(fun.getCallbackParameters(0, convParms, wrapper.getAliases()), "string", "str")
~")";
}
text ~= "{";
@@ -1077,15 +1039,15 @@ public class GtkDClass
}
else
{
- text ~= " dlg("~fun.getCallbackVars(convParms, wrapper.getAliases()).replace("string", "str")~");";
+ text ~= " dlg("~ std.array.replace(fun.getCallbackVars(convParms, wrapper.getAliases()), "string", "str")~");";
text ~= " }";
}
text ~= "}";
text ~= "";
}
}
- void addAddListener(inout char[][] text, char[] signalName, char[] gtkDSignalName, char[] dlg)
+ void addAddListener(ref string[] text, string signalName, string gtkDSignalName, string dlg)
{
text ~= "void addOn"~gtkDSignalName~"("~dlg~" dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)"~iFaceChar;
if ( !convParms.isInterface )
@@ -1134,42 +1096,39 @@ public class GtkDClass
}
}
- public static char[] getClassVar(ConvParms* convParms)
+ public static string getClassVar(ConvParms* convParms)
{
- char[] cv;
-
+ string cv;
if ( convParms.interf.length > 0)
{
- cv = convParms.interf.dup;
- cv[0] = std.ctype.tolower(cv[0]);
+ cv = convParms.interf;
}
else if ( convParms.clss.length > 0 )
{
- cv = convParms.clss.dup;
- cv[0] = std.ctype.tolower(cv[0]);
+ cv = convParms.clss;
}
- return cv;
+ return (cv is null) ? null : (toLower(cv[0 .. 1]) ~ cv[1 .. $]);
}
- private char[] signalNameToGtkD(char[] signalName)
+ private string signalNameToGtkD(string signalName)
{
- char[] signalGtkD;
+ string signalGtkD;
char pc = ' ';
foreach ( int count, char c ; signalName )
{
if ( count == 0 )
{
- signalGtkD ~= std.ctype.toupper(c);
+ signalGtkD ~= std.ascii.toUpper(c);
}
else
{
if ( c!='-' && c!='_' )
{
if ( pc=='-' || pc=='_' )
{
- signalGtkD ~= std.ctype.toupper(c);
+ signalGtkD ~= std.ascii.toUpper(c);
}
else
{
@@ -1193,12 +1152,12 @@ public class GtkDClass
}
- private char[] getSignalFunctionDeclaration(inout int line, char[][] lines)
+ private string getSignalFunctionDeclaration(ref int line, string[] lines)
{
debug(signalFunction)writefln("getSignalFunctionDeclaration");
- char[] funct;
+ string funct;
while ( line<lines.length
- && std.string.find(lines[line], ")")<0
+ && std.string.indexOf(lines[line], ")")<0
)
{
funct ~= lines[line]~ " ";
@@ -1208,7 +1167,7 @@ public class GtkDClass
);
++line;
}
- if ( line<lines.length && std.string.find(lines[line], ")")>0 )
+ if ( line<lines.length && std.string.indexOf(lines[line], ")")>0 )
{
funct ~= lines[line++];
}
@@ -1217,16 +1176,16 @@ public class GtkDClass
- private char[][] getMembers(ConvParms* convParms)
+ private string[] getMembers(ConvParms* convParms)
{
currLine = 0;
getUntil("Details");
- char[][] text;
+ string[] text;
while ( currLine < inLines.length )
{
- char[][] member = getMember(convParms.prefixes);
+ string[] member = getMember(convParms.prefixes);
//Don't add empty members.
if(member.length > 1)
@@ -1242,10 +1201,10 @@ public class GtkDClass
* prefixes = a list of valid prefixes for new members
* (gtk_xxx_).
*/
- private char[][] getMember(char[][] prefixes)
+ private string[] getMember(string[] prefixes)
{
- char[][] lines;
- char[][] member;
+ string[] lines;
+ string[] member;
if ( convParms.text.length > 0 )
{
@@ -1271,7 +1230,7 @@ public class GtkDClass
debug(getMember)
{
writefln("getMember:");
- foreach (char[] line ; lines )
+ foreach (string line ; lines )
{
writefln("\t%s", line);
}
@@ -1346,20 +1305,20 @@ public class GtkDClass
}
- private void collectGTypes(char[][] lines, ConvParms* convParms)
+ private void collectGTypes(string[] lines, ConvParms* convParms)
{
debug(gTypes)writefln("gype lines\n\t%s\n\t%s\n\t%s",lines[0],lines[1],lines[2]);
int defLine = 1;
if ( lines.length > 0
- && std.string.find(lines[defLine],"G_TYPE_MAKE_FUNDAMENTAL")>=0
+ && std.string.indexOf(lines[defLine],"G_TYPE_MAKE_FUNDAMENTAL")>=0
&& endsWith(lines[defLine],")")
- && std.string.find(lines[defLine],"<<") < 0
+ && std.string.indexOf(lines[defLine],"<<") < 0
)
{
- int pos = std.string.find(lines[defLine], "(");
+ int pos = std.string.indexOf(lines[defLine], "(");
if ( pos > 0 )
{
- int posf = std.string.find(lines[defLine], ")");
+ int posf = std.string.indexOf(lines[defLine], ")");
if ( posf>pos )
{
gTypes ~= lines[0][7..lines[0].length]
@@ -1374,17 +1333,17 @@ public class GtkDClass
int stockCurrEnum;
- private void collectStockItems(char[][] lines, ConvParms* convParms)
+ private void collectStockItems(string[] lines, ConvParms* convParms)
{
debug(stockItems)writefln("stock items lines\n\t%s\n\t%s\n\t%s",lines[0],lines[1],lines[2]);
int defLine = 1;
if ( lines.length > 0 && startsWith(lines[defLine],"#define GTK_") )
{
- char[] line = lines[defLine];
- char[] stockID;
- char[] stockValue;
+ string line = lines[defLine];
+ string stockID;
+ string stockValue;
- int pos = std.string.find(line[12..line.length],' ')+12;
+ int pos = std.string.indexOf(line[12..line.length],' ')+12;
debug(stockItems)writefln("pos=%s", pos);
if ( pos > 12 )
{
@@ -1408,7 +1367,7 @@ public class GtkDClass
stockEnums ~= "/**";
while ( ln < lines.length && lines[ln][0] > ' ' )
{
- stockEnums ~= " * "~lines[ln++].dup;
+ stockEnums ~= " * "~lines[ln++];
}
stockEnums ~= " */";
stockEnums ~= stockID~",";
@@ -1424,33 +1383,33 @@ public class GtkDClass
}
- private void collectAliases(char[][] lines, ConvParms* convParms)
+ private void collectAliases(string[] lines, ConvParms* convParms)
{
int pos = 0;
- char[][] tokens = std.string.split(until(pos, lines[1], ';'));
+ string[] tokens = std.string.split(until(pos, lines[1], ';'));
if ( convParms.omitCode(tokens[2]) )
return;
- char[] alis = "public alias " ~ tokens[1] ~ ' ' ~ tokens[2] ~ ';';
+ string alis = "public alias " ~ tokens[1] ~ ' ' ~ tokens[2] ~ ';';
collectedAliases ~= "";
collectedAliases ~= "/**";
int ln = 1;
while ( ln < lines.length && lines[ln][0] > ' ' )
{
- collectedAliases ~= " * "~lines[ln++].dup;
+ collectedAliases ~= " * "~lines[ln++];
}
collectedAliases ~= " */";
collectedAliases ~= stringToGtkD(alis, convParms, wrapper.getAliases());
}
- private char[] getEnumPrefix(char[] enumName, char[] enumEntry)
+ private string getEnumPrefix(string enumName, string enumEntry)
{
debug(enumPrefix)writefln("%s.%s", enumName, enumEntry);
- char[] prefix;
- char[] upper = std.string.toupper(enumName.dup);
+ string prefix;
+ string upper = std.string.toUpper(enumName);
int n = 0;
int e = 0;
@@ -1523,12 +1482,12 @@ public class GtkDClass
return prefix;
}
- private void collectEnums(char[][] lines, ConvParms* convParms)
+ private void collectEnums(string[] lines, ConvParms* convParms)
{
- char[] enumName = lines[0][5..lines[0].length];
- char[] gtkDEnumName;
+ string enumName = lines[0][5..lines[0].length];
+ string gtkDEnumName;
- bool isGdkPrefix(char[] name)
+ bool isGdkPrefix(string name)
{
return
startsWith(enumName, "Gdk")
@@ -1559,9 +1518,9 @@ public class GtkDClass
{
gtkDEnumName = "C" ~ removeUnderscore(enumName[1 .. $-2]);
}
- //char[] enumName = removeUnderscore(lines[0][5..lines[0].length]);
+ //string enumName = removeUnderscore(lines[0][5..lines[0].length]);
debug(enums)writefln("enum %s", enumName);
- char[][] values;
+ string[] values;
// skipp until the start of the enumerations
int pos = 1;
while ( pos<lines.length
@@ -1577,18 +1536,18 @@ public class GtkDClass
bool invalidDEnum = false;
if ( pos<lines.length && lines[pos][0] != '}' )
{
- char[] enumPrefix = getEnumPrefix(enumName, std.string.strip(lines[pos].dup));
+ string enumPrefix = getEnumPrefix(enumName, std.string.strip(lines[pos]));
int prefixLength = enumPrefix.length;
while ( pos<lines.length && lines[pos][0] != '}' )
{
debug(enums)writefln("\tenum line %s", lines[pos]);
- char[] value = lines[pos++].dup.strip().chomp("\\");
+ string value = lines[pos++].strip().chomp("\\");
debug(enums)writefln("\traw %s", value);
value = enumToGtkD(enumName, value, convParms, wrapper);
debug(enums)writefln("\tprocessed %s", value);
- //if ( std.string.find(value, ":") >= 0 )
+ //if ( std.string.indexOf(value, ":") >= 0 )
//{
// invalidDEnum = true;
// debug(structs)writefln("- INVALID >>>%s<<<", value);
@@ -1601,40 +1560,8 @@ public class GtkDClass
}
else
{
-
-
- char[] replace(char[] s, char[] from, char[] to)
- {
- char[] p;
- if ( from.length == 0 )
- {
- p = s.dup;
- }
- else
- {
- int i;
- int istart;
-
- istart = 0;
- while (istart < s.length)
- {
- i = std.string.find(s[istart .. s.length], from);
- if (i == -1)
- {
- p ~= s[istart .. s.length];
- break;
- }
- p ~= s[istart .. istart + i];
- p ~= to;
- istart += i + from.length;
- }
- }
- return p;
- }
-
-
debug(enumPrefix)writefln("\t\t%s", value);
- char[] v = replace(value, enumPrefix, "");
+ string v = std.array.replace(value, enumPrefix, "");
if ( enumName == "cairo_ps_level_t" )
{
v = "LEVEL_"~v;
@@ -1658,16 +1585,6 @@ public class GtkDClass
values ~= v;
- //debug(enumPrefix)writefln("-> %s", value[prefixLength..value.length]);
-// if ( startsWith(value, enumPrefix) )
-// {
-// values ~= value[prefixLength..value.length];
-// }
-// else
-// {
-// values ~= value;
-// debug(enumPrefix)writefln();
-// }
debug(enums)writefln("+ ADDED >>>%s<<<", v);
}
}
@@ -1678,7 +1595,7 @@ public class GtkDClass
collectedEnums ~= "/**";
while ( pos < lines.length && lines[pos] != "<hr>" )
{
- collectedEnums ~= " * "~lines[pos++].dup;
+ collectedEnums ~= " * "~lines[pos++];
}
collectedEnums ~= " */";
}
@@ -1692,7 +1609,7 @@ public class GtkDClass
collectedEnums ~= "public enum "~enumName;
collectedEnums ~= "{";
- foreach ( char[] value ; values )
+ foreach ( string value ; values )
{
debug(enums)writefln("\t\t%s", value);
collectedEnums ~= stringToGtkD(value, convParms, wrapper.getAliases());
@@ -1709,9 +1626,9 @@ public class GtkDClass
}
}
- private void collectUnions(char[][] lines, ConvParms* convParms)
+ private void collectUnions(string[] lines, ConvParms* convParms)
{
- char[] unionName = lines[0][6..lines[0].length];
+ string unionName = lines[0][6..lines[0].length];
foreach ( name; convParms.noStructs )
{
@@ -1727,12 +1644,12 @@ public class GtkDClass
return;
}
debug(unions)writefln("union %s", unionName);
- char[][] values;
+ string[] values;
int pos = 3;
while ( pos<lines.length && lines[pos][0] != '}' )
{
debug(unions)writefln("\tunion line %s", lines[pos]);
- char[] value = std.string.strip(lines[pos++].dup);
+ string value = std.string.strip(lines[pos++]);
debug(unions)writefln("\traw %s", value);
value = stringToGtkD(value, convParms, wrapper.getAliases());
debug(unions)writefln("\tprocessed %s", value);
@@ -1744,15 +1661,15 @@ public class GtkDClass
collectedUnions ~= "/**";
while ( pos < lines.length && lines[pos][0] > ' ' )
{
- collectedUnions ~= " * "~lines[pos++].dup;
+ collectedUnions ~= " * "~lines[pos++];
}
collectedUnions ~= " */";
}
collectedUnions ~= "public struct "~unionName;
collectedUnions ~= "{";
collectedUnions ~= "union";
collectedUnions ~= "{";
- foreach ( char[] value ; values )
+ foreach ( string value ; values )
{
debug(unions)writefln("\t\t%s", value);
collectedUnions ~= value;
@@ -1761,9 +1678,9 @@ public class GtkDClass
collectedUnions ~= "}";
}
- private void collectStructs(char[][] lines, ConvParms* convParms)
+ private void collectStructs(string[] lines, ConvParms* convParms)
{
- char[] structName = lines[0].dup;
+ string structName = lines[0];
if ( startsWith(structName, "struct ") )
{
structName = structName[7..structName.length];
@@ -1780,25 +1697,25 @@ public class GtkDClass
if ( includeStruct )
{
- char[][] structDef; /// all elements of the struct
+ string[] structDef; /// all elements of the struct
int pos = 1;
if ( lines[1][lines[1].length-1] == '{' )
{
++pos;
debug(structs)writefln("collectStructs %s",std.string.strip(lines[pos]));
while ( pos < lines.length && lines[pos][0] != '}' )
{
- structDef ~= lines[pos].dup;
+ structDef ~= lines[pos];
++pos;
}
}
if ( pos < lines.length )
{
collectedStructs ~= "";
- char[] line = lines[pos];
+ string line = lines[pos];
++pos;
- char[] gtkStruct = convParms.realStrct.length > 0
+ string gtkStruct = convParms.realStrct.length > 0
? convParms.realStrct
: convParms.strct;
@@ -1811,7 +1728,7 @@ public class GtkDClass
}
while ( pos < lines.length && lines[pos][0] > ' ' )
{
- collectedStructs ~= " * "~lines[pos++].dup;
+ collectedStructs ~= " * "~lines[pos++];
}
collectedStructs ~= " */";
}
@@ -1837,16 +1754,16 @@ public class GtkDClass
}
}
- void getStructInternals(char[][] structDef, ConvParms* convParms)
+ void getStructInternals(string[] structDef, ConvParms* convParms)
{
- char[] getFunctionPointer(char[] def, inout int i)
+ string getFunctionPointer(string def, inout int i)
{
- char[] funct = std.string.split(def, ";")[0];
- char[] comment = std.string.split(def, ";")[1];
+ string funct = std.string.split(def, ";")[0];
+ string comment = std.string.split(def, ";")[1];
- char[][] splitFunct = std.string.split(funct, "(");
+ string[] splitFunct = std.string.split(funct, "(");
- char[] name = (splitFunct[1][1..$-2] == "ref") ? "doref" : splitFunct[1][1..$-2];
+ string name = (splitFunct[1][1..$-2] == "ref") ? "doref" : splitFunct[1][1..$-2];
return splitFunct[0] ~ " function(" ~ ((splitFunct[2][0..$-1] == "void") ? ")" : splitFunct[2]) ~" "~ name ~";"~ comment;
}
@@ -1858,35 +1775,36 @@ public class GtkDClass
for ( int i; i < structDef.length; i++ )
{
// Remove GSEAL macro
- if ( std.string.find(structDef[i], "GSEAL (") > -1 )
+ if ( std.string.indexOf(structDef[i], "GSEAL (") > -1 )
{
- char[] remove(char[] src, char[] rem)
+ string remove(string src, string rem)
{
- return src[0 .. src.find(rem)] ~ src[src.find(rem) + rem.length .. $];
+ return src[0 .. src.indexOf(rem)] ~ src[src.indexOf(rem) + rem.length .. $];
}
- structDef[i] = structDef[i].remove("GSEAL (").remove(")");
+ structDef[i] = std.array.replace(structDef[i], "GSEAL (", "");
+ structDef[i] = std.array.replace(structDef[i], ")", "");
}
- char[] elem = stringToGtkD(structDef[i], convParms, wrapper.getAliases());
+ string elem = stringToGtkD(structDef[i], convParms, wrapper.getAliases());
- if ( startsWith(elem, "*") && std.string.find(elem, "+/") < elem.length - 2)
- elem = std.string.replace(elem, "/", "\\"); //Some comments are broken
+ if ( startsWith(elem, "*") && std.string.indexOf(elem, "+/") < elem.length - 2)
+ elem = std.array.replace(elem, "/", "\\"); //Some comments are broken
- if ( std.string.find(elem, "unsigned long") == 0)
+ if ( std.string.indexOf(elem, "unsigned long") == 0)
elem = "ulong"~ elem[13..$]; //TODO: posibly use fixtype
- if ( std.string.find(structDef[i], ":") >= 0 && (std.string.find(structDef[i], ":") < std.string.find(structDef[i], "/+*") || std.string.find(structDef[i], "/+*") == -1) )
+ if ( std.string.indexOf(structDef[i], ":") >= 0 && (std.string.indexOf(structDef[i], ":") < std.string.indexOf(structDef[i], "/+*") || std.string.indexOf(structDef[i], "/+*") == -1) )
//Bit fields.
{
if ( !bitField )
{
bitField = true;
- collectedStructs ~= "\tuint bitfield"~ std.string.toString(bitFieldNr) ~";";
+ collectedStructs ~= "\tuint bitfield" ~ to!string(bitFieldNr) ~";";
}
- if (std.string.find(elem, "/+*") > 0 && std.string.find(elem, "+/") < 0)
+ if (std.string.indexOf(elem, "/+*") > 0 && std.string.indexOf(elem, "+/") < 0)
{
- char[][] parts = std.string.split(elem, "/+*");
+ string[] parts = std.string.split(elem, "/+*");
collectedStructs ~= "//" ~ parts[0];
collectedStructs ~= "/+*" ~ parts[1];
}
@@ -1895,73 +1813,73 @@ public class GtkDClass
collectedStructs ~= "//" ~ elem;
}
- bits += std.string.atoi(std.string.split(elem, ":")[1]);
+ bits += to!int(std.string.split(elem, ":")[1]);
if ( bits >= 32)
{
bitField = false;
bitFieldNr++;
bits = 0;
}
}
- else if ( std.string.find(elem, "#") > -1 && std.string.find(elem, "#") < 2 )
+ else if ( std.string.indexOf(elem, "#") > -1 && std.string.indexOf(elem, "#") < 2 )
//Versions.
{
- if ( std.string.find(elem, "#if defined (G_OS_WIN32) GLIB_SIZEOF_VOID_P == 8") > -1 )
+ if ( std.string.indexOf(elem, "#if defined (G_OS_WIN32) GLIB_SIZEOF_VOID_P == 8") > -1 )
{
//GLIB_SIZEOF_VOID_P == 8 means 64 bit. assuming WIN32 is an bad name for just windows.
collectedStructs ~= "version(Win64)";
collectedStructs ~= "{";
}
- if ( std.string.find(elem, "#ifndef") == 0 )
+ if ( std.string.indexOf(elem, "#ifndef") == 0 )
{
collectedStructs ~= "version("~ elem[8..$] ~")";
collectedStructs ~= "{";
}
- else if ( std.string.find(elem, "#else") == 0 )
+ else if ( std.string.indexOf(elem, "#else") == 0 )
{
collectedStructs ~= "}";
collectedStructs ~= "else";
collectedStructs ~= "{";
}
- else if ( std.string.find(elem, "#endif") == 0 )
+ else if ( std.string.indexOf(elem, "#endif") == 0 )
{
collectedStructs ~= "}";
}
}
- else if ( std.string.find(elem, "(") > 0 && !startsWith(elem, "* ") && !startsWith(elem, "/+*") )
+ else if ( std.string.indexOf(elem, "(") > 0 && !startsWith(elem, "* ") && !startsWith(elem, "/+*") )
//Function Pointers.
{
- char[] funct;
+ string funct;
for ( ; i < structDef.length; i++ )
{
funct ~= stringToGtkD(structDef[i], convParms, wrapper.getAliases());
- if ( std.string.find(structDef[i], ");") > 0 )
+ if ( std.string.indexOf(structDef[i], ");") > 0 )
break;
}
collectedStructs ~= "extern(C) " ~ getFunctionPointer(funct, i);
}
- else if( std.string.find(elem, "{") > 0 )
+ else if( std.string.indexOf(elem, "{") > 0 )
//Nested Structs and unions.
{
- char[] structUnion = std.string.split(structDef[i])[0];
+ string structUnion = std.string.split(structDef[i])[0];
int parentCount;
- char[][] def;
+ string[] def;
for ( i++; i < structDef.length; i++ )
{
- if ( std.string.find(structDef[i], "{") > -1 )
+ if ( std.string.indexOf(structDef[i], "{") > -1 )
parentCount++;
- if ( std.string.find(structDef[i], "}") > -1 && parentCount-- == 0)
+ if ( std.string.indexOf(structDef[i], "}") > -1 && parentCount-- == 0)
break;
def ~= stringToGtkD(structDef[i], convParms, wrapper.getAliases());
}
- char[] varName = stringToGtkD(std.string.split(structDef[i])[1][0..$-1], convParms, wrapper.getAliases());
- char[] structName = std.string.toupper(varName)[0..1] ~ varName[1..$];
+ string varName = stringToGtkD(std.string.split(structDef[i])[1][0..$-1], convParms, wrapper.getAliases());
+ string structName = std.string.toUpper(varName)[0..1] ~ varName[1..$];
collectedStructs ~= structUnion ~" "~ structName;
collectedStructs ~= "{";
@@ -1977,7 +1895,7 @@ public class GtkDClass
}
/// hack... we don't have all types (do we?)
- bool isEnum(char[] type)
+ bool isEnum(string type)
{
if ( type == "GdkEventType" )
{
@@ -1986,11 +1904,11 @@ public class GtkDClass
return false;
}
- bool primitiveType(char[] line)
+ bool primitiveType(string line)
{
int p=0;
skipBlank(p, line);
- char[] type = untilBlank(p, line);
+ string type = untilBlank(p, line);
if ( isEnum(type) )
{
return true;
@@ -2003,23 +1921,23 @@ public class GtkDClass
return (type in wrapper.getAliases()) !is null;
}
- public static void skipBlank(inout int p, char[] text)
+ public static void skipBlank(ref int p, string text)
{
while( p<text.length && text[p]<=' ' )
{
++p;
}
}
- public static void skip(inout int p, char[] text, char s)
+ public static void skip(ref int p, string text, char s)
{
while( p<text.length && text[p]==s)
{
++p;
}
}
- public static char[] untilBlank(inout int p, char[] text)
+ public static string untilBlank(ref int p, string text)
{
int start=p;
while ( p<text.length && text[p]>' ')
@@ -2029,17 +1947,17 @@ public class GtkDClass
return text[start..p];
}
- public static char[] untilBlank(inout int p, char[] text, char[] s)
+ public static string untilBlank(ref int p, string text, string s)
{
int start=p;
- while ( p<text.length && text[p]>' ' && std.string.find(s,text[p])<0 )
+ while ( p<text.length && text[p]>' ' && std.string.indexOf(s,text[p])<0 )
{
++p;
}
return text[start..p];
}
- public static char[] until(inout int p, char[] text, char s)
+ public static string until(ref int p, string text, char s)
{
int start=p;
while ( p<text.length && text[p]!=s)
@@ -2049,19 +1967,19 @@ public class GtkDClass
return text[start..p];
}
- public static char[] until(inout int p, char[] text, char[] s)
+ public static string until(ref int p, string text, string s)
{
int start=p;
- while ( p<text.length && std.string.find(s,text[p])<0 )
+ while ( p<text.length && std.string.indexOf(s,text[p])<0 )
{
++p;
}
return text[start..p];
}
- private char[] getFunctionDeclaration(inout int line, char[][] lines)
+ private string getFunctionDeclaration(ref int line, string[] lines)
{
- char[] funct;
+ string funct;
while ( line<lines.length
&& (!endsWith(lines[line], ");")
&& !startsWith(funct, "#define"))
@@ -2089,13 +2007,13 @@ public class GtkDClass
* function, extracted from the documentation.
* prefixes = a list of prefixes to look for in 'lines' (gtk_xxx).
*/
- private char[][] getFunction(char[][] lines, char[][] prefixes)
+ private string[] getFunction(string[] lines, string[] prefixes)
{
- char[][] member;
+ string[] member;
int line = 1;
- char[] funct = getFunctionDeclaration(line, lines);
+ string funct = getFunctionDeclaration(line, lines);
Funct fun;
fun.init(funct, convParms);
@@ -2197,21 +2115,21 @@ public class GtkDClass
// comment
void addComments()
{
- char[][] phraseParams(char[][] comments)
+ string[] phraseParams(string[] comments)
{
- char[][] description;
- char[][] params;
- char[] ret;
+ string[] description;
+ string[] params;
+ string ret;
for(int i; i < comments.length; i++)
{
- if(find(comments[i], ":") == comments[i].length-1 && comments[i].chomp(":").strip() != "Returns" )
+ if(indexOf(comments[i], ":") == comments[i].length-1 && comments[i].chomp(":").strip() != "Returns" )
{
//Get the GtkD name of the param
- char[] param = strip( idsToGtkD(comments[i][0 .. $-1], convParms, wrapper.getAliases()) );
+ string param = strip( idsToGtkD(comments[i][0 .. $-1], convParms, wrapper.getAliases()) );
//If this param is not in the Gtkd Function Skip it.
- if(find(fun.declaration(convParms,wrapper.getAliases()), param) == -1)
+ if(indexOf(fun.declaration(convParms,wrapper.getAliases()), param) == -1)
{
//Loop for multi line descriptons for this param.
while(i+1 < comments.length && stilInParam(comments[i+1]))
@@ -2229,7 +2147,7 @@ public class GtkDClass
i++;
if(firstRun)
{
- params ~= param ~" = "~ stripl(comments[i]);
+ params ~= param ~" = "~ stripLeft(comments[i]);
firstRun = false;
}
else
@@ -2239,7 +2157,7 @@ public class GtkDClass
else if( comments[i].chomp(":").strip() == "Returns" )
{
//Skip return for Constructors.
- if(find(fun.declaration(convParms,wrapper.getAliases()), "this (") > -1)
+ if(indexOf(fun.declaration(convParms,wrapper.getAliases()), "this (") > -1)
{
//Loop for multi line descriptons for this return.
while(i+1 < comments.length && stilInParam(comments[i+1]))
@@ -2257,7 +2175,7 @@ public class GtkDClass
ret ~= " " ~ comments[i].strip();
}
}
- else if(find(comments[i], "See Also") == 0 || find(comments[i], "Property Details") == 0)
+ else if(indexOf(comments[i], "See Also") == 0 || indexOf(comments[i], "Property Details") == 0)
{
//These sections get included with the last function.
break;
@@ -2271,20 +2189,20 @@ public class GtkDClass
if(params.length > 0)
{
- foreach(char[] line; params)
+ foreach(string line; params)
description ~= line;
}
if(ret.length > 0)
description ~= ret;
- if ( find(fun.getExternal(convParms, wrapper.getAliases()), "GError**") > -1
- && find(fun.declaration(convParms,wrapper.getAliases()), "Error") == -1 )
+ if ( indexOf(fun.getExternal(convParms, wrapper.getAliases()), "GError**") > -1
+ && indexOf(fun.declaration(convParms,wrapper.getAliases()), "Error") == -1 )
{
description ~= "Throws: GException on failure.";
}
- if ( find(fun.declaration(convParms,wrapper.getAliases()), "this (") > -1 )
+ if ( indexOf(fun.declaration(convParms,wrapper.getAliases()), "this (") > -1 )
{
description ~= "Throws: ConstructionException GTK+ fails to create the object.";
}
@@ -2294,7 +2212,7 @@ public class GtkDClass
if ( wrapper.includeComments() )
{
- char[][] comments;
+ string[] comments;
while ( line<lines.length )
{
//if ( !tooSoon )
@@ -2307,7 +2225,7 @@ public class GtkDClass
member ~= "/**";
comments = phraseParams(comments);
- foreach(char[] line; comments)
+ foreach(string line; comments)
member ~= " * "~ line;
member ~= " */";
@@ -2323,23 +2241,23 @@ public class GtkDClass
{
if ( !convParms.isInterface )
{
- char[] externalDeclaration = fun.getExternal(convParms, wrapper.getAliases());
+ string externalDeclaration = fun.getExternal(convParms, wrapper.getAliases());
/* Don't add repeated declarations. */
bool addme = true;
- foreach(ref char[] declaration; externalDeclarations)
+ foreach(ref string declaration; externalDeclarations)
{
if(externalDeclaration == declaration){ addme = false; break; }
}
if(addme) externalDeclarations ~= externalDeclaration;
}
// body
- if ( !convParms.omitCode(fun.name) && find(fun.declaration(convParms,wrapper.getAliases()), "...") < 0 )
+ if ( !convParms.omitCode(fun.name) && indexOf(fun.declaration(convParms,wrapper.getAliases()), "...") < 0 )
{
- char[] gtkDDeclaration = fun.declaration(convParms,wrapper.getAliases());
- //char[] gtkDDeclaration = stringToGtkD(rawDeclaration,convParms,wrapper.getAliases());
+ string gtkDDeclaration = fun.declaration(convParms,wrapper.getAliases());
+ //string gtkDDeclaration = stringToGtkD(rawDeclaration,convParms,wrapper.getAliases());
debug(declaration) writefln("Declaration\n\t%s\n\t%s",rawDeclaration, gtkDDeclaration);
addComments();
member ~= gtkDDeclaration~iFaceChar;
@@ -2360,7 +2278,7 @@ public class GtkDClass
// member ~= "return 0;";
// break;
//
-// case "char[]": member ~= "return "";"; break;
+// case "string": member ~= "return "";"; break;
// default: member ~= "return null;"; break;
// }
}
@@ -2384,7 +2302,7 @@ public class GtkDClass
private bool checkIfDupFunction(Funct fun)
{
- char[] signature = fun.convName~'('~fun.getWrapParametersType()~')';
+ string signature = fun.convName~'('~fun.getWrapParametersType()~')';
if ( signature in functionSignatures )
{
writefln("######################## duplicated function %s", signature);
@@ -2404,13 +2322,13 @@ public class GtkDClass
* comments = Line to check.
* Returns: true if we are still in the description of the param.
*/
- bool stilInParam(char[] comments)
+ bool stilInParam(string comments)
{
- return !(find(comments, ":") == comments.length-1 ||
+ return !(indexOf(comments, ":") == comments.length-1 ||
comments.chomp(":").strip() == "Returns" ||
- ( find(comments, "Since 2.") == 0 || find(comments, "Since 1.") == 0) ||
- find(comments, "See Also") == 0 ||
- find(comments, "Property Details") == 0 ||
+ ( indexOf(comments, "Since 2.") == 0 || indexOf(comments, "Since 1.") == 0) ||
+ indexOf(comments, "See Also") == 0 ||
+ indexOf(comments, "Property Details") == 0 ||
comments == "<hr>");
}
@@ -2424,7 +2342,7 @@ public class GtkDClass
private void checkIfGtkStructs(Funct fun)
{
bool found = false;
- void check(char[] type)
+ void check(string type)
{
if ( startsWith(type, 'G')
&& endsWith(type, '*')
@@ -2443,27 +2361,27 @@ public class GtkDClass
// fun.convName~"("~fun.getWrapParametersType()~")"
// );
- char[] strct = type.dup;
- char[] dName = "";
- char[] pack = "";
+ string strct = type;
+ string dName = "";
+ string pack = "";
if ( startsWith(strct, "Gtk") )
{
pack = "gtk";
dName = strct[3..strct.length-1];
- //dName[0] = std.ctype.tolower(dName[0]);
+ //dName[0] = std.ascii.toLower(dName[0]);
}
else if ( startsWith(strct, "Gdk") )
{
pack = "gdk";
dName = strct[3..strct.length-1];
- //dName[0] = std.ctype.tolower(dName[0]);
+ //dName[0] = std.ascii.toLower(dName[0]);
if ( dName == "Pixbuf") pack = "gdkpixbuf";
}
else if ( startsWith(strct, "Gst") )
{
pack = "gstreamer";
dName = strct[3..strct.length-1];
- //dName[0] = std.ctype.tolower(dName[0]);
+ //dName[0] = std.ascii.toLower(dName[0]);
}
else if ( startsWith(strct, "G") )
{
@@ -2522,7 +2440,7 @@ public class GtkDClass
{
check(fun.typeWrap);
}
- foreach ( int count , char[] parm ; fun.parmsWrap )
+ foreach ( int count , string parm ; fun.parmsWrap )
{
if ( count > 0 || parm != convParms.strct~'*' )
{
@@ -2537,24 +2455,23 @@ public class GtkDClass
* convParms = the Conversion parameters
* Returns:
*/
- private char[] getFunction(char[] line, ConvParms* convParms)
+ private string getFunction(string line, ConvParms* convParms)
{
debug(functionType) writefln("\ngetFunction line = %s", line);
// void (*GChildWatchFunc) (GPid pid, gint status, gpointer data);
// public typedef extern(C) void function(int, int, void*) GChildWatchFunc;
- char[] f = "public alias extern(C) ";
+ string f = "public alias extern(C) ";
int pos = 0;
- char[] type = until(pos, line, "(");
+ string type = until(pos, line, "(");
until(pos, line, "*");
skip(pos, line, '*');
- char[] name = until(pos, line, ")");
+ string name = until(pos, line, ")");
if (convParms.omitCode(name)) {
return "";
}
- //adjustTypeName(type, name);
f ~= stringToGtkD(type, convParms, wrapper.getAliases());
f ~= " function (";
@@ -2563,8 +2480,8 @@ public class GtkDClass
skip(pos, line, '(');
skipBlank(pos, line);
- char[] sourceParms = std.string.strip(until(pos, line, ")"));
- char[] parms;
+ string sourceParms = std.string.strip(until(pos, line, ")"));
+ string parms;
if ( sourceParms != "void" )
{
@@ -2579,10 +2496,10 @@ public class GtkDClass
{
parms ~= ", ";
}
- char[] pType = untilBlank(sPos, sourceParms);
+ string pType = untilBlank(sPos, sourceParms);
fixType(pType, sPos, sourceParms);
- char[] pName = until(sPos, sourceParms, ",)");
+ string pName = until(sPos, sourceParms, ",)");