Convert some source files to Unix line endings

No real code change in this commit.
This commit is contained in:
Bertrand Lorentz 2015-05-25 16:57:08 +02:00
parent a3db272fee
commit 5422daaabc
7 changed files with 980 additions and 980 deletions

View file

@ -1,72 +1,72 @@
// extract-missing.cs - grab missing api elements from api-diff files.
//
// Author: Mike Kestner <mkestner@novell.com>
//
// Copyright (c) 2005 Mike Kestner
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the GNU General Public
// License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GtkSharp.Auditing {
using System;
using System.IO;
using System.Xml;
using System.Xml.XPath;
public class ExtractMissing {
public static int Main (string[] args)
{
if (args.Length != 1 || !File.Exists (args [0])) {
Console.WriteLine ("Usage: extract-missing <filename>");
return 0;
}
XmlDocument doc = new XmlDocument ();
try {
Stream stream = File.OpenRead (args [0]);
doc.Load (stream);
stream.Close ();
} catch (XmlException e) {
Console.WriteLine ("Invalid apidiff file.");
Console.WriteLine (e);
return 1;
}
XPathNavigator nav = doc.CreateNavigator ();
XPathNodeIterator iter = nav.Select ("//*[@presence='missing']");
while (iter.MoveNext ()) {
XmlElement node = ((IHasXmlNode)iter.Current).GetNode () as XmlElement;
if (node.Name == "class")
Console.WriteLine ("Missing type: " + node.GetAttribute ("name"));
else if (node.ParentNode.ParentNode.Name == "class")
Console.WriteLine ("Missing " + node.Name + " " + (node.ParentNode.ParentNode as XmlElement).GetAttribute ("name") + "." + node.GetAttribute ("name"));
else if (node.Name == "attribute") {
if (node.ParentNode.ParentNode.Name == "class")
Console.WriteLine ("Missing attribute (" + (node as XmlElement).GetAttribute ("name") + ") on type: " + (node.ParentNode.ParentNode as XmlElement).GetAttribute ("name"));
else if (node.ParentNode.ParentNode.ParentNode.ParentNode.Name == "class")
Console.WriteLine ("Missing attribute (" + (node as XmlElement).GetAttribute ("name") + ") on " + (node.ParentNode.ParentNode.ParentNode.ParentNode as XmlElement).GetAttribute ("name") + "." + (node.ParentNode.ParentNode as XmlElement).GetAttribute ("name"));
else
Console.WriteLine ("oopsie: " + node.Name + " " + node.ParentNode.ParentNode.Name);
} else
Console.WriteLine ("oopsie: " + node.Name + " " + node.ParentNode.ParentNode.Name);
}
return 0;
}
}
}
// extract-missing.cs - grab missing api elements from api-diff files.
//
// Author: Mike Kestner <mkestner@novell.com>
//
// Copyright (c) 2005 Mike Kestner
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the GNU General Public
// License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GtkSharp.Auditing {
using System;
using System.IO;
using System.Xml;
using System.Xml.XPath;
public class ExtractMissing {
public static int Main (string[] args)
{
if (args.Length != 1 || !File.Exists (args [0])) {
Console.WriteLine ("Usage: extract-missing <filename>");
return 0;
}
XmlDocument doc = new XmlDocument ();
try {
Stream stream = File.OpenRead (args [0]);
doc.Load (stream);
stream.Close ();
} catch (XmlException e) {
Console.WriteLine ("Invalid apidiff file.");
Console.WriteLine (e);
return 1;
}
XPathNavigator nav = doc.CreateNavigator ();
XPathNodeIterator iter = nav.Select ("//*[@presence='missing']");
while (iter.MoveNext ()) {
XmlElement node = ((IHasXmlNode)iter.Current).GetNode () as XmlElement;
if (node.Name == "class")
Console.WriteLine ("Missing type: " + node.GetAttribute ("name"));
else if (node.ParentNode.ParentNode.Name == "class")
Console.WriteLine ("Missing " + node.Name + " " + (node.ParentNode.ParentNode as XmlElement).GetAttribute ("name") + "." + node.GetAttribute ("name"));
else if (node.Name == "attribute") {
if (node.ParentNode.ParentNode.Name == "class")
Console.WriteLine ("Missing attribute (" + (node as XmlElement).GetAttribute ("name") + ") on type: " + (node.ParentNode.ParentNode as XmlElement).GetAttribute ("name"));
else if (node.ParentNode.ParentNode.ParentNode.ParentNode.Name == "class")
Console.WriteLine ("Missing attribute (" + (node as XmlElement).GetAttribute ("name") + ") on " + (node.ParentNode.ParentNode.ParentNode.ParentNode as XmlElement).GetAttribute ("name") + "." + (node.ParentNode.ParentNode as XmlElement).GetAttribute ("name"));
else
Console.WriteLine ("oopsie: " + node.Name + " " + node.ParentNode.ParentNode.Name);
} else
Console.WriteLine ("oopsie: " + node.Name + " " + node.ParentNode.ParentNode.Name);
}
return 0;
}
}
}

View file

@ -1,77 +1,77 @@
// add-since.cs - Adds a since element to a Type document.
//
// Author: Mike Kestner <mkestner@novell.com>
//
// Copyright (c) 2007 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the GNU General Public
// License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GtkSharp.Docs {
using System;
using System.Collections;
using System.IO;
using System.Reflection;
using System.Xml;
using System.Xml.XPath;
public class GenHandlerArgsDocs {
public static int Main (string[] args)
{
string version = null;
ArrayList files = new ArrayList ();
foreach (string arg in args) {
if (arg.StartsWith ("--version=")) {
version = arg.Substring (10);
} else {
files.Add (arg);
}
}
if (version == null) {
Console.WriteLine ("Usage: add-since --version=<version> <paths>");
return 1;
}
Console.WriteLine ("version: " + version);
XmlDocument api_doc = new XmlDocument ();
foreach (string file in files) {
Console.WriteLine ("file: " + file);
try {
Stream stream = File.OpenRead (file);
api_doc.Load (stream);
stream.Close ();
} catch (XmlException e) {
Console.WriteLine (e);
return 1;
}
XPathNavigator api_nav = api_doc.CreateNavigator ();
XPathNodeIterator iter = api_nav.Select ("/Type/Docs");
if (iter.MoveNext ()) {
XmlElement docs = ((IHasXmlNode)iter.Current).GetNode () as XmlElement;
XmlElement since = api_doc.CreateElement ("since");
since.SetAttribute ("version", version);
docs.AppendChild (since);
api_doc.Save (file);
}
}
return 0;
}
}
}
// add-since.cs - Adds a since element to a Type document.
//
// Author: Mike Kestner <mkestner@novell.com>
//
// Copyright (c) 2007 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the GNU General Public
// License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GtkSharp.Docs {
using System;
using System.Collections;
using System.IO;
using System.Reflection;
using System.Xml;
using System.Xml.XPath;
public class GenHandlerArgsDocs {
public static int Main (string[] args)
{
string version = null;
ArrayList files = new ArrayList ();
foreach (string arg in args) {
if (arg.StartsWith ("--version=")) {
version = arg.Substring (10);
} else {
files.Add (arg);
}
}
if (version == null) {
Console.WriteLine ("Usage: add-since --version=<version> <paths>");
return 1;
}
Console.WriteLine ("version: " + version);
XmlDocument api_doc = new XmlDocument ();
foreach (string file in files) {
Console.WriteLine ("file: " + file);
try {
Stream stream = File.OpenRead (file);
api_doc.Load (stream);
stream.Close ();
} catch (XmlException e) {
Console.WriteLine (e);
return 1;
}
XPathNavigator api_nav = api_doc.CreateNavigator ();
XPathNodeIterator iter = api_nav.Select ("/Type/Docs");
if (iter.MoveNext ()) {
XmlElement docs = ((IHasXmlNode)iter.Current).GetNode () as XmlElement;
XmlElement since = api_doc.CreateElement ("since");
since.SetAttribute ("version", version);
docs.AppendChild (since);
api_doc.Save (file);
}
}
return 0;
}
}
}

View file

@ -1,197 +1,197 @@
// gen-handlerargs-docs.cs - Generate documentation for event handlers/args
//
// Author: Mike Kestner <mkestner@ximian.com>
//
// Copyright (c) 2004 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the GNU General Public
// License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GtkSharp.Docs {
using System;
using System.Collections;
using System.IO;
using System.Reflection;
using System.Xml;
using System.Xml.XPath;
public class GenHandlerArgsDocs {
public static int Main (string[] args)
{
Hashtable hndlrs = new Hashtable ();
XmlDocument api_doc = new XmlDocument ();
BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly;
foreach (string arg in args) {
Assembly assembly;
try {
assembly = Assembly.LoadFile (arg);
} catch (XmlException e) {
Console.WriteLine (e);
return 1;
}
foreach (Type t in assembly.GetTypes ()) {
if (!t.IsSubclassOf (typeof (GLib.Object)))
continue;
foreach (EventInfo ei in t.GetEvents (flags)) {
foreach (Attribute attr in ei.GetCustomAttributes (false)) {
if (attr.ToString () == "GLib.SignalAttribute") {
if (ei.EventHandlerType.ToString() == "System.EventHandler")
break;
ArrayList sigs;
if (hndlrs.Contains (ei.EventHandlerType))
sigs = hndlrs [ei.EventHandlerType] as ArrayList;
else {
sigs = new ArrayList ();
hndlrs [ei.EventHandlerType] = sigs;
}
sigs.Add (t + "." + ei.Name);
break;
}
}
}
}
}
if (hndlrs.Count == 0)
return 0;
foreach (Type hndlr in hndlrs.Keys) {
string filename = "en/" + hndlr.Namespace + "/" + hndlr.Name + ".xml";
try {
Stream stream = File.OpenRead (filename);
api_doc.Load (stream);
stream.Close ();
} catch (XmlException e) {
Console.WriteLine (e);
return 1;
}
Type arg_type = hndlr.GetMethod ("Invoke").GetParameters ()[1].ParameterType;
XPathNavigator api_nav = api_doc.CreateNavigator ();
XPathNodeIterator iter = api_nav.Select ("/Type/Docs");
if (iter.MoveNext ()) {
XmlElement elem = ((IHasXmlNode)iter.Current).GetNode () as XmlElement;
XmlElement summ = elem ["summary"];
XmlElement rem = elem ["remarks"];
string summary = summ.InnerXml;
string remarks = rem.InnerXml;
if (summary == "To be added." && remarks == "To be added.") {
Console.WriteLine (filename + ": Documenting summary and remarks");
summ.InnerXml = "Event handler.";
ArrayList sigs = hndlrs[hndlr] as ArrayList;
string rems;
if (sigs.Count > 1) {
rems = "<para>The following events utilize this delegate:</para><para><list type=\"bullet\">";
foreach (string ev in sigs)
rems += "<item><term><see cref=\"M:" + ev + "\"/></term></item>";
rems += "</list></para>";
} else
rems = "<para>The <see cref=\"M:" + sigs[0] + "\"/> event utilizes this delegate:</para>";
rems += "<para>Event data is passed via the <see cref=\"T:" + arg_type + "\"/> parameter.</para><para>To attach a <see cref=\"T:" + hndlr + "\"/> to an event, add the " + hndlr.Name + " instance to the event. The methods referenced by the " + hndlr.Name + " instance are invoked whenever the event is raised, until the " + hndlr.Name + " is removed from the event.</para>";
rem.InnerXml = rems;
}
XPathNavigator param_nav = api_doc.CreateNavigator ();
XPathNodeIterator param_iter = param_nav.Select ("/Type/Docs/param");
while (param_iter.MoveNext ()) {
XmlElement param = ((IHasXmlNode)param_iter.Current).GetNode () as XmlElement;
if (param.InnerXml == "To be added.") {
string param_name = param.GetAttribute ("name");
switch (param_name) {
case "o":
param.InnerXml = "Event sender.";
break;
case "args":
param.InnerXml = "Event arguments.";
break;
default:
Console.WriteLine (filename + ": Unexpected param " + param.GetAttribute ("name"));
break;
}
Console.WriteLine (filename + ": Documenting param " + param.GetAttribute ("name"));
}
}
}
api_doc.Save (filename);
filename = "en/" + arg_type.Namespace + "/" + arg_type.Name + ".xml";
try {
Stream stream = File.OpenRead (filename);
api_doc.Load (stream);
stream.Close ();
} catch (XmlException e) {
Console.WriteLine (e);
return 1;
}
api_nav = api_doc.CreateNavigator ();
iter = api_nav.Select ("/Type/Docs");
if (iter.MoveNext ()) {
XmlElement elem = ((IHasXmlNode)iter.Current).GetNode () as XmlElement;
XmlElement summ = elem ["summary"];
XmlElement rem = elem ["remarks"];
string summary = summ.InnerXml;
string remarks = rem.InnerXml;
if (summary == "To be added." && remarks == "To be added.") {
Console.WriteLine (filename + ": Documenting summary and remarks");
summ.InnerXml = "Event data.";
ArrayList sigs = hndlrs[hndlr] as ArrayList;
string rems;
if (sigs.Count > 1) {
rems = "<para>The following events invoke <see cref=\"T:" + hndlr + "\"/> delegates which pass event data via this class:</para><para><list type=\"bullet\">";
foreach (string ev in sigs)
rems += "<item><term><see cref=\"M:" + ev + "\"/></term></item>";
rems += "</list></para>";
} else
rems = "<para>The <see cref=\"M:" + sigs[0] + "\"/> event invokes <see cref=\"T:" + hndlr + "\"/> delegates which pass event data via this class.</para>";
rem.InnerXml = rems;
}
}
api_nav = api_doc.CreateNavigator ();
iter = api_nav.Select ("/Type/Members/Member[@MemberName='.ctor']");
if (iter.MoveNext ()) {
XmlElement elem = ((IHasXmlNode)iter.Current).GetNode () as XmlElement;
XmlElement summ = elem ["Docs"] ["summary"];
XmlElement rem = elem ["Docs"] ["remarks"];
XmlElement ret = elem ["Docs"] ["returns"];
string summary = summ.InnerXml;
string remarks = rem.InnerXml;
if (summary == "To be added." && remarks == "To be added.") {
Console.WriteLine (filename + ": Documenting constructor");
summ.InnerXml = "Public Constructor.";
if (ret != null)
ret.InnerXml = "A new <see cref=\"T:" + arg_type + "\"/>.";
rem.InnerXml = "Create a new <see cref=\"T:" + arg_type + "\"/> instance with this constructor if you need to invoke a <see cref=\"T:" + hndlr + "\"/> delegate.";
}
}
api_doc.Save (filename);
}
return 0;
}
}
}
// gen-handlerargs-docs.cs - Generate documentation for event handlers/args
//
// Author: Mike Kestner <mkestner@ximian.com>
//
// Copyright (c) 2004 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the GNU General Public
// License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GtkSharp.Docs {
using System;
using System.Collections;
using System.IO;
using System.Reflection;
using System.Xml;
using System.Xml.XPath;
public class GenHandlerArgsDocs {
public static int Main (string[] args)
{
Hashtable hndlrs = new Hashtable ();
XmlDocument api_doc = new XmlDocument ();
BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly;
foreach (string arg in args) {
Assembly assembly;
try {
assembly = Assembly.LoadFile (arg);
} catch (XmlException e) {
Console.WriteLine (e);
return 1;
}
foreach (Type t in assembly.GetTypes ()) {
if (!t.IsSubclassOf (typeof (GLib.Object)))
continue;
foreach (EventInfo ei in t.GetEvents (flags)) {
foreach (Attribute attr in ei.GetCustomAttributes (false)) {
if (attr.ToString () == "GLib.SignalAttribute") {
if (ei.EventHandlerType.ToString() == "System.EventHandler")
break;
ArrayList sigs;
if (hndlrs.Contains (ei.EventHandlerType))
sigs = hndlrs [ei.EventHandlerType] as ArrayList;
else {
sigs = new ArrayList ();
hndlrs [ei.EventHandlerType] = sigs;
}
sigs.Add (t + "." + ei.Name);
break;
}
}
}
}
}
if (hndlrs.Count == 0)
return 0;
foreach (Type hndlr in hndlrs.Keys) {
string filename = "en/" + hndlr.Namespace + "/" + hndlr.Name + ".xml";
try {
Stream stream = File.OpenRead (filename);
api_doc.Load (stream);
stream.Close ();
} catch (XmlException e) {
Console.WriteLine (e);
return 1;
}
Type arg_type = hndlr.GetMethod ("Invoke").GetParameters ()[1].ParameterType;
XPathNavigator api_nav = api_doc.CreateNavigator ();
XPathNodeIterator iter = api_nav.Select ("/Type/Docs");
if (iter.MoveNext ()) {
XmlElement elem = ((IHasXmlNode)iter.Current).GetNode () as XmlElement;
XmlElement summ = elem ["summary"];
XmlElement rem = elem ["remarks"];
string summary = summ.InnerXml;
string remarks = rem.InnerXml;
if (summary == "To be added." && remarks == "To be added.") {
Console.WriteLine (filename + ": Documenting summary and remarks");
summ.InnerXml = "Event handler.";
ArrayList sigs = hndlrs[hndlr] as ArrayList;
string rems;
if (sigs.Count > 1) {
rems = "<para>The following events utilize this delegate:</para><para><list type=\"bullet\">";
foreach (string ev in sigs)
rems += "<item><term><see cref=\"M:" + ev + "\"/></term></item>";
rems += "</list></para>";
} else
rems = "<para>The <see cref=\"M:" + sigs[0] + "\"/> event utilizes this delegate:</para>";
rems += "<para>Event data is passed via the <see cref=\"T:" + arg_type + "\"/> parameter.</para><para>To attach a <see cref=\"T:" + hndlr + "\"/> to an event, add the " + hndlr.Name + " instance to the event. The methods referenced by the " + hndlr.Name + " instance are invoked whenever the event is raised, until the " + hndlr.Name + " is removed from the event.</para>";
rem.InnerXml = rems;
}
XPathNavigator param_nav = api_doc.CreateNavigator ();
XPathNodeIterator param_iter = param_nav.Select ("/Type/Docs/param");
while (param_iter.MoveNext ()) {
XmlElement param = ((IHasXmlNode)param_iter.Current).GetNode () as XmlElement;
if (param.InnerXml == "To be added.") {
string param_name = param.GetAttribute ("name");
switch (param_name) {
case "o":
param.InnerXml = "Event sender.";
break;
case "args":
param.InnerXml = "Event arguments.";
break;
default:
Console.WriteLine (filename + ": Unexpected param " + param.GetAttribute ("name"));
break;
}
Console.WriteLine (filename + ": Documenting param " + param.GetAttribute ("name"));
}
}
}
api_doc.Save (filename);
filename = "en/" + arg_type.Namespace + "/" + arg_type.Name + ".xml";
try {
Stream stream = File.OpenRead (filename);
api_doc.Load (stream);
stream.Close ();
} catch (XmlException e) {
Console.WriteLine (e);
return 1;
}
api_nav = api_doc.CreateNavigator ();
iter = api_nav.Select ("/Type/Docs");
if (iter.MoveNext ()) {
XmlElement elem = ((IHasXmlNode)iter.Current).GetNode () as XmlElement;
XmlElement summ = elem ["summary"];
XmlElement rem = elem ["remarks"];
string summary = summ.InnerXml;
string remarks = rem.InnerXml;
if (summary == "To be added." && remarks == "To be added.") {
Console.WriteLine (filename + ": Documenting summary and remarks");
summ.InnerXml = "Event data.";
ArrayList sigs = hndlrs[hndlr] as ArrayList;
string rems;
if (sigs.Count > 1) {
rems = "<para>The following events invoke <see cref=\"T:" + hndlr + "\"/> delegates which pass event data via this class:</para><para><list type=\"bullet\">";
foreach (string ev in sigs)
rems += "<item><term><see cref=\"M:" + ev + "\"/></term></item>";
rems += "</list></para>";
} else
rems = "<para>The <see cref=\"M:" + sigs[0] + "\"/> event invokes <see cref=\"T:" + hndlr + "\"/> delegates which pass event data via this class.</para>";
rem.InnerXml = rems;
}
}
api_nav = api_doc.CreateNavigator ();
iter = api_nav.Select ("/Type/Members/Member[@MemberName='.ctor']");
if (iter.MoveNext ()) {
XmlElement elem = ((IHasXmlNode)iter.Current).GetNode () as XmlElement;
XmlElement summ = elem ["Docs"] ["summary"];
XmlElement rem = elem ["Docs"] ["remarks"];
XmlElement ret = elem ["Docs"] ["returns"];
string summary = summ.InnerXml;
string remarks = rem.InnerXml;
if (summary == "To be added." && remarks == "To be added.") {
Console.WriteLine (filename + ": Documenting constructor");
summ.InnerXml = "Public Constructor.";
if (ret != null)
ret.InnerXml = "A new <see cref=\"T:" + arg_type + "\"/>.";
rem.InnerXml = "Create a new <see cref=\"T:" + arg_type + "\"/> instance with this constructor if you need to invoke a <see cref=\"T:" + hndlr + "\"/> delegate.";
}
}
api_doc.Save (filename);
}
return 0;
}
}
}

View file

@ -1,114 +1,114 @@
// gen-vm-docs.cs - Generate documentation for virtual methods.
//
// Author: Mike Kestner <mkestner@ximian.com>
//
// Copyright (c) 2004 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the GNU General Public
// License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GtkSharp.Docs {
using System;
using System.Collections;
using System.IO;
using System.Reflection;
using System.Xml;
using System.Xml.XPath;
public class GenVMDocs {
public static int Main (string[] args)
{
XmlDocument api_doc = new XmlDocument ();
BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly;
foreach (string arg in args) {
Assembly assembly;
try {
assembly = Assembly.LoadFile (arg);
} catch (XmlException e) {
Console.WriteLine (e);
return 1;
}
foreach (Type t in assembly.GetTypes ()) {
if (!t.IsSubclassOf (typeof (GLib.Object)))
continue;
Hashtable sigs = new Hashtable ();
foreach (EventInfo ei in t.GetEvents (flags))
foreach (GLib.SignalAttribute attr in ei.GetCustomAttributes (typeof (GLib.SignalAttribute), false))
sigs [attr.CName] = ei.Name;
if (sigs.Count == 0) continue;
Hashtable vms = new Hashtable ();
foreach (MethodInfo mi in t.GetMethods (flags)) {
foreach (GLib.DefaultSignalHandlerAttribute attr in mi.GetCustomAttributes (typeof (GLib.DefaultSignalHandlerAttribute), false)) {
string conn_name = attr.ConnectionMethod;
if (sigs.ContainsValue (conn_name.Substring (8)))
vms [mi.Name] = conn_name.Substring (8);
}
}
if (vms.Count == 0) continue;
string filename = "en/" + t.Namespace + "/" + t.Name + ".xml";
try {
Stream stream = File.OpenRead (filename);
api_doc.Load (stream);
stream.Close ();
Console.WriteLine ("opened:" + filename);
} catch (XmlException e) {
Console.WriteLine (e);
return 1;
}
XPathNavigator api_nav = api_doc.CreateNavigator ();
bool dirty = false;
foreach (string vm in vms.Keys) {
XPathNodeIterator iter = api_nav.Select ("/Type/Members/Member[@MemberName='" + vm + "']");
if (iter.MoveNext ()) {
XmlElement elem = ((IHasXmlNode)iter.Current).GetNode () as XmlElement;
XmlElement summ = elem ["Docs"] ["summary"];
XmlElement rem = elem ["Docs"] ["remarks"];
string summary = summ.InnerXml;
string remarks = rem.InnerXml;
if (summary == "To be added." && remarks == "To be added.") {
summ.InnerXml = "Default handler for the <see cref=\"M:" + t + "." + vms [vm] + "\" /> event.";
rem.InnerXml = "Override this method in a subclass to provide a default handler for the <see cref=\"M:" + t + "." + vms [vm] + "\" /> event.";
dirty = true;
} else
Console.WriteLine ("Member had docs:" + vm);
} else {
Console.WriteLine ("Member not found:" + vm);
}
if (dirty)
api_doc.Save (filename);
}
}
}
return 0;
}
}
}
// gen-vm-docs.cs - Generate documentation for virtual methods.
//
// Author: Mike Kestner <mkestner@ximian.com>
//
// Copyright (c) 2004 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the GNU General Public
// License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GtkSharp.Docs {
using System;
using System.Collections;
using System.IO;
using System.Reflection;
using System.Xml;
using System.Xml.XPath;
public class GenVMDocs {
public static int Main (string[] args)
{
XmlDocument api_doc = new XmlDocument ();
BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly;
foreach (string arg in args) {
Assembly assembly;
try {
assembly = Assembly.LoadFile (arg);
} catch (XmlException e) {
Console.WriteLine (e);
return 1;
}
foreach (Type t in assembly.GetTypes ()) {
if (!t.IsSubclassOf (typeof (GLib.Object)))
continue;
Hashtable sigs = new Hashtable ();
foreach (EventInfo ei in t.GetEvents (flags))
foreach (GLib.SignalAttribute attr in ei.GetCustomAttributes (typeof (GLib.SignalAttribute), false))
sigs [attr.CName] = ei.Name;
if (sigs.Count == 0) continue;
Hashtable vms = new Hashtable ();
foreach (MethodInfo mi in t.GetMethods (flags)) {
foreach (GLib.DefaultSignalHandlerAttribute attr in mi.GetCustomAttributes (typeof (GLib.DefaultSignalHandlerAttribute), false)) {
string conn_name = attr.ConnectionMethod;
if (sigs.ContainsValue (conn_name.Substring (8)))
vms [mi.Name] = conn_name.Substring (8);
}
}
if (vms.Count == 0) continue;
string filename = "en/" + t.Namespace + "/" + t.Name + ".xml";
try {
Stream stream = File.OpenRead (filename);
api_doc.Load (stream);
stream.Close ();
Console.WriteLine ("opened:" + filename);
} catch (XmlException e) {
Console.WriteLine (e);
return 1;
}
XPathNavigator api_nav = api_doc.CreateNavigator ();
bool dirty = false;
foreach (string vm in vms.Keys) {
XPathNodeIterator iter = api_nav.Select ("/Type/Members/Member[@MemberName='" + vm + "']");
if (iter.MoveNext ()) {
XmlElement elem = ((IHasXmlNode)iter.Current).GetNode () as XmlElement;
XmlElement summ = elem ["Docs"] ["summary"];
XmlElement rem = elem ["Docs"] ["remarks"];
string summary = summ.InnerXml;
string remarks = rem.InnerXml;
if (summary == "To be added." && remarks == "To be added.") {
summ.InnerXml = "Default handler for the <see cref=\"M:" + t + "." + vms [vm] + "\" /> event.";
rem.InnerXml = "Override this method in a subclass to provide a default handler for the <see cref=\"M:" + t + "." + vms [vm] + "\" /> event.";
dirty = true;
} else
Console.WriteLine ("Member had docs:" + vm);
} else {
Console.WriteLine ("Member not found:" + vm);
}
if (dirty)
api_doc.Save (filename);
}
}
}
return 0;
}
}
}

View file

@ -1,108 +1,108 @@
// scan-deprecations.cs - scans docs for deprecated nodes, cleans up and nags.
//
// Author: Mike Kestner <mkestner@ximian.com>
//
// Copyright (c) 2004 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the GNU General Public
// License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GtkSharp.Docs {
using System;
using System.Collections;
using System.IO;
using System.Xml;
using System.Xml.XPath;
public class ScanDeprecations {
public static int Main (string[] args)
{
string api_filename = "";
XmlDocument api_doc = new XmlDocument ();
foreach (string arg in args) {
try {
Stream stream = File.OpenRead (arg);
api_doc.Load (stream);
stream.Close ();
} catch (XmlException e) {
Console.WriteLine (e);
return 1;
}
string ignores = "";
string kills = "";
string nonstubs = "";
ArrayList kill_elems = new ArrayList ();
XPathNavigator api_nav = api_doc.CreateNavigator ();
XPathNodeIterator iter = api_nav.Select ("/Type/Members/Member[@Deprecated='true']");
while (iter.MoveNext ()) {
XmlElement elem = ((IHasXmlNode)iter.Current).GetNode () as XmlElement;
string member_type = elem["MemberType"].InnerText;
switch (member_type) {
case "Method":
case "Property":
case "Constructor":
case "Field":
string summary = elem["Docs"]["summary"].InnerText;
string remarks = elem["Docs"]["remarks"].InnerText;
if (summary == "To be added" && remarks == "To be added") {
kills += " " + elem.GetAttribute ("MemberName") + "(" + member_type + ")";
kill_elems.Add (elem);
} else
nonstubs += " " + elem.GetAttribute ("MemberName") + "(" + member_type + ")";
break;
default:
ignores += " " + elem.GetAttribute ("MemberName") + "(" + member_type + ")";
break;
}
}
iter = api_nav.Select ("/Type/Base/BaseTypeName");
if (iter.MoveNext ()) {
XmlElement elem = ((IHasXmlNode)iter.Current).GetNode () as XmlElement;
if (elem.InnerText == "System.Enum") {
iter = api_nav.Select ("/Type/Members/Member[@MemberName='value__']");
if (iter.MoveNext ()) {
elem = ((IHasXmlNode)iter.Current).GetNode () as XmlElement;
elem ["Docs"] ["summary"].InnerXml = "Internal field.";
elem ["Docs"] ["remarks"].InnerXml = "Do not use.";
}
}
}
foreach (XmlNode node in kill_elems)
node.ParentNode.RemoveChild (node);
api_doc.Save (arg);
if (ignores != "" || kills != "" || nonstubs != "") {
Console.WriteLine (arg + ":");
if (ignores != "")
Console.WriteLine (" Ignored:" + ignores);
if (kills != "")
Console.WriteLine (" Killed:" + kills);
if (nonstubs != "")
Console.WriteLine (" Non-stubbed deprecates:" + nonstubs);
}
}
return 0;
}
}
}
// scan-deprecations.cs - scans docs for deprecated nodes, cleans up and nags.
//
// Author: Mike Kestner <mkestner@ximian.com>
//
// Copyright (c) 2004 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the GNU General Public
// License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GtkSharp.Docs {
using System;
using System.Collections;
using System.IO;
using System.Xml;
using System.Xml.XPath;
public class ScanDeprecations {
public static int Main (string[] args)
{
string api_filename = "";
XmlDocument api_doc = new XmlDocument ();
foreach (string arg in args) {
try {
Stream stream = File.OpenRead (arg);
api_doc.Load (stream);
stream.Close ();
} catch (XmlException e) {
Console.WriteLine (e);
return 1;
}
string ignores = "";
string kills = "";
string nonstubs = "";
ArrayList kill_elems = new ArrayList ();
XPathNavigator api_nav = api_doc.CreateNavigator ();
XPathNodeIterator iter = api_nav.Select ("/Type/Members/Member[@Deprecated='true']");
while (iter.MoveNext ()) {
XmlElement elem = ((IHasXmlNode)iter.Current).GetNode () as XmlElement;
string member_type = elem["MemberType"].InnerText;
switch (member_type) {
case "Method":
case "Property":
case "Constructor":
case "Field":
string summary = elem["Docs"]["summary"].InnerText;
string remarks = elem["Docs"]["remarks"].InnerText;
if (summary == "To be added" && remarks == "To be added") {
kills += " " + elem.GetAttribute ("MemberName") + "(" + member_type + ")";
kill_elems.Add (elem);
} else
nonstubs += " " + elem.GetAttribute ("MemberName") + "(" + member_type + ")";
break;
default:
ignores += " " + elem.GetAttribute ("MemberName") + "(" + member_type + ")";
break;
}
}
iter = api_nav.Select ("/Type/Base/BaseTypeName");
if (iter.MoveNext ()) {
XmlElement elem = ((IHasXmlNode)iter.Current).GetNode () as XmlElement;
if (elem.InnerText == "System.Enum") {
iter = api_nav.Select ("/Type/Members/Member[@MemberName='value__']");
if (iter.MoveNext ()) {
elem = ((IHasXmlNode)iter.Current).GetNode () as XmlElement;
elem ["Docs"] ["summary"].InnerXml = "Internal field.";
elem ["Docs"] ["remarks"].InnerXml = "Do not use.";
}
}
}
foreach (XmlNode node in kill_elems)
node.ParentNode.RemoveChild (node);
api_doc.Save (arg);
if (ignores != "" || kills != "" || nonstubs != "") {
Console.WriteLine (arg + ":");
if (ignores != "")
Console.WriteLine (" Ignored:" + ignores);
if (kills != "")
Console.WriteLine (" Killed:" + kills);
if (nonstubs != "")
Console.WriteLine (" Non-stubbed deprecates:" + nonstubs);
}
}
return 0;
}
}
}

View file

@ -1,242 +1,242 @@
// gapi-fixup.cs - xml alteration engine.
//
// Authors:
// Mike Kestner <mkestner@speakeasy.net>
// Stephan Sundermann <stephansundermann@gmail.com>
//
// Copyright (c) 2003 Mike Kestner
// Copyright (c) 2013 Stephan Sundermann
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the GNU General Public
// License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GtkSharp.Parsing {
using System;
using System.IO;
using System.Xml;
using System.Xml.XPath;
public class Fixup {
public static int Main (string[] args)
{
if (args.Length < 2) {
Console.WriteLine ("Usage: gapi-fixup --metadata=<filename> --api=<filename> --symbols=<filename>");
return 0;
}
string api_filename = "";
XmlDocument api_doc = new XmlDocument ();
XmlDocument meta_doc = new XmlDocument ();
XmlDocument symbol_doc = new XmlDocument ();
foreach (string arg in args) {
if (arg.StartsWith("--metadata=")) {
string meta_filename = arg.Substring (11);
try {
Stream stream = File.OpenRead (meta_filename);
meta_doc.Load (stream);
stream.Close ();
} catch (XmlException e) {
Console.WriteLine ("Invalid meta file.");
Console.WriteLine (e);
return 1;
}
} else if (arg.StartsWith ("--api=")) {
api_filename = arg.Substring (6);
try {
Stream stream = File.OpenRead (api_filename);
api_doc.Load (stream);
stream.Close ();
} catch (XmlException e) {
Console.WriteLine ("Invalid api file.");
Console.WriteLine (e);
return 1;
}
} else if (arg.StartsWith ("--symbols=")) {
string symbol_filename = arg.Substring (10);
try {
Stream stream = File.OpenRead (symbol_filename);
symbol_doc.Load (stream);
stream.Close ();
} catch (XmlException e) {
Console.WriteLine ("Invalid api file.");
Console.WriteLine (e);
return 1;
}
} else {
Console.WriteLine ("Usage: gapi-fixup --metadata=<filename> --api=<filename>");
return 1;
}
}
XPathNavigator meta_nav = meta_doc.CreateNavigator ();
XPathNavigator api_nav = api_doc.CreateNavigator ();
XPathNodeIterator copy_iter = meta_nav.Select ("/metadata/copy-node");
while (copy_iter.MoveNext ()) {
string path = copy_iter.Current.GetAttribute ("path", String.Empty);
XPathExpression expr = api_nav.Compile (path);
string parent = copy_iter.Current.Value;
XPathNodeIterator parent_iter = api_nav.Select (parent);
bool matched = false;
while (parent_iter.MoveNext ()) {
XmlNode parent_node = ((IHasXmlNode)parent_iter.Current).GetNode ();
XPathNodeIterator path_iter = parent_iter.Current.Clone ().Select (expr);
while (path_iter.MoveNext ()) {
XmlNode node = ((IHasXmlNode)path_iter.Current).GetNode ();
parent_node.AppendChild (node.Clone ());
}
matched = true;
}
if (!matched)
Console.WriteLine ("Warning: <copy-node path=\"{0}\"/> matched no nodes", path);
}
XPathNodeIterator rmv_iter = meta_nav.Select ("/metadata/remove-node");
while (rmv_iter.MoveNext ()) {
string path = rmv_iter.Current.GetAttribute ("path", "");
XPathNodeIterator api_iter = api_nav.Select (path);
bool matched = false;
while (api_iter.MoveNext ()) {
XmlElement api_node = ((IHasXmlNode)api_iter.Current).GetNode () as XmlElement;
api_node.ParentNode.RemoveChild (api_node);
matched = true;
}
if (!matched)
Console.WriteLine ("Warning: <remove-node path=\"{0}\"/> matched no nodes", path);
}
XPathNodeIterator add_iter = meta_nav.Select ("/metadata/add-node");
while (add_iter.MoveNext ()) {
string path = add_iter.Current.GetAttribute ("path", "");
XPathNodeIterator api_iter = api_nav.Select (path);
bool matched = false;
while (api_iter.MoveNext ()) {
XmlElement api_node = ((IHasXmlNode)api_iter.Current).GetNode () as XmlElement;
foreach (XmlNode child in ((IHasXmlNode)add_iter.Current).GetNode().ChildNodes)
api_node.AppendChild (api_doc.ImportNode (child, true));
matched = true;
}
if (!matched)
Console.WriteLine ("Warning: <add-node path=\"{0}\"/> matched no nodes", path);
}
XPathNodeIterator change_node_type_iter = meta_nav.Select ("/metadata/change-node-type");
while (change_node_type_iter.MoveNext ()) {
string path = change_node_type_iter.Current.GetAttribute ("path", "");
XPathNodeIterator api_iter = api_nav.Select (path);
bool matched = false;
while (api_iter.MoveNext ()) {
XmlElement node = ( (IHasXmlNode) api_iter.Current).GetNode () as XmlElement;
XmlElement parent = node.ParentNode as XmlElement;
XmlElement new_node = api_doc.CreateElement (change_node_type_iter.Current.Value);
foreach (XmlNode child in node.ChildNodes)
new_node.AppendChild (child.Clone ());
foreach (XmlAttribute attribute in node.Attributes)
new_node.Attributes.Append ( (XmlAttribute) attribute.Clone ());
parent.ReplaceChild (new_node, node);
matched = true;
}
if (!matched)
Console.WriteLine ("Warning: <change-node-type path=\"{0}\"/> matched no nodes", path);
}
XPathNodeIterator attr_iter = meta_nav.Select ("/metadata/attr");
while (attr_iter.MoveNext ()) {
string path = attr_iter.Current.GetAttribute ("path", "");
string attr_name = attr_iter.Current.GetAttribute ("name", "");
XPathNodeIterator api_iter = api_nav.Select (path);
bool matched = false;
while (api_iter.MoveNext ()) {
XmlElement node = ((IHasXmlNode)api_iter.Current).GetNode () as XmlElement;
node.SetAttribute (attr_name, attr_iter.Current.Value);
matched = true;
}
if (!matched)
Console.WriteLine ("Warning: <attr path=\"{0}\"/> matched no nodes", path);
}
XPathNodeIterator move_iter = meta_nav.Select ("/metadata/move-node");
while (move_iter.MoveNext ()) {
string path = move_iter.Current.GetAttribute ("path", "");
XPathExpression expr = api_nav.Compile (path);
string parent = move_iter.Current.Value;
XPathNodeIterator parent_iter = api_nav.Select (parent);
bool matched = false;
while (parent_iter.MoveNext ()) {
XmlNode parent_node = ((IHasXmlNode)parent_iter.Current).GetNode ();
XPathNodeIterator path_iter = parent_iter.Current.Clone ().Select (expr);
while (path_iter.MoveNext ()) {
XmlNode node = ((IHasXmlNode)path_iter.Current).GetNode ();
parent_node.AppendChild (node.Clone ());
node.ParentNode.RemoveChild (node);
}
matched = true;
}
if (!matched)
Console.WriteLine ("Warning: <move-node path=\"{0}\"/> matched no nodes", path);
}
XPathNodeIterator remove_attr_iter = meta_nav.Select ("/metadata/remove-attr");
while (remove_attr_iter.MoveNext ()) {
string path = remove_attr_iter.Current.GetAttribute ("path", "");
string name = remove_attr_iter.Current.GetAttribute ("name", "");
XPathNodeIterator api_iter = api_nav.Select (path);
bool matched = false;
while (api_iter.MoveNext ()) {
XmlElement node = ( (IHasXmlNode) api_iter.Current).GetNode () as XmlElement;
node.RemoveAttribute (name);
matched = true;
}
if (!matched)
Console.WriteLine ("Warning: <remove-attr path=\"{0}\"/> matched no nodes", path);
}
if (symbol_doc != null) {
XPathNavigator symbol_nav = symbol_doc.CreateNavigator ();
XPathNodeIterator iter = symbol_nav.Select ("/api/*");
while (iter.MoveNext ()) {
XmlNode sym_node = ((IHasXmlNode)iter.Current).GetNode ();
XPathNodeIterator parent_iter = api_nav.Select ("/api");
if (parent_iter.MoveNext ()) {
XmlNode parent_node = ((IHasXmlNode)parent_iter.Current).GetNode ();
parent_node.AppendChild (api_doc.ImportNode (sym_node, true));
}
}
}
api_doc.Save (api_filename);
return 0;
}
}
}
// gapi-fixup.cs - xml alteration engine.
//
// Authors:
// Mike Kestner <mkestner@speakeasy.net>
// Stephan Sundermann <stephansundermann@gmail.com>
//
// Copyright (c) 2003 Mike Kestner
// Copyright (c) 2013 Stephan Sundermann
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the GNU General Public
// License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GtkSharp.Parsing {
using System;
using System.IO;
using System.Xml;
using System.Xml.XPath;
public class Fixup {
public static int Main (string[] args)
{
if (args.Length < 2) {
Console.WriteLine ("Usage: gapi-fixup --metadata=<filename> --api=<filename> --symbols=<filename>");
return 0;
}
string api_filename = "";
XmlDocument api_doc = new XmlDocument ();
XmlDocument meta_doc = new XmlDocument ();
XmlDocument symbol_doc = new XmlDocument ();
foreach (string arg in args) {
if (arg.StartsWith("--metadata=")) {
string meta_filename = arg.Substring (11);
try {
Stream stream = File.OpenRead (meta_filename);
meta_doc.Load (stream);
stream.Close ();
} catch (XmlException e) {
Console.WriteLine ("Invalid meta file.");
Console.WriteLine (e);
return 1;
}
} else if (arg.StartsWith ("--api=")) {
api_filename = arg.Substring (6);
try {
Stream stream = File.OpenRead (api_filename);
api_doc.Load (stream);
stream.Close ();
} catch (XmlException e) {
Console.WriteLine ("Invalid api file.");
Console.WriteLine (e);
return 1;
}
} else if (arg.StartsWith ("--symbols=")) {
string symbol_filename = arg.Substring (10);
try {
Stream stream = File.OpenRead (symbol_filename);
symbol_doc.Load (stream);
stream.Close ();
} catch (XmlException e) {
Console.WriteLine ("Invalid api file.");
Console.WriteLine (e);
return 1;
}
} else {
Console.WriteLine ("Usage: gapi-fixup --metadata=<filename> --api=<filename>");
return 1;
}
}
XPathNavigator meta_nav = meta_doc.CreateNavigator ();
XPathNavigator api_nav = api_doc.CreateNavigator ();
XPathNodeIterator copy_iter = meta_nav.Select ("/metadata/copy-node");
while (copy_iter.MoveNext ()) {
string path = copy_iter.Current.GetAttribute ("path", String.Empty);
XPathExpression expr = api_nav.Compile (path);
string parent = copy_iter.Current.Value;
XPathNodeIterator parent_iter = api_nav.Select (parent);
bool matched = false;
while (parent_iter.MoveNext ()) {
XmlNode parent_node = ((IHasXmlNode)parent_iter.Current).GetNode ();
XPathNodeIterator path_iter = parent_iter.Current.Clone ().Select (expr);
while (path_iter.MoveNext ()) {
XmlNode node = ((IHasXmlNode)path_iter.Current).GetNode ();
parent_node.AppendChild (node.Clone ());
}
matched = true;
}
if (!matched)
Console.WriteLine ("Warning: <copy-node path=\"{0}\"/> matched no nodes", path);
}
XPathNodeIterator rmv_iter = meta_nav.Select ("/metadata/remove-node");
while (rmv_iter.MoveNext ()) {
string path = rmv_iter.Current.GetAttribute ("path", "");
XPathNodeIterator api_iter = api_nav.Select (path);
bool matched = false;
while (api_iter.MoveNext ()) {
XmlElement api_node = ((IHasXmlNode)api_iter.Current).GetNode () as XmlElement;
api_node.ParentNode.RemoveChild (api_node);
matched = true;
}
if (!matched)
Console.WriteLine ("Warning: <remove-node path=\"{0}\"/> matched no nodes", path);
}
XPathNodeIterator add_iter = meta_nav.Select ("/metadata/add-node");
while (add_iter.MoveNext ()) {
string path = add_iter.Current.GetAttribute ("path", "");
XPathNodeIterator api_iter = api_nav.Select (path);
bool matched = false;
while (api_iter.MoveNext ()) {
XmlElement api_node = ((IHasXmlNode)api_iter.Current).GetNode () as XmlElement;
foreach (XmlNode child in ((IHasXmlNode)add_iter.Current).GetNode().ChildNodes)
api_node.AppendChild (api_doc.ImportNode (child, true));
matched = true;
}
if (!matched)
Console.WriteLine ("Warning: <add-node path=\"{0}\"/> matched no nodes", path);
}
XPathNodeIterator change_node_type_iter = meta_nav.Select ("/metadata/change-node-type");
while (change_node_type_iter.MoveNext ()) {
string path = change_node_type_iter.Current.GetAttribute ("path", "");
XPathNodeIterator api_iter = api_nav.Select (path);
bool matched = false;
while (api_iter.MoveNext ()) {
XmlElement node = ( (IHasXmlNode) api_iter.Current).GetNode () as XmlElement;
XmlElement parent = node.ParentNode as XmlElement;
XmlElement new_node = api_doc.CreateElement (change_node_type_iter.Current.Value);
foreach (XmlNode child in node.ChildNodes)
new_node.AppendChild (child.Clone ());
foreach (XmlAttribute attribute in node.Attributes)
new_node.Attributes.Append ( (XmlAttribute) attribute.Clone ());
parent.ReplaceChild (new_node, node);
matched = true;
}
if (!matched)
Console.WriteLine ("Warning: <change-node-type path=\"{0}\"/> matched no nodes", path);
}
XPathNodeIterator attr_iter = meta_nav.Select ("/metadata/attr");
while (attr_iter.MoveNext ()) {
string path = attr_iter.Current.GetAttribute ("path", "");
string attr_name = attr_iter.Current.GetAttribute ("name", "");
XPathNodeIterator api_iter = api_nav.Select (path);
bool matched = false;
while (api_iter.MoveNext ()) {
XmlElement node = ((IHasXmlNode)api_iter.Current).GetNode () as XmlElement;
node.SetAttribute (attr_name, attr_iter.Current.Value);
matched = true;
}
if (!matched)
Console.WriteLine ("Warning: <attr path=\"{0}\"/> matched no nodes", path);
}
XPathNodeIterator move_iter = meta_nav.Select ("/metadata/move-node");
while (move_iter.MoveNext ()) {
string path = move_iter.Current.GetAttribute ("path", "");
XPathExpression expr = api_nav.Compile (path);
string parent = move_iter.Current.Value;
XPathNodeIterator parent_iter = api_nav.Select (parent);
bool matched = false;
while (parent_iter.MoveNext ()) {
XmlNode parent_node = ((IHasXmlNode)parent_iter.Current).GetNode ();
XPathNodeIterator path_iter = parent_iter.Current.Clone ().Select (expr);
while (path_iter.MoveNext ()) {
XmlNode node = ((IHasXmlNode)path_iter.Current).GetNode ();
parent_node.AppendChild (node.Clone ());
node.ParentNode.RemoveChild (node);
}
matched = true;
}
if (!matched)
Console.WriteLine ("Warning: <move-node path=\"{0}\"/> matched no nodes", path);
}
XPathNodeIterator remove_attr_iter = meta_nav.Select ("/metadata/remove-attr");
while (remove_attr_iter.MoveNext ()) {
string path = remove_attr_iter.Current.GetAttribute ("path", "");
string name = remove_attr_iter.Current.GetAttribute ("name", "");
XPathNodeIterator api_iter = api_nav.Select (path);
bool matched = false;
while (api_iter.MoveNext ()) {
XmlElement node = ( (IHasXmlNode) api_iter.Current).GetNode () as XmlElement;
node.RemoveAttribute (name);
matched = true;
}
if (!matched)
Console.WriteLine ("Warning: <remove-attr path=\"{0}\"/> matched no nodes", path);
}
if (symbol_doc != null) {
XPathNavigator symbol_nav = symbol_doc.CreateNavigator ();
XPathNodeIterator iter = symbol_nav.Select ("/api/*");
while (iter.MoveNext ()) {
XmlNode sym_node = ((IHasXmlNode)iter.Current).GetNode ();
XPathNodeIterator parent_iter = api_nav.Select ("/api");
if (parent_iter.MoveNext ()) {
XmlNode parent_node = ((IHasXmlNode)parent_iter.Current).GetNode ();
parent_node.AppendChild (api_doc.ImportNode (sym_node, true));
}
}
}
api_doc.Save (api_filename);
return 0;
}
}
}

View file

@ -1,170 +1,170 @@
// gapi-parser.cs - parsing driver application.
//
// Author: Mike Kestner <mkestner@novell.com>
//
// Copyright (c) 2005 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the GNU General Public
// License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GtkSharp.Parsing {
using System;
using System.Collections;
using System.IO;
using System.Runtime.InteropServices;
using System.Xml;
public class Parser {
[DllImport ("libc")]
static extern int system (string command);
public static int Main (string[] args)
{
if (args.Length != 1) {
Console.WriteLine ("Usage: gapi2-parser <filename>");
return 0;
}
XmlDocument src_doc = new XmlDocument ();
try {
using (Stream stream = File.OpenRead (args [0]))
src_doc.Load (stream);
} catch (XmlException e) {
Console.WriteLine ("Couldn't open source file.");
Console.WriteLine (e);
return 1;
}
XmlNode root = src_doc.DocumentElement;
if (root.Name != "gapi-parser-input") {
Console.WriteLine ("Improperly formatted input file: " + args [0]);
return 1;
}
foreach (XmlNode apinode in root.ChildNodes) {
if (apinode.Name != "api")
continue;
string outfile = (apinode as XmlElement).GetAttribute ("filename");
string prefile = outfile + ".pre";
if (File.Exists (prefile))
File.Delete (prefile);
foreach (XmlNode libnode in apinode.ChildNodes) {
if (libnode.Name != "library")
continue;
string lib = (libnode as XmlElement).GetAttribute ("name");
foreach (XmlNode nsnode in libnode.ChildNodes) {
if (nsnode.Name != "namespace")
continue;
string ns = (nsnode as XmlElement).GetAttribute ("name");
ArrayList files = new ArrayList ();
Hashtable excludes = new Hashtable ();
foreach (XmlNode srcnode in nsnode.ChildNodes) {
if (!(srcnode is XmlElement))
continue;
XmlElement elem = srcnode as XmlElement;
switch (srcnode.Name) {
case "dir":
string dir = elem.InnerXml;
Console.Write ("<dir {0}> ", dir);
DirectoryInfo di = new DirectoryInfo (dir);
foreach (FileInfo file in di.GetFiles ("*.c"))
files.Add (dir + Path.DirectorySeparatorChar + file.Name);
foreach (FileInfo file in di.GetFiles ("*.h"))
files.Add (dir + Path.DirectorySeparatorChar + file.Name);
break;
case "file":
string incfile = elem.InnerXml;
Console.Write ("<file {0}> ", incfile);
files.Add (incfile);
break;
case "exclude":
string excfile = elem.InnerXml;
Console.Write ("<exclude {0}> ", excfile);
excludes [excfile] = 1;
break;
case "directory":
string dir_path = elem.GetAttribute ("path");
Console.Write ("<directory {0}: excluding ", dir_path);
Hashtable excs = new Hashtable ();
foreach (XmlNode exc_node in srcnode.ChildNodes) {
if (exc_node.Name != "exclude")
continue;
string excfilename = (exc_node as XmlElement).InnerXml;
Console.Write (excfilename + " ");
excs [excfilename] = 1;
}
DirectoryInfo dinfo = new DirectoryInfo (dir_path);
foreach (FileInfo file in dinfo.GetFiles ("*.c")) {
if (excs.Contains (file.Name))
continue;
files.Add (dir_path + Path.DirectorySeparatorChar + file.Name);
}
foreach (FileInfo file in dinfo.GetFiles ("*.h")) {
if (excs.Contains (file.Name))
continue;
files.Add (dir_path + Path.DirectorySeparatorChar + file.Name);
}
Console.Write ("> ");
break;
default:
Console.WriteLine ("Invalid source: " + srcnode.Name);
break;
}
}
Console.WriteLine ();
if (files.Count == 0)
continue;
ArrayList realfiles = new ArrayList ();
foreach (string file in files) {
string trimfile = file.TrimEnd ();
if (excludes.Contains (trimfile))
continue;
realfiles.Add (trimfile);
}
string[] filenames = (string[]) realfiles.ToArray (typeof (string));
string pp_args = String.Join (" ", filenames);
system ("gapi_pp.pl " + pp_args + " | gapi2xml.pl " + ns + " " + prefile + " " + lib);
}
}
XmlDocument final = new XmlDocument ();
final.Load (prefile);
XmlTextWriter writer = new XmlTextWriter (outfile, null);
writer.Formatting = Formatting.Indented;
final.Save (writer);
File.Delete (prefile);
}
return 0;
}
}
}
// gapi-parser.cs - parsing driver application.
//
// Author: Mike Kestner <mkestner@novell.com>
//
// Copyright (c) 2005 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the GNU General Public
// License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GtkSharp.Parsing {
using System;
using System.Collections;
using System.IO;
using System.Runtime.InteropServices;
using System.Xml;
public class Parser {
[DllImport ("libc")]
static extern int system (string command);
public static int Main (string[] args)
{
if (args.Length != 1) {
Console.WriteLine ("Usage: gapi2-parser <filename>");
return 0;
}
XmlDocument src_doc = new XmlDocument ();
try {
using (Stream stream = File.OpenRead (args [0]))
src_doc.Load (stream);
} catch (XmlException e) {
Console.WriteLine ("Couldn't open source file.");
Console.WriteLine (e);
return 1;
}
XmlNode root = src_doc.DocumentElement;
if (root.Name != "gapi-parser-input") {
Console.WriteLine ("Improperly formatted input file: " + args [0]);
return 1;
}
foreach (XmlNode apinode in root.ChildNodes) {
if (apinode.Name != "api")
continue;
string outfile = (apinode as XmlElement).GetAttribute ("filename");
string prefile = outfile + ".pre";
if (File.Exists (prefile))
File.Delete (prefile);
foreach (XmlNode libnode in apinode.ChildNodes) {
if (libnode.Name != "library")
continue;
string lib = (libnode as XmlElement).GetAttribute ("name");
foreach (XmlNode nsnode in libnode.ChildNodes) {
if (nsnode.Name != "namespace")
continue;
string ns = (nsnode as XmlElement).GetAttribute ("name");
ArrayList files = new ArrayList ();
Hashtable excludes = new Hashtable ();
foreach (XmlNode srcnode in nsnode.ChildNodes) {
if (!(srcnode is XmlElement))
continue;
XmlElement elem = srcnode as XmlElement;
switch (srcnode.Name) {
case "dir":
string dir = elem.InnerXml;
Console.Write ("<dir {0}> ", dir);
DirectoryInfo di = new DirectoryInfo (dir);
foreach (FileInfo file in di.GetFiles ("*.c"))
files.Add (dir + Path.DirectorySeparatorChar + file.Name);
foreach (FileInfo file in di.GetFiles ("*.h"))
files.Add (dir + Path.DirectorySeparatorChar + file.Name);
break;
case "file":
string incfile = elem.InnerXml;
Console.Write ("<file {0}> ", incfile);
files.Add (incfile);
break;
case "exclude":
string excfile = elem.InnerXml;
Console.Write ("<exclude {0}> ", excfile);
excludes [excfile] = 1;
break;
case "directory":
string dir_path = elem.GetAttribute ("path");
Console.Write ("<directory {0}: excluding ", dir_path);
Hashtable excs = new Hashtable ();
foreach (XmlNode exc_node in srcnode.ChildNodes) {
if (exc_node.Name != "exclude")
continue;
string excfilename = (exc_node as XmlElement).InnerXml;
Console.Write (excfilename + " ");
excs [excfilename] = 1;
}
DirectoryInfo dinfo = new DirectoryInfo (dir_path);
foreach (FileInfo file in dinfo.GetFiles ("*.c")) {
if (excs.Contains (file.Name))
continue;
files.Add (dir_path + Path.DirectorySeparatorChar + file.Name);
}
foreach (FileInfo file in dinfo.GetFiles ("*.h")) {
if (excs.Contains (file.Name))
continue;
files.Add (dir_path + Path.DirectorySeparatorChar + file.Name);
}
Console.Write ("> ");
break;
default:
Console.WriteLine ("Invalid source: " + srcnode.Name);
break;
}
}
Console.WriteLine ();
if (files.Count == 0)
continue;
ArrayList realfiles = new ArrayList ();
foreach (string file in files) {
string trimfile = file.TrimEnd ();
if (excludes.Contains (trimfile))
continue;
realfiles.Add (trimfile);
}
string[] filenames = (string[]) realfiles.ToArray (typeof (string));
string pp_args = String.Join (" ", filenames);
system ("gapi_pp.pl " + pp_args + " | gapi2xml.pl " + ns + " " + prefile + " " + lib);
}
}
XmlDocument final = new XmlDocument ();
final.Load (prefile);
XmlTextWriter writer = new XmlTextWriter (outfile, null);
writer.Formatting = Formatting.Indented;
final.Save (writer);
File.Delete (prefile);
}
return 0;
}
}
}