2002-06-26 Rachel Hestilow <hestilow@ximian.com>

* generator/*.cs: Deal with whitespace XmlNodes.

	* parser/build.pl: Dump non-indented file to local directory.

	* parser/makefile, parser/formatXml.c: Added.

	* generator/gtkapi.xml: Nicely indented now. woo!

svn path=/trunk/gtk-sharp/; revision=5465
This commit is contained in:
Rachel Hestilow 2002-06-26 13:10:48 +00:00
parent 34cf63f0cc
commit b203c33bb7
14 changed files with 22246 additions and 12 deletions

View file

@ -1,3 +1,13 @@
2002-06-26 Rachel Hestilow <hestilow@ximian.com>
* generator/*.cs: Deal with whitespace XmlNodes.
* parser/build.pl: Dump non-indented file to local directory.
* parser/makefile, parser/formatXml.c: Added.
* generator/gtkapi.xml: Nicely indented now. woo!
2002-06-26 Rachel Hestilow <hestilow@ximian.com>
* parser/Gtk.metadata: Change gtk_label_new to be the

View file

@ -48,7 +48,7 @@ namespace GtkSharp.Generation {
Hashtable clash_map = new Hashtable();
foreach (XmlNode node in Elem.ChildNodes) {
if (!(node is XmlElement)) continue;
XmlElement member = (XmlElement) node;
switch (node.Name) {

View file

@ -39,6 +39,7 @@ namespace GtkSharp.Generation {
protected ClassBase (XmlElement ns, XmlElement elem) : base (ns, elem) {
foreach (XmlNode node in elem.ChildNodes) {
if (!(node is XmlElement)) continue;
XmlElement member = (XmlElement) node;
switch (node.Name) {

View file

@ -51,7 +51,7 @@ namespace GtkSharp.Generation {
sw.WriteLine ();
foreach (XmlNode node in Elem.ChildNodes) {
if (node.Name != "member") {
if (!(node is XmlElement) || node.Name != "member") {
continue;
}

View file

@ -19,6 +19,7 @@ namespace GtkSharp.Generation {
{
foreach (XmlNode node in elem.ChildNodes) {
if (!(node is XmlElement)) continue;
XmlElement member = (XmlElement) node;
switch (node.Name) {

View file

@ -50,7 +50,7 @@ namespace GtkSharp.Generation {
public bool Validate ()
{
foreach (XmlNode parm in elem.ChildNodes) {
if (parm.Name != "parameter") {
if (!(parm is XmlElement) || parm.Name != "parameter") {
continue;
}
@ -233,7 +233,7 @@ namespace GtkSharp.Generation {
int length = 0;
string pass_as = "";
foreach (XmlNode parm in elem.ChildNodes) {
if (parm.Name != "parameter") {
if (!(parm is XmlElement) || parm.Name != "parameter") {
continue;
}
@ -254,7 +254,12 @@ namespace GtkSharp.Generation {
if ((elem.ChildNodes == null) || (elem.ChildNodes.Count < 1))
return false;
XmlElement p_elem = (XmlElement) elem.ChildNodes[elem.ChildNodes.Count - 1];
XmlElement p_elem = null;
foreach (XmlNode parm in elem.ChildNodes) {
if (!(parm is XmlElement) || parm.Name != "parameter")
continue;
p_elem = (XmlElement) parm;
}
string type = p_elem.GetAttribute("type");
return (type == "GError**");
}

View file

@ -40,7 +40,7 @@ namespace GtkSharp.Generation {
}
foreach (XmlNode ns in root.ChildNodes) {
if (ns.Name != "namespace") {
if (!(ns is XmlElement) || ns.Name != "namespace") {
continue;
}

View file

@ -50,7 +50,7 @@ namespace GtkSharp.Generation {
}
foreach (XmlNode parm in params_elem.ChildNodes) {
if (parm.Name != "parameter") continue;
if (!(parm is XmlElement) || parm.Name != "parameter") continue;
XmlElement elem = (XmlElement) parm;
String type = elem.GetAttribute("type");

View file

@ -175,7 +175,7 @@ namespace GtkSharp.Generation {
bool need_comma = false;
foreach (XmlNode parm in parms.ChildNodes) {
if (parm.Name != "parameter") {
if (!(parm is XmlElement) || parm.Name != "parameter") {
Console.Write(parm.Name + " node ");
return false;
}
@ -209,7 +209,7 @@ namespace GtkSharp.Generation {
bool need_comma = false;
foreach (XmlNode parm in parms.ChildNodes) {
if (parm.Name != "parameter") {
if (!(parm is XmlElement) || parm.Name != "parameter") {
continue;
}

View file

@ -49,7 +49,7 @@ namespace GtkSharp.Generation {
sw.WriteLine ();
foreach (XmlNode node in Elem.ChildNodes) {
if (!(node is XmlElement)) continue;
XmlElement member = (XmlElement) node;
switch (node.Name) {

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
#!/usr/bin/perl -w
$file = "../generator/gtkapi.xml";
$file = "gtkapi.xml";
unlink ($file);

41
parser/formatXml.c Normal file
View file

@ -0,0 +1,41 @@
#include <glib.h>
#include <stdlib.h>
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
static int
formatFile (const gchar *input, const gchar *output)
{
xmlDocPtr doc;
/*
* build an XML tree from a the file;
*/
doc = xmlParseFile (input);
if (doc == NULL){
g_warning ("File %s empty or not well-formed.", input);
return -1;
}
if (xmlSaveFormatFile (output, doc, TRUE) == -1){
g_warning ("Error saving config data to %s", input);
}
xmlFreeDoc (doc);
return 0;
}
int main(int argc, char **argv)
{
if (argc != 3){
g_print ("Usage: formatXml inputfile outputfile\n\n");
return -1;
}
xmlKeepBlanksDefault(0);
formatFile (argv [1], argv [2]);
return 0;
}

10
parser/makefile Normal file
View file

@ -0,0 +1,10 @@
all: generated-stamp
generated-stamp: formatXml gtkapi.xml
./formatXml gtkapi.xml ../generator/gtkapi.xml && touch generated-stamp
formatXml: formatXml.c
cc -o formatXml formatXml.c `pkg-config --cflags --libs libxml-2.0 glib-2.0`
gtkapi.xml: build.pl
./build.pl