Author: mkestner
Date: 2007-09-07 10:40:46 -0400 (Fri, 07 Sep 2007)
New Revision: 85480
Added:
trunk/gtk-sharp/glib/IgnoreClassInitializersAttribute.cs
trunk/gtk-sharp/glib/TypeInitializerAttribute.cs
Modified:
trunk/gtk-sharp/AssemblyInfo.cs.in
trunk/gtk-sharp/ChangeLog
trunk/gtk-sharp/generator/ObjectGen.cs
trunk/gtk-sharp/glib/ClassInitializerAttribute.cs
trunk/gtk-sharp/glib/Makefile.am
trunk/gtk-sharp/glib/Object.cs
trunk/gtk-sharp/gtk/Gtk.metadata
trunk/gtk-sharp/gtk/Widget.custom
trunk/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: trunk/gtk-sharp/AssemblyInfo.cs.in
===================================================================
--- trunk/gtk-sharp/AssemblyInfo.cs.in 2007-09-07 14:36:04 UTC (rev 85479)
+++ trunk/gtk-sharp/AssemblyInfo.cs.in 2007-09-07 14:40:46 UTC (rev 85480)
@@ -4,3 +4,4 @@
[assembly:AssemblyVersion("@API_VERSION@")]
[assembly:AssemblyDelaySign(false)]
[assembly:AssemblyKeyFile("gtk-sharp.snk")]
+[assembly:GLib.IgnoreClassInitializers]
Modified: trunk/gtk-sharp/ChangeLog
===================================================================
--- trunk/gtk-sharp/ChangeLog 2007-09-07 14:36:04 UTC (rev 85479)
+++ trunk/gtk-sharp/ChangeLog 2007-09-07 14:40:46 UTC (rev 85480)
@@ -1,3 +1,17 @@
+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.
+
2007-08-14 Mike Kestner <[EMAIL PROTECTED]>
* gtk/Gtk.metadata : kill a few "new" warnings in FileChooser
Modified: trunk/gtk-sharp/generator/ObjectGen.cs
===================================================================
--- trunk/gtk-sharp/generator/ObjectGen.cs 2007-09-07 14:36:04 UTC (rev
85479)
+++ trunk/gtk-sharp/generator/ObjectGen.cs 2007-09-07 14:40:46 UTC (rev
85480)
@@ -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: trunk/gtk-sharp/glib/ClassInitializerAttribute.cs
===================================================================
--- trunk/gtk-sharp/glib/ClassInitializerAttribute.cs 2007-09-07 14:36:04 UTC
(rev 85479)
+++ trunk/gtk-sharp/glib/ClassInitializerAttribute.cs 2007-09-07 14:40:46 UTC
(rev 85480)
@@ -23,6 +23,7 @@
using System;
+ [Obsolete ("Replaced by TypeInitializerAttribute")]
public sealed class ClassInitializerAttribute : Attribute
{
public ClassInitializerAttribute () {}
Added: trunk/gtk-sharp/glib/IgnoreClassInitializersAttribute.cs
===================================================================
--- trunk/gtk-sharp/glib/IgnoreClassInitializersAttribute.cs 2007-09-07
14:36:04 UTC (rev 85479)
+++ trunk/gtk-sharp/glib/IgnoreClassInitializersAttribute.cs 2007-09-07
14:40:46 UTC (rev 85480)
@@ -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: trunk/gtk-sharp/glib/Makefile.am
===================================================================
--- trunk/gtk-sharp/glib/Makefile.am 2007-09-07 14:36:04 UTC (rev 85479)
+++ trunk/gtk-sharp/glib/Makefile.am 2007-09-07 14:40:46 UTC (rev 85480)
@@ -32,6 +32,7 @@
GType.cs \
GTypeAttribute.cs \
Idle.cs \
+ IgnoreClassInitializersAttribute.cs \
InitiallyUnowned.cs \
IWrapper.cs \
ListBase.cs \
@@ -59,6 +60,7 @@
ToggleRef.cs \
TypeConverter.cs \
TypeFundamentals.cs \
+ TypeInitializerAttribute.cs \
UnwrappedObject.cs \
ValueArray.cs \
Value.cs \
Modified: trunk/gtk-sharp/glib/Object.cs
===================================================================
--- trunk/gtk-sharp/glib/Object.cs 2007-09-07 14:36:04 UTC (rev 85479)
+++ trunk/gtk-sharp/glib/Object.cs 2007-09-07 14:40:46 UTC (rev 85480)
@@ -163,16 +163,29 @@
private static void InvokeClassInitializers (GType gtype,
System.Type t)
{
object[] parms = {gtype, t};
- BindingFlags flags = BindingFlags.Static |
BindingFlags.NonPublic | BindingFlags.FlattenHierarchy;
- foreach (MethodInfo minfo in t.GetMethods(flags))
- if (minfo.IsDefined (typeof
(ClassInitializerAttribute), true))
- minfo.Invoke (null, parms);
- }
+ 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);
+ }
+
+ for (Type curr = t; curr != typeof(GLib.Object); curr =
curr.BaseType) {
+
+ if (curr.Assembly.IsDefined (typeof
(IgnoreClassInitializersAttribute), false))
+ continue;
+
+ foreach (MethodInfo minfo in
curr.GetMethods(flags))
+ if (minfo.IsDefined (typeof
(ClassInitializerAttribute), true))
+ minfo.Invoke (null, parms);
+ }
+ }
+
[DllImport("glibsharpglue-2")]
static extern IntPtr gtksharp_register_type (IntPtr name,
IntPtr parent_type);
-
static int type_uid;
static string BuildEscapedName (System.Type t)
{
Added: trunk/gtk-sharp/glib/TypeInitializerAttribute.cs
===================================================================
--- trunk/gtk-sharp/glib/TypeInitializerAttribute.cs 2007-09-07 14:36:04 UTC
(rev 85479)
+++ trunk/gtk-sharp/glib/TypeInitializerAttribute.cs 2007-09-07 14:40:46 UTC
(rev 85480)
@@ -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: trunk/gtk-sharp/gtk/Gtk.metadata
===================================================================
--- trunk/gtk-sharp/gtk/Gtk.metadata 2007-09-07 14:36:04 UTC (rev 85479)
+++ trunk/gtk-sharp/gtk/Gtk.metadata 2007-09-07 14:40:46 UTC (rev 85480)
@@ -637,6 +637,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: trunk/gtk-sharp/gtk/Widget.custom
===================================================================
--- trunk/gtk-sharp/gtk/Widget.custom 2007-09-07 14:36:04 UTC (rev 85479)
+++ trunk/gtk-sharp/gtk/Widget.custom 2007-09-07 14:40:46 UTC (rev 85480)
@@ -293,7 +293,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: trunk/gtk-sharp/sample/Subclass.cs
===================================================================
--- trunk/gtk-sharp/sample/Subclass.cs 2007-09-07 14:36:04 UTC (rev 85479)
+++ trunk/gtk-sharp/sample/Subclass.cs 2007-09-07 14:40:46 UTC (rev 85480)
@@ -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