[Gtk-sharp-list] gtkhtml namespace problem

Martin Willemoes Hansen mwh@sysrq.dk
Sun, 31 Aug 2003 11:12:52 +0200


--=-0CT52vj1msr/7eCbbnZr
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

On Thu, 2003-08-28 at 12:31, Martin Willemoes Hansen wrote:
> On Thu, 2003-08-28 at 05:08, Mike Kestner wrote:
> > On Wed, 2003-08-27 at 04:45, Martin Willemoes Hansen wrote:
> > 
> > > Here is the patch for the generator.
> > 
> > I want to mull this over a bit.  This patch is a lot bigger than it
> > should have to be because of some suckiness in the generator I've been
> > wanting to fix for a while.  
> 
> I was thinking the same thing, a refactoring will do much good.
> 
> > Tomorrow night I'm going to ignore email and hack instead. :) I'll see
> > if I can adapt your patch to some refactoring I've done in the
> > generator.
> > 
> > Thanks for the patch.
> No problemo, cant wait for your modification to the generator :o)

I made a new updated patch for the generator which takes into account
that not all api.xml files may have a assembly tag.

There is one problem with this patch, it doesnt place Callbacks in the
correct directories :( Ill see if I can find and squish the bug.

-- 
Martin Willemoes Hansen

--------------------------------------------------------
E-Mail	mwh@sysrq.dk	Website	mwh.sysrq.dk
IRC     MWH, freenode.net
--------------------------------------------------------               


--=-0CT52vj1msr/7eCbbnZr
Content-Disposition: attachment; filename=AssemblyTagGenerator.diff
Content-Type: text/plain; name=AssemblyTagGenerator.diff; charset=iso-8859-1
Content-Transfer-Encoding: 7bit

? AssemblyTagGenerator.diff
? AssemblyTagGenerator2.diff
Index: CallbackGen.cs
===================================================================
RCS file: /cvs/public/gtk-sharp/generator/CallbackGen.cs,v
retrieving revision 1.24
diff -u -r1.24 CallbackGen.cs
--- CallbackGen.cs	23 Jul 2003 17:19:19 -0000	1.24
+++ CallbackGen.cs	31 Aug 2003 08:58:46 -0000
@@ -57,7 +57,7 @@
 		public string GenWrapper (string ns)
 		{
 			char sep = Path.DirectorySeparatorChar;
-			string dir = ".." + sep + ns.ToLower() + sep + "generated";
+			string dir = ".." + sep + Assembly + sep + "generated";
 
 			if (!Directory.Exists (dir))
 				Directory.CreateDirectory (dir);
Index: GenBase.cs
===================================================================
RCS file: /cvs/public/gtk-sharp/generator/GenBase.cs,v
retrieving revision 1.11
diff -u -r1.11 GenBase.cs
--- GenBase.cs	2 Jul 2003 18:13:24 -0000	1.11
+++ GenBase.cs	31 Aug 2003 08:58:46 -0000
@@ -52,6 +52,15 @@
 			}
 		}
 
+		public string Assembly {
+			get { 
+				if (ns.HasAttribute ("assembly"))
+					return ns.GetAttribute ("assembly");
+				else
+					return NS.ToLower();
+			}
+		}
+
 		public string QualifiedName {
 			get {
 				return NS + "." + Name;
@@ -66,7 +75,7 @@
 		protected StreamWriter CreateWriter () 
 		{
 			char sep = Path.DirectorySeparatorChar;
-			string dir = ".." + sep + NS.ToLower() + sep + "generated";
+			string dir = ".." + sep + Assembly + sep + "generated";
 			if (!Directory.Exists(dir)) {
 				Console.WriteLine ("creating " + dir);
 				Directory.CreateDirectory(dir);
@@ -99,7 +108,7 @@
 		public void AppendCustom (StreamWriter sw)
 		{
 			char sep = Path.DirectorySeparatorChar;
-			string custom = ".." + sep + NS.ToLower() + sep + Name + ".custom";
+			string custom = ".." + sep + Assembly + sep + Name + ".custom";
 			if (File.Exists(custom)) {
 				sw.WriteLine ("#region Customized extensions");
 				sw.WriteLine ("#line 1 \"" + Name + ".custom\"");
Index: ObjectGen.cs
===================================================================
RCS file: /cvs/public/gtk-sharp/generator/ObjectGen.cs,v
retrieving revision 1.44
diff -u -r1.44 ObjectGen.cs
--- ObjectGen.cs	19 May 2003 02:45:17 -0000	1.44
+++ ObjectGen.cs	31 Aug 2003 08:58:47 -0000
@@ -16,6 +16,7 @@
 
 		private ArrayList strings = new ArrayList();
 		private static Hashtable namespaces = new Hashtable ();
+		private static string assembly;
 
 		public ObjectGen (XmlElement ns, XmlElement elem) : base (ns, elem) 
 		{
@@ -49,6 +50,7 @@
 					break;
 				}
 			}
+			assembly = Assembly;
 		}
 
 		public void Generate ()
@@ -189,10 +191,10 @@
 					continue;
 	
 				char sep = Path.DirectorySeparatorChar;
-				string dir = ".." + sep + ns.ToLower () + sep + "generated";
+				string dir = ".." + sep + assembly + sep + "generated";
 				if (!Directory.Exists(dir)) {
         			Console.WriteLine ("creating " + dir);
-      		  	Directory.CreateDirectory(dir);
+				Directory.CreateDirectory(dir);
 				}
 				String filename = dir + sep + "ObjectManager.cs";
 
Index: Signal.cs
===================================================================
RCS file: /cvs/public/gtk-sharp/generator/Signal.cs,v
retrieving revision 1.15
diff -u -r1.15 Signal.cs
--- Signal.cs	14 Jun 2003 17:30:32 -0000	1.15
+++ Signal.cs	31 Aug 2003 08:58:47 -0000
@@ -39,7 +39,7 @@
 
 		public bool Validate ()
 		{
-			marsh = SignalHandler.GetName(elem, container_type.NS, false);
+			marsh = SignalHandler.GetName(elem, container_type.NS, container_type.Assembly, false);
 			if ((Name == "") || (marsh == "")) {
 				Console.Write ("bad signal " + Name);
 				Statistics.ThrottledCount++;
@@ -83,8 +83,9 @@
 				return handler;
 
 			string ns = container_type.NS;
+			string assembly = container_type.Assembly;
 			char sep = Path.DirectorySeparatorChar;
-			string dir = ".." + sep + ns.ToLower() + sep + "generated";
+			string dir = ".." + sep + assembly + sep + "generated";
 
 			if (!Directory.Exists (dir))
 				Directory.CreateDirectory (dir);
@@ -126,12 +127,16 @@
 		{
 			string cname = "\"" + elem.GetAttribute("cname") + "\"";
 			string ns;
-			if (implementor == null)
+			string assembly;
+			if (implementor == null) {
 				ns = container_type.NS;
-			else
+				assembly = container_type.Assembly;
+			} else {
 				ns = implementor.NS;
+				assembly = implementor.Assembly;
+			}
 
-			string qual_marsh = SignalHandler.GetName(elem, ns, container_type.DoGenerate);
+			string qual_marsh = SignalHandler.GetName(elem, ns, assembly, container_type.DoGenerate);
 
 			string argsname;
 			string handler = GenHandler (out argsname);
Index: SignalHandler.cs
===================================================================
RCS file: /cvs/public/gtk-sharp/generator/SignalHandler.cs,v
retrieving revision 1.30
diff -u -r1.30 SignalHandler.cs
--- SignalHandler.cs	19 Aug 2003 04:52:25 -0000	1.30
+++ SignalHandler.cs	31 Aug 2003 08:58:47 -0000
@@ -13,7 +13,7 @@
 
 	public class SignalHandler {
 		
-		public static string GetName(XmlElement sig, string ns, bool generate)
+		public static string GetName(XmlElement sig, string ns, string assembly, bool generate)
 		{
 			XmlElement ret_elem = sig["return-type"];
 			if (ret_elem == null) {
@@ -84,7 +84,7 @@
 				return ns + "." + sname;
 
 			char sep = Path.DirectorySeparatorChar;
-			String dir = ".." + sep + ns.ToLower() + sep + "generated";
+			String dir = ".." + sep + assembly + sep + "generated";
 
 			if (!Directory.Exists(dir)) {
 				Directory.CreateDirectory(dir);

--=-0CT52vj1msr/7eCbbnZr--