diff options
Diffstat (limited to 'qtsharp/src/generator/Converter.cs')
-rw-r--r-- | qtsharp/src/generator/Converter.cs | 130 |
1 files changed, 65 insertions, 65 deletions
diff --git a/qtsharp/src/generator/Converter.cs b/qtsharp/src/generator/Converter.cs index 8f6ce3b0..f6bbf06e 100644 --- a/qtsharp/src/generator/Converter.cs +++ b/qtsharp/src/generator/Converter.cs @@ -27,12 +27,12 @@ namespace QtCSharp { public class Converter { ArrayList qtypes; - QType qtype; - QTypeMap qmap; + TQType qtype; + TQTypeMap qmap; StringCollection sigs; StringBuilder sig; - public Converter (ArrayList qtypes, QType qtype, QTypeMap qmap) + public Converter (ArrayList qtypes, TQType qtype, TQTypeMap qmap) { this.qtypes = qtypes; this.qtype = qtype; @@ -45,14 +45,14 @@ namespace QtCSharp { qtype.IsConverted = true; } - public QType GetQType () + public TQType GetTQType () { return qtype; } public void Convert () { - foreach (QCtor qctor in qtype.QCtors) { + foreach (TQCtor qctor in qtype.TQCtors) { qctor.Name = qmap.ReservedType (qctor.Name); if (!qctor.Overload) { ConvertCSharpParams (qctor.CSharpParams); @@ -63,7 +63,7 @@ namespace QtCSharp { } CheckSig (qctor); } - foreach (QMethod qmethod in qtype.QMethods) { + foreach (TQMethod qmethod in qtype.TQMethods) { if (qmethod.Name.StartsWith ("protected_")) qmethod.Name = qmethod.Name.Replace ("protected_", ""); qmethod.Name = qmap.ReservedType (qmethod.Name); @@ -81,10 +81,10 @@ namespace QtCSharp { } } - public void CheckSig (QMethod qmethod) + public void CheckSig (TQMethod qmethod) { sig.Append (qmethod.PascalName); - foreach (QParam qparam in qmethod.CSharpParams) { + foreach (TQParam qparam in qmethod.CSharpParams) { sig.Append (qparam.Type); } if (!sigs.Contains (sig.ToString ()) && !sigs.Contains ("The"+sig.ToString ())) { @@ -96,11 +96,11 @@ namespace QtCSharp { sig.Length = 0; } - public void CheckSig (QCtor qctor) + public void CheckSig (TQCtor qctor) { sig.Append (qctor.Name); - foreach (QParam qparam in qctor.CSharpParams) { - //if (qparam.Type == "TQWidget" && qparam.Name == "parent") + foreach (TQParam qparam in qctor.CSharpParams) { + //if (qparam.Type == "TTQWidget" && qparam.Name == "parent") if (qparam.Name == "parent") qctor.Parent = true; sig.Append (qparam.Type); @@ -116,54 +116,54 @@ namespace QtCSharp { public void ConvertCSharpParams (ArrayList qparams) { - foreach (QParam qparam in qparams) { + foreach (TQParam qparam in qparams) { qparam.Type = qmap.ArrayType (qparam.Type); qparam.Type = StripBad (qparam.Type); qparam.Type = qmap.CSharpType (qparam.Type); - qparam.Type = ConvertQString (qparam.Type); + qparam.Type = ConvertTQString (qparam.Type); qparam.Name = qmap.ReservedType (qparam.Name); } } public void ConvertPinvokeCallParams (ArrayList qparams) { - foreach (QParam qparam in qparams) { + foreach (TQParam qparam in qparams) { qparam.Type = qmap.ArrayType (qparam.Type); qparam.Type = StripBad (qparam.Type); qparam.Type = qmap.CSharpType (qparam.Type); qparam.Name = qmap.ReservedType (qparam.Name); - if (IsQObject (qparam.Type)) + if (IsTQObject (qparam.Type)) qparam.Name = qparam.Name + ".RawObject"; - if (IsIQObject (qparam.Type)) + if (IsITQObject (qparam.Type)) qparam.Name = qparam.Name + "." + StripInterface (qparam.Type) + " ()"; - /* if (IsQString (qparam.Type)) - qparam.Name = "new TQString ("+StripPtr(qparam.Name)+").RawObject";*/ + /* if (IsTQString (qparam.Type)) + qparam.Name = "new TTQString ("+StripPtr(qparam.Name)+").RawObject";*/ qparam.Type = ""; } } public void ConvertPinvokeParams (ArrayList qparams) { - foreach (QParam qparam in qparams) { + foreach (TQParam qparam in qparams) { qparam.Type = qmap.ArrayType (qparam.Type); qparam.Type = StripBad (qparam.Type); qparam.Type = qmap.PinvokeType (qparam.Type); qparam.Name = qmap.ReservedType (qparam.Name); - if (IsQObject (qparam.Type) || IsIQObject (qparam.Type)) + if (IsTQObject (qparam.Type) || IsITQObject (qparam.Type)) qparam.Type = "IntPtr"; } } public void ConvertOverloadParams (ArrayList qparams) { - foreach (QParam qparam in qparams) { + foreach (TQParam qparam in qparams) { qparam.Type = qmap.ArrayType (qparam.Type); qparam.Type = StripBad (qparam.Type); qparam.Type = qmap.CSharpType (qparam.Type); OverloadedLastParam (qparam, qparams); OverloadedNull (qparam); - OverloadedQString (qparam); - OverloadedQObject (qparam); + OverloadedTQString (qparam); + OverloadedTQObject (qparam); OverloadedNestedEnum (qparam); OverloadedNullString (qparam); OverloadedBool (qparam); @@ -174,23 +174,23 @@ namespace QtCSharp { } } - public void OverloadedLastParam (QParam qparam, ArrayList qparams) + public void OverloadedLastParam (TQParam qparam, ArrayList qparams) { if (qparams.IndexOf (qparam) != qparams.Count - 1) qparam.Default = null; } - public void OverloadedNull (QParam qparam) + public void OverloadedNull (TQParam qparam) { if (qparam.Default == null) qparam.Type = ""; } - public void OverloadedQString (QParam qparam) + public void OverloadedTQString (TQParam qparam) { - if (IsQString (qparam.Type)){ - qparam.Type = "TQString"; - if (qparam.Default == "TQString::null") + if (IsTQString (qparam.Type)){ + qparam.Type = "TTQString"; + if (qparam.Default == "TTQString::null") qparam.Default = "null"; else if (qparam.Default == "quotquot") qparam.Default = "null"; @@ -199,19 +199,19 @@ namespace QtCSharp { } } - public void OverloadedQObject (QParam qparam) + public void OverloadedTQObject (TQParam qparam) { - if (IsQObject (qparam.Type)) { + if (IsTQObject (qparam.Type)) { qparam.Name = "new "+qparam.Type+" ()"; qparam.Type = ""; } } - public void OverloadedNestedEnum (QParam qparam) + public void OverloadedNestedEnum (TQParam qparam) { - foreach (QEnum qenum in qtype.QEnums) { + foreach (TQEnum qenum in qtype.TQEnums) { if (qparam.Type == qenum.Name) { - foreach (QItem qitem in qenum.QItems) { + foreach (TQItem qitem in qenum.TQItems) { if (qparam.Default == qitem.Name) { qparam.Name = qparam.Type+"."+qparam.Default; qparam.Type = ""; @@ -221,7 +221,7 @@ namespace QtCSharp { } } - public void OverloadedNullString (QParam qparam) + public void OverloadedNullString (TQParam qparam) { if (qmap.OverloadType (qparam.Type) == "string" && qparam.Default == "0") { qparam.Type = ""; @@ -229,7 +229,7 @@ namespace QtCSharp { } } - public void OverloadedBool (QParam qparam) + public void OverloadedBool (TQParam qparam) { if (qparam.Default == "TRUE") { qparam.Type = ""; @@ -246,7 +246,7 @@ namespace QtCSharp { } } - public void OverloadedEnum (QParam qparam) + public void OverloadedEnum (TQParam qparam) { if (IsEnum (qparam.Type)) { qparam.Name = qparam.Type + "." + EnumValue (qparam.Type, qparam.Default); @@ -254,7 +254,7 @@ namespace QtCSharp { } } - public void OverloadedArray (QParam qparam) + public void OverloadedArray (TQParam qparam) { if (IsArray (qparam.Type)) { qparam.Name = "new "+qparam.Type+"{"+qparam.Default+"}"; @@ -262,13 +262,13 @@ namespace QtCSharp { } } - public void OverloadedHex (QParam qparam) + public void OverloadedHex (TQParam qparam) { if (qparam.Default == "0xffffffff") qparam.Default = "1"; } - public void OverloadedDefault (QParam qparam) + public void OverloadedDefault (TQParam qparam) { if (qparam.Type != "") { qparam.Type = "("+qmap.OverloadType (qparam.Type)+")"; @@ -276,18 +276,18 @@ namespace QtCSharp { } } - public void ConvertReturnType (QMethod qmethod) + public void ConvertReturnType (TQMethod qmethod) { qmethod.Return = qmap.ArrayType (qmethod.Return); qmethod.Return = qmap.PinvokeType (StripBad (qmethod.Return)); - if (IsQObject(qmethod.Return)) { + if (IsTQObject(qmethod.Return)) { qmethod.Boxer = true; qmethod.PinvokeReturn = "IntPtr"; } else { qmethod.PinvokeReturn = qmethod.Return; } - if (qmethod.Return == "TQString") { - qmethod.QStringReturn = true; + if (qmethod.Return == "TTQString") { + qmethod.TQStringReturn = true; } } @@ -309,10 +309,10 @@ namespace QtCSharp { return str; } - public string ConvertQString (string str) + public string ConvertTQString (string str) { - if (IsQString (str)) - return "TQString"; + if (IsTQString (str)) + return "TTQString"; else return str; } @@ -344,7 +344,7 @@ namespace QtCSharp { public string ToPascalCase (string name) { string pascal = System.Char.ToUpper (name[0]).ToString ()+name.Substring (1, name.Length -1); - foreach (QEnum qenum in qtype.QEnums) { + foreach (TQEnum qenum in qtype.TQEnums) { if (pascal == qenum.Name) pascal = "The"+pascal; } @@ -358,16 +358,16 @@ namespace QtCSharp { value = StripEnum (value); // There _has_ to be a better way, but I'm tired... - foreach (QType qtype in qtypes) { - foreach (QEnum qenum in qtype.QEnums) { + foreach (TQType qtype in qtypes) { + foreach (TQEnum qenum in qtype.TQEnums) { if (enumname == qenum.Name) { - foreach (QItem qitem in qenum.QItems) { + foreach (TQItem qitem in qenum.TQItems) { if (value == qitem.Name) { match = true; } } if (!match) { - foreach (QItem qitem in qenum.QItems) { + foreach (TQItem qitem in qenum.TQItems) { value = qitem.Name; break; } @@ -380,22 +380,22 @@ namespace QtCSharp { public void Ancestors () { - if (qtype.IsInterface || qtype.QAncestors.Count < 2) + if (qtype.IsInterface || qtype.TQAncestors.Count < 2) return; string iname = ""; - foreach (QAncestor qancestor in qtype.QAncestors) { + foreach (TQAncestor qancestor in qtype.TQAncestors) { iname = qmap.InterfaceType (qancestor.Name); - foreach (QType _qtype in qtypes) { + foreach (TQType _qtype in qtypes) { if (_qtype.Name == qancestor.Name && iname != qancestor.Name) { if (!_qtype.IsConverted) { Converter converter = new Converter (qtypes, _qtype, qmap); } - qtype.AddQMethod (instPointer (qancestor.Name)); - qancestor.QMethods = _qtype.QMethods; + qtype.AddTQMethod (instPointer (qancestor.Name)); + qancestor.TQMethods = _qtype.TQMethods; qancestor.IsInterface = true; qancestor.IName = iname; - foreach (QMethod qmethod in qancestor.QMethods) { + foreach (TQMethod qmethod in qancestor.TQMethods) { CheckSig (qmethod); } } @@ -403,9 +403,9 @@ namespace QtCSharp { } } - public QMethod instPointer (string name) + public TQMethod instPointer (string name) { - QMethod qmethod = new QMethod (); + TQMethod qmethod = new TQMethod (); qmethod.Name = name; qmethod.PascalName = name; qmethod.Access = "public"; @@ -415,17 +415,17 @@ namespace QtCSharp { return qmethod; } - public bool IsQString (string str) + public bool IsTQString (string str) { - if (qtype.Name == "TQString") + if (qtype.Name == "TTQString") return true; - else if (IsQObject (str) && str == "TQString") + else if (IsTQObject (str) && str == "TTQString") return true; else return false; } - public bool IsQObject (string str) + public bool IsTQObject (string str) { //IndexOf is a hack to search for a char ;-) if (str.StartsWith ("Q") && str.IndexOf (".") < 0) @@ -434,7 +434,7 @@ namespace QtCSharp { return false; } - public bool IsIQObject (string str) + public bool IsITQObject (string str) { //IndexOf is a hack to search for a char ;-) if (str == "IntPtr") return false; |