diff --git a/ChangeLog b/ChangeLog index af15399b5..427ae54d1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,26 @@ +2003-05-18 Mike Kestner + + * generator/CallbackGen.cs : use non-static symtab, kill doc comments + * generator/ClassBase.cs : use non-static symtab + * generator/CodeGenerator.cs : use non-static symtab + * generator/EnumGen.cs : kill doc comments, don't gen using System here + * generator/GenBase.cs : gen using System here for all types + * generator/InterfaceGen.cs : don't gen using System here. + * generator/Method.cs : use non-static symtab + * generator/ObjectGen.cs : kill doc comments, use non-static symtab + * generator/OpaqueGen.cs : don't gen using System here. + * generator/Parameters.cs : use non static symtab. + * generator/Parser.cs : use non static symtab. add SimpleGen's and + ManualGen's + * generator/Property.cs : use non static symtab + * generator/SignalHandler.cs : use non static symtab + * generator/StructBase.cs : use non static symtab + * generator/SymbolTable.cs : major refactoring. now uses SimpleGen and + ManualGen IGeneratables to simplify the method and prop code. Is now + instance based with a static prop to get the singleton instance, so that + a this indexer can be provided to access the IGeneratables nicely. Gearing + up to remove even more code from here by accessing IGeneratables directly. + 2003-05-18 Mike Kestner * generator/ClassBase.cs : Use QualifiedName in spew diff --git a/generator/CallbackGen.cs b/generator/CallbackGen.cs index 88b0cdff9..90829a519 100644 --- a/generator/CallbackGen.cs +++ b/generator/CallbackGen.cs @@ -83,22 +83,24 @@ namespace GtkSharp.Generation { sig = parms.Signature; } + SymbolTable table = SymbolTable.Table; + XmlElement ret_elem = Elem["return-type"]; string rettype = ret_elem.GetAttribute("type"); - string m_ret = SymbolTable.GetMarshalReturnType (rettype); - string s_ret = SymbolTable.GetCSType (rettype); - ClassBase ret_wrapper = SymbolTable.GetClassGen (rettype); + string m_ret = table.GetMarshalReturnType (rettype); + string s_ret = table.GetCSType (rettype); + ClassBase ret_wrapper = table.GetClassGen (rettype); sw.WriteLine ("\tinternal delegate " + m_ret + " " + wrapper + "(" + import_sig + ");"); sw.WriteLine (); sw.WriteLine ("\tpublic class " + Name + "Wrapper : GLib.DelegateWrapper {"); if (m_ret != "void") { - if (SymbolTable.IsEnum (rettype)) { + if (table.IsEnum (rettype)) { sw.WriteLine ("\t\tstatic int _dummy;"); } else if (ret_wrapper != null && (ret_wrapper is ObjectGen || ret_wrapper is OpaqueGen)) { // Do nothing - } else if (!SymbolTable.IsStruct (rettype) && !SymbolTable.IsBoxed (rettype)) { + } else if (!table.IsStruct (rettype) && !table.IsBoxed (rettype)) { sw.WriteLine ("\t\tstatic {0} _dummy;", s_ret); } } @@ -108,7 +110,7 @@ namespace GtkSharp.Generation { sw.WriteLine ("\t\tpublic " + m_ret + " NativeCallback (" + import_sig + ")"); sw.WriteLine ("\t\t{"); sw.Write ("\t\t\tif (RemoveIfNotAlive ()) return "); - if (SymbolTable.IsStruct (rettype) || SymbolTable.IsBoxed (rettype)) + if (table.IsStruct (rettype) || table.IsBoxed (rettype)) sw.WriteLine ("IntPtr.Zero;"); else if (ret_wrapper != null && (ret_wrapper is ObjectGen || ret_wrapper is OpaqueGen)) sw.WriteLine ("IntPtr.Zero;"); @@ -134,9 +136,9 @@ namespace GtkSharp.Generation { string cstype = parms[i].CSType; // FIXME: Too much code copy/pasted here. Refactor? - ClassBase parm_wrapper = SymbolTable.GetClassGen (ctype); - sw.WriteLine("\t\t\t_args[" + idx + "] = " + SymbolTable.FromNative (ctype, parm_name) + ";"); - if ((parm_wrapper != null && ((parm_wrapper is OpaqueGen))) || SymbolTable.IsManuallyWrapped (ctype)) { + ClassBase parm_wrapper = table.GetClassGen (ctype); + sw.WriteLine("\t\t\t_args[" + idx + "] = " + table.FromNative (ctype, parm_name) + ";"); + if ((parm_wrapper != null && ((parm_wrapper is OpaqueGen))) || table.IsManuallyWrapped (ctype)) { sw.WriteLine("\t\t\tif (_args[" + idx + "] == null)"); sw.WriteLine("\t\t\t\t_args[{0}] = new {1}({2});", idx, cstype, parm_name); } @@ -153,11 +155,11 @@ namespace GtkSharp.Generation { if (m_ret != "void") { if (ret_wrapper != null && (ret_wrapper is ObjectGen || ret_wrapper is OpaqueGen)) sw.WriteLine ("return (({0}) {1}).Handle;", s_ret, invoke); - else if (SymbolTable.IsStruct (rettype) || SymbolTable.IsBoxed (rettype)) { + else if (table.IsStruct (rettype) || table.IsBoxed (rettype)) { // Shoot. I have no idea what to do here. sw.WriteLine ("return IntPtr.Zero;"); } - else if (SymbolTable.IsEnum (rettype)) + else if (table.IsEnum (rettype)) sw.WriteLine ("return (int) {0};", invoke); else sw.WriteLine ("return ({0}) {1};", s_ret, invoke); @@ -196,8 +198,10 @@ namespace GtkSharp.Generation { return; } + SymbolTable table = SymbolTable.Table; + string rettype = ret_elem.GetAttribute("type"); - string s_ret = SymbolTable.GetCSType (rettype); + string s_ret = table.GetCSType (rettype); if (s_ret == "") { Console.WriteLine("rettype: " + rettype + " in callback " + CName); Statistics.ThrottledCount++; diff --git a/generator/ClassBase.cs b/generator/ClassBase.cs index cc81979b5..a40993167 100644 --- a/generator/ClassBase.cs +++ b/generator/ClassBase.cs @@ -38,7 +38,7 @@ namespace GtkSharp.Generation { public ClassBase Parent { get { string parent = Elem.GetAttribute("parent"); - return SymbolTable.GetClassGen(parent); + return SymbolTable.Table.GetClassGen(parent); } } @@ -250,7 +250,7 @@ namespace GtkSharp.Generation { if (check_self && p == null && interfaces != null) { foreach (string iface in interfaces) { - ClassBase igen = SymbolTable.GetClassGen (iface); + ClassBase igen = SymbolTable.Table.GetClassGen (iface); p = igen.GetMethodRecursively (name, true); if (p != null) break; @@ -287,7 +287,7 @@ namespace GtkSharp.Generation { if (check_self && p == null && interfaces != null) { foreach (string iface in interfaces) { - ClassBase igen = SymbolTable.GetClassGen (iface); + ClassBase igen = SymbolTable.Table.GetClassGen (iface); p = igen.GetSignalRecursively (name, true); if (p != null) break; diff --git a/generator/CodeGenerator.cs b/generator/CodeGenerator.cs index f233b4282..ea97f07bc 100644 --- a/generator/CodeGenerator.cs +++ b/generator/CodeGenerator.cs @@ -32,10 +32,8 @@ namespace GtkSharp.Generation { Parser p = new Parser (arg); p.Parse (generate); } - - Console.WriteLine (SymbolTable.Count + " types parsed."); - foreach (IGeneratable gen in SymbolTable.Generatables) { + foreach (IGeneratable gen in SymbolTable.Table.Generatables) { gen.Generate (); } diff --git a/generator/EnumGen.cs b/generator/EnumGen.cs index da4f17742..32ed0612e 100644 --- a/generator/EnumGen.cs +++ b/generator/EnumGen.cs @@ -50,16 +50,9 @@ namespace GtkSharp.Generation { StreamWriter sw = CreateWriter (); if (Elem.GetAttribute("type") == "flags") { - sw.WriteLine ("\tusing System;"); sw.WriteLine (); - } - - sw.WriteLine("\t\t/// " + Name + " enumeration "); - sw.WriteLine("\t\t/// "); - sw.WriteLine("\t\t/// "); - - if (Elem.GetAttribute("type") == "flags") sw.WriteLine ("\t[Flags]"); + } // Ok, this is obscene. We need to go through the enums first // to find "large" values. If we find some, we need to change diff --git a/generator/GenBase.cs b/generator/GenBase.cs index 095f9e906..2ece3873c 100644 --- a/generator/GenBase.cs +++ b/generator/GenBase.cs @@ -82,6 +82,8 @@ namespace GtkSharp.Generation { sw.WriteLine (); sw.WriteLine ("namespace " + NS + " {"); sw.WriteLine (); + sw.WriteLine ("\tusing System;"); + sw.WriteLine (); return sw; } diff --git a/generator/InterfaceGen.cs b/generator/InterfaceGen.cs index 6772ae813..e1b2842f9 100644 --- a/generator/InterfaceGen.cs +++ b/generator/InterfaceGen.cs @@ -21,9 +21,6 @@ namespace GtkSharp.Generation { StreamWriter sw = CreateWriter (); - sw.WriteLine ("\tusing System;"); - sw.WriteLine (); - sw.WriteLine ("#region Autogenerated code"); sw.WriteLine ("\tpublic interface " + Name + " : GLib.IWrapper {"); sw.WriteLine (); diff --git a/generator/Method.cs b/generator/Method.cs index 7846d2408..2f9799039 100644 --- a/generator/Method.cs +++ b/generator/Method.cs @@ -148,9 +148,11 @@ namespace GtkSharp.Generation { return false; } + SymbolTable table = SymbolTable.Table; + rettype = ret_elem.GetAttribute("type"); - m_ret = SymbolTable.GetMarshalReturnType(rettype); - s_ret = SymbolTable.GetCSType(rettype); + m_ret = table.GetMarshalReturnType(rettype); + s_ret = table.GetCSType(rettype); cname = elem.GetAttribute("cname"); if (ret_elem.HasAttribute("element_type")) element_type = ret_elem.GetAttribute("element_type"); @@ -385,17 +387,19 @@ namespace GtkSharp.Generation { if (parms != null) parms.Initialize(sw, is_get, is_set, indent); + SymbolTable table = SymbolTable.Table; + sw.Write(indent + "\t\t\t"); if (m_ret == "void") { sw.WriteLine(cname + call + ";"); } else { - if (SymbolTable.IsObject (rettype) || SymbolTable.IsOpaque (rettype)) + if (table.IsObject (rettype) || table.IsOpaque (rettype)) { sw.WriteLine(m_ret + " raw_ret = " + cname + call + ";"); - sw.WriteLine(indent +"\t\t\t" + s_ret + " ret = " + SymbolTable.FromNativeReturn(rettype, "raw_ret") + ";"); + sw.WriteLine(indent +"\t\t\t" + s_ret + " ret = " + table.FromNativeReturn(rettype, "raw_ret") + ";"); if (needs_ref) sw.WriteLine(indent + "\t\t\tret.Ref ();"); - if (SymbolTable.IsOpaque (rettype)) + if (table.IsOpaque (rettype)) sw.WriteLine(indent + "\t\t\tif (ret == null) ret = new " + s_ret + "(raw_ret);"); } else { @@ -404,7 +408,7 @@ namespace GtkSharp.Generation { string raw_parms = "raw_ret"; if (element_type != null) raw_parms += ", typeof (" + element_type + ")"; - sw.WriteLine(s_ret + " ret = " + SymbolTable.FromNativeReturn(rettype, raw_parms) + ";"); + sw.WriteLine(s_ret + " ret = " + table.FromNativeReturn(rettype, raw_parms) + ";"); } } diff --git a/generator/ObjectGen.cs b/generator/ObjectGen.cs index ee13c8689..2c7412e63 100644 --- a/generator/ObjectGen.cs +++ b/generator/ObjectGen.cs @@ -58,25 +58,22 @@ namespace GtkSharp.Generation { StreamWriter sw = CreateWriter (); - sw.WriteLine ("\tusing System;"); sw.WriteLine ("\tusing System.Collections;"); sw.WriteLine ("\tusing System.Runtime.InteropServices;"); sw.WriteLine (); - sw.WriteLine("\t\t/// " + Name + " Class"); - sw.WriteLine("\t\t/// "); - sw.WriteLine("\t\t/// "); + SymbolTable table = SymbolTable.Table; sw.WriteLine ("#region Autogenerated code"); sw.Write ("\tpublic class " + Name); - string cs_parent = SymbolTable.GetCSType(Elem.GetAttribute("parent")); + string cs_parent = table.GetCSType(Elem.GetAttribute("parent")); if (cs_parent != "") sw.Write (" : " + cs_parent); if (interfaces != null) { foreach (string iface in interfaces) { if (Parent != null && Parent.Implements (iface)) continue; - sw.Write (", " + SymbolTable.GetCSType (iface)); + sw.Write (", " + table.GetCSType (iface)); } } sw.WriteLine (" {"); @@ -88,7 +85,7 @@ namespace GtkSharp.Generation { bool has_sigs = (sigs != null); if (!has_sigs) { foreach (string iface in interfaces) { - ClassBase igen = SymbolTable.GetClassGen (iface); + ClassBase igen = table.GetClassGen (iface); if (igen.Signals != null) { has_sigs = true; break; @@ -108,7 +105,7 @@ namespace GtkSharp.Generation { Hashtable all_methods = new Hashtable (); Hashtable collisions = new Hashtable (); foreach (string iface in interfaces) { - ClassBase igen = SymbolTable.GetClassGen (iface); + ClassBase igen = table.GetClassGen (iface); foreach (Method m in igen.Methods.Values) { if (all_methods.Contains (m.Name)) collisions[m.Name] = true; @@ -120,7 +117,7 @@ namespace GtkSharp.Generation { foreach (string iface in interfaces) { if (Parent != null && Parent.Implements (iface)) continue; - ClassBase igen = SymbolTable.GetClassGen (iface); + ClassBase igen = table.GetClassGen (iface); igen.GenMethods (sw, collisions, this, false); igen.GenSignals (sw, this); } diff --git a/generator/OpaqueGen.cs b/generator/OpaqueGen.cs index 0b05f8a70..2d39ead86 100644 --- a/generator/OpaqueGen.cs +++ b/generator/OpaqueGen.cs @@ -34,7 +34,6 @@ namespace GtkSharp.Generation { StreamWriter sw = CreateWriter (); - sw.WriteLine ("\tusing System;"); sw.WriteLine ("\tusing System.Collections;"); sw.WriteLine ("\tusing System.Runtime.InteropServices;"); sw.WriteLine (); diff --git a/generator/Parameters.cs b/generator/Parameters.cs index bc4b06885..66937cb05 100644 --- a/generator/Parameters.cs +++ b/generator/Parameters.cs @@ -30,7 +30,7 @@ namespace GtkSharp.Generation { public string CSType { get { - string cstype = SymbolTable.GetCSType( elem.GetAttribute("type")); + string cstype = SymbolTable.Table.GetCSType( elem.GetAttribute("type")); if (cstype == "void") cstype = "System.IntPtr"; if (elem.HasAttribute("array")) { @@ -56,7 +56,7 @@ namespace GtkSharp.Generation { public string MarshalType { get { - string type = SymbolTable.GetMarshalType( elem.GetAttribute("type")); + string type = SymbolTable.Table.GetMarshalType( elem.GetAttribute("type")); if (type == "void") type = "System.IntPtr"; if (elem.HasAttribute("array")) { @@ -191,7 +191,7 @@ namespace GtkSharp.Generation { Parameter p = new Parameter (p_elem); if ((p.CSType == "") || (p.Name == "") || - (p.MarshalType == "") || (SymbolTable.CallByName(p.CType, p.Name) == "")) { + (p.MarshalType == "") || (SymbolTable.Table.CallByName(p.CType, p.Name) == "")) { Console.Write("Name: " + p.Name + " Type: " + p.CType + " "); return false; } @@ -208,6 +208,7 @@ namespace GtkSharp.Generation { bool last_was_user_data = false; bool has_user_data = false; + SymbolTable table = SymbolTable.Table; int len = 0; Parameter last_param = null; foreach (XmlNode parm in elem.ChildNodes) { @@ -250,14 +251,14 @@ namespace GtkSharp.Generation { call_parm_name = "value"; string call_parm; - if (SymbolTable.IsCallback (type)) { + if (table.IsCallback (type)) { has_callback = true; - call_parm = SymbolTable.CallByName (type, call_parm_name + "_wrapper"); + call_parm = table.CallByName (type, call_parm_name + "_wrapper"); } else - call_parm = SymbolTable.CallByName(type, call_parm_name); + call_parm = table.CallByName(type, call_parm_name); - if (p_elem.HasAttribute ("null_ok") && cs_type != "IntPtr" && cs_type != "System.IntPtr" && !SymbolTable.IsStruct (type)) - call_parm = String.Format ("({0} != null) ? {1} : {2}", call_parm_name, call_parm, SymbolTable.IsCallback (type) ? "null" : "IntPtr.Zero"); + if (p_elem.HasAttribute ("null_ok") && cs_type != "IntPtr" && cs_type != "System.IntPtr" && !table.IsStruct (type)) + call_parm = String.Format ("({0} != null) ? {1} : {2}", call_parm_name, call_parm, table.IsCallback (type) ? "null" : "IntPtr.Zero"); if (p_elem.HasAttribute("array")) call_parm = call_parm.Replace ("ref ", ""); @@ -289,7 +290,7 @@ namespace GtkSharp.Generation { call_string += pass_as + " "; } - if (SymbolTable.IsEnum (type)) + if (table.IsEnum (type)) call_parm = name + "_as_int"; } else if (type == "GError**") @@ -340,6 +341,8 @@ namespace GtkSharp.Generation { { string name = ""; + SymbolTable table = SymbolTable.Table; + foreach (XmlNode parm in elem.ChildNodes) { if (parm.Name != "parameter") { continue; @@ -361,11 +364,11 @@ namespace GtkSharp.Generation { sw.WriteLine (indent + "\t\t\t" + type + " " + name + ";"); } - if ((is_get || (p_elem.HasAttribute("pass_as") && p_elem.GetAttribute ("pass_as") == "out")) && (SymbolTable.IsObject (c_type) || SymbolTable.IsOpaque (c_type) || type == "GLib.Value")) { + if ((is_get || (p_elem.HasAttribute("pass_as") && p_elem.GetAttribute ("pass_as") == "out")) && (table.IsObject (c_type) || table.IsOpaque (c_type) || type == "GLib.Value")) { sw.WriteLine(indent + "\t\t\t" + name + " = new " + type + "();"); } - if (p_elem.HasAttribute("pass_as") && p_elem.GetAttribute ("pass_as") == "out" && SymbolTable.IsEnum (c_type)) { + if (p_elem.HasAttribute("pass_as") && p_elem.GetAttribute ("pass_as") == "out" && table.IsEnum (c_type)) { sw.WriteLine(indent + "\t\t\tint " + name + "_as_int;"); } } @@ -390,7 +393,7 @@ namespace GtkSharp.Generation { name = p.Name; } - if (SymbolTable.IsCallback (c_type)) { + if (table.IsCallback (c_type)) { type = type.Replace(".", "Sharp.") + "Wrapper"; sw.WriteLine (indent + "\t\t\t{0} {1}_wrapper = null;", type, name); @@ -417,7 +420,7 @@ namespace GtkSharp.Generation { string name = p.Name; string type = p.CSType; - if (p_elem.HasAttribute("pass_as") && p_elem.GetAttribute ("pass_as") == "out" && SymbolTable.IsEnum (c_type)) { + if (p_elem.HasAttribute("pass_as") && p_elem.GetAttribute ("pass_as") == "out" && SymbolTable.Table.IsEnum (c_type)) { sw.WriteLine(indent + "\t\t\t" + name + " = (" + type + ") " + name + "_as_int;"); } } @@ -500,7 +503,7 @@ namespace GtkSharp.Generation { if (parm.Name != "parameter") continue; XmlElement p_elem = (XmlElement) parm; - return SymbolTable.GetCSType(p_elem.GetAttribute ("type")); + return SymbolTable.Table.GetCSType(p_elem.GetAttribute ("type")); } return null; } diff --git a/generator/Parser.cs b/generator/Parser.cs index dae7364f9..dc317a64c 100644 --- a/generator/Parser.cs +++ b/generator/Parser.cs @@ -77,7 +77,7 @@ namespace GtkSharp.Generation { string atype = elem.GetAttribute("type"); if ((aname == "") || (atype == "")) continue; - SymbolTable.AddAlias (aname, atype); + SymbolTable.Table.AddAlias (aname, atype); break; case "boxed": @@ -117,7 +117,7 @@ namespace GtkSharp.Generation { if (igen != null) { igen.DoGenerate = generate; - SymbolTable.AddType (igen); + SymbolTable.Table.AddType (igen); } } } @@ -129,9 +129,9 @@ namespace GtkSharp.Generation { string name = symbol.GetAttribute ("name"); if (type == "simple") - SymbolTable.AddSimpleType (cname, name); + SymbolTable.Table.AddType (new SimpleGen (cname, name)); else if (type == "manual") - SymbolTable.AddManualType (cname, name); + SymbolTable.Table.AddType (new ManualGen (cname, name)); else Console.WriteLine ("Unexpected symbol type " + type); } diff --git a/generator/Property.cs b/generator/Property.cs index 5dc0139c1..6c441e365 100644 --- a/generator/Property.cs +++ b/generator/Property.cs @@ -31,7 +31,8 @@ namespace GtkSharp.Generation { public bool Validate () { string c_type = elem.GetAttribute("type"); - string cs_type = SymbolTable.GetCSType(c_type); + SymbolTable table = SymbolTable.Table; + string cs_type = table.GetCSType(c_type); if (cs_type == "") { Console.Write("Property has unknown Type {0} ", c_type); @@ -39,7 +40,7 @@ namespace GtkSharp.Generation { return false; } - if (SymbolTable.IsInterface(c_type)) { + if (table.IsInterface(c_type)) { // FIXME: Handle interface props properly. Console.Write("Interface property detected "); Statistics.ThrottledCount++; @@ -51,8 +52,10 @@ namespace GtkSharp.Generation { public void Generate (StreamWriter sw) { + SymbolTable table = SymbolTable.Table; + string c_type = elem.GetAttribute("type"); - string cs_type = SymbolTable.GetCSType(c_type); + string cs_type = table.GetCSType(c_type); string modifiers = ""; if (elem.HasAttribute("new_flag") || (container_type.Parent != null && container_type.Parent.GetPropertyRecursively (Name) != null)) @@ -66,18 +69,18 @@ namespace GtkSharp.Generation { string cname = "\"" + elem.GetAttribute("cname") + "\""; string v_type = ""; - if (SymbolTable.IsEnum(c_type)) { + if (table.IsEnum(c_type)) { v_type = "(int) (GLib.EnumWrapper)"; - } else if (SymbolTable.IsInterface(c_type)) { + } else if (table.IsInterface(c_type)) { // FIXME: Handle interface props properly. Console.Write("Interface property detected "); Statistics.ThrottledCount++; return; - } else if (SymbolTable.IsObject(c_type)) { + } else if (table.IsObject(c_type)) { v_type = "(GLib.UnwrappedObject)"; - } else if (SymbolTable.IsBoxed (c_type)) { + } else if (table.IsBoxed (c_type)) { v_type = "(GLib.Boxed)"; - } else if (SymbolTable.IsOpaque (c_type)) { + } else if (table.IsOpaque (c_type)) { v_type = "(GLib.Opaque)"; } @@ -118,10 +121,10 @@ namespace GtkSharp.Generation { sw.WriteLine("\t\t\tget {"); sw.WriteLine("\t\t\t\tGLib.Value val = new GLib.Value (Handle, " + cname + ");"); sw.WriteLine("\t\t\t\tGetProperty(" + cname + ", val);"); - if (SymbolTable.IsObject (c_type) || SymbolTable.IsOpaque (c_type) || SymbolTable.IsBoxed (c_type)) { + if (table.IsObject (c_type) || table.IsOpaque (c_type) || table.IsBoxed (c_type)) { sw.WriteLine("\t\t\t\tSystem.IntPtr raw_ret = (System.IntPtr) {0} val;", v_type); - sw.WriteLine("\t\t\t\t" + cs_type + " ret = " + SymbolTable.FromNativeReturn(c_type, "raw_ret") + ";"); - if (!SymbolTable.IsBoxed (c_type)) + sw.WriteLine("\t\t\t\t" + cs_type + " ret = " + table.FromNativeReturn(c_type, "raw_ret") + ";"); + if (!table.IsBoxed (c_type)) sw.WriteLine("\t\t\t\tif (ret == null) ret = new " + cs_type + "(raw_ret);"); } else { sw.Write("\t\t\t\t" + cs_type + " ret = "); @@ -143,12 +146,12 @@ namespace GtkSharp.Generation { } else if (elem.HasAttribute("writeable") && !elem.HasAttribute("construct-only")) { sw.WriteLine("\t\t\tset {"); sw.Write("\t\t\t\tSetProperty(" + cname + ", new GLib.Value("); - if (SymbolTable.IsEnum(c_type)) { - sw.WriteLine("Handle, " + cname + ", new GLib.EnumWrapper ((int) value, {0})));", SymbolTable.IsEnumFlags (c_type) ? "true" : "false"); - } else if (SymbolTable.IsBoxed (c_type)) { + if (table.IsEnum(c_type)) { + sw.WriteLine("Handle, " + cname + ", new GLib.EnumWrapper ((int) value, {0})));", table.IsEnumFlags (c_type) ? "true" : "false"); + } else if (table.IsBoxed (c_type)) { sw.WriteLine("Handle, " + cname + ", new GLib.Boxed (value)));"); } else { - if (v_type != "" && !(SymbolTable.IsObject (c_type) || SymbolTable.IsOpaque (c_type))) { + if (v_type != "" && !(table.IsObject (c_type) || table.IsOpaque (c_type))) { sw.Write(v_type + " "); } sw.WriteLine("value));"); diff --git a/generator/SignalHandler.cs b/generator/SignalHandler.cs index 4b9117622..58fd6d7c9 100644 --- a/generator/SignalHandler.cs +++ b/generator/SignalHandler.cs @@ -2,7 +2,7 @@ // // Author: Mike Kestner // -// (c) 2002 Mike Kestner +// (c) 2002-2003 Mike Kestner namespace GtkSharp.Generation { @@ -27,8 +27,10 @@ namespace GtkSharp.Generation { return ""; } - string s_ret = SymbolTable.GetCSType(retval); - string p_ret = SymbolTable.GetMarshalReturnType(retval); + SymbolTable table = SymbolTable.Table; + + string s_ret = table.GetCSType(retval); + string p_ret = table.GetMarshalReturnType(retval); if ((s_ret == "") || (p_ret == "")) { Console.Write("Funky type: " + retval); return ""; @@ -36,7 +38,7 @@ namespace GtkSharp.Generation { string key = retval; string pinv = ""; - string name = SymbolTable.GetName(retval); + string name = table.GetName(retval); int pcnt = 0; ArrayList parms = new ArrayList(); @@ -52,7 +54,7 @@ namespace GtkSharp.Generation { XmlElement elem = (XmlElement) parm; string type = elem.GetAttribute("type"); - string ptype = SymbolTable.GetMarshalType(type); + string ptype = table.GetMarshalType(type); if (ptype == "") { Console.Write("Funky type: " + type); return ""; @@ -64,11 +66,11 @@ namespace GtkSharp.Generation { pinv += (ptype + " arg" + pcnt); parms.Add(type); - if (SymbolTable.IsObject(type) || SymbolTable.IsInterface(type)) { + if (table.IsObject(type) || table.IsInterface(type)) { name += "Object"; key += "Object"; } else { - name += SymbolTable.GetName(type); + name += table.GetName(type); key += type; } pcnt++; @@ -131,22 +133,22 @@ namespace GtkSharp.Generation { } for (int idx=1; idx < parms.Count; idx++) { string ctype = (string) parms[idx]; - ClassBase wrapper = SymbolTable.GetClassGen (ctype); - if ((wrapper != null && !(wrapper is StructBase)) || SymbolTable.IsManuallyWrapped (ctype)) { + ClassBase wrapper = table.GetClassGen (ctype); + if ((wrapper != null && !(wrapper is StructBase)) || table.IsManuallyWrapped (ctype)) { sw.WriteLine("\t\t\tif (arg{0} == IntPtr.Zero)", idx); sw.WriteLine("\t\t\t\targs.Args[{0}] = null;", idx - 1); sw.WriteLine("\t\t\telse {"); if (wrapper != null && wrapper is ObjectGen) sw.WriteLine("\t\t\t\targs.Args[" + (idx-1) + "] = GLib.Object.GetObject(arg" + idx + ");"); else - sw.WriteLine("\t\t\t\targs.Args[" + (idx-1) + "] = " + SymbolTable.FromNative (ctype, "arg" + idx) + ";"); - if ((wrapper != null && (wrapper is OpaqueGen)) || SymbolTable.IsManuallyWrapped (ctype)) { + sw.WriteLine("\t\t\t\targs.Args[" + (idx-1) + "] = " + table.FromNative (ctype, "arg" + idx) + ";"); + if ((wrapper != null && (wrapper is OpaqueGen)) || table.IsManuallyWrapped (ctype)) { sw.WriteLine("\t\t\t\tif (args.Args[" + (idx-1) + "] == null)"); - sw.WriteLine("\t\t\t\t\targs.Args[{0}] = new {1}(arg{2});", idx-1, SymbolTable.GetCSType (ctype), idx); + sw.WriteLine("\t\t\t\t\targs.Args[{0}] = new {1}(arg{2});", idx-1, table.GetCSType (ctype), idx); } sw.WriteLine("\t\t\t}"); } else { - sw.WriteLine("\t\t\targs.Args[" + (idx-1) + "] = " + SymbolTable.FromNative (ctype, "arg" + idx) + ";"); + sw.WriteLine("\t\t\targs.Args[" + (idx-1) + "] = " + table.FromNative (ctype, "arg" + idx) + ";"); } } sw.WriteLine("\t\t\tobject[] argv = new object[2];"); @@ -160,7 +162,7 @@ namespace GtkSharp.Generation { else sw.WriteLine ("\t\t\t\tthrow new Exception(\"args.RetVal unset in callback\");"); - sw.WriteLine("\t\t\treturn (" + p_ret + ") " + SymbolTable.CallByName (retval, "((" + s_ret + ")args.RetVal)") + ";"); + sw.WriteLine("\t\t\treturn (" + p_ret + ") " + table.CallByName (retval, "((" + s_ret + ")args.RetVal)") + ";"); } sw.WriteLine("\t\t}"); sw.WriteLine(); diff --git a/generator/StructBase.cs b/generator/StructBase.cs index 17e210813..0466eafc4 100644 --- a/generator/StructBase.cs +++ b/generator/StructBase.cs @@ -112,13 +112,13 @@ namespace GtkSharp.Generation { { name = ""; c_type = field.GetAttribute ("type"); - type = SymbolTable.GetCSType (c_type); + type = SymbolTable.Table.GetCSType (c_type); if (IsBit (field)) { type = "uint"; - } else if ((IsPointer (field) || SymbolTable.IsOpaque (c_type)) && type != "string") { + } else if ((IsPointer (field) || SymbolTable.Table.IsOpaque (c_type)) && type != "string") { type = "IntPtr"; name = "_"; - } else if (SymbolTable.IsCallback (c_type)) { + } else if (SymbolTable.Table.IsCallback (c_type)) { type = "IntPtr"; } else { if (type == "") { @@ -149,34 +149,35 @@ namespace GtkSharp.Generation { if (field.HasAttribute("array_len")) Console.WriteLine ("warning: array field {0}.{1} probably incorrectly generated", QualifiedName, name); + SymbolTable table = SymbolTable.Table; - string wrapped = SymbolTable.GetCSType (c_type); + string wrapped = table.GetCSType (c_type); string wrapped_name = MangleName (field.GetAttribute ("cname")); - if (SymbolTable.IsObject (c_type)) { + if (table.IsObject (c_type)) { sw.WriteLine (); sw.WriteLine ("\t\tpublic " + wrapped + " " + wrapped_name + " {"); sw.WriteLine ("\t\t\tget { "); - sw.WriteLine ("\t\t\t\t" + wrapped + " ret = " + SymbolTable.FromNativeReturn(c_type, name) + ";"); + sw.WriteLine ("\t\t\t\t" + wrapped + " ret = " + table.FromNativeReturn(c_type, name) + ";"); sw.WriteLine ("\t\t\t\tret.Ref ();"); sw.WriteLine ("\t\t\t\treturn ret;"); sw.WriteLine ("\t\t\t}"); - sw.WriteLine ("\t\t\tset { " + name + " = " + SymbolTable.CallByName (c_type, "value") + "; }"); + sw.WriteLine ("\t\t\tset { " + name + " = " + table.CallByName (c_type, "value") + "; }"); sw.WriteLine ("\t\t}"); - } else if (SymbolTable.IsOpaque (c_type)) { + } else if (table.IsOpaque (c_type)) { sw.WriteLine (); sw.WriteLine ("\t\tpublic " + wrapped + " " + wrapped_name + " {"); sw.WriteLine ("\t\t\tget { "); - sw.WriteLine ("\t\t\t\t" + wrapped + " ret = " + SymbolTable.FromNativeReturn(c_type, name) + ";"); + sw.WriteLine ("\t\t\t\t" + wrapped + " ret = " + table.FromNativeReturn(c_type, name) + ";"); sw.WriteLine ("\t\t\t\tif (ret == null) ret = new " + wrapped + "(" + name + ");"); sw.WriteLine ("\t\t\t\treturn ret;"); sw.WriteLine ("\t\t\t}"); - sw.WriteLine ("\t\t\tset { " + name + " = " + SymbolTable.CallByName (c_type, "value") + "; }"); + sw.WriteLine ("\t\t\tset { " + name + " = " + table.CallByName (c_type, "value") + "; }"); sw.WriteLine ("\t\t}"); - } else if (IsPointer (field) && (SymbolTable.IsStruct (c_type) || SymbolTable.IsBoxed (c_type))) { + } else if (IsPointer (field) && (table.IsStruct (c_type) || table.IsBoxed (c_type))) { sw.WriteLine (); sw.WriteLine ("\t\tpublic " + wrapped + " " + wrapped_name + " {"); - sw.WriteLine ("\t\t\tget { return " + SymbolTable.FromNativeReturn (c_type, name) + "; }"); + sw.WriteLine ("\t\t\tget { return " + table.FromNativeReturn (c_type, name) + "; }"); sw.WriteLine ("\t\t}"); } @@ -210,7 +211,6 @@ namespace GtkSharp.Generation { { StreamWriter sw = CreateWriter (); - sw.WriteLine ("\tusing System;"); sw.WriteLine ("\tusing System.Collections;"); sw.WriteLine ("\tusing System.Runtime.InteropServices;"); sw.WriteLine (); diff --git a/generator/SymbolTable.cs b/generator/SymbolTable.cs index 5983f307f..e691787a7 100644 --- a/generator/SymbolTable.cs +++ b/generator/SymbolTable.cs @@ -2,7 +2,7 @@ // // Author: Mike Kestner // -// (c) 2001-2002 Mike Kestner +// (c) 2001-2003 Mike Kestner namespace GtkSharp.Generation { @@ -11,109 +11,116 @@ namespace GtkSharp.Generation { public class SymbolTable { - private static Hashtable alias = new Hashtable (); - private static Hashtable complex_types = new Hashtable (); - private static Hashtable simple_types; - private static Hashtable manually_wrapped_types; + static SymbolTable table = null; + + Hashtable alias = new Hashtable (); + Hashtable types = new Hashtable (); - static SymbolTable () + public static SymbolTable Table { + get { + if (table == null) + table = new SymbolTable (); + + return table; + } + } + + public SymbolTable () { - simple_types = new Hashtable (); - simple_types.Add ("void", "void"); - simple_types.Add ("gboolean", "bool"); - simple_types.Add ("gint", "int"); - simple_types.Add ("guint", "uint"); - simple_types.Add ("glong", "long"); - simple_types.Add ("gshort", "short"); - simple_types.Add ("gushort", "ushort"); - simple_types.Add ("guint32", "uint"); - simple_types.Add ("guint64", "ulong"); - simple_types.Add ("const-gchar", "string"); - simple_types.Add ("const-char", "string"); - simple_types.Add ("gchar", "string"); - simple_types.Add ("GObject", "GLib.Object"); - simple_types.Add ("gfloat", "float"); - simple_types.Add ("gdouble", "double"); - simple_types.Add ("gint8", "byte"); - simple_types.Add ("guint8", "byte"); - simple_types.Add ("gint16", "short"); - simple_types.Add ("gint32", "int"); - simple_types.Add ("gint64", "long"); - simple_types.Add ("guint16", "ushort"); - simple_types.Add ("guint1", "bool"); - simple_types.Add ("gpointer", "System.IntPtr"); - simple_types.Add ("guchar", "byte"); - simple_types.Add ("long", "long"); - simple_types.Add ("gulong", "ulong"); - simple_types.Add ("GQuark", "int"); - simple_types.Add ("int", "int"); - simple_types.Add ("char", "string"); - simple_types.Add ("double", "double"); - simple_types.Add ("float", "float"); - simple_types.Add ("gunichar", "string"); - simple_types.Add ("uint1", "bool"); - simple_types.Add ("GPtrArray", "System.IntPtr[]"); - simple_types.Add ("GType", "uint"); - simple_types.Add ("GError", "IntPtr"); + Hashtable alias = new Hashtable (); + Hashtable types = new Hashtable (); + + AddType (new SimpleGen ("void", "void")); + AddType (new SimpleGen ("gboolean", "bool")); + AddType (new SimpleGen ("gint", "int")); + AddType (new SimpleGen ("guint", "uint")); + AddType (new SimpleGen ("glong", "long")); + AddType (new SimpleGen ("gshort", "short")); + AddType (new SimpleGen ("gushort", "ushort")); + AddType (new SimpleGen ("guint32", "uint")); + AddType (new SimpleGen ("guint64", "ulong")); + AddType (new SimpleGen ("const-gchar", "string")); + AddType (new SimpleGen ("const-char", "string")); + AddType (new SimpleGen ("gchar", "string")); + AddType (new SimpleGen ("gfloat", "float")); + AddType (new SimpleGen ("gdouble", "double")); + AddType (new SimpleGen ("gint8", "sbyte")); + AddType (new SimpleGen ("guint8", "byte")); + AddType (new SimpleGen ("gint16", "short")); + AddType (new SimpleGen ("gint32", "int")); + AddType (new SimpleGen ("gint64", "long")); + AddType (new SimpleGen ("guint16", "ushort")); + AddType (new SimpleGen ("guint1", "bool")); + AddType (new SimpleGen ("gpointer", "IntPtr")); + AddType (new SimpleGen ("guchar", "byte")); + AddType (new SimpleGen ("long", "long")); + AddType (new SimpleGen ("gulong", "ulong")); + AddType (new SimpleGen ("GQuark", "int")); + AddType (new SimpleGen ("int", "int")); + AddType (new SimpleGen ("char", "string")); + AddType (new SimpleGen ("double", "double")); + AddType (new SimpleGen ("float", "float")); + AddType (new SimpleGen ("gunichar", "string")); + AddType (new SimpleGen ("uint1", "bool")); + AddType (new SimpleGen ("GPtrArray", "IntPtr[]")); + AddType (new SimpleGen ("GType", "uint")); + AddType (new SimpleGen ("GError", "IntPtr")); // gsize is a system-specific typedef in glibconfig.h, // but this should work for now - simple_types.Add ("gsize", "uint"); - simple_types.Add ("gssize", "int"); - simple_types.Add ("size_t", "int"); + AddType (new SimpleGen ("gsize", "uint")); + AddType (new SimpleGen ("gssize", "int")); + AddType (new SimpleGen ("size_t", "int")); // FIXME: These ought to be handled properly. - simple_types.Add ("GMemChunk", "System.IntPtr"); - simple_types.Add ("GTimeVal", "System.IntPtr"); - simple_types.Add ("GClosure", "System.IntPtr"); - simple_types.Add ("GArray", "System.IntPtr"); - simple_types.Add ("GData", "System.IntPtr"); - simple_types.Add ("GTypeModule", "GLib.Object"); - simple_types.Add ("GHashTable", "System.IntPtr"); - simple_types.Add ("va_list", "System.IntPtr"); - simple_types.Add ("GParamSpec", "System.IntPtr"); - simple_types.Add ("gconstpointer", "System.IntPtr"); + AddType (new SimpleGen ("GMemChunk", "IntPtr")); + AddType (new SimpleGen ("GTimeVal", "IntPtr")); + AddType (new SimpleGen ("GClosure", "IntPtr")); + AddType (new SimpleGen ("GArray", "IntPtr")); + AddType (new SimpleGen ("GData", "IntPtr")); + AddType (new SimpleGen ("GTypeModule", "GLib.Object")); + AddType (new SimpleGen ("GHashTable", "System.IntPtr")); + AddType (new SimpleGen ("va_list", "IntPtr")); + AddType (new SimpleGen ("GParamSpec", "IntPtr")); + AddType (new SimpleGen ("gconstpointer", "IntPtr")); - manually_wrapped_types = new Hashtable (); - manually_wrapped_types.Add ("GSList", "GLib.SList"); - manually_wrapped_types.Add ("GList", "GLib.List"); - manually_wrapped_types.Add ("GValue", "GLib.Value"); + AddType (new ManualGen ("GSList", "GLib", "SList")); + AddType (new ManualGen ("GList", "GLib", "List")); + AddType (new ManualGen ("GValue", "GLib", "Value")); + AddType (new ManualGen ("GObject", "GLib", "Object")); } - public static void AddAlias (string name, string type) + public void AddAlias (string name, string type) { type = type.TrimEnd(' ', '\t'); alias [name] = type; } - public static void AddType (IGeneratable gen) + public void AddType (IGeneratable gen) { - complex_types [gen.CName] = gen; + types [gen.CName] = gen; } - public static void AddSimpleType (string cname, string name) - { - simple_types.Add (cname, name); - } - - public static void AddManualType (string cname, string name) - { - manually_wrapped_types.Add (cname, name); - } - - public static int Count { + public int Count { get { - return complex_types.Count; + return types.Count; } } - public static IEnumerable Generatables { + public IEnumerable Generatables { get { - return complex_types.Values; + return types.Values; } } - private static string Trim(string type) + public IGeneratable this [string ctype] { + get { + ctype = DeAlias (ctype); + return types [ctype] as IGeneratable; + } + } + + private string Trim(string type) { // HACK: If we don't detect this here, there is no // way of indicating it in the symbol table @@ -124,243 +131,149 @@ namespace GtkSharp.Generation { return trim_type; } - private static string DeAlias (string type) + private string DeAlias (string type) { + type = Trim (type); while (alias.ContainsKey(type)) type = (string) alias[type]; return type; } - public static string FromNativeReturn(string c_type, string val) + public string FromNativeReturn(string c_type, string val) { - return FromNative (c_type, val, true); + IGeneratable gen = this[c_type]; + if (gen == null) + return ""; + return gen.FromNativeReturn (val); } - public static string FromNative(string c_type, string val) + public string FromNative(string c_type, string val) { - return FromNative (c_type, val, false); + IGeneratable gen = this[c_type]; + if (gen == null) + return ""; + return gen.FromNative (val); } - public static string FromNative(string c_type, string val, bool ret) + public string GetCSType(string c_type) { - c_type = Trim(c_type); - c_type = DeAlias(c_type); - if (simple_types.ContainsKey(c_type)) { - return val; - } else if (complex_types.ContainsKey(c_type)) { - IGeneratable gen = (IGeneratable) complex_types[c_type]; - if (ret) - return gen.FromNativeReturn(val); - else - return gen.FromNative(val); - } else if (manually_wrapped_types.ContainsKey(c_type)) { - string cs_type = (string) manually_wrapped_types[c_type]; - return String.Format ("new {0} ({1})", cs_type, val); - } else { + IGeneratable gen = this[c_type]; + if (gen == null) return ""; - } + return gen.QualifiedName; } - public static string GetCSType(string c_type) + public string GetName(string c_type) { - c_type = Trim(c_type); - c_type = DeAlias(c_type); - if (simple_types.ContainsKey(c_type)) { - return (string) simple_types[c_type]; - } else if (complex_types.ContainsKey(c_type)) { - IGeneratable gen = (IGeneratable) complex_types[c_type]; - return gen.QualifiedName; - } else if (manually_wrapped_types.ContainsKey(c_type)) { - return (string) manually_wrapped_types[c_type]; - } else { + IGeneratable gen = this[c_type]; + if (gen == null) return ""; - } + return gen.Name; } - public static string GetName(string c_type) + public string GetMarshalReturnType(string c_type) { - c_type = Trim(c_type); - c_type = DeAlias(c_type); - if (simple_types.ContainsKey(c_type) || manually_wrapped_types.ContainsKey(c_type)) { - string stype; - if (simple_types.ContainsKey(c_type)) - stype = (string) simple_types[c_type]; - else - stype = (string) manually_wrapped_types[c_type]; - int dotidx = stype.IndexOf("."); - if (dotidx == -1) { - return stype; - } else { - return stype.Substring(dotidx+1); - } - } else if (complex_types.ContainsKey(c_type)) { - IGeneratable gen = (IGeneratable) complex_types[c_type]; - return gen.Name; - } else { + IGeneratable gen = this[c_type]; + if (gen == null) return ""; - } + return gen.MarshalReturnType; } - public static string GetMarshalReturnType(string c_type) + public string GetMarshalType(string c_type) { - return GetMarshalType (c_type, true); - } - - public static string GetMarshalType(string c_type) - { - return GetMarshalType (c_type, false); - } - - public static string GetMarshalType(string c_type, bool ret) - { - c_type = Trim(c_type); - c_type = DeAlias(c_type); - if (simple_types.ContainsKey(c_type)) { - return (string) simple_types[c_type]; - } else if (manually_wrapped_types.ContainsKey(c_type)) { - return "IntPtr"; - } else if (complex_types.ContainsKey(c_type)) { - IGeneratable gen = (IGeneratable) complex_types[c_type]; - if (ret) - return gen.MarshalReturnType; - else - return gen.MarshalType; - } else { + IGeneratable gen = this[c_type]; + if (gen == null) return ""; - } + return gen.MarshalType; } - public static string CallByName(string c_type, string var_name) + public string CallByName(string c_type, string var_name) { - c_type = Trim(c_type); - c_type = DeAlias(c_type); - if (simple_types.ContainsKey(c_type)) { - return var_name; - } else if (manually_wrapped_types.ContainsKey(c_type)) { - return var_name + ".Handle"; - } else if (complex_types.ContainsKey(c_type)) { - IGeneratable gen = (IGeneratable) complex_types[c_type]; - return gen.CallByName(var_name); - } else { + IGeneratable gen = this[c_type]; + if (gen == null) return ""; - } + return gen.CallByName(var_name); } - public static bool IsOpaque(string c_type) + public bool IsOpaque(string c_type) { - c_type = Trim(c_type); - c_type = DeAlias(c_type); - if (complex_types.ContainsKey(c_type)) { - IGeneratable gen = (IGeneratable) complex_types[c_type]; - if (gen is OpaqueGen) { - return true; - } - } + if (this[c_type] is OpaqueGen) + return true; + return false; } - public static bool IsBoxed(string c_type) + public bool IsBoxed(string c_type) { - c_type = Trim(c_type); - c_type = DeAlias(c_type); - if (complex_types.ContainsKey(c_type)) { - IGeneratable gen = (IGeneratable) complex_types[c_type]; - if (gen is BoxedGen) { - return true; - } - } + if (this[c_type] is BoxedGen) + return true; + return false; } - public static bool IsStruct(string c_type) + public bool IsStruct(string c_type) { - c_type = Trim(c_type); - c_type = DeAlias(c_type); - if (complex_types.ContainsKey(c_type)) { - IGeneratable gen = (IGeneratable) complex_types[c_type]; - if (gen is StructGen) { - return true; - } - } + if (this[c_type] is StructGen) + return true; + return false; } - public static bool IsEnum(string c_type) + public bool IsEnum(string c_type) { - c_type = Trim(c_type); - c_type = DeAlias(c_type); - if (complex_types.ContainsKey(c_type)) { - IGeneratable gen = (IGeneratable) complex_types[c_type]; - if (gen is EnumGen) { - return true; - } - } + if (this[c_type] is EnumGen) + return true; + return false; } - public static bool IsEnumFlags(string c_type) + public bool IsEnumFlags(string c_type) { c_type = Trim(c_type); c_type = DeAlias(c_type); - if (complex_types.ContainsKey(c_type)) { - EnumGen gen = complex_types[c_type] as EnumGen; + if (types.ContainsKey(c_type)) { + EnumGen gen = types[c_type] as EnumGen; return (gen != null && gen.Elem.GetAttribute ("type") == "flags"); } return false; } - public static bool IsInterface(string c_type) + public bool IsInterface(string c_type) { - c_type = Trim(c_type); - c_type = DeAlias(c_type); - if (complex_types.ContainsKey(c_type)) { - IGeneratable gen = (IGeneratable) complex_types[c_type]; - if (gen is InterfaceGen) { - return true; - } - } + if (this[c_type] is InterfaceGen) + return true; + return false; } - public static ClassBase GetClassGen(string c_type) + public ClassBase GetClassGen(string c_type) { - c_type = Trim(c_type); - c_type = DeAlias(c_type); - return (complex_types[c_type] as ClassBase); + return this[c_type] as ClassBase; } - public static bool IsObject(string c_type) + public bool IsObject(string c_type) { - c_type = Trim(c_type); - c_type = DeAlias(c_type); - if (complex_types.ContainsKey(c_type)) { - IGeneratable gen = (IGeneratable) complex_types[c_type]; - if (gen is ObjectGen) { - return true; - } - } + if (this[c_type] is ObjectGen) + return true; + return false; } - public static bool IsCallback(string c_type) + public bool IsCallback(string c_type) { - c_type = Trim(c_type); - c_type = DeAlias(c_type); - if (complex_types.ContainsKey(c_type)) { - IGeneratable gen = (IGeneratable) complex_types[c_type]; - if (gen is CallbackGen) { - return true; - } - } + if (this[c_type] is CallbackGen) + return true; + return false; } - public static bool IsManuallyWrapped(string c_type) + public bool IsManuallyWrapped(string c_type) { - c_type = Trim(c_type); - c_type = DeAlias(c_type); - return manually_wrapped_types.ContainsKey(c_type); + if (this[c_type] is ManualGen) + return true; + + return false; } }