summaryrefslogtreecommitdiffstats
path: root/qtsharp/src/generator/Printer.cs
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2011-12-05 15:55:57 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2011-12-05 15:55:57 -0600
commit9ba04742771370f59740e32e11c5f3a1e6a1b70a (patch)
treec81c34dae2b3b1ea73801bf18a960265dc4207f7 /qtsharp/src/generator/Printer.cs
parent1a96c45b22d01378202d9dc7ed9c47acd30f966e (diff)
downloadtdebindings-9ba04742771370f59740e32e11c5f3a1e6a1b70a.tar.gz
tdebindings-9ba04742771370f59740e32e11c5f3a1e6a1b70a.zip
Initial TQt conversion
Diffstat (limited to 'qtsharp/src/generator/Printer.cs')
-rw-r--r--qtsharp/src/generator/Printer.cs66
1 files changed, 33 insertions, 33 deletions
diff --git a/qtsharp/src/generator/Printer.cs b/qtsharp/src/generator/Printer.cs
index e6243250..c71bed7c 100644
--- a/qtsharp/src/generator/Printer.cs
+++ b/qtsharp/src/generator/Printer.cs
@@ -25,10 +25,10 @@ namespace QtCSharp {
public class Printer {
- QType qtype;
+ TQType qtype;
string tab, directory;
- public Printer (QType qtype, string directory)
+ public Printer (TQType qtype, string directory)
{
this.qtype = qtype;
this.directory = directory;
@@ -44,15 +44,15 @@ namespace QtCSharp {
StreamWriter writer = new StreamWriter(directory + Path.DirectorySeparatorChar +
qtype.Name + ".cs", false, new ASCIIEncoding());
writer.Write(Header);
- writer.Write(StartClass(qtype.Name, qtype.Access, new ArrayList(qtype.QAncestors)));
+ writer.Write(StartClass(qtype.Name, qtype.Access, new ArrayList(qtype.TQAncestors)));
- foreach (QEnum qenum in qtype.QEnums) {
+ foreach (TQEnum qenum in qtype.TQEnums) {
writer.Write(StartEnum(qenum.Name, qenum.Access, qenum.Type));
- writer.Write(Items(qenum.QItems));
+ writer.Write(Items(qenum.TQItems));
writer.Write(EndMember);
}
- foreach (QCtor qctor in qtype.QCtors) {
+ foreach (TQCtor qctor in qtype.TQCtors) {
if (qctor.Throttle) {
} else if (qctor.Inherited) {
writer.Write (WriteInherited (qctor.Name, qctor.Access));
@@ -80,7 +80,7 @@ namespace QtCSharp {
//writer.Write (DisposePublic ());
- foreach (QDCtor qdctor in qtype.QDCtors) {
+ foreach (TQDCtor qdctor in qtype.TQDCtors) {
writer.Write (ImportAttrib);
writer.Write (ImportDCtorCall (qdctor.Name));
}
@@ -88,18 +88,18 @@ namespace QtCSharp {
//writer.Write (DisposeProtected ());
writer.Write (Delete ());
- foreach (QMethod qmethod in qtype.QMethods) {
+ foreach (TQMethod qmethod in qtype.TQMethods) {
if (qmethod.Throttle) {
} else if (!qmethod.Overload) {
writer.Write(ImportAttrib);
if (qmethod.Access == "public" || qmethod.Access == "protected" || qmethod.Access == "internal") {
writer.Write(ImportMethodCall(qtype.Name, qmethod.Name, qmethod.Id, qmethod.PinvokeReturn, qmethod.PinvokeParams));
writer.Write(StartMethod(qmethod.PascalName, qmethod.Access, qmethod.Return, qmethod.CSharpParams));
- writer.Write(MethodCall(qmethod.QStringReturn, qmethod.Boxer, qtype.Name, qmethod.Name, "rawObject", qmethod.Id, qmethod.Return, qmethod.PinvokeCallParams));
+ writer.Write(MethodCall(qmethod.TQStringReturn, qmethod.Boxer, qtype.Name, qmethod.Name, "rawObject", qmethod.Id, qmethod.Return, qmethod.PinvokeCallParams));
} else {
writer.Write(StaticImportMethodCall(qtype.Name, qmethod.Name, qmethod.Id, qmethod.PinvokeReturn, qmethod.PinvokeParams));
writer.Write(StartMethod(qmethod.PascalName, qmethod.Access, qmethod.Return, qmethod.CSharpParams));
- writer.Write(StaticMethodCall(qmethod.QStringReturn, qmethod.Boxer, qtype.Name, qmethod.Name, qmethod.Id, qmethod.Return, qmethod.PinvokeCallParams));
+ writer.Write(StaticMethodCall(qmethod.TQStringReturn, qmethod.Boxer, qtype.Name, qmethod.Name, qmethod.Id, qmethod.Return, qmethod.PinvokeCallParams));
}
writer.Write(EndMember);
} else {
@@ -107,22 +107,22 @@ namespace QtCSharp {
}
}
- foreach (QAncestor qancestor in qtype.QAncestors) {
+ foreach (TQAncestor qancestor in qtype.TQAncestors) {
writer.Write("\n\n"+tab+tab+"// Begin interface methods.\n");
if (qancestor.IsInterface) {
Printer printer = new Printer (qancestor, directory);
- foreach (QMethod qmethod in qancestor.QMethods) {
+ foreach (TQMethod qmethod in qancestor.TQMethods) {
if (qmethod.Throttle) {
} else if (!qmethod.Overload) {
writer.Write(ImportAttrib);
if (qmethod.Access == "public" || qmethod.Access == "protected") {
writer.Write(ImportMethodCall(qancestor.Name, qmethod.Name, qmethod.Id, qmethod.PinvokeReturn, qmethod.PinvokeParams));
writer.Write(StartMethod(qmethod.PascalName, qmethod.Access, qmethod.Return, qmethod.CSharpParams));
- writer.Write(MethodCall(qmethod.QStringReturn, qmethod.Boxer, qancestor.Name, qmethod.Name, qancestor.Name+" ()", qmethod.Id, qmethod.Return, qmethod.PinvokeCallParams));
+ writer.Write(MethodCall(qmethod.TQStringReturn, qmethod.Boxer, qancestor.Name, qmethod.Name, qancestor.Name+" ()", qmethod.Id, qmethod.Return, qmethod.PinvokeCallParams));
} else {
writer.Write(StaticImportMethodCall(qancestor.Name, qmethod.Name, qmethod.Id, qmethod.PinvokeReturn, qmethod.PinvokeParams));
writer.Write(StartMethod(qmethod.PascalName, qmethod.Access, qmethod.Return, qmethod.CSharpParams));
- writer.Write(StaticMethodCall(qmethod.QStringReturn, qmethod.Boxer, qancestor.Name, qmethod.Name, qmethod.Id, qmethod.Return, qmethod.PinvokeCallParams));
+ writer.Write(StaticMethodCall(qmethod.TQStringReturn, qmethod.Boxer, qancestor.Name, qmethod.Name, qmethod.Id, qmethod.Return, qmethod.PinvokeCallParams));
}
writer.Write(EndMember);
} else {
@@ -142,9 +142,9 @@ namespace QtCSharp {
StreamWriter writer = new StreamWriter(directory + Path.DirectorySeparatorChar +
qtype.IName + ".cs", false, new ASCIIEncoding());
writer.Write(Header);
- writer.Write(StartClass(qtype.IName, "public", qtype.QAncestors));
+ writer.Write(StartClass(qtype.IName, "public", qtype.TQAncestors));
- foreach (QMethod qmethod in qtype.QMethods) {
+ foreach (TQMethod qmethod in qtype.TQMethods) {
if (qmethod.Throttle || qmethod.Access == "public static" || qmethod.Access == "protected") {
} else {
writer.Write(IMethod(qmethod.PascalName, qmethod.Return, qmethod.CSharpParams));
@@ -167,7 +167,7 @@ namespace QtCSharp {
sb.Append(tab+access+" class "+name+" : ");
if (qancestors.Count == 0) sb.Append ("QtSupport");
- foreach (QAncestor qancestor in qancestors) {
+ foreach (TQAncestor qancestor in qancestors) {
if (!qancestor.IsInterface) {
if (qancestor.Name == "Qt") {
sb.Append ("QtSupport");
@@ -180,7 +180,7 @@ namespace QtCSharp {
}
}
- foreach (QAncestor qancestor in qancestors) {
+ foreach (TQAncestor qancestor in qancestors) {
if (qancestor.IsInterface) {
sb.Append (", "+qancestor.IName);
}
@@ -205,18 +205,18 @@ namespace QtCSharp {
public string WriteInherited (string name, string access)
{
- return "\n\n"+tab+tab+access+" "+name+" () : this (QNull.Instance) {}";
+ return "\n\n"+tab+tab+access+" "+name+" () : this (TQNull.Instance) {}";
}
public string WriteDummy (string name, string access)
{
- return "\n\n"+tab+tab+access+" "+name+" (QNull dummy) : base (QNull.Instance) {}";
+ return "\n\n"+tab+tab+access+" "+name+" (TQNull dummy) : base (TQNull.Instance) {}";
}
public string WriteBoxer (string name, string access)
{
return "\n\n" +
- tab+tab+access+" "+name+" (IntPtr ptr) : this (QNull.Instance)\n"+tab+tab+"{\n" +
+ tab+tab+access+" "+name+" (IntPtr ptr) : this (TQNull.Instance)\n"+tab+tab+"{\n" +
tab+tab+tab+"rawObject = ptr;\n" +
tab+tab+tab+"RegisterObject(this);\n" +
tab+tab+"}";
@@ -233,7 +233,7 @@ namespace QtCSharp {
public string StartCtor (string name, string access, ArrayList csharpparams)
{
- return "\n"+tab+tab+access+" "+name+" ("+Params(csharpparams)+") : this (QNull.Instance)\n"+tab+tab+"{\n";
+ return "\n"+tab+tab+access+" "+name+" ("+Params(csharpparams)+") : this (TQNull.Instance)\n"+tab+tab+"{\n";
}
public string StartDCtor (string name)
@@ -245,7 +245,7 @@ namespace QtCSharp {
{
string str = "\n"+tab+tab+access+" "+returntype+" "+name+" ("+Params(csharpparams)+")\n"+tab+tab+"{\n";
- // QEvents should never be disposed inside C#
+ // TQEvents should never be disposed inside C#
if (access.IndexOf ("static") <= 0)
str += "\t\t\tif (disposed)\n\t\t\t\tthrow new ObjectDisposedException (this+\": Attempted use of disposed object\");\n\n";
@@ -284,7 +284,7 @@ namespace QtCSharp {
{
int count = 0;
StringBuilder sb = new StringBuilder();
- foreach (QItem qitem in qitems) {
+ foreach (TQItem qitem in qitems) {
count++;
sb.Append("\n"+tab+tab+tab+qitem.Name+" = "+qitem.Value);
if (count != qitems.Count)
@@ -297,7 +297,7 @@ namespace QtCSharp {
{
int count = 0;
StringBuilder sb = new StringBuilder();
- foreach (QParam qparam in qparams) {
+ foreach (TQParam qparam in qparams) {
count++;
if (qparam.Type != "")
sb.Append(qparam.Type+" "+qparam.Name);
@@ -347,13 +347,13 @@ namespace QtCSharp {
public string RawObject (string name, string id, ArrayList qparams)
{
- if (qtype.IsQObject) {
+ if (qtype.IsTQObject) {
ArrayList newparams = new ArrayList ();
- foreach (QParam parm in qparams) {
+ foreach (TQParam parm in qparams) {
//Console.WriteLine ("--> {0}", parm.Name);
if (parm.Name == "parent.RawObject") {
- QParam newparm = parm.Clone() as QParam;
+ TQParam newparm = parm.Clone() as TQParam;
newparm.Name = "parent != null ? parent.RawObject : IntPtr.Zero";
newparams.Add (newparm);
}
@@ -390,7 +390,7 @@ namespace QtCSharp {
string newid = id == "0" ? "" : id;
if (boxer && qstring) {
- ret = "\t\t\treturn new TQString (qt_"+type+"_"+name+newid+" ("+instPtr+comma+Params (qparams)+"));\n";
+ ret = "\t\t\treturn new TTQString (qt_"+type+"_"+name+newid+" ("+instPtr+comma+Params (qparams)+"));\n";
}
else if (boxer) {
ret = "\t\t\treturn LookupObject (qt_"+type+"_"+name+newid+" ("+instPtr+comma+Params (qparams)+"), typeof ("+ReturnType+")) as "+ReturnType+";";
@@ -416,7 +416,7 @@ namespace QtCSharp {
string newid = id == "0" ? "" : id;
if (boxer && qstring) {
- ret = "\t\t\treturn new TQString (qt_"+type+"_"+name+newid+" ("+Params (qparams)+"));\n";
+ ret = "\t\t\treturn new TTQString (qt_"+type+"_"+name+newid+" ("+Params (qparams)+"));\n";
}
else if (boxer) {
ret = "\t\t\treturn LookupObject (qt_"+type+"_"+name+newid+" ("+Params (qparams)+"), typeof ("+ReturnType+")) as "+ReturnType+";\n";
@@ -496,12 +496,12 @@ namespace QtCSharp {
"\t\tinternal override void Delete ()\n" +
"\t\t{\n";
- // Let Qt manage QEvents
+ // Let Qt manage TQEvents
if (! (qtype.Name.StartsWith ("Q") && qtype.Name.EndsWith ("Event")))
{
ret += "\t\t\tif (deleted) return;\n\n";
- if (qtype.QDCtors.Count > 0)
+ if (qtype.TQDCtors.Count > 0)
ret += "\t\t\tqt_del_"+qtype.Name+" (rawObject);\n";
else
ret = "\n" + ret + "\t\t\t// libqtc lacks a qt_del_"+qtype.Name+" function\n";
@@ -517,7 +517,7 @@ namespace QtCSharp {
public string DefaultConnections ()
{
- if (qtype.IsQObject)
+ if (qtype.IsTQObject)
return "\n\t\t\tConnect (this, TQT_SIGNAL (\"destroyed ()\"), TQT_SLOT (\"NativeDestroyed ()\"));";
else
return "";