[Mono-list] mcs.exe problem compiling gtk-sharp

Jaroslaw Kowalski jaak@zd.com.pl
Mon, 13 Oct 2003 19:55:13 +0200


This is a multi-part message in MIME format.

------=_NextPart_000_0035_01C391C3.EABED110
Content-Type: text/plain;
	charset="iso-8859-2"
Content-Transfer-Encoding: 7bit


I've recently updated mcs from AnonCVS and I have the following problem
compiling CVS gtk-sharp:

"gtk-sharp/parser/gapi-fixup.cs" (as it's quite small, I've attached a copy)

--------------
$ mcs gapi-fixup.cs

** (/opt/mono/bin/mcs.exe:28302): WARNING **: Missing method
DiscardBufferedData in assembly /opt/mono/bin/mcs.exe typeref index 69
System.NullReferenceException: A null value was found where an object
instance was required
in (unmanaged) Mono.CSharp.SeekableStreamReader:set_Position (int)
in <0x0016e> Mono.CSharp.Tokenizer:is_punct (char,bool&)
in <0x00349> Mono.CSharp.Tokenizer:xtoken ()
in <0x00017> Mono.CSharp.Tokenizer:token ()
in <0x002dc> Mono.CSharp.CSharpParser:yyparse (Mono.CSharp.yyParser.yyInput)
in <0x00079> Mono.CSharp.CSharpParser:parse ()

gapi-fixup.cs(72) error CS8025: Parsing error
Compilation failed: 1 error(s), 0 warnings
--------------

The problematic lines are:

 XmlElement node = ((IHasXmlNode)api_iter.Current).GetNode () as XmlElement;
 node.SetAttribute (attr_name, attr_iter.Current.Value);

after I comment them out - it compiles fine but that's obviously not the
solution.

Is it my fault or a bug?

Jarek

------=_NextPart_000_0035_01C391C3.EABED110
Content-Type: text/plain;
	name="gapi-fixup.cs"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="gapi-fixup.cs"

// GtkSharp.Parsing.gapi-fixup.cs - xml alteration engine.
//
// Author: Mike Kestner <mkestner@speakeasy.net>
//
// (c) 2003 Mike Kestner

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 !=3D 2) {
				Console.WriteLine ("Usage: gapi-fixup --metadata=3D<filename> =
--api=3D<filename>");
				return 0;
			}

			string api_filename =3D "";
			XmlDocument api_doc =3D new XmlDocument ();
			XmlDocument meta_doc =3D new XmlDocument ();

			foreach (string arg in args) {

				if (arg.StartsWith("--metadata=3D")) {

					string meta_filename =3D arg.Substring (11);

					try {
						Stream stream =3D 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=3D")) {

					api_filename =3D arg.Substring (6);

					try {
						Stream stream =3D File.OpenRead (api_filename);
						api_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=3D<filename> =
--api=3D<filename>");
					return 1;
				}
			}

			XPathNavigator meta_nav =3D meta_doc.CreateNavigator ();
			XPathNavigator api_nav =3D api_doc.CreateNavigator ();

			XPathNodeIterator attr_iter =3D meta_nav.Select ("//attr");
			while (attr_iter.MoveNext ()) {
				string path =3D attr_iter.Current.GetAttribute ("path", "");
				string attr_name =3D attr_iter.Current.GetAttribute ("name", "");
				XPathNodeIterator api_iter =3D api_nav.Select (path);
				while (api_iter.MoveNext ()) {
					XmlElement node =3D ((IHasXmlNode)api_iter.Current).GetNode() as =
XmlElement;
					node.SetAttribute (attr_name, attr_iter.Current.Value);
				}
			}

			Stream out_stream =3D File.OpenWrite (api_filename);
			api_doc.Save (out_stream);
			out_stream.Close ();
			return 0;
		}
	}
}

------=_NextPart_000_0035_01C391C3.EABED110--