Restructure log warnings in validation.
* generator/*.cs: Add a LogWriter class which formats warnings consistently on the console. Supports the concept of non-fatal validation warnings, since it doesn't rely on the unrolling of the validation stack to associate a warning to a given type. Main purpose was to add a non-fatal warning for missing element_type attributes on list return values, though it results in cleaner log output, and also updates some warning messages to be more helpful in how to resolve them.
This commit is contained in:
parent
0a094c2662
commit
2ba496479f
24 changed files with 105 additions and 122 deletions
|
@ -36,7 +36,7 @@ namespace GtkSharp.Generation {
|
||||||
methods.Remove ("Copy");
|
methods.Remove ("Copy");
|
||||||
methods.Remove ("Free");
|
methods.Remove ("Free");
|
||||||
|
|
||||||
gen_info.CurrentType = Name;
|
gen_info.CurrentType = QualifiedName;
|
||||||
|
|
||||||
StreamWriter sw = gen_info.Writer = gen_info.OpenStream (Name);
|
StreamWriter sw = gen_info.Writer = gen_info.OpenStream (Name);
|
||||||
base.Generate (gen_info);
|
base.Generate (gen_info);
|
||||||
|
|
|
@ -46,22 +46,15 @@ namespace GtkSharp.Generation {
|
||||||
|
|
||||||
public override bool Validate ()
|
public override bool Validate ()
|
||||||
{
|
{
|
||||||
if (!retval.Validate ()) {
|
|
||||||
Console.WriteLine ("rettype: " + retval.CType + " in callback " + CName);
|
|
||||||
Statistics.ThrottledCount++;
|
|
||||||
valid = false;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!parms.Validate ()) {
|
|
||||||
Console.WriteLine (" in callback " + CName);
|
|
||||||
Statistics.ThrottledCount++;
|
|
||||||
valid = false;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
valid = true;
|
valid = true;
|
||||||
return true;
|
LogWriter log = new LogWriter ();
|
||||||
|
log.Type = QualifiedName;
|
||||||
|
if (!retval.Validate (log) || !parms.Validate (log)) {
|
||||||
|
Statistics.ThrottledCount++;
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string InvokerName {
|
public string InvokerName {
|
||||||
|
@ -281,7 +274,7 @@ namespace GtkSharp.Generation {
|
||||||
|
|
||||||
public override void Generate (GenerationInfo gen_info)
|
public override void Generate (GenerationInfo gen_info)
|
||||||
{
|
{
|
||||||
gen_info.CurrentType = Name;
|
gen_info.CurrentType = QualifiedName;
|
||||||
|
|
||||||
sig = new Signature (parms);
|
sig = new Signature (parms);
|
||||||
|
|
||||||
|
|
|
@ -116,14 +116,16 @@ namespace GtkSharp.Generation {
|
||||||
|
|
||||||
public override bool Validate ()
|
public override bool Validate ()
|
||||||
{
|
{
|
||||||
|
LogWriter log = new LogWriter (QualifiedName);
|
||||||
|
|
||||||
foreach (string iface in interfaces) {
|
foreach (string iface in interfaces) {
|
||||||
InterfaceGen igen = SymbolTable.Table[iface] as InterfaceGen;
|
InterfaceGen igen = SymbolTable.Table[iface] as InterfaceGen;
|
||||||
if (igen == null) {
|
if (igen == null) {
|
||||||
Console.WriteLine (QualifiedName + " implements unknown GInterface " + iface);
|
log.Warn ("implements unknown GInterface " + iface);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!igen.ValidateForSubclass ()) {
|
if (!igen.ValidateForSubclass ()) {
|
||||||
Console.WriteLine (QualifiedName + " implements invalid GInterface " + iface);
|
log.Warn ("implements invalid GInterface " + iface);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -131,40 +133,32 @@ namespace GtkSharp.Generation {
|
||||||
ArrayList invalids = new ArrayList ();
|
ArrayList invalids = new ArrayList ();
|
||||||
|
|
||||||
foreach (Property prop in props.Values) {
|
foreach (Property prop in props.Values) {
|
||||||
if (!prop.Validate ()) {
|
if (!prop.Validate (log))
|
||||||
Console.WriteLine ("in type " + QualifiedName);
|
|
||||||
invalids.Add (prop);
|
invalids.Add (prop);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
foreach (Property prop in invalids)
|
foreach (Property prop in invalids)
|
||||||
props.Remove (prop.Name);
|
props.Remove (prop.Name);
|
||||||
invalids.Clear ();
|
invalids.Clear ();
|
||||||
|
|
||||||
foreach (ObjectField field in fields.Values) {
|
foreach (ObjectField field in fields.Values) {
|
||||||
if (!field.Validate ()) {
|
if (!field.Validate (log))
|
||||||
Console.WriteLine ("in type " + QualifiedName);
|
|
||||||
invalids.Add (field);
|
invalids.Add (field);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
foreach (ObjectField field in invalids)
|
foreach (ObjectField field in invalids)
|
||||||
fields.Remove (field.Name);
|
fields.Remove (field.Name);
|
||||||
invalids.Clear ();
|
invalids.Clear ();
|
||||||
|
|
||||||
foreach (Method method in methods.Values) {
|
foreach (Method method in methods.Values) {
|
||||||
if (!method.Validate ()) {
|
if (!method.Validate (log))
|
||||||
Console.WriteLine ("in type " + QualifiedName);
|
|
||||||
invalids.Add (method);
|
invalids.Add (method);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
foreach (Method method in invalids)
|
foreach (Method method in invalids)
|
||||||
methods.Remove (method.Name);
|
methods.Remove (method.Name);
|
||||||
invalids.Clear ();
|
invalids.Clear ();
|
||||||
|
|
||||||
foreach (Ctor ctor in ctors) {
|
foreach (Ctor ctor in ctors) {
|
||||||
if (!ctor.Validate ()) {
|
if (!ctor.Validate (log))
|
||||||
Console.WriteLine ("in type " + QualifiedName);
|
|
||||||
invalids.Add (ctor);
|
invalids.Add (ctor);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
foreach (Ctor ctor in invalids)
|
foreach (Ctor ctor in invalids)
|
||||||
ctors.Remove (ctor);
|
ctors.Remove (ctor);
|
||||||
|
|
|
@ -31,13 +31,17 @@ namespace GtkSharp.Generation {
|
||||||
this.container_type = container_type;
|
this.container_type = container_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Validate () {
|
public override bool Validate (LogWriter log)
|
||||||
|
{
|
||||||
|
if (!base.Validate (log))
|
||||||
|
return false;
|
||||||
|
|
||||||
if (IsBitfield) {
|
if (IsBitfield) {
|
||||||
Console.WriteLine ("Field {0}.{1} is a bitfield which is not supported yet", container_type.ClassStructName, Name);
|
log.Warn ("bitfields are not supported");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return base.Validate ();
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ namespace GtkSharp.Generation {
|
||||||
|
|
||||||
public override void Generate (GenerationInfo gen_info)
|
public override void Generate (GenerationInfo gen_info)
|
||||||
{
|
{
|
||||||
gen_info.CurrentType = Name;
|
gen_info.CurrentType = QualifiedName;
|
||||||
|
|
||||||
StreamWriter sw = gen_info.Writer = gen_info.OpenStream(Name);
|
StreamWriter sw = gen_info.Writer = gen_info.OpenStream(Name);
|
||||||
|
|
||||||
|
|
|
@ -92,9 +92,6 @@ namespace GtkSharp.Generation {
|
||||||
|
|
||||||
public void Generate (GenerationInfo gen_info)
|
public void Generate (GenerationInfo gen_info)
|
||||||
{
|
{
|
||||||
if (!Validate ())
|
|
||||||
return;
|
|
||||||
|
|
||||||
StreamWriter sw = gen_info.Writer;
|
StreamWriter sw = gen_info.Writer;
|
||||||
gen_info.CurrentMember = CName;
|
gen_info.CurrentMember = CName;
|
||||||
|
|
||||||
|
|
|
@ -28,10 +28,11 @@ namespace GtkSharp.Generation {
|
||||||
public abstract class FieldBase : PropertyBase {
|
public abstract class FieldBase : PropertyBase {
|
||||||
public FieldBase (XmlElement elem, ClassBase container_type) : base (elem, container_type) {}
|
public FieldBase (XmlElement elem, ClassBase container_type) : base (elem, container_type) {}
|
||||||
|
|
||||||
public virtual bool Validate ()
|
public virtual bool Validate (LogWriter log)
|
||||||
{
|
{
|
||||||
|
log.Member = Name;
|
||||||
if (!Ignored && !Hidden && CSType == "") {
|
if (!Ignored && !Hidden && CSType == "") {
|
||||||
Console.Write("Field {0} has unknown Type {1} ", Name, CType);
|
log.Warn ("field has unknown type: " + CType);
|
||||||
Statistics.ThrottledCount++;
|
Statistics.ThrottledCount++;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -141,10 +142,10 @@ namespace GtkSharp.Generation {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CheckGlue ();
|
CheckGlue ();
|
||||||
if ((getterName != null || setterName != null || getOffsetName != null) &&
|
if ((getterName != null || setterName != null || getOffsetName != null) && gen_info.GlueWriter == null) {
|
||||||
gen_info.GlueWriter == null) {
|
LogWriter log = new LogWriter (container_type.QualifiedName);
|
||||||
Console.WriteLine ("No glue-filename specified, can't create glue for {0}.{1}",
|
log.Member = Name;
|
||||||
container_type.Name, Name);
|
log.Warn ("needs glue for field access. Specify --glue-filename");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -342,26 +342,26 @@ namespace GtkSharp.Generation {
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Validate ()
|
public override bool Validate (LogWriter log)
|
||||||
{
|
{
|
||||||
if (!base.Validate ()) return false;
|
if (!base.Validate (log))
|
||||||
|
return false;
|
||||||
|
|
||||||
bool is_valid = true;
|
bool is_valid = true;
|
||||||
|
|
||||||
if (this.IsStatic) {
|
if (this.IsStatic) {
|
||||||
switch (OverrideType) {
|
switch (OverrideType) {
|
||||||
case VMOverrideType.Unspecified:
|
case VMOverrideType.Unspecified:
|
||||||
Console.Write ("Static virtual methods can only be generated if you provide info on how to override this method via the metadata ");
|
log.Warn ("Static virtual methods can only be generated if you provide info on how to override this method via the metadata ");
|
||||||
is_valid = false;
|
is_valid = false;
|
||||||
break;
|
break;
|
||||||
case VMOverrideType.ImplementingClass:
|
case VMOverrideType.ImplementingClass:
|
||||||
Console.Write ("Overriding static virtual methods in the implementing class is not supported yet ");
|
log.Warn ("Overriding static virtual methods in the implementing class is not supported yet ");
|
||||||
is_valid = false;
|
is_valid = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_valid)
|
|
||||||
Console.WriteLine (" (in virtual method {0}.{1})", container_type.QualifiedName, this.Name);
|
|
||||||
return is_valid;
|
return is_valid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ namespace GtkSharp.Generation {
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (!base.IsNodeNameHandled (node.Name))
|
if (!base.IsNodeNameHandled (node.Name))
|
||||||
Console.WriteLine ("Unexpected node " + node.Name + " in " + CName);
|
new LogWriter (QualifiedName).Warn ("Unexpected node " + node.Name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,19 +70,20 @@ namespace GtkSharp.Generation {
|
||||||
|
|
||||||
public override bool ValidateForSubclass ()
|
public override bool ValidateForSubclass ()
|
||||||
{
|
{
|
||||||
ArrayList invalids = new ArrayList ();
|
if (!base.ValidateForSubclass ())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
LogWriter log = new LogWriter (QualifiedName);
|
||||||
|
ArrayList invalids = new ArrayList ();
|
||||||
foreach (Method method in methods.Values) {
|
foreach (Method method in methods.Values) {
|
||||||
if (!method.Validate ()) {
|
if (!method.Validate (log))
|
||||||
Console.WriteLine ("in type " + QualifiedName);
|
|
||||||
invalids.Add (method);
|
invalids.Add (method);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
foreach (Method method in invalids)
|
foreach (Method method in invalids)
|
||||||
methods.Remove (method.Name);
|
methods.Remove (method.Name);
|
||||||
invalids.Clear ();
|
invalids.Clear ();
|
||||||
|
|
||||||
return base.ValidateForSubclass ();
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenerateStaticCtor (StreamWriter sw)
|
void GenerateStaticCtor (StreamWriter sw)
|
||||||
|
@ -93,7 +94,7 @@ namespace GtkSharp.Generation {
|
||||||
sw.WriteLine ("\t\t{");
|
sw.WriteLine ("\t\t{");
|
||||||
sw.WriteLine ("\t\t\tGLib.GType.Register (_gtype, typeof({0}Adapter));", Name);
|
sw.WriteLine ("\t\t\tGLib.GType.Register (_gtype, typeof({0}Adapter));", Name);
|
||||||
foreach (InterfaceVM vm in interface_vms) {
|
foreach (InterfaceVM vm in interface_vms) {
|
||||||
if (vm.IsValid)
|
if (vm.Validate (new LogWriter (QualifiedName)))
|
||||||
sw.WriteLine ("\t\t\tiface.{0} = new {0}NativeDelegate ({0}_cb);", vm.Name);
|
sw.WriteLine ("\t\t\tiface.{0} = new {0}NativeDelegate ({0}_cb);", vm.Name);
|
||||||
}
|
}
|
||||||
sw.WriteLine ("\t\t}");
|
sw.WriteLine ("\t\t}");
|
||||||
|
@ -288,7 +289,7 @@ namespace GtkSharp.Generation {
|
||||||
foreach (InterfaceVM vm in interface_vms) {
|
foreach (InterfaceVM vm in interface_vms) {
|
||||||
if (vm_table [vm.Name] == null)
|
if (vm_table [vm.Name] == null)
|
||||||
continue;
|
continue;
|
||||||
else if (!vm.IsValid) {
|
else if (!vm.Validate (new LogWriter (QualifiedName))) {
|
||||||
vm_table.Remove (vm.Name);
|
vm_table.Remove (vm.Name);
|
||||||
continue;
|
continue;
|
||||||
} else if (vm.IsGetter || vm.IsSetter) {
|
} else if (vm.IsGetter || vm.IsSetter) {
|
||||||
|
|
|
@ -85,13 +85,17 @@ namespace GtkSharp.Generation {
|
||||||
sw.WriteLine ("\t\t" + retval.CSType + " " + Name + " (" + Signature + ");");
|
sw.WriteLine ("\t\t" + retval.CSType + " " + Name + " (" + Signature + ");");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Validate ()
|
public override bool Validate (LogWriter log)
|
||||||
{
|
{
|
||||||
|
if (!base.Validate (log))
|
||||||
|
return false;
|
||||||
|
|
||||||
if (target == null && !(container_type as InterfaceGen).IsConsumeOnly) {
|
if (target == null && !(container_type as InterfaceGen).IsConsumeOnly) {
|
||||||
Console.WriteLine ("Virtual method {0}->{1} has no matching target to invoke", container_type.CName, CName);
|
log.Warn ("No matching target method to invoke. Add target_method attribute with fixup.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return base.Validate ();
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ sources = \
|
||||||
IManualMarshaler.cs \
|
IManualMarshaler.cs \
|
||||||
InterfaceGen.cs \
|
InterfaceGen.cs \
|
||||||
InterfaceVM.cs \
|
InterfaceVM.cs \
|
||||||
|
LogWriter.cs \
|
||||||
LPGen.cs \
|
LPGen.cs \
|
||||||
LPUGen.cs \
|
LPUGen.cs \
|
||||||
ManagedCallString.cs \
|
ManagedCallString.cs \
|
||||||
|
|
|
@ -82,12 +82,11 @@ namespace GtkSharp.Generation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Validate ()
|
public override bool Validate (LogWriter log)
|
||||||
{
|
{
|
||||||
if (!retval.Validate () || !base.Validate ()) {
|
log.Member = Name;
|
||||||
Console.Write(" in method " + Name + " ");
|
if (!retval.Validate (log) || !base.Validate (log))
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
Parameters parms = Parameters;
|
Parameters parms = Parameters;
|
||||||
is_get = ((((parms.IsAccessor && retval.IsVoid) || (parms.Count == 0 && !retval.IsVoid)) || (parms.Count == 0 && !retval.IsVoid)) && HasGetterName);
|
is_get = ((((parms.IsAccessor && retval.IsVoid) || (parms.Count == 0 && !retval.IsVoid)) || (parms.Count == 0 && !retval.IsVoid)) && HasGetterName);
|
||||||
|
@ -214,9 +213,6 @@ namespace GtkSharp.Generation {
|
||||||
|
|
||||||
public void Generate (GenerationInfo gen_info, ClassBase implementor)
|
public void Generate (GenerationInfo gen_info, ClassBase implementor)
|
||||||
{
|
{
|
||||||
if (!Validate ())
|
|
||||||
return;
|
|
||||||
|
|
||||||
Method comp = null;
|
Method comp = null;
|
||||||
|
|
||||||
gen_info.CurrentMember = Name;
|
gen_info.CurrentMember = Name;
|
||||||
|
|
|
@ -168,10 +168,10 @@ namespace GtkSharp.Generation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual bool Validate ()
|
public virtual bool Validate (LogWriter log)
|
||||||
{
|
{
|
||||||
if (!parms.Validate ()) {
|
log.Member = Name;
|
||||||
Console.Write("in " + CName + " ");
|
if (!parms.Validate (log)) {
|
||||||
Statistics.ThrottledCount++;
|
Statistics.ThrottledCount++;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,7 +122,7 @@ namespace GtkSharp.Generation {
|
||||||
case "call":
|
case "call":
|
||||||
default:
|
default:
|
||||||
if (p.Scope == String.Empty)
|
if (p.Scope == String.Empty)
|
||||||
Console.WriteLine ("Defaulting " + gen.Name + " param to 'call' scope in method " + gen_info.CurrentMember);
|
Console.WriteLine (gen_info.CurrentMember + " - defaulting " + gen.Name + " param to 'call' scope. Specify callback scope (call|async|notified) attribute with fixup.");
|
||||||
sw.WriteLine (indent + "\t\t\t{0} {1}_wrapper = new {0} ({1});", wrapper, name);
|
sw.WriteLine (indent + "\t\t\t{0} {1}_wrapper = new {0} ({1});", wrapper, name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -261,13 +261,16 @@ namespace GtkSharp.Generation {
|
||||||
|
|
||||||
public override bool Validate ()
|
public override bool Validate ()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (Parent != null && !(Parent as ObjectBase).ValidateForSubclass ())
|
if (Parent != null && !(Parent as ObjectBase).ValidateForSubclass ())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
LogWriter log = new LogWriter (QualifiedName);
|
||||||
|
|
||||||
ArrayList invalids = new ArrayList ();
|
ArrayList invalids = new ArrayList ();
|
||||||
|
|
||||||
foreach (GObjectVM vm in virtual_methods)
|
foreach (GObjectVM vm in virtual_methods)
|
||||||
if (!vm.Validate ())
|
if (!vm.Validate (log))
|
||||||
invalids.Add (vm);
|
invalids.Add (vm);
|
||||||
|
|
||||||
foreach (VirtualMethod invalid_vm in invalids) {
|
foreach (VirtualMethod invalid_vm in invalids) {
|
||||||
|
@ -278,11 +281,11 @@ namespace GtkSharp.Generation {
|
||||||
|
|
||||||
class_fields_valid = true;
|
class_fields_valid = true;
|
||||||
foreach (ClassField field in class_fields)
|
foreach (ClassField field in class_fields)
|
||||||
if (!field.Validate ())
|
if (!field.Validate (log))
|
||||||
class_fields_valid = false;
|
class_fields_valid = false;
|
||||||
|
|
||||||
foreach (InterfaceVM vm in interface_vms)
|
foreach (InterfaceVM vm in interface_vms)
|
||||||
if (!vm.Validate ())
|
if (!vm.Validate (log))
|
||||||
invalids.Add (vm);
|
invalids.Add (vm);
|
||||||
|
|
||||||
foreach (InterfaceVM invalid_vm in invalids) {
|
foreach (InterfaceVM invalid_vm in invalids) {
|
||||||
|
@ -292,10 +295,8 @@ namespace GtkSharp.Generation {
|
||||||
invalids.Clear ();
|
invalids.Clear ();
|
||||||
|
|
||||||
foreach (Signal sig in sigs.Values) {
|
foreach (Signal sig in sigs.Values) {
|
||||||
if (!sig.Validate ()) {
|
if (!sig.Validate (log))
|
||||||
Console.WriteLine ("in type " + QualifiedName);
|
|
||||||
invalids.Add (sig);
|
invalids.Add (sig);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
foreach (Signal sig in invalids)
|
foreach (Signal sig in invalids)
|
||||||
sigs.Remove (sig.Name);
|
sigs.Remove (sig.Name);
|
||||||
|
@ -305,11 +306,11 @@ namespace GtkSharp.Generation {
|
||||||
|
|
||||||
public virtual bool ValidateForSubclass ()
|
public virtual bool ValidateForSubclass ()
|
||||||
{
|
{
|
||||||
|
LogWriter log = new LogWriter (QualifiedName);
|
||||||
ArrayList invalids = new ArrayList ();
|
ArrayList invalids = new ArrayList ();
|
||||||
|
|
||||||
foreach (Signal sig in sigs.Values) {
|
foreach (Signal sig in sigs.Values) {
|
||||||
if (!sig.Validate ()) {
|
if (!sig.Validate (log)) {
|
||||||
Console.WriteLine ("in type " + QualifiedName);
|
|
||||||
invalids.Add (sig);
|
invalids.Add (sig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,13 +77,13 @@ namespace GtkSharp.Generation {
|
||||||
|
|
||||||
public override bool Validate ()
|
public override bool Validate ()
|
||||||
{
|
{
|
||||||
|
LogWriter log = new LogWriter (QualifiedName);
|
||||||
|
|
||||||
ArrayList invalids = new ArrayList ();
|
ArrayList invalids = new ArrayList ();
|
||||||
|
|
||||||
foreach (ChildProperty prop in childprops.Values) {
|
foreach (ChildProperty prop in childprops.Values) {
|
||||||
if (!prop.Validate ()) {
|
if (!prop.Validate (log))
|
||||||
Console.WriteLine ("in Object " + QualifiedName);
|
|
||||||
invalids.Add (prop);
|
invalids.Add (prop);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
foreach (ChildProperty prop in invalids)
|
foreach (ChildProperty prop in invalids)
|
||||||
childprops.Remove (prop);
|
childprops.Remove (prop);
|
||||||
|
@ -129,7 +129,7 @@ namespace GtkSharp.Generation {
|
||||||
|
|
||||||
public override void Generate (GenerationInfo gen_info)
|
public override void Generate (GenerationInfo gen_info)
|
||||||
{
|
{
|
||||||
gen_info.CurrentType = Name;
|
gen_info.CurrentType = QualifiedName;
|
||||||
|
|
||||||
string asm_name = gen_info.AssemblyName.Length == 0 ? NS.ToLower () + "-sharp" : gen_info.AssemblyName;
|
string asm_name = gen_info.AssemblyName.Length == 0 ? NS.ToLower () + "-sharp" : gen_info.AssemblyName;
|
||||||
DirectoryInfo di = GetDirectoryInfo (gen_info.Dir, asm_name);
|
DirectoryInfo di = GetDirectoryInfo (gen_info.Dir, asm_name);
|
||||||
|
|
|
@ -43,7 +43,7 @@ namespace GtkSharp.Generation {
|
||||||
|
|
||||||
public override void Generate (GenerationInfo gen_info)
|
public override void Generate (GenerationInfo gen_info)
|
||||||
{
|
{
|
||||||
gen_info.CurrentType = Name;
|
gen_info.CurrentType = QualifiedName;
|
||||||
|
|
||||||
StreamWriter sw = gen_info.Writer = gen_info.OpenStream (Name);
|
StreamWriter sw = gen_info.Writer = gen_info.OpenStream (Name);
|
||||||
|
|
||||||
|
|
|
@ -622,7 +622,7 @@ namespace GtkSharp.Generation {
|
||||||
|
|
||||||
bool valid = false;
|
bool valid = false;
|
||||||
|
|
||||||
public bool Validate ()
|
public bool Validate (LogWriter log)
|
||||||
{
|
{
|
||||||
if (valid)
|
if (valid)
|
||||||
return true;
|
return true;
|
||||||
|
@ -637,14 +637,14 @@ namespace GtkSharp.Generation {
|
||||||
Parameter p = new Parameter (parm);
|
Parameter p = new Parameter (parm);
|
||||||
|
|
||||||
if (p.IsEllipsis) {
|
if (p.IsEllipsis) {
|
||||||
Console.Write("Ellipsis parameter ");
|
log.Warn ("Ellipsis parameter: hide and bind manually if no alternative exists. ");
|
||||||
Clear ();
|
Clear ();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((p.CSType == "") || (p.Name == "") ||
|
if ((p.CSType == "") || (p.Name == "") ||
|
||||||
(p.MarshalType == "") || (SymbolTable.Table.CallByName(p.CType, p.Name) == "")) {
|
(p.MarshalType == "") || (SymbolTable.Table.CallByName(p.CType, p.Name) == "")) {
|
||||||
Console.Write ("Invalid parameter {0} of type {1}", p.Name, p.CType);
|
log.Warn ("Unknown type {1} on parameter {0}", p.Name, p.CType);
|
||||||
Clear ();
|
Clear ();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,10 +31,11 @@ namespace GtkSharp.Generation {
|
||||||
|
|
||||||
public Property (XmlElement elem, ClassBase container_type) : base (elem, container_type) {}
|
public Property (XmlElement elem, ClassBase container_type) : base (elem, container_type) {}
|
||||||
|
|
||||||
public bool Validate ()
|
public bool Validate (LogWriter log)
|
||||||
{
|
{
|
||||||
if (CSType == "" && !Hidden) {
|
if (CSType == "" && !Hidden) {
|
||||||
Console.Write("Property has unknown Type {0} ", CType);
|
log.Member = Name;
|
||||||
|
log.Warn ("property has unknown type '{0}' ", CType);
|
||||||
Statistics.ThrottledCount++;
|
Statistics.ThrottledCount++;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,12 +158,13 @@ namespace GtkSharp.Generation {
|
||||||
return IGen.CallByName (var);
|
return IGen.CallByName (var);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Validate ()
|
public bool Validate (LogWriter log)
|
||||||
{
|
{
|
||||||
if (MarshalType == "" || CSType == "") {
|
if (MarshalType == "" || CSType == "") {
|
||||||
Console.Write("rettype: " + CType);
|
log.Warn ("Unknown return type: {0}", CType);
|
||||||
return false;
|
return false;
|
||||||
}
|
} else if ((CSType == "GLib.List" || CSType == "GLib.SList") && String.IsNullOrEmpty (ElementType))
|
||||||
|
log.Warn ("Returns {0} with unknown element type. Add element_type attribute with gapi-fixup.", CType);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,20 +60,17 @@ namespace GtkSharp.Generation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Validate ()
|
public bool Validate (LogWriter log)
|
||||||
{
|
{
|
||||||
|
log.Member = Name;
|
||||||
if (Name == "") {
|
if (Name == "") {
|
||||||
Console.Write ("Nameless signal ");
|
log.Warn ("Nameless signal found. Add name attribute with fixup.");
|
||||||
|
Statistics.ThrottledCount++;
|
||||||
|
return false;
|
||||||
|
} else if (!parms.Validate (log) || !retval.Validate (log)) {
|
||||||
Statistics.ThrottledCount++;
|
Statistics.ThrottledCount++;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!parms.Validate () || !retval.Validate ()) {
|
|
||||||
Console.Write (" in signal " + Name + " ");
|
|
||||||
Statistics.ThrottledCount++;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -127,9 +127,9 @@ namespace GtkSharp.Generation {
|
||||||
|
|
||||||
public override bool Validate ()
|
public override bool Validate ()
|
||||||
{
|
{
|
||||||
|
LogWriter log = new LogWriter (QualifiedName);
|
||||||
foreach (StructField field in fields) {
|
foreach (StructField field in fields) {
|
||||||
if (!field.Validate ()) {
|
if (!field.Validate (log)) {
|
||||||
Console.WriteLine ("in Struct " + QualifiedName);
|
|
||||||
if (!field.IsPointer)
|
if (!field.IsPointer)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace GtkSharp.Generation {
|
||||||
|
|
||||||
public override void Generate (GenerationInfo gen_info)
|
public override void Generate (GenerationInfo gen_info)
|
||||||
{
|
{
|
||||||
gen_info.CurrentType = Name;
|
gen_info.CurrentType = QualifiedName;
|
||||||
|
|
||||||
StreamWriter sw = gen_info.Writer = gen_info.OpenStream (Name);
|
StreamWriter sw = gen_info.Writer = gen_info.OpenStream (Name);
|
||||||
base.Generate (gen_info);
|
base.Generate (gen_info);
|
||||||
|
|
|
@ -61,7 +61,9 @@ namespace GtkSharp.Generation {
|
||||||
*/
|
*/
|
||||||
public void GenerateCallback (StreamWriter sw, ClassBase implementor)
|
public void GenerateCallback (StreamWriter sw, ClassBase implementor)
|
||||||
{
|
{
|
||||||
if (!Validate ())
|
LogWriter log = new LogWriter ();
|
||||||
|
log.Type = container_type.QualifiedName;
|
||||||
|
if (!Validate (log))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
string native_signature = "";
|
string native_signature = "";
|
||||||
|
@ -118,12 +120,6 @@ namespace GtkSharp.Generation {
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsValid {
|
|
||||||
get {
|
|
||||||
return Validate ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
enum ValidState {
|
enum ValidState {
|
||||||
Unvalidated,
|
Unvalidated,
|
||||||
Invalid,
|
Invalid,
|
||||||
|
@ -132,24 +128,20 @@ namespace GtkSharp.Generation {
|
||||||
|
|
||||||
ValidState vstate = ValidState.Unvalidated;
|
ValidState vstate = ValidState.Unvalidated;
|
||||||
|
|
||||||
public override bool Validate ()
|
public override bool Validate (LogWriter log)
|
||||||
{
|
{
|
||||||
if (vstate != ValidState.Unvalidated)
|
if (vstate != ValidState.Unvalidated)
|
||||||
return vstate == ValidState.Valid;
|
return vstate == ValidState.Valid;
|
||||||
|
|
||||||
vstate = ValidState.Valid;
|
vstate = ValidState.Valid;
|
||||||
if (!parms.Validate () || !retval.Validate ()) {
|
log.Member = Name;
|
||||||
|
if (!parms.Validate (log) || !retval.Validate (log)) {
|
||||||
vstate = ValidState.Invalid;
|
vstate = ValidState.Invalid;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vstate == ValidState.Invalid) {
|
call = new ManagedCallString (parms);
|
||||||
Console.WriteLine ("(in virtual method " + container_type.QualifiedName + "." + Name + ")");
|
return true;
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
// The call string has to be created *after* the params have been validated since the Parameters class contains no elements before validation
|
|
||||||
call = new ManagedCallString (parms);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue