Browse Source

clean up and cosmetic changes

pull/1/head
Andreia Gaita 15 years ago
parent
commit
b8b046011e
  1. 5
      src/generator/Entry.cs
  2. 15
      src/generator/Main.cs

5
src/generator/Entry.cs

@ -89,6 +89,11 @@ namespace Mono.VisualC.Tools.Generator {
where o.Value.name == name where o.Value.name == name
select o.Value).FirstOrDefault (); select o.Value).FirstOrDefault ();
} }
public override string ToString ()
{
return String.Format ("{0} - {1}", name, computedName);
}
} }
} }

15
src/generator/Main.cs

@ -359,7 +359,6 @@ namespace Mono.VisualC.Tools.Generator {
argname = arg.name; argname = arg.name;
CppType argtype = findType (clas.Class, arg.Base, removed); CppType argtype = findType (clas.Class, arg.Base, removed);
var templat = argtype.Modifiers.OfType<CppModifiers.TemplateModifier> ().SingleOrDefault ();
if (templated != null) { if (templated != null) {
for (int i = 0; i < templated.Types.Length; i++) for (int i = 0; i < templated.Types.Length; i++)
argtype = replaceType (argtype, templated.Types[i], genericTypeArgs[i]); argtype = replaceType (argtype, templated.Types[i], genericTypeArgs[i]);
@ -394,7 +393,8 @@ namespace Mono.VisualC.Tools.Generator {
// if it's const, returns a value, has no parameters, and there is no other method with the same name // if it's const, returns a value, has no parameters, and there is no other method with the same name
// in this class assume it's a property getter (for now?) // in this class assume it's a property getter (for now?)
if (methodAtom.IsConst && !retType.Equals (CppTypes.Void) && !methodAtom.Parameters.Any () && clas.Members.Where (o => o.name == mname).FirstOrDefault () == null) { if (methodAtom.IsConst && !retType.Equals (CppTypes.Void) && !methodAtom.Parameters.Any () &&
clas.Members.Where (o => o.name == mname).FirstOrDefault () == null) {
var pname = methodAtom.FormattedName; var pname = methodAtom.FormattedName;
Property propertyAtom; Property propertyAtom;
@ -411,7 +411,8 @@ namespace Mono.VisualC.Tools.Generator {
// if it's name starts with "set", does not return a value, and has one arg (besides this ptr) // if it's name starts with "set", does not return a value, and has one arg (besides this ptr)
// and there is no other method with the same name... // and there is no other method with the same name...
if (mname.ToLower ().StartsWith ("set") && retType.Equals (CppTypes.Void) && methodAtom.Parameters.Count == 1 && clas.Members.Where (o => o.name == mname).FirstOrDefault () == null) { if (mname.ToLower ().StartsWith ("set") && retType.Equals (CppTypes.Void) &&
methodAtom.Parameters.Count == 1 && clas.Members.Where (o => o.name == mname).FirstOrDefault () == null) {
string getterName = mname.Substring (3).TrimStart ('_').ToLower (); string getterName = mname.Substring (3).TrimStart ('_').ToLower ();
@ -851,13 +852,10 @@ namespace Mono.VisualC.Tools.Generator {
case "Class": case "Class":
if (removed.Contains (entry)) if (removed.Contains (entry))
return modifiers.CopyTypeFrom (CppTypes.Unknown); return modifiers.CopyTypeFrom (CppTypes.Unknown);
if (entry.Class != null && entry.Class.GenericName != null) { if (entry.Class.GenericName != null) {
if (clas == entry.Class) { if (clas == entry.Class) {
Console.WriteLine ("Replacing {0} with {1}", name, entry.Class.GenericName);
return modifiers.CopyTypeFrom (new CppType (CppTypes.Class, entry.Class.GenericName)); return modifiers.CopyTypeFrom (new CppType (CppTypes.Class, entry.Class.GenericName));
} else { } else {
Console.WriteLine ("Replacing {0} with Unknown", name);
// return modifiers.CopyTypeFrom (new CppType (CppTypes.Class, name));
return modifiers.CopyTypeFrom (CppTypes.Unknown); return modifiers.CopyTypeFrom (CppTypes.Unknown);
} }
} else } else
@ -865,17 +863,14 @@ namespace Mono.VisualC.Tools.Generator {
case "Struct": case "Struct":
if (removed.Contains (entry)) if (removed.Contains (entry))
return modifiers.CopyTypeFrom (CppTypes.Unknown); return modifiers.CopyTypeFrom (CppTypes.Unknown);
Console.WriteLine ("Return struct {0}", name);
return modifiers.CopyTypeFrom (new CppType (CppTypes.Struct, name)); return modifiers.CopyTypeFrom (new CppType (CppTypes.Struct, name));
case "Union": case "Union":
if (removed.Contains (entry)) if (removed.Contains (entry))
return modifiers.CopyTypeFrom (CppTypes.Unknown); return modifiers.CopyTypeFrom (CppTypes.Unknown);
Console.WriteLine ("Return union {0}", entry.name);
return modifiers.CopyTypeFrom (ProcessUnion (clas, entry, removed)); return modifiers.CopyTypeFrom (ProcessUnion (clas, entry, removed));
case "Enumeration": case "Enumeration":
if (removed.Contains (entry)) if (removed.Contains (entry))
return modifiers.CopyTypeFrom (CppTypes.Unknown); return modifiers.CopyTypeFrom (CppTypes.Unknown);
Console.WriteLine ("Return enumeration {0}", entry.name);
return modifiers.CopyTypeFrom (ProcessEnum (entry)); return modifiers.CopyTypeFrom (ProcessEnum (entry));
// FIXME: support function pointers betters // FIXME: support function pointers betters

Loading…
Cancel
Save