generator: readable&writable attribs to be backwards compat

This commit is contained in:
Stephan Sundermann 2013-10-08 18:55:34 +02:00 committed by Andrés G. Aragoneses
parent dc4e7f30b9
commit fd2fb44f99
3 changed files with 11 additions and 8 deletions

View file

@ -42,12 +42,16 @@ namespace GtkSharp.Generation {
protected virtual bool Readable {
get {
if (Parser.GetVersion (elem.OwnerDocument.DocumentElement) <= 2)
return elem.GetAttribute ("readable") != "false";
return elem.HasAttribute ("readable") && elem.GetAttributeAsBoolean ("readable");
}
}
protected virtual bool Writable {
get {
if (Parser.GetVersion (elem.OwnerDocument.DocumentElement) <= 2)
return elem.GetAttribute ("writeable") != "false";
return elem.HasAttribute ("writeable") && elem.GetAttributeAsBoolean ("writeable");
}
}

View file

@ -53,7 +53,7 @@ namespace GtkSharp.Generation {
private bool throws = false;
public bool Throws {
get {
if (ParserVersion <= 2)
if (Parser.GetVersion (elem.OwnerDocument.DocumentElement) <= 2)
return true;
if (!throws && elem.HasAttribute ("throws"))
throws = elem.GetAttributeAsBoolean ("throws");
@ -289,12 +289,5 @@ namespace GtkSharp.Generation {
return String.Join (", ", result);
}
}
private int ParserVersion {
get {
XmlElement root = elem.OwnerDocument.DocumentElement;
return root.HasAttribute ("parser_version") ? int.Parse (root.GetAttribute ("parser_version")) : 1;
}
}
}
}

View file

@ -187,6 +187,12 @@ namespace GtkSharp.Generation {
return result;
}
internal static int GetVersion (XmlElement document_element)
{
XmlElement root = document_element;
return root.HasAttribute ("parser_version") ? int.Parse (root.GetAttribute ("parser_version")) : 1;
}
private IGeneratable ParseSymbol (XmlElement symbol)
{
string type = symbol.GetAttribute ("type");