2004-01-21 Mike Kestner <mkestner@ximian.com>

* generator/Field.cs : kill Protection, restructure Generate
	and add FIXMEs for broken parts. Add StudlyName and move array
	fields to use Studly names.

svn path=/trunk/gtk-sharp/; revision=22357
This commit is contained in:
Mike Kestner 2004-01-21 20:47:41 +00:00
parent a75fe8ae55
commit e4165fbb18
2 changed files with 36 additions and 14 deletions

View file

@ -1,3 +1,9 @@
2004-01-21 Mike Kestner <mkestner@ximian.com>
* generator/Field.cs : kill Protection, restructure Generate
and add FIXMEs for broken parts. Add StudlyName and move array
fields to use Studly names.
2004-01-20 John Luke <jluke@cfl.rr.com> 2004-01-20 John Luke <jluke@cfl.rr.com>
* samples/GtkDemo: * samples/GtkDemo:

View file

@ -75,7 +75,7 @@ namespace GtkSharp.Generation {
public bool IsPadding { public bool IsPadding {
get { get {
string c_name = elem.GetAttribute ("cname"); string c_name = elem.GetAttribute ("cname");
return (c_name.StartsWith ("dummy")); return (c_name.StartsWith ("dummy") || c_name.StartsWith ("padding"));
} }
} }
@ -100,17 +100,17 @@ namespace GtkSharp.Generation {
} }
} }
public string Protection { public string StudlyName {
get { get {
if (IsArray) string name = Name;
// FIXME string[] segs = name.Split('_');
return "public"; string studly = "";
else if (IsBit || IsPadding || SymbolTable.Table.IsCallback (CType)) foreach (string s in segs) {
return "private"; if (s.Trim () == "")
else if ((IsPointer || SymbolTable.Table.IsOpaque (CType)) && CSType != "string") continue;
return "private"; studly += (s.Substring(0,1).ToUpper() + s.Substring(1));
else }
return "public"; return studly;
} }
} }
@ -126,12 +126,21 @@ namespace GtkSharp.Generation {
if (IsArray) if (IsArray)
sw.WriteLine ("\t\t[MarshalAs (UnmanagedType.ByValArray, SizeConst=" + ArrayLength + ")]"); sw.WriteLine ("\t\t[MarshalAs (UnmanagedType.ByValArray, SizeConst=" + ArrayLength + ")]");
sw.WriteLine ("\t\t{0} {1} {2};", Protection, CSType, table.MangleName (Name));
string wrapped = table.GetCSType (CType); string wrapped = table.GetCSType (CType);
string wrapped_name = SymbolTable.Table.MangleName (elem.GetAttribute ("cname")); string wrapped_name = SymbolTable.Table.MangleName (elem.GetAttribute ("cname"));
if (table.IsObject (CType)) { if (IsArray) {
sw.WriteLine ("\t\tpublic {0} {1};", CSType, StudlyName);
} else if (IsPadding) {
sw.WriteLine ("\t\tprivate {0} {1};", CSType, Name);
} else if (IsBit) {
// FIXME
sw.WriteLine ("\t\tprivate {0} {1};", CSType, Name);
} else if (table.IsCallback (CType)) {
// FIXME
sw.WriteLine ("\t\tprivate {0} {1};", CSType, Name);
} else if (table.IsObject (CType)) {
sw.WriteLine ("\t\tprivate {0} {1};", CSType, Name);
sw.WriteLine (); sw.WriteLine ();
sw.WriteLine ("\t\tpublic " + wrapped + " " + wrapped_name + " {"); sw.WriteLine ("\t\tpublic " + wrapped + " " + wrapped_name + " {");
sw.WriteLine ("\t\t\tget { "); sw.WriteLine ("\t\t\tget { ");
@ -141,6 +150,7 @@ namespace GtkSharp.Generation {
sw.WriteLine ("\t\t\tset { " + Name + " = " + table.CallByName (CType, "value") + "; }"); sw.WriteLine ("\t\t\tset { " + Name + " = " + table.CallByName (CType, "value") + "; }");
sw.WriteLine ("\t\t}"); sw.WriteLine ("\t\t}");
} else if (table.IsOpaque (CType)) { } else if (table.IsOpaque (CType)) {
sw.WriteLine ("\t\tprivate {0} {1};", CSType, Name);
sw.WriteLine (); sw.WriteLine ();
sw.WriteLine ("\t\tpublic " + wrapped + " " + wrapped_name + " {"); sw.WriteLine ("\t\tpublic " + wrapped + " " + wrapped_name + " {");
sw.WriteLine ("\t\t\tget { "); sw.WriteLine ("\t\t\tget { ");
@ -152,10 +162,16 @@ namespace GtkSharp.Generation {
sw.WriteLine ("\t\t\tset { " + Name + " = " + table.CallByName (CType, "value") + "; }"); sw.WriteLine ("\t\t\tset { " + Name + " = " + table.CallByName (CType, "value") + "; }");
sw.WriteLine ("\t\t}"); sw.WriteLine ("\t\t}");
} else if (IsPointer && (table.IsStruct (CType) || table.IsBoxed (CType))) { } else if (IsPointer && (table.IsStruct (CType) || table.IsBoxed (CType))) {
sw.WriteLine ("\t\tprivate {0} {1};", CSType, Name);
sw.WriteLine (); sw.WriteLine ();
sw.WriteLine ("\t\tpublic " + wrapped + " " + wrapped_name + " {"); sw.WriteLine ("\t\tpublic " + wrapped + " " + wrapped_name + " {");
sw.WriteLine ("\t\t\tget { return " + table.FromNativeReturn (CType, Name) + "; }"); sw.WriteLine ("\t\t\tget { return " + table.FromNativeReturn (CType, Name) + "; }");
sw.WriteLine ("\t\t}"); sw.WriteLine ("\t\t}");
} else if (IsPointer && CSType != "string") {
// FIXME: probably some fields here which should be visible.
sw.WriteLine ("\t\tprivate {0} {1};", CSType, Name);
} else {
sw.WriteLine ("\t\tpublic {0} {1};", CSType, Name);
} }
return true; return true;