Author: iainmc
Date: 2005-07-06 09:14:16 -0400 (Wed, 06 Jul 2005)
New Revision: 46995

Modified:
   trunk/mcs/class/PresentationFramework/ChangeLog
   
trunk/mcs/class/PresentationFramework/Mono.Windows.Serialization/CodeWriter.cs
   trunk/mcs/tools/xamlc/ChangeLog
   trunk/mcs/tools/xamlc/demo/Makefile
   trunk/mcs/tools/xamlc/xamlc.cs
Log:
2005-07-06  Iain McCoy  <[EMAIL PROTECTED]>

        * Mono.Windows.Serialization/CodeWriter.cs: cleaned up a little, added
        support for the `partial' class modifier
        * xamlc.cs: add support for emitting classes with the partial modifier
        set



Modified: trunk/mcs/class/PresentationFramework/ChangeLog
===================================================================
--- trunk/mcs/class/PresentationFramework/ChangeLog     2005-07-06 13:02:01 UTC 
(rev 46994)
+++ trunk/mcs/class/PresentationFramework/ChangeLog     2005-07-06 13:14:16 UTC 
(rev 46995)
@@ -1,5 +1,10 @@
 2005-07-06  Iain McCoy  <[EMAIL PROTECTED]>
 
+       * Mono.Windows.Serialization/CodeWriter.cs: cleaned up a little, added
+       support for the `partial' class modifier
+
+2005-07-06  Iain McCoy  <[EMAIL PROTECTED]>
+
        * Mono.Windows.Serialization/Mapping.cs: removed in favour of
        System.Windows.Serialization/Mapper.cs
        * System.Windows.Serialization/Mapper.cs: Added because it is the

Modified: 
trunk/mcs/class/PresentationFramework/Mono.Windows.Serialization/CodeWriter.cs
===================================================================
--- 
trunk/mcs/class/PresentationFramework/Mono.Windows.Serialization/CodeWriter.cs  
    2005-07-06 13:02:01 UTC (rev 46994)
+++ 
trunk/mcs/class/PresentationFramework/Mono.Windows.Serialization/CodeWriter.cs  
    2005-07-06 13:14:16 UTC (rev 46995)
@@ -36,6 +36,9 @@
 namespace Mono.Windows.Serialization {
        public class CodeWriter : XamlWriter {
                TextWriter writer;
+               ICodeGenerator generator;
+               bool isPartial;
+               
                ArrayList objects = new ArrayList();
                Hashtable nameClashes = new Hashtable();
                int tempIndex = 0;
@@ -45,9 +48,11 @@
                CodeConstructor constructor;
                
                // pushes: the code writer
-               public CodeWriter(TextWriter writer)
+               public CodeWriter(ICodeGenerator generator, TextWriter writer, 
bool isPartial)
                {
+                       this.generator = generator;
                        this.writer = writer;
+                       this.isPartial = isPartial;
                        code = new CodeCompileUnit();
                        objects.Add(code);
                }
@@ -67,6 +72,13 @@
                        ((CodeCompileUnit)objects[0]).Namespaces.Add(ns);
 
                        type = new CodeTypeDeclaration(className);
+                       if (isPartial) {
+#if NET_2_0
+                               type.IsPartial = isPartial;
+#else
+                               throw new Exception("Cannot create partial 
class");
+#endif
+                       }
                        type.BaseTypes.Add(new CodeTypeReference(parent));
                        constructor = new CodeConstructor();
                        type.Members.Add(constructor);
@@ -238,7 +250,6 @@
 
                public void Finish()
                {
-                       ICodeGenerator generator = (new 
Microsoft.CSharp.CSharpCodeProvider()).CreateGenerator();
                        generator.GenerateCodeFromCompileUnit(code, writer, 
null);
                        writer.Close();
                }

Modified: trunk/mcs/tools/xamlc/ChangeLog
===================================================================
--- trunk/mcs/tools/xamlc/ChangeLog     2005-07-06 13:02:01 UTC (rev 46994)
+++ trunk/mcs/tools/xamlc/ChangeLog     2005-07-06 13:14:16 UTC (rev 46995)
@@ -1,5 +1,10 @@
 2005-07-06  Iain McCoy  <[EMAIL PROTECTED]>
 
+       * xamlc.cs: add support for emitting classes with the partial modifier
+       set
+
+2005-07-06  Iain McCoy  <[EMAIL PROTECTED]>
+
        * demo/TestVocab/ConsoleApp.cs: remove default value hack, since we
        have proper default value support now
 

Modified: trunk/mcs/tools/xamlc/demo/Makefile
===================================================================
--- trunk/mcs/tools/xamlc/demo/Makefile 2005-07-06 13:02:01 UTC (rev 46994)
+++ trunk/mcs/tools/xamlc/demo/Makefile 2005-07-06 13:14:16 UTC (rev 46995)
@@ -4,11 +4,15 @@
 SOURCES=TestVocab/ConsoleApp.cs TestVocab/ConsoleWriter.cs 
TestVocab/IConsoleAction.cs
 
 run:
+       make clean
        make TestVocab.dll
        MONO_PATH="." $(RUNTIME) --debug ../xamlc.exe -o:test.xaml.out.cs 
test.xaml
        $(CSCOMPILE) -r:TestVocab.dll -o test.exe test.xaml.out.cs
        $(RUNTIME) --debug test.exe
 
+clean-local:
+       rm -f TestVocab.dll test.xaml.out.cs
+
 all-local: TestVocab.dll
 
 TestVocab.dll: $(SOURCES)

Modified: trunk/mcs/tools/xamlc/xamlc.cs
===================================================================
--- trunk/mcs/tools/xamlc/xamlc.cs      2005-07-06 13:02:01 UTC (rev 46994)
+++ trunk/mcs/tools/xamlc/xamlc.cs      2005-07-06 13:14:16 UTC (rev 46995)
@@ -28,10 +28,15 @@
 
 using System;
 using System.IO;
+using System.CodeDom;
+using System.CodeDom.Compiler;
 using Mono.GetOptions;
 using Mono.Windows.Serialization;
 
 class XamlOptions : Options {
+       [Option("Whether or not the class should be marked as partial", "p", 
"partial")]
+       public bool Partial;
+       
        [Option("the file to output to", "o", "output")]
        public string OutputFile;
 }
@@ -42,11 +47,16 @@
                        Console.WriteLine("Input filenames must end in .xaml");
                        return;
                }
+               if (Environment.Version.Major < 2 && options.Partial) {
+                       Console.WriteLine("This runtime version does not 
support partial classes");
+                       return;
+               }
                if (options.OutputFile == null) {
                        options.OutputFile = input + ".out";
                }
+               ICodeGenerator generator = (new 
Microsoft.CSharp.CSharpCodeProvider()).CreateGenerator();
                TextWriter tw = new StreamWriter(options.OutputFile);
-               CodeWriter cw = new CodeWriter(tw);
+               CodeWriter cw = new CodeWriter(generator, tw, options.Partial);
                XamlParser r = new XamlParser(input, cw);
                r.Parse();
        }

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

Reply via email to