2009-03-19 Christian Hoff <christian_hoff@gmx.net>
* parser/gapi2xml.pl: Introduce a "parser_version" attribute. * generator/GenBase.cs: Implement a property to access the attribute's value. svn path=/trunk/gtk-sharp/; revision=129807
This commit is contained in:
parent
87dc12c27e
commit
01ed1a5e3e
10 changed files with 40 additions and 7 deletions
|
@ -1,3 +1,9 @@
|
|||
2009-03-19 Christian Hoff <christian_hoff@gmx.net>
|
||||
|
||||
* parser/gapi2xml.pl: Introduce a "parser_version" attribute.
|
||||
* generator/GenBase.cs: Implement a property to access the
|
||||
attribute's value.
|
||||
|
||||
2009-03-17 Mike Kestner <mkestner@novell.com>
|
||||
|
||||
* bootstrap-generic: expose LIBTOOLIZE env variable to support
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0"?>
|
||||
<api>
|
||||
<api parser_version="1">
|
||||
<!--
|
||||
|
||||
This file was automatically generated.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0"?>
|
||||
<api>
|
||||
<api parser_version="1">
|
||||
<!--
|
||||
|
||||
This file was automatically generated.
|
||||
|
|
|
@ -49,6 +49,13 @@ namespace GtkSharp.Generation {
|
|||
}
|
||||
}
|
||||
|
||||
public int ParserVersion {
|
||||
get {
|
||||
XmlElement root = elem.OwnerDocument.DocumentElement;
|
||||
return root.HasAttribute ("parser_version") ? int.Parse (root.GetAttribute ("parser_version")) : 1;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsInternal {
|
||||
get {
|
||||
if (elem.HasAttribute ("internal")) {
|
||||
|
|
|
@ -28,7 +28,8 @@ namespace GtkSharp.Generation {
|
|||
using System.Xml;
|
||||
|
||||
public class Parser {
|
||||
|
||||
const int curr_parser_version = 1;
|
||||
|
||||
private XmlDocument Load (string filename)
|
||||
{
|
||||
XmlDocument doc = new XmlDocument ();
|
||||
|
@ -59,6 +60,20 @@ namespace GtkSharp.Generation {
|
|||
return null;
|
||||
}
|
||||
|
||||
int parser_version;
|
||||
if (root.HasAttribute ("parser_version")) {
|
||||
try {
|
||||
parser_version = int.Parse (root.GetAttribute ("parser_version"));
|
||||
} catch {
|
||||
Console.WriteLine ("ERROR: Unable to parse parser_version attribute value \"{0}\" to a number. Input file {1} will be ignored", root.GetAttribute ("parser_version"), filename);
|
||||
return null;
|
||||
}
|
||||
} else
|
||||
parser_version = 1;
|
||||
|
||||
if (parser_version > curr_parser_version)
|
||||
Console.WriteLine ("WARNING: The input file {0} was created by a parser that was released after this version of the generator. Consider updating the code generator if you experience problems.", filename);
|
||||
|
||||
ArrayList gens = new ArrayList ();
|
||||
|
||||
foreach (XmlNode child in root.ChildNodes) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0"?>
|
||||
<api>
|
||||
<api parser_version="1">
|
||||
<!--
|
||||
|
||||
This file was automatically generated.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0"?>
|
||||
<api>
|
||||
<api parser_version="1">
|
||||
<!--
|
||||
|
||||
This file was automatically generated.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0"?>
|
||||
<api>
|
||||
<api parser_version="1">
|
||||
<!--
|
||||
|
||||
This file was automatically generated.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0"?>
|
||||
<api>
|
||||
<api parser_version="1">
|
||||
<!--
|
||||
|
||||
This file was automatically generated.
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
# Boston, MA 02111-1307, USA.
|
||||
##############################################################
|
||||
|
||||
$parser_version = 1;
|
||||
$debug=$ENV{'GAPI_DEBUG'};
|
||||
|
||||
use XML::LibXML;
|
||||
|
@ -43,9 +44,13 @@ if (-e $ARGV[1]) {
|
|||
#parse existing file and get root node.
|
||||
$doc = XML::LibXML->new->parse_file($ARGV[1]);
|
||||
$root = $doc->getDocumentElement();
|
||||
if ($root->getAttribute ('parser_version') != $parser_version) {
|
||||
die "The version of the file does not match the version of the parser";
|
||||
}
|
||||
} else {
|
||||
$doc = XML::LibXML::Document->new();
|
||||
$root = $doc->createElement('api');
|
||||
$root->setAttribute('parser_version', $parser_version);
|
||||
$doc->setDocumentElement($root);
|
||||
$warning_node = XML::LibXML::Comment->new ("\n\n This file was automatically generated.\n Please DO NOT MODIFY THIS FILE, modify .metadata files instead.\n\n");
|
||||
$root->appendChild($warning_node);
|
||||
|
|
Loading…
Reference in a new issue