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>
|
2009-03-17 Mike Kestner <mkestner@novell.com>
|
||||||
|
|
||||||
* bootstrap-generic: expose LIBTOOLIZE env variable to support
|
* bootstrap-generic: expose LIBTOOLIZE env variable to support
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<api>
|
<api parser_version="1">
|
||||||
<!--
|
<!--
|
||||||
|
|
||||||
This file was automatically generated.
|
This file was automatically generated.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<api>
|
<api parser_version="1">
|
||||||
<!--
|
<!--
|
||||||
|
|
||||||
This file was automatically generated.
|
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 {
|
public bool IsInternal {
|
||||||
get {
|
get {
|
||||||
if (elem.HasAttribute ("internal")) {
|
if (elem.HasAttribute ("internal")) {
|
||||||
|
|
|
@ -28,6 +28,7 @@ namespace GtkSharp.Generation {
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
|
||||||
public class Parser {
|
public class Parser {
|
||||||
|
const int curr_parser_version = 1;
|
||||||
|
|
||||||
private XmlDocument Load (string filename)
|
private XmlDocument Load (string filename)
|
||||||
{
|
{
|
||||||
|
@ -59,6 +60,20 @@ namespace GtkSharp.Generation {
|
||||||
return null;
|
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 ();
|
ArrayList gens = new ArrayList ();
|
||||||
|
|
||||||
foreach (XmlNode child in root.ChildNodes) {
|
foreach (XmlNode child in root.ChildNodes) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<api>
|
<api parser_version="1">
|
||||||
<!--
|
<!--
|
||||||
|
|
||||||
This file was automatically generated.
|
This file was automatically generated.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<api>
|
<api parser_version="1">
|
||||||
<!--
|
<!--
|
||||||
|
|
||||||
This file was automatically generated.
|
This file was automatically generated.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<api>
|
<api parser_version="1">
|
||||||
<!--
|
<!--
|
||||||
|
|
||||||
This file was automatically generated.
|
This file was automatically generated.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<api>
|
<api parser_version="1">
|
||||||
<!--
|
<!--
|
||||||
|
|
||||||
This file was automatically generated.
|
This file was automatically generated.
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
# Boston, MA 02111-1307, USA.
|
# Boston, MA 02111-1307, USA.
|
||||||
##############################################################
|
##############################################################
|
||||||
|
|
||||||
|
$parser_version = 1;
|
||||||
$debug=$ENV{'GAPI_DEBUG'};
|
$debug=$ENV{'GAPI_DEBUG'};
|
||||||
|
|
||||||
use XML::LibXML;
|
use XML::LibXML;
|
||||||
|
@ -43,9 +44,13 @@ if (-e $ARGV[1]) {
|
||||||
#parse existing file and get root node.
|
#parse existing file and get root node.
|
||||||
$doc = XML::LibXML->new->parse_file($ARGV[1]);
|
$doc = XML::LibXML->new->parse_file($ARGV[1]);
|
||||||
$root = $doc->getDocumentElement();
|
$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 {
|
} else {
|
||||||
$doc = XML::LibXML::Document->new();
|
$doc = XML::LibXML::Document->new();
|
||||||
$root = $doc->createElement('api');
|
$root = $doc->createElement('api');
|
||||||
|
$root->setAttribute('parser_version', $parser_version);
|
||||||
$doc->setDocumentElement($root);
|
$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");
|
$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);
|
$root->appendChild($warning_node);
|
||||||
|
|
Loading…
Reference in a new issue