mirror of
				https://github.com/Ryujinx/GtkSharp.git
				synced 2025-11-04 13:04:53 +00:00 
			
		
		
		
	Merge remote-tracking branch 'upstream/master'
This commit is contained in:
		
						commit
						120b3ce9cd
					
				
							
								
								
									
										2
									
								
								.gitattributes
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								.gitattributes
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,2 @@
 | 
			
		|||
# Declare files that will always have CRLF line endings on checkout.
 | 
			
		||||
*.sln text eol=crlf
 | 
			
		||||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -107,7 +107,7 @@ AC_CHECK_SIZEOF(off_t)
 | 
			
		|||
OFF_T_FLAGS="-define:OFF_T_$ac_cv_sizeof_off_t"
 | 
			
		||||
AC_SUBST(OFF_T_FLAGS)
 | 
			
		||||
 | 
			
		||||
MONO_REQUIRED_VERSION=2.8
 | 
			
		||||
MONO_REQUIRED_VERSION=3.2.8
 | 
			
		||||
PKG_CHECK_MODULES(MONO_DEPENDENCY, mono >= $MONO_REQUIRED_VERSION, has_mono=true, has_mono=false)
 | 
			
		||||
 | 
			
		||||
AC_PATH_PROG(GACUTIL, gacutil, no)
 | 
			
		||||
| 
						 | 
				
			
			@ -136,7 +136,7 @@ if test "x$RUNTIME" != "no" ; then
 | 
			
		|||
	RUNTIME="mono$RUNTIME_DEBUG_FLAGS"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
AC_PATH_PROG(CSC, gmcs, no)
 | 
			
		||||
AC_PATH_PROG(CSC, mcs, no)
 | 
			
		||||
if test `uname -s` = "Darwin"; then
 | 
			
		||||
	LIB_PREFIX=
 | 
			
		||||
	LIB_SUFFIX=.dylib
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										154
									
								
								doc/add-since.cs
									
									
									
									
									
								
							
							
						
						
									
										154
									
								
								doc/add-since.cs
									
									
									
									
									
								
							| 
						 | 
				
			
			@ -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;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -23,7 +23,7 @@ namespace GLib {
 | 
			
		|||
	using System.Runtime.InteropServices;
 | 
			
		||||
	
 | 
			
		||||
	public partial class AppInfoAdapter {
 | 
			
		||||
		[DllImport ("libgio-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
 | 
			
		||||
		[DllImport (GioGlobal.GioNativeDll, CallingConvention = CallingConvention.Cdecl)]
 | 
			
		||||
		static extern IntPtr g_app_info_get_all();
 | 
			
		||||
 | 
			
		||||
		public static GLib.IAppInfo[] GetAll () {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										67
									
								
								gio/Application.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										67
									
								
								gio/Application.cs
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,67 @@
 | 
			
		|||
//
 | 
			
		||||
// Application.cs
 | 
			
		||||
//
 | 
			
		||||
// Author(s):
 | 
			
		||||
//	Antonius Riha <antoniusriha@gmail.com>
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2014 Antonius Riha
 | 
			
		||||
//
 | 
			
		||||
// This program is free software; you can redistribute it and/or
 | 
			
		||||
// modify it under the terms of version 2 of the Lesser 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
 | 
			
		||||
// Lesser General Public License for more details.
 | 
			
		||||
//
 | 
			
		||||
// You should have received a copy of the GNU Lesser 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.
 | 
			
		||||
 | 
			
		||||
using System;
 | 
			
		||||
using System.Runtime.InteropServices;
 | 
			
		||||
 | 
			
		||||
namespace GLib
 | 
			
		||||
{
 | 
			
		||||
	public partial class Application
 | 
			
		||||
	{
 | 
			
		||||
		public Application () : this (null, ApplicationFlags.None)
 | 
			
		||||
		{
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		[DllImport (GioGlobal.GioNativeDll, CallingConvention = CallingConvention.Cdecl)]
 | 
			
		||||
		static extern int g_application_run (IntPtr raw, int argc, IntPtr argv);
 | 
			
		||||
 | 
			
		||||
		public int Run ()
 | 
			
		||||
		{
 | 
			
		||||
			return Run (null, null);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public int Run (string program_name, string[] args)
 | 
			
		||||
		{
 | 
			
		||||
			var argc = 0;
 | 
			
		||||
			var argv = IntPtr.Zero;
 | 
			
		||||
			if (program_name != null) {
 | 
			
		||||
				program_name = program_name.Trim ();
 | 
			
		||||
				if (program_name.Length == 0) {
 | 
			
		||||
					throw new ArgumentException ("program_name must not be empty.", "program_name");
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				if (args == null) {
 | 
			
		||||
					throw new ArgumentNullException ("args");
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				var prog_args = new string [args.Length + 1];
 | 
			
		||||
				prog_args [0] = program_name;
 | 
			
		||||
				args.CopyTo (prog_args, 1);
 | 
			
		||||
 | 
			
		||||
				argc = prog_args.Length;
 | 
			
		||||
				argv = new Argv (prog_args).Handle;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			return g_application_run (Handle, argc, argv);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -37,7 +37,7 @@ namespace GLib {
 | 
			
		|||
			return Delete (null);
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		[DllImport ("libgio-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
 | 
			
		||||
		[DllImport (GioGlobal.GioNativeDll, CallingConvention = CallingConvention.Cdecl)]
 | 
			
		||||
		static extern IntPtr g_file_get_uri(IntPtr raw);
 | 
			
		||||
		
 | 
			
		||||
		public System.Uri Uri {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -27,7 +27,7 @@ namespace GLib
 | 
			
		|||
{
 | 
			
		||||
	public class FileFactory
 | 
			
		||||
	{
 | 
			
		||||
		[DllImport ("libgio-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
 | 
			
		||||
		[DllImport (GioGlobal.GioNativeDll, CallingConvention = CallingConvention.Cdecl)]
 | 
			
		||||
		private static extern IntPtr g_file_new_for_uri (string uri);
 | 
			
		||||
 | 
			
		||||
		public static IFile NewForUri (string uri)
 | 
			
		||||
| 
						 | 
				
			
			@ -40,7 +40,7 @@ namespace GLib
 | 
			
		|||
			return GLib.FileAdapter.GetObject (g_file_new_for_uri (uri.ToString ()), false) as IFile;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		[DllImport ("libgio-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
 | 
			
		||||
		[DllImport (GioGlobal.GioNativeDll, CallingConvention = CallingConvention.Cdecl)]
 | 
			
		||||
		private static extern IntPtr g_file_new_for_path (string path);
 | 
			
		||||
		
 | 
			
		||||
		public static IFile NewForPath (string path)
 | 
			
		||||
| 
						 | 
				
			
			@ -48,7 +48,7 @@ namespace GLib
 | 
			
		|||
			return GLib.FileAdapter.GetObject (g_file_new_for_path (path), false) as IFile;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		[DllImport ("libgio-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
 | 
			
		||||
		[DllImport (GioGlobal.GioNativeDll, CallingConvention = CallingConvention.Cdecl)]
 | 
			
		||||
		private static extern IntPtr g_file_new_for_commandline_arg (string arg);
 | 
			
		||||
 | 
			
		||||
		public static IFile NewFromCommandlineArg (string arg)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -106,6 +106,7 @@
 | 
			
		|||
  <attr path="/api/namespace/object/property[@type='GDbusServerFlags']" name="type">GDBusServerFlags</attr>
 | 
			
		||||
  <attr path="/api/namespace/object/property[@type='GIoStream']" name="type">GIOStream</attr>
 | 
			
		||||
  <attr path="/api/namespace/object/property[@type='GUnixFdList']" name="type">GUnixFDList</attr>
 | 
			
		||||
  <attr path="/api/namespace/object[@cname='GApplication']/method[@cname='g_application_run']" name="hidden">1</attr>
 | 
			
		||||
  <attr path="/api/namespace/object[@cname='GApplication']/signal[@cname='activate']" name="name">Activated</attr>
 | 
			
		||||
  <attr path="/api/namespace/object[@cname='GApplication']/signal[@cname='open']" name="name">Opened</attr>
 | 
			
		||||
  <attr path="/api/namespace/object[@cname='GAppLaunchContext']/signal[@cname='launch-failed']" name="name">LaunchedFailed</attr>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										29
									
								
								gio/GioGlobal.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								gio/GioGlobal.cs
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,29 @@
 | 
			
		|||
//
 | 
			
		||||
// Global.cs
 | 
			
		||||
//
 | 
			
		||||
// Author(s):
 | 
			
		||||
//	Antonius Riha <antoniusriha@gmail.com>
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2014 Antonius Riha
 | 
			
		||||
//
 | 
			
		||||
// This program is free software; you can redistribute it and/or
 | 
			
		||||
// modify it under the terms of version 2 of the Lesser 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
 | 
			
		||||
// Lesser General Public License for more details.
 | 
			
		||||
//
 | 
			
		||||
// You should have received a copy of the GNU Lesser 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 GLib
 | 
			
		||||
{
 | 
			
		||||
	public partial class GioGlobal
 | 
			
		||||
	{
 | 
			
		||||
		internal const string GioNativeDll = "libgio-2.0-0.dll";
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -12,10 +12,12 @@ glue_includes = gio/gio.h
 | 
			
		|||
POLICY_VERSIONS=
 | 
			
		||||
 | 
			
		||||
sources =			\
 | 
			
		||||
	Application.cs		\
 | 
			
		||||
	AppInfoAdapter.cs	\
 | 
			
		||||
	FileAdapter.cs		\
 | 
			
		||||
	FileEnumerator.cs	\
 | 
			
		||||
	FileFactory.cs		\
 | 
			
		||||
	GioGlobal.cs		\
 | 
			
		||||
	GioStream.cs		\
 | 
			
		||||
	IFile.cs
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -368,6 +368,8 @@
 | 
			
		|||
    <Compile Include="generated\GLib\ZlibCompressor.cs" />
 | 
			
		||||
    <Compile Include="generated\GLib\ZlibCompressorFormat.cs" />
 | 
			
		||||
    <Compile Include="generated\GLib\ZlibDecompressor.cs" />
 | 
			
		||||
    <Compile Include="Application.cs" />
 | 
			
		||||
    <Compile Include="GioGlobal.cs" />
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <ProjectReference Include="..\glib\glib.csproj">
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,7 @@ lib_LTLIBRARIES = libopaque.la
 | 
			
		|||
assemblies=../../glib/glib-sharp.dll ../../gio/gio-sharp.dll ../../pango/pango-sharp.dll ../../atk/atk-sharp.dll ../../gdk/gdk-sharp.dll ../../gtk/gtk-sharp.dll
 | 
			
		||||
references=$(addprefix -r:, $(assemblies))
 | 
			
		||||
 | 
			
		||||
opaquetest.exe: OpaqueTest.cs $(GENERATED_SOURCES_FILES) $(assemblies)
 | 
			
		||||
opaquetest.exe: generated-stamp OpaqueTest.cs $(assemblies)
 | 
			
		||||
	$(CSC) $(CSFLAGS) -out:opaquetest.exe $(references) $(srcdir)/OpaqueTest.cs $(GENERATED_SOURCES_OPTION)
 | 
			
		||||
 | 
			
		||||
libopaque_la_SOURCES =	\
 | 
			
		||||
| 
						 | 
				
			
			@ -17,11 +17,13 @@ libopaque_la_LIBADD = $(GTK_LIBS)
 | 
			
		|||
 | 
			
		||||
AM_CPPFLAGS = $(GTK_CFLAGS)
 | 
			
		||||
 | 
			
		||||
$(GENERATED_SOURCES_FILES): opaque-api.xml
 | 
			
		||||
generated-stamp: opaque-api.xml
 | 
			
		||||
	rm -rf generated/* &&	\
 | 
			
		||||
	$(RUNTIME) ../../generator/gapi_codegen.exe --generate $(srcdir)/opaque-api.xml	\
 | 
			
		||||
	--include=../../gtk/gtk-api.xml --include=../../gdk/gdk-api.xml 				\
 | 
			
		||||
	--outdir=generated --assembly-name=opaque-sharp									\
 | 
			
		||||
	--schema=$(top_srcdir)/gapi.xsd
 | 
			
		||||
	--include=../../gtk/gtk-api.xml --include=../../gdk/gdk-api.xml			\
 | 
			
		||||
	--outdir=generated --assembly-name=opaque-sharp					\
 | 
			
		||||
	--schema=$(top_srcdir)/gapi.xsd							\
 | 
			
		||||
	&& touch generated-stamp
 | 
			
		||||
 | 
			
		||||
api:
 | 
			
		||||
	PATH=../../parser:$(PATH) $(RUNTIME) ../../parser/gapi-parser.exe opaque-sources.xml
 | 
			
		||||
| 
						 | 
				
			
			@ -32,6 +34,7 @@ install:
 | 
			
		|||
CLEANFILES =			\
 | 
			
		||||
	opaquetest.exe		\
 | 
			
		||||
	opaquetest.exe.mdb	\
 | 
			
		||||
	generated-stamp		\
 | 
			
		||||
	$(GENERATED_SOURCES_FILES)
 | 
			
		||||
 | 
			
		||||
EXTRA_DIST =		\
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,7 @@ lib_LTLIBRARIES = libvalobj.la
 | 
			
		|||
assemblies=../../glib/glib-sharp.dll ../../gio/gio-sharp.dll ../../cairo/cairo-sharp.dll ../../pango/pango-sharp.dll ../../atk/atk-sharp.dll ../../gdk/gdk-sharp.dll ../../gtk/gtk-sharp.dll
 | 
			
		||||
references=$(addprefix -r:, $(assemblies))
 | 
			
		||||
 | 
			
		||||
valtest.exe: Valtest.cs $(GENERATED_SOURCES_FILES) $(assemblies)
 | 
			
		||||
valtest.exe: generated-stamp Valtest.cs $(assemblies)
 | 
			
		||||
	$(CSC) $(CSFLAGS) -out:valtest.exe $(references) $(srcdir)/Valtest.cs $(GENERATED_SOURCES_OPTION)
 | 
			
		||||
 | 
			
		||||
libvalobj_la_SOURCES =	\
 | 
			
		||||
| 
						 | 
				
			
			@ -17,11 +17,13 @@ libvalobj_la_LIBADD = $(GTK_LIBS)
 | 
			
		|||
 | 
			
		||||
AM_CPPFLAGS = $(GTK_CFLAGS)
 | 
			
		||||
 | 
			
		||||
$(GENERATED_SOURCES_FILES): valobj-api.xml
 | 
			
		||||
generated-stamp: valobj-api.xml
 | 
			
		||||
	rm -rf generated/* && \
 | 
			
		||||
	$(RUNTIME) ../../generator/gapi_codegen.exe --generate $(srcdir)/valobj-api.xml	\
 | 
			
		||||
	--include=../../gtk/gtk-api.xml --include=../../gdk/gdk-api.xml					\
 | 
			
		||||
	--outdir=generated --assembly-name=valobj-sharp											\
 | 
			
		||||
	--schema=$(top_srcdir)/gapi.xsd
 | 
			
		||||
	--schema=$(top_srcdir)/gapi.xsd && \
 | 
			
		||||
	touch generated-stamp
 | 
			
		||||
 | 
			
		||||
api:
 | 
			
		||||
	PATH=../../parser:$(PATH) $(RUNTIME) ../../parser/gapi-parser.exe valobj-sources.xml
 | 
			
		||||
| 
						 | 
				
			
			@ -31,6 +33,7 @@ install:
 | 
			
		|||
CLEANFILES =		\
 | 
			
		||||
	valtest.exe	\
 | 
			
		||||
	valtest.exe.mdb	\
 | 
			
		||||
	generated-stamp \
 | 
			
		||||
	$(GENERATED_SOURCES_FILES)
 | 
			
		||||
 | 
			
		||||
EXTRA_DIST =		\
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue