2007-09-06 Mike Kestner <mkestner@novell.com>
* 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. svn path=/trunk/gtk-sharp/; revision=85480
This commit is contained in:
parent
2a423bd228
commit
c2230278b3
11 changed files with 126 additions and 7 deletions
|
@ -4,3 +4,4 @@ using System.Runtime.CompilerServices;
|
|||
[assembly:AssemblyVersion("@API_VERSION@")]
|
||||
[assembly:AssemblyDelaySign(false)]
|
||||
[assembly:AssemblyKeyFile("gtk-sharp.snk")]
|
||||
[assembly:GLib.IgnoreClassInitializers]
|
||||
|
|
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
2007-09-06 Mike Kestner <mkestner@novell.com>
|
||||
|
||||
* 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 <mkestner@novell.com>
|
||||
|
||||
* gtk/Gtk.metadata : kill a few "new" warnings in FileChooser
|
||||
|
|
|
@ -30,6 +30,7 @@ namespace GtkSharp.Generation {
|
|||
|
||||
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 @@ namespace GtkSharp.Generation {
|
|||
Statistics.IgnoreCount++;
|
||||
break;
|
||||
|
||||
case "custom-attribute":
|
||||
custom_attrs.Add (member.InnerXml);
|
||||
break;
|
||||
|
||||
case "virtual_method":
|
||||
Statistics.IgnoreCount++;
|
||||
break;
|
||||
|
@ -150,6 +155,8 @@ namespace GtkSharp.Generation {
|
|||
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 != "") {
|
||||
|
|
|
@ -23,6 +23,7 @@ namespace GLib {
|
|||
|
||||
using System;
|
||||
|
||||
[Obsolete ("Replaced by TypeInitializerAttribute")]
|
||||
public sealed class ClassInitializerAttribute : Attribute
|
||||
{
|
||||
public ClassInitializerAttribute () {}
|
||||
|
|
31
glib/IgnoreClassInitializersAttribute.cs
Normal file
31
glib/IgnoreClassInitializersAttribute.cs
Normal file
|
@ -0,0 +1,31 @@
|
|||
// IgnoreClassInitializersAttribute.cs
|
||||
//
|
||||
// Author: Mike Kestner <mkestner@novell.com>
|
||||
//
|
||||
// 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 () {}
|
||||
}
|
||||
}
|
|
@ -32,6 +32,7 @@ sources = \
|
|||
GType.cs \
|
||||
GTypeAttribute.cs \
|
||||
Idle.cs \
|
||||
IgnoreClassInitializersAttribute.cs \
|
||||
InitiallyUnowned.cs \
|
||||
IWrapper.cs \
|
||||
ListBase.cs \
|
||||
|
@ -59,6 +60,7 @@ sources = \
|
|||
ToggleRef.cs \
|
||||
TypeConverter.cs \
|
||||
TypeFundamentals.cs \
|
||||
TypeInitializerAttribute.cs \
|
||||
UnwrappedObject.cs \
|
||||
ValueArray.cs \
|
||||
Value.cs \
|
||||
|
|
|
@ -163,16 +163,29 @@ namespace GLib {
|
|||
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)
|
||||
{
|
||||
|
|
48
glib/TypeInitializerAttribute.cs
Normal file
48
glib/TypeInitializerAttribute.cs
Normal file
|
@ -0,0 +1,48 @@
|
|||
// TypeInitializerAttribute.cs
|
||||
//
|
||||
// Author: Mike Kestner <mkestner@novell.com>
|
||||
//
|
||||
// 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; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -637,6 +637,7 @@
|
|||
<attr path="/api/namespace/object[@cname='GtkUIManager']/method[@name='GetToplevels']" name="hidden">1</attr>
|
||||
<attr path="/api/namespace/object[@cname='GtkViewport']/signal[@name='SetScrollAdjustments']" name="name">ScrollAdjustmentsSet</attr>
|
||||
<attr path="/api/namespace/object[@cname='GtkVScale']/constructor[@cname='gtk_vscale_new_with_range']" name="hidden">1</attr>
|
||||
<add-node path="/api/namespace/object[@cname='GtkWidget']"><custom-attribute>[GLib.TypeInitializer (typeof (Gtk.Widget), "ClassInit")]</custom-attribute></add-node>
|
||||
<attr path="/api/namespace/object[@cname='GtkWidget']" name="disable_gtype_ctor">1</attr>
|
||||
<attr path="/api/namespace/object[@cname='GtkWidget']/constructor[@cname='gtk_widget_new']" name="hidden">1</attr>
|
||||
<attr path="/api/namespace/object[@cname='GtkWidget']/field[@name='Allocation']" name="hidden">1</attr>
|
||||
|
|
|
@ -293,7 +293,6 @@ static extern void gtksharp_widget_add_binding_signal (IntPtr gvalue, IntPtr nam
|
|||
[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);
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
//
|
||||
// (c) 2001-2003 Mike Kestner, Novell, Inc.
|
||||
|
||||
[assembly:GLib.IgnoreClassInitializers]
|
||||
|
||||
namespace GtkSamples {
|
||||
|
||||
using Gtk;
|
||||
|
|
Loading…
Reference in a new issue