Author: mkestner
Date: 2005-04-15 16:52:44 -0400 (Fri, 15 Apr 2005)
New Revision: 43077

Added:
   trunk/gtk-sharp/parser/gapi-parser.cs
Removed:
   trunk/gtk-sharp/parser/gapi_parser.pl
Modified:
   trunk/gtk-sharp/ChangeLog
   trunk/gtk-sharp/parser/Makefile.am
   trunk/gtk-sharp/parser/gapi2-parser.in
   trunk/gtk-sharp/sources/Makefile.am
Log:

2005-04-15  Mike Kestner  <[EMAIL PROTECTED]>

        * parser/gapi-parser.cs : C# rewrite of the old perl driver script.
        * parser/gapi_parser.pl : kill.
        * parser/gapi2-parser.in : invoke via $(RUNTIME).
        * parser/Makefile.am : build rework for C# parser driver.
        * sources/Makefile.am : use $(RUNTIME) to invoke new parser assm.


Modified: trunk/gtk-sharp/ChangeLog
===================================================================
--- trunk/gtk-sharp/ChangeLog   2005-04-15 20:42:58 UTC (rev 43076)
+++ trunk/gtk-sharp/ChangeLog   2005-04-15 20:52:44 UTC (rev 43077)
@@ -1,3 +1,11 @@
+2005-04-15  Mike Kestner  <[EMAIL PROTECTED]>
+
+       * parser/gapi-parser.cs : C# rewrite of the old perl driver script.
+       * parser/gapi_parser.pl : kill.
+       * parser/gapi2-parser.in : invoke via $(RUNTIME).
+       * parser/Makefile.am : build rework for C# parser driver.
+       * sources/Makefile.am : use $(RUNTIME) to invoke new parser assm.
+
 2005-04-12  Mike Kestner  <[EMAIL PROTECTED]>
 
        * configure.in : bump version to 1.9.3 and tag.

Modified: trunk/gtk-sharp/parser/Makefile.am
===================================================================
--- trunk/gtk-sharp/parser/Makefile.am  2005-04-15 20:42:58 UTC (rev 43076)
+++ trunk/gtk-sharp/parser/Makefile.am  2005-04-15 20:52:44 UTC (rev 43077)
@@ -1,29 +1,30 @@
 assemblydir = $(libdir)/gtk-sharp-2.0
 pkgconfigdir = $(libdir)/pkgconfig
-assembly_DATA = gapi-fixup.exe
+assembly_DATA = gapi-fixup.exe gapi-parser.exe
 pkgconfig_DATA = gapi-2.0.pc
 bin_SCRIPTS = gapi2-fixup gapi2-parser
-assembly_SCRIPTS = gapi_parser.pl gapi_pp.pl gapi2xml.pl
+assembly_SCRIPTS = gapi_pp.pl gapi2xml.pl
 CLEANFILES = gapi-fixup.exe
 DISTCLEANFILES = gapi2-fixup gapi2-parser gapi-2.0.pc
 
 sources =                              \
-       gapi-fixup.cs
+       gapi-fixup.cs                   \
+       gapi-parser.cs
 
-build_sources = $(addprefix $(srcdir)/, $(sources))
-
 EXTRA_DIST =                                   \
        makefile.win32                          \
        $(sources)                              \
        gapi2-parser.in                         \
-       gapi_parser.pl                          \
        gapi_pp.pl                              \
        gapi2xml.pl                             \
        gapi-2.0.pc.in
 
-gapi-fixup.exe: $(build_sources)
-       $(CSC) /out:gapi-fixup.exe $(build_sources)
+gapi-fixup.exe: $(srcdir)/gapi-fixup.cs
+       $(CSC) /out:gapi-fixup.exe $(srcdir)/gapi-fixup.cs
 
+gapi-parser.exe: $(srcdir)/gapi-parser.cs
+       $(CSC) /out:gapi-parser.exe $(srcdir)/gapi-parser.cs
+
 INCLUDES = $(GLIB_CFLAGS) $(XML_CFLAGS)
 
 assembly_PROGRAMS = gapi_format_xml

Added: trunk/gtk-sharp/parser/gapi-parser.cs
===================================================================
--- trunk/gtk-sharp/parser/gapi-parser.cs       2005-04-15 20:42:58 UTC (rev 
43076)
+++ trunk/gtk-sharp/parser/gapi-parser.cs       2005-04-15 20:52:44 UTC (rev 
43077)
@@ -0,0 +1,143 @@
+// gapi-parser.cs - parsing driver application.
+//
+// Author: Mike Kestner <[EMAIL PROTECTED]>
+//
+// 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;
+                                                       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);
+                                       }
+                               }
+                       
+                               system ("gapi_format_xml " + prefile + " " + 
outfile);
+                               File.Delete (prefile);
+                       }
+
+                       return 0;
+               }
+       }
+}

Modified: trunk/gtk-sharp/parser/gapi2-parser.in
===================================================================
--- trunk/gtk-sharp/parser/gapi2-parser.in      2005-04-15 20:42:58 UTC (rev 
43076)
+++ trunk/gtk-sharp/parser/gapi2-parser.in      2005-04-15 20:52:44 UTC (rev 
43077)
@@ -1,3 +1,3 @@
 #!/bin/sh
 export [EMAIL PROTECTED]@/lib/gtk-sharp-2.0:$PATH
[EMAIL PROTECTED]@/lib/gtk-sharp-2.0/gapi_parser.pl "$@"
[EMAIL PROTECTED]@ @prefix@/lib/gtk-sharp-2.0/gapi-parser.exe "$@"

Deleted: trunk/gtk-sharp/parser/gapi_parser.pl
===================================================================
--- trunk/gtk-sharp/parser/gapi_parser.pl       2005-04-15 20:42:58 UTC (rev 
43076)
+++ trunk/gtk-sharp/parser/gapi_parser.pl       2005-04-15 20:52:44 UTC (rev 
43077)
@@ -1,112 +0,0 @@
-#!/usr/bin/perl -w
-# gapi-parser - parser frontend for XML-based sources file format.
-#
-# Author:  Mike Kestner  <[EMAIL PROTECTED]>
-#
-# Copyright (c) 2003  Mike Kestner
-# Copyright (c) 2003  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.
-
-use XML::LibXML;
-
-die "Usage: gapi-parser <xml_sources_file>\n" if (!$ARGV[0]);
-
-my $parser = new XML::LibXML;
-my $doc = $parser->parse_file($ARGV[0]);
-die "Unable to parse input file $ARGV[0].\n" if (!$doc);
-my $root = $doc->documentElement;
-die "Improperly formatted input file $ARGV[0].\n" if (!$root || 
$root->nodeName ne "gapi-parser-input");
-
-for ($apinode = $root->firstChild; $apinode; $apinode = $apinode->nextSibling 
()) {
-       next if ($apinode->nodeName ne "api");
-       @attrs = $apinode->attributes;
-       my $outfile = "";
-       foreach $attr (@attrs) {
-               if ($attr->name eq "filename") {
-                       $outfile = $attr->value;
-               } else {
-                       die "Unexpected attribute $attr->name\n";
-               }
-       }
-
-       unlink "$outfile.pre";
-
-       for ($libnode = $apinode->firstChild; $libnode; $libnode = 
$libnode->nextSibling ()) {
-               next if ($libnode->nodeName ne "library");
-               @attrs = $libnode->attributes;
-               my ($lib);
-               foreach $attr (@attrs) {
-                       if ($attr->name eq "name") {
-                               $lib = $attr->value;
-                       } else {
-                               die "Unexpected attribute $attr->name\n";
-                       }
-               }
-
-               for ($nsnode = $libnode->firstChild; $nsnode; $nsnode = 
$nsnode->nextSibling ()) {
-                       next if ($nsnode->nodeName ne "namespace");
-                       @attrs = $nsnode->attributes;
-                       my ($ns);
-                       foreach $attr (@attrs) {
-                               if ($attr->name eq "name") {
-                                       $ns = $attr->value;
-                               } else {
-                                       die "Unexpected attribute 
$attr->name\n";
-                               }
-                       }
-
-                       my @files = ();
-                       my @realfiles = ();
-                       my %excludes = ();
-                       for ($srcnode = $nsnode->firstChild; $srcnode; $srcnode 
= $srcnode->nextSibling ()) {
-                               next if ($srcnode->nodeName ne "dir" && 
$srcnode->nodeName ne "file" && $srcnode->nodeName ne "exclude");
-
-                               if ($srcnode->nodeName eq "dir") {
-                                       my ($dir);
-                                       $dir = $srcnode->firstChild->nodeValue;
-                                       print "<dir $dir> ";
-                                       @files = (@files, `ls $dir/*.c`);
-                                       @files = (@files, `ls $dir/*.h`);
-                               } elsif ($srcnode->nodeName eq "file") {
-                                       $incfile = 
$srcnode->firstChild->nodeValue;
-                                       print "<file $incfile> ";
-                                       @files = (@files, 
$srcnode->firstChild->nodeValue);
-                               } elsif ($srcnode->nodeName eq "exclude") {
-                                       $excfile = 
$srcnode->firstChild->nodeValue;
-                                       print "<exclude $excfile> ";
-                                       
$excludes{$srcnode->firstChild->nodeValue} = 1;
-                               } else {
-                                       die "Unexpected source 
$srcnode->nodeName \n";
-                               }
-
-                       }
-                       print "\n";
-                       if ($#files >= 0) {
-                               foreach $file (@files) {
-                                       chomp ($file);
-                                       @realfiles = (@realfiles, $file) if 
(!exists($excludes{$file}));
-                               }
-                                       
-                               $pp_args = join (" ", @realfiles);
-                               system ("gapi_pp.pl $pp_args | gapi2xml.pl $ns 
$outfile.pre $lib");
-                       }
-               }
-       }
-
-       system ("gapi_format_xml $outfile.pre $outfile");
-       unlink "$outfile.pre";
-}
-

Modified: trunk/gtk-sharp/sources/Makefile.am
===================================================================
--- trunk/gtk-sharp/sources/Makefile.am 2005-04-15 20:42:58 UTC (rev 43076)
+++ trunk/gtk-sharp/sources/Makefile.am 2005-04-15 20:52:44 UTC (rev 43077)
@@ -37,7 +37,7 @@
         gtkhtml-3.0.10/src/gtkhtml-stream.h
 
 api:
-       PATH=../parser:$$PATH ../parser/gapi_parser.pl gtk-sharp-sources.xml
+       PATH=../parser:$$PATH $(RUNTIME) ../parser/gapi-parser.exe 
gtk-sharp-sources.xml
 
 get-gtkhtml-code:
        wget 
http://ftp.gnome.org/pub/GNOME/sources/gtkhtml/3.0/gtkhtml-3.0.10.tar.gz 
--output-document=- | tar -xz $(GTKHTML_SOURCEFILES)

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to