Author: mkestner
Date: 2007-09-06 16:41:08 -0400 (Thu, 06 Sep 2007)
New Revision: 85455

Added:
   
branches/gtk-sharp-2-468-branch/gtk-sharp/glib/IgnoreClassInitializersAttribute.cs
   branches/gtk-sharp-2-468-branch/gtk-sharp/glib/TypeInitializerAttribute.cs
Modified:
   branches/gtk-sharp-2-468-branch/gtk-sharp/AssemblyInfo.cs.in
   branches/gtk-sharp-2-468-branch/gtk-sharp/ChangeLog
   branches/gtk-sharp-2-468-branch/gtk-sharp/generator/ObjectGen.cs
   branches/gtk-sharp-2-468-branch/gtk-sharp/glib/ClassInitializerAttribute.cs
   branches/gtk-sharp-2-468-branch/gtk-sharp/glib/Makefile.am
   branches/gtk-sharp-2-468-branch/gtk-sharp/glib/Object.cs
   branches/gtk-sharp-2-468-branch/gtk-sharp/gtk/Gtk.metadata
   branches/gtk-sharp-2-468-branch/gtk-sharp/gtk/Widget.custom
   branches/gtk-sharp-2-468-branch/gtk-sharp/sample/Subclass.cs
Log:

2007-09-06  Mike Kestner  <[EMAIL PROTECTED]>

        * AssemblyInfo.cs.in : add IgnoreClassInitializers attr to all.
        * generator/ObjectGen.cs : add custom-attr generation for objects.
        * glib/ClassInitializerAttribute.cs : obsolete
        * glib/IgnoreClassInitializersAttribute.cs : new assembly attr
        to avoid a blind GetMethods reflection.
        * glib/Makefile.am : add files
        * glib/TypeInitializerAttribute.cs : new attr to specify init
        method to be run at type registration.
        * gtk/Widget.custom : remove the ClassInitializerAttr.
        * gtk/Gtk.metadata : add a custom-attr node to GtkWidget.
        * sample/Subclass.cs : use the IgnoreClassInitializers attr.


Modified: branches/gtk-sharp-2-468-branch/gtk-sharp/AssemblyInfo.cs.in
===================================================================
--- branches/gtk-sharp-2-468-branch/gtk-sharp/AssemblyInfo.cs.in        
2007-09-06 20:27:10 UTC (rev 85454)
+++ branches/gtk-sharp-2-468-branch/gtk-sharp/AssemblyInfo.cs.in        
2007-09-06 20:41:08 UTC (rev 85455)
@@ -4,3 +4,4 @@
 [assembly:AssemblyVersion("@API_VERSION@")]
 [assembly:AssemblyDelaySign(false)]
 [assembly:AssemblyKeyFile("gtk-sharp.snk")]
+[assembly:GLib.IgnoreClassInitializers]

Modified: branches/gtk-sharp-2-468-branch/gtk-sharp/ChangeLog
===================================================================
--- branches/gtk-sharp-2-468-branch/gtk-sharp/ChangeLog 2007-09-06 20:27:10 UTC 
(rev 85454)
+++ branches/gtk-sharp-2-468-branch/gtk-sharp/ChangeLog 2007-09-06 20:41:08 UTC 
(rev 85455)
@@ -1,8 +1,22 @@
 2007-09-06  Mike Kestner  <[EMAIL PROTECTED]>
 
-       bootstrap-generic : use automake --foreign for newer automakes.
-       sample/gconf/Makefile.am : install-data-hook for newer am too.
+       * AssemblyInfo.cs.in : add IgnoreClassInitializers attr to all.
+       * generator/ObjectGen.cs : add custom-attr generation for objects.
+       * glib/ClassInitializerAttribute.cs : obsolete
+       * glib/IgnoreClassInitializersAttribute.cs : new assembly attr
+       to avoid a blind GetMethods reflection.
+       * glib/Makefile.am : add files
+       * glib/TypeInitializerAttribute.cs : new attr to specify init
+       method to be run at type registration.
+       * gtk/Widget.custom : remove the ClassInitializerAttr.
+       * gtk/Gtk.metadata : add a custom-attr node to GtkWidget.
+       * sample/Subclass.cs : use the IgnoreClassInitializers attr.
+       
+2007-09-06  Mike Kestner  <[EMAIL PROTECTED]>
 
+       * bootstrap-generic : use automake --foreign for newer automakes.
+       * sample/gconf/Makefile.am : install-data-hook for newer am too.
+
 2007-07-17  Mike Kestner  <[EMAIL PROTECTED]>
 
        * gtk/Gtk.metadata : map TreeModelFilter ctor param to prop to

Modified: branches/gtk-sharp-2-468-branch/gtk-sharp/generator/ObjectGen.cs
===================================================================
--- branches/gtk-sharp-2-468-branch/gtk-sharp/generator/ObjectGen.cs    
2007-09-06 20:27:10 UTC (rev 85454)
+++ branches/gtk-sharp-2-468-branch/gtk-sharp/generator/ObjectGen.cs    
2007-09-06 20:41:08 UTC (rev 85455)
@@ -30,6 +30,7 @@
 
        public class ObjectGen : ObjectBase  {
 
+               private ArrayList custom_attrs = new ArrayList();
                private ArrayList strings = new ArrayList();
                private ArrayList vm_nodes = new ArrayList();
                private Hashtable childprops = new Hashtable();
@@ -48,6 +49,10 @@
                                        Statistics.IgnoreCount++;
                                        break;
 
+                               case "custom-attribute":
+                                       custom_attrs.Add (member.InnerXml);
+                                       break;
+
                                case "virtual_method":
                                        Statistics.IgnoreCount++;
                                        break;
@@ -150,6 +155,8 @@
                        sw.WriteLine ("#region Autogenerated code");
                        if (IsDeprecated)
                                sw.WriteLine ("\t[Obsolete]");
+                       foreach (string attr in custom_attrs)
+                               sw.WriteLine ("\t" + attr);
                        sw.Write ("\tpublic {0} class " + Name, IsAbstract ? 
"abstract" : "");
                        string cs_parent = 
table.GetCSType(Elem.GetAttribute("parent"));
                        if (cs_parent != "") {

Modified: 
branches/gtk-sharp-2-468-branch/gtk-sharp/glib/ClassInitializerAttribute.cs
===================================================================
--- branches/gtk-sharp-2-468-branch/gtk-sharp/glib/ClassInitializerAttribute.cs 
2007-09-06 20:27:10 UTC (rev 85454)
+++ branches/gtk-sharp-2-468-branch/gtk-sharp/glib/ClassInitializerAttribute.cs 
2007-09-06 20:41:08 UTC (rev 85455)
@@ -23,6 +23,7 @@
 
        using System;
 
+       [Obsolete ("Replaced by TypeInitializerAttribute")]
        public sealed class ClassInitializerAttribute : Attribute 
        {
                public ClassInitializerAttribute () {}

Added: 
branches/gtk-sharp-2-468-branch/gtk-sharp/glib/IgnoreClassInitializersAttribute.cs
===================================================================
--- 
branches/gtk-sharp-2-468-branch/gtk-sharp/glib/IgnoreClassInitializersAttribute.cs
  2007-09-06 20:27:10 UTC (rev 85454)
+++ 
branches/gtk-sharp-2-468-branch/gtk-sharp/glib/IgnoreClassInitializersAttribute.cs
  2007-09-06 20:41:08 UTC (rev 85455)
@@ -0,0 +1,31 @@
+// IgnoreClassInitializersAttribute.cs
+//
+// Author:   Mike Kestner  <[EMAIL PROTECTED]>
+//
+// 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 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 {
+
+       using System;
+
+       [AttributeUsage (AttributeTargets.Assembly)]
+       public sealed class IgnoreClassInitializersAttribute : Attribute 
+       {
+               public IgnoreClassInitializersAttribute () {}
+       }
+}

Modified: branches/gtk-sharp-2-468-branch/gtk-sharp/glib/Makefile.am
===================================================================
--- branches/gtk-sharp-2-468-branch/gtk-sharp/glib/Makefile.am  2007-09-06 
20:27:10 UTC (rev 85454)
+++ branches/gtk-sharp-2-468-branch/gtk-sharp/glib/Makefile.am  2007-09-06 
20:41:08 UTC (rev 85455)
@@ -32,6 +32,7 @@
        GType.cs                                \
        GTypeAttribute.cs                       \
        Idle.cs                                 \
+       IgnoreClassInitializersAttribute.cs     \
        InitiallyUnowned.cs                     \
        IWrapper.cs                             \
        ListBase.cs                             \
@@ -58,6 +59,7 @@
        Timeout.cs                              \
        TypeConverter.cs                        \
        TypeFundamentals.cs                     \
+       TypeInitializerAttribute.cs             \
        UnwrappedObject.cs                      \
        ValueArray.cs                           \
        Value.cs                                \

Modified: branches/gtk-sharp-2-468-branch/gtk-sharp/glib/Object.cs
===================================================================
--- branches/gtk-sharp-2-468-branch/gtk-sharp/glib/Object.cs    2007-09-06 
20:27:10 UTC (rev 85454)
+++ branches/gtk-sharp-2-468-branch/gtk-sharp/glib/Object.cs    2007-09-06 
20:41:08 UTC (rev 85455)
@@ -155,7 +155,19 @@
                private static void InvokeClassInitializers (GType gtype, 
System.Type t)
                {
                        object[] parms = {gtype, t};
-                       BindingFlags flags = BindingFlags.Static | 
BindingFlags.NonPublic | BindingFlags.FlattenHierarchy;
+
+                       BindingFlags flags = BindingFlags.Static | 
BindingFlags.NonPublic;
+
+                       foreach (TypeInitializerAttribute tia in 
t.GetCustomAttributes (typeof (TypeInitializerAttribute), true)) {
+                               MethodInfo m = tia.Type.GetMethod 
(tia.MethodName, flags);
+                               if (m != null)
+                                       m.Invoke (null, parms);
+                       }
+
+                       if (t.Assembly.GetCustomAttributes (typeof 
(IgnoreClassInitializersAttribute), false).Length != 0)
+                               return;
+
+                       flags |= BindingFlags.FlattenHierarchy;
                        foreach (MethodInfo minfo in t.GetMethods(flags))
                                if (minfo.IsDefined (typeof 
(ClassInitializerAttribute), true))
                                        minfo.Invoke (null, parms);

Added: 
branches/gtk-sharp-2-468-branch/gtk-sharp/glib/TypeInitializerAttribute.cs
===================================================================
--- branches/gtk-sharp-2-468-branch/gtk-sharp/glib/TypeInitializerAttribute.cs  
2007-09-06 20:27:10 UTC (rev 85454)
+++ branches/gtk-sharp-2-468-branch/gtk-sharp/glib/TypeInitializerAttribute.cs  
2007-09-06 20:41:08 UTC (rev 85455)
@@ -0,0 +1,48 @@
+// TypeInitializerAttribute.cs
+//
+// Author:   Mike Kestner  <[EMAIL PROTECTED]>
+//
+// 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 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 {
+
+       using System;
+
+       [AttributeUsage (AttributeTargets.Class)]
+       public sealed class TypeInitializerAttribute : Attribute 
+       {
+               string method_name;
+               Type type;
+
+               public TypeInitializerAttribute (Type type, string method_name) 
+               {
+                       this.type = type;
+                       this.method_name = method_name;
+               }
+
+               public string MethodName {
+                       get { return method_name; }
+                       set { method_name = value; }
+               }
+
+               public Type Type {
+                       get { return type; }
+                       set { type = value; }
+               }
+       }
+}

Modified: branches/gtk-sharp-2-468-branch/gtk-sharp/gtk/Gtk.metadata
===================================================================
--- branches/gtk-sharp-2-468-branch/gtk-sharp/gtk/Gtk.metadata  2007-09-06 
20:27:10 UTC (rev 85454)
+++ branches/gtk-sharp-2-468-branch/gtk-sharp/gtk/Gtk.metadata  2007-09-06 
20:41:08 UTC (rev 85455)
@@ -613,6 +613,7 @@
    <attr path="/api/namespace/[EMAIL PROTECTED]'GtkUIManager']/[EMAIL 
PROTECTED]'GetToplevels']" name="hidden">1</attr>
   <attr path="/api/namespace/[EMAIL PROTECTED]'GtkViewport']/[EMAIL 
PROTECTED]'SetScrollAdjustments']" name="name">ScrollAdjustmentsSet</attr>
   <attr path="/api/namespace/[EMAIL PROTECTED]'GtkVScale']/[EMAIL 
PROTECTED]'gtk_vscale_new_with_range']" name="hidden">1</attr>
+  <add-node path="/api/namespace/[EMAIL 
PROTECTED]'GtkWidget']"><custom-attribute>[GLib.TypeInitializer (typeof 
(Gtk.Widget), "ClassInit")]</custom-attribute></add-node>
   <attr path="/api/namespace/[EMAIL PROTECTED]'GtkWidget']" 
name="disable_gtype_ctor">1</attr>
   <attr path="/api/namespace/[EMAIL PROTECTED]'GtkWidget']/[EMAIL 
PROTECTED]'gtk_widget_new']" name="hidden">1</attr>
   <attr path="/api/namespace/[EMAIL PROTECTED]'GtkWidget']/[EMAIL 
PROTECTED]'Allocation']" name="hidden">1</attr>

Modified: branches/gtk-sharp-2-468-branch/gtk-sharp/gtk/Widget.custom
===================================================================
--- branches/gtk-sharp-2-468-branch/gtk-sharp/gtk/Widget.custom 2007-09-06 
20:27:10 UTC (rev 85454)
+++ branches/gtk-sharp-2-468-branch/gtk-sharp/gtk/Widget.custom 2007-09-06 
20:41:08 UTC (rev 85455)
@@ -265,7 +265,6 @@
 [DllImport ("gtksharpglue-2")]
 static extern void gtksharp_widget_register_binding (IntPtr gvalue, IntPtr 
name, uint key, int mod, IntPtr data);
 
-[GLib.ClassInitializer]
 static void ClassInit (GLib.GType gtype, Type t)
 {
        object[] attrs = t.GetCustomAttributes (typeof (BindingAttribute), 
true);

Modified: branches/gtk-sharp-2-468-branch/gtk-sharp/sample/Subclass.cs
===================================================================
--- branches/gtk-sharp-2-468-branch/gtk-sharp/sample/Subclass.cs        
2007-09-06 20:27:10 UTC (rev 85454)
+++ branches/gtk-sharp-2-468-branch/gtk-sharp/sample/Subclass.cs        
2007-09-06 20:41:08 UTC (rev 85455)
@@ -4,6 +4,8 @@
 //
 // (c) 2001-2003 Mike Kestner, Novell, Inc.
 
+[assembly:GLib.IgnoreClassInitializers]
+
 namespace GtkSamples {
 
        using Gtk;

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

Reply via email to