Ryujinx-GtkSharp/Source/Libs/GLibSharp/ObjectManager.cs

91 lines
2.9 KiB
C#
Raw Normal View History

// GLib.ObjectManager.cs - GLib ObjectManager class implementation
//
// Author: Mike Kestner <mkestner@speakeasy.net>
//
// Copyright <c> 2001-2002 Mike Kestner
// Copyright <c> 2004-2005 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.
2002-08-19 Rachel Hestilow <hestilow@ximian.com> * art/Makefile.in (clean): Change to avoid bugging out on generated/CVS. * glib/ObjectManager.cs: Added. Used to be auto-generated, but now it can infer names, and relies on per-namespace ObjectManager classes to inform it of oddly-named classes. * generator/IGeneratable.cs, GenBase.cs: New "DoGenerate" property. * generator/*Gen.cs: Honor DoGenerate. * generator/CodeGenerator.cs: Support including dependency files which will not be generated. * generator/ObjectGen.cs: Generate mapping file per-namespace, as one that calls back to the one in glib. Only generate if the name does not follow the normal conventions, otherwise, GtkSharp.ObjectManager can infer the name. * generator/Parser.cs: Accept 'generate' flag to pass on to the IGeneratables. Parse a new toplevel element, "symbol", which adds a type to the SymbolTable (instead of hard-coding it). * generator/SignalHandler.cs: Do not optimize signal handler creation, instead creating them in their own namespaces. Do not generate if the calling Signal told us not to. * generator/Signal.cs: Do not generate handlers if container's DoGenerate is false. Adjust to the marshaller name being in a sub-namespace. * generator/SymbolTable.cs (AddSimpleType, AddManualType): Used to add simple and manually wrapped types at runtime instead of compile-time. (FromNative): Remove hard-coded cases for manually wrapped types, use a generic case instead. * api: Added. Move api files and generation targets here. * source: Added. Move source parsing here. * generator/makefile: Move actual generation to api/. * glib/Makefile.in: Remove generated/* target. * glue/Makefile.am: Fix to include canvas-marshal. Move canvas stuff to GNOME target. * gnome/CanvasProxy.cs: Update to work with SignalHandlers being namespace-specific. * parser/Metadata.pm: Moved to GAPI/Metadata.pm, renamed, etc. * parser/gapi2xml.pl: Use GAPI::Metadata. * parser/makefile: Install scripts, remove source parse build target. Rename formatXML to gapi_format_xml. svn path=/trunk/gtk-sharp/; revision=6818
2002-08-20 21:56:18 +02:00
namespace GLib {
2002-08-19 Rachel Hestilow <hestilow@ximian.com> * art/Makefile.in (clean): Change to avoid bugging out on generated/CVS. * glib/ObjectManager.cs: Added. Used to be auto-generated, but now it can infer names, and relies on per-namespace ObjectManager classes to inform it of oddly-named classes. * generator/IGeneratable.cs, GenBase.cs: New "DoGenerate" property. * generator/*Gen.cs: Honor DoGenerate. * generator/CodeGenerator.cs: Support including dependency files which will not be generated. * generator/ObjectGen.cs: Generate mapping file per-namespace, as one that calls back to the one in glib. Only generate if the name does not follow the normal conventions, otherwise, GtkSharp.ObjectManager can infer the name. * generator/Parser.cs: Accept 'generate' flag to pass on to the IGeneratables. Parse a new toplevel element, "symbol", which adds a type to the SymbolTable (instead of hard-coding it). * generator/SignalHandler.cs: Do not optimize signal handler creation, instead creating them in their own namespaces. Do not generate if the calling Signal told us not to. * generator/Signal.cs: Do not generate handlers if container's DoGenerate is false. Adjust to the marshaller name being in a sub-namespace. * generator/SymbolTable.cs (AddSimpleType, AddManualType): Used to add simple and manually wrapped types at runtime instead of compile-time. (FromNative): Remove hard-coded cases for manually wrapped types, use a generic case instead. * api: Added. Move api files and generation targets here. * source: Added. Move source parsing here. * generator/makefile: Move actual generation to api/. * glib/Makefile.in: Remove generated/* target. * glue/Makefile.am: Fix to include canvas-marshal. Move canvas stuff to GNOME target. * gnome/CanvasProxy.cs: Update to work with SignalHandlers being namespace-specific. * parser/Metadata.pm: Moved to GAPI/Metadata.pm, renamed, etc. * parser/gapi2xml.pl: Use GAPI::Metadata. * parser/makefile: Install scripts, remove source parse build target. Rename formatXML to gapi_format_xml. svn path=/trunk/gtk-sharp/; revision=6818
2002-08-20 21:56:18 +02:00
using System;
using System.Runtime.InteropServices;
using System.Reflection;
2002-08-19 Rachel Hestilow <hestilow@ximian.com> * art/Makefile.in (clean): Change to avoid bugging out on generated/CVS. * glib/ObjectManager.cs: Added. Used to be auto-generated, but now it can infer names, and relies on per-namespace ObjectManager classes to inform it of oddly-named classes. * generator/IGeneratable.cs, GenBase.cs: New "DoGenerate" property. * generator/*Gen.cs: Honor DoGenerate. * generator/CodeGenerator.cs: Support including dependency files which will not be generated. * generator/ObjectGen.cs: Generate mapping file per-namespace, as one that calls back to the one in glib. Only generate if the name does not follow the normal conventions, otherwise, GtkSharp.ObjectManager can infer the name. * generator/Parser.cs: Accept 'generate' flag to pass on to the IGeneratables. Parse a new toplevel element, "symbol", which adds a type to the SymbolTable (instead of hard-coding it). * generator/SignalHandler.cs: Do not optimize signal handler creation, instead creating them in their own namespaces. Do not generate if the calling Signal told us not to. * generator/Signal.cs: Do not generate handlers if container's DoGenerate is false. Adjust to the marshaller name being in a sub-namespace. * generator/SymbolTable.cs (AddSimpleType, AddManualType): Used to add simple and manually wrapped types at runtime instead of compile-time. (FromNative): Remove hard-coded cases for manually wrapped types, use a generic case instead. * api: Added. Move api files and generation targets here. * source: Added. Move source parsing here. * generator/makefile: Move actual generation to api/. * glib/Makefile.in: Remove generated/* target. * glue/Makefile.am: Fix to include canvas-marshal. Move canvas stuff to GNOME target. * gnome/CanvasProxy.cs: Update to work with SignalHandlers being namespace-specific. * parser/Metadata.pm: Moved to GAPI/Metadata.pm, renamed, etc. * parser/gapi2xml.pl: Use GAPI::Metadata. * parser/makefile: Install scripts, remove source parse build target. Rename formatXML to gapi_format_xml. svn path=/trunk/gtk-sharp/; revision=6818
2002-08-20 21:56:18 +02:00
public static class ObjectManager {
2002-08-19 Rachel Hestilow <hestilow@ximian.com> * art/Makefile.in (clean): Change to avoid bugging out on generated/CVS. * glib/ObjectManager.cs: Added. Used to be auto-generated, but now it can infer names, and relies on per-namespace ObjectManager classes to inform it of oddly-named classes. * generator/IGeneratable.cs, GenBase.cs: New "DoGenerate" property. * generator/*Gen.cs: Honor DoGenerate. * generator/CodeGenerator.cs: Support including dependency files which will not be generated. * generator/ObjectGen.cs: Generate mapping file per-namespace, as one that calls back to the one in glib. Only generate if the name does not follow the normal conventions, otherwise, GtkSharp.ObjectManager can infer the name. * generator/Parser.cs: Accept 'generate' flag to pass on to the IGeneratables. Parse a new toplevel element, "symbol", which adds a type to the SymbolTable (instead of hard-coding it). * generator/SignalHandler.cs: Do not optimize signal handler creation, instead creating them in their own namespaces. Do not generate if the calling Signal told us not to. * generator/Signal.cs: Do not generate handlers if container's DoGenerate is false. Adjust to the marshaller name being in a sub-namespace. * generator/SymbolTable.cs (AddSimpleType, AddManualType): Used to add simple and manually wrapped types at runtime instead of compile-time. (FromNative): Remove hard-coded cases for manually wrapped types, use a generic case instead. * api: Added. Move api files and generation targets here. * source: Added. Move source parsing here. * generator/makefile: Move actual generation to api/. * glib/Makefile.in: Remove generated/* target. * glue/Makefile.am: Fix to include canvas-marshal. Move canvas stuff to GNOME target. * gnome/CanvasProxy.cs: Update to work with SignalHandlers being namespace-specific. * parser/Metadata.pm: Moved to GAPI/Metadata.pm, renamed, etc. * parser/gapi2xml.pl: Use GAPI::Metadata. * parser/makefile: Install scripts, remove source parse build target. Rename formatXML to gapi_format_xml. svn path=/trunk/gtk-sharp/; revision=6818
2002-08-20 21:56:18 +02:00
static BindingFlags flags = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.CreateInstance;
2002-08-19 Rachel Hestilow <hestilow@ximian.com> * art/Makefile.in (clean): Change to avoid bugging out on generated/CVS. * glib/ObjectManager.cs: Added. Used to be auto-generated, but now it can infer names, and relies on per-namespace ObjectManager classes to inform it of oddly-named classes. * generator/IGeneratable.cs, GenBase.cs: New "DoGenerate" property. * generator/*Gen.cs: Honor DoGenerate. * generator/CodeGenerator.cs: Support including dependency files which will not be generated. * generator/ObjectGen.cs: Generate mapping file per-namespace, as one that calls back to the one in glib. Only generate if the name does not follow the normal conventions, otherwise, GtkSharp.ObjectManager can infer the name. * generator/Parser.cs: Accept 'generate' flag to pass on to the IGeneratables. Parse a new toplevel element, "symbol", which adds a type to the SymbolTable (instead of hard-coding it). * generator/SignalHandler.cs: Do not optimize signal handler creation, instead creating them in their own namespaces. Do not generate if the calling Signal told us not to. * generator/Signal.cs: Do not generate handlers if container's DoGenerate is false. Adjust to the marshaller name being in a sub-namespace. * generator/SymbolTable.cs (AddSimpleType, AddManualType): Used to add simple and manually wrapped types at runtime instead of compile-time. (FromNative): Remove hard-coded cases for manually wrapped types, use a generic case instead. * api: Added. Move api files and generation targets here. * source: Added. Move source parsing here. * generator/makefile: Move actual generation to api/. * glib/Makefile.in: Remove generated/* target. * glue/Makefile.am: Fix to include canvas-marshal. Move canvas stuff to GNOME target. * gnome/CanvasProxy.cs: Update to work with SignalHandlers being namespace-specific. * parser/Metadata.pm: Moved to GAPI/Metadata.pm, renamed, etc. * parser/gapi2xml.pl: Use GAPI::Metadata. * parser/makefile: Install scripts, remove source parse build target. Rename formatXML to gapi_format_xml. svn path=/trunk/gtk-sharp/; revision=6818
2002-08-20 21:56:18 +02:00
public static GLib.Object CreateObject (IntPtr raw)
{
if (raw == IntPtr.Zero)
return null;
Type type = GetTypeOrParent (raw);
if (type == null)
2002-08-19 Rachel Hestilow <hestilow@ximian.com> * art/Makefile.in (clean): Change to avoid bugging out on generated/CVS. * glib/ObjectManager.cs: Added. Used to be auto-generated, but now it can infer names, and relies on per-namespace ObjectManager classes to inform it of oddly-named classes. * generator/IGeneratable.cs, GenBase.cs: New "DoGenerate" property. * generator/*Gen.cs: Honor DoGenerate. * generator/CodeGenerator.cs: Support including dependency files which will not be generated. * generator/ObjectGen.cs: Generate mapping file per-namespace, as one that calls back to the one in glib. Only generate if the name does not follow the normal conventions, otherwise, GtkSharp.ObjectManager can infer the name. * generator/Parser.cs: Accept 'generate' flag to pass on to the IGeneratables. Parse a new toplevel element, "symbol", which adds a type to the SymbolTable (instead of hard-coding it). * generator/SignalHandler.cs: Do not optimize signal handler creation, instead creating them in their own namespaces. Do not generate if the calling Signal told us not to. * generator/Signal.cs: Do not generate handlers if container's DoGenerate is false. Adjust to the marshaller name being in a sub-namespace. * generator/SymbolTable.cs (AddSimpleType, AddManualType): Used to add simple and manually wrapped types at runtime instead of compile-time. (FromNative): Remove hard-coded cases for manually wrapped types, use a generic case instead. * api: Added. Move api files and generation targets here. * source: Added. Move source parsing here. * generator/makefile: Move actual generation to api/. * glib/Makefile.in: Remove generated/* target. * glue/Makefile.am: Fix to include canvas-marshal. Move canvas stuff to GNOME target. * gnome/CanvasProxy.cs: Update to work with SignalHandlers being namespace-specific. * parser/Metadata.pm: Moved to GAPI/Metadata.pm, renamed, etc. * parser/gapi2xml.pl: Use GAPI::Metadata. * parser/makefile: Install scripts, remove source parse build target. Rename formatXML to gapi_format_xml. svn path=/trunk/gtk-sharp/; revision=6818
2002-08-20 21:56:18 +02:00
return null;
GLib.Object obj;
try {
obj = Activator.CreateInstance (type, flags, null, new object[] {raw}, null) as GLib.Object;
} catch (MissingMethodException) {
2012-03-29 04:33:48 +02:00
throw new GLib.MissingIntPtrCtorException ("Unable to construct instance of type " + type + " from native object handle. Instance of managed subclass may have been prematurely disposed.");
}
return obj;
2002-08-19 Rachel Hestilow <hestilow@ximian.com> * art/Makefile.in (clean): Change to avoid bugging out on generated/CVS. * glib/ObjectManager.cs: Added. Used to be auto-generated, but now it can infer names, and relies on per-namespace ObjectManager classes to inform it of oddly-named classes. * generator/IGeneratable.cs, GenBase.cs: New "DoGenerate" property. * generator/*Gen.cs: Honor DoGenerate. * generator/CodeGenerator.cs: Support including dependency files which will not be generated. * generator/ObjectGen.cs: Generate mapping file per-namespace, as one that calls back to the one in glib. Only generate if the name does not follow the normal conventions, otherwise, GtkSharp.ObjectManager can infer the name. * generator/Parser.cs: Accept 'generate' flag to pass on to the IGeneratables. Parse a new toplevel element, "symbol", which adds a type to the SymbolTable (instead of hard-coding it). * generator/SignalHandler.cs: Do not optimize signal handler creation, instead creating them in their own namespaces. Do not generate if the calling Signal told us not to. * generator/Signal.cs: Do not generate handlers if container's DoGenerate is false. Adjust to the marshaller name being in a sub-namespace. * generator/SymbolTable.cs (AddSimpleType, AddManualType): Used to add simple and manually wrapped types at runtime instead of compile-time. (FromNative): Remove hard-coded cases for manually wrapped types, use a generic case instead. * api: Added. Move api files and generation targets here. * source: Added. Move source parsing here. * generator/makefile: Move actual generation to api/. * glib/Makefile.in: Remove generated/* target. * glue/Makefile.am: Fix to include canvas-marshal. Move canvas stuff to GNOME target. * gnome/CanvasProxy.cs: Update to work with SignalHandlers being namespace-specific. * parser/Metadata.pm: Moved to GAPI/Metadata.pm, renamed, etc. * parser/gapi2xml.pl: Use GAPI::Metadata. * parser/makefile: Install scripts, remove source parse build target. Rename formatXML to gapi_format_xml. svn path=/trunk/gtk-sharp/; revision=6818
2002-08-20 21:56:18 +02:00
}
* parser/gapi2xml.pl: make note of _get_type methods for enums * */*-api.xml: Regen, adding gtype="..." to many enum types * generator/EnumGen.cs (Generate): if the enum has the "gtype" property, add a GTypeAttribute pointing to an internal FooGType class whose GType property can be used to get the enum's GType. * generator/ObjectGen.cs: s/ObjectManager.RegisterType/GType.Register/ * glib/GTypeAttribute.cs: attribute for indicating a property that will return the GType of a type (particularly for enums, which can't have GType properties added to them). * glib/GType.cs: renamed from Type.cs to match the type name (public static readonly GType ...): add a few missing types. (Register): moved from ObjectManager.RegisterType (LookupGType): moved from TypeConverter.LookupType and extended to handle GTypeAttribute. Also, fix mappings for sbyte/byte/char, and return specific GTypes for Object subclasses rather than always returning GType.Object. [Fixes #74699] (LookupType): moved from ObjectWrapper.LookupType (ToString): return the type name * glib/Object.cs (RegisterGType): s/ObjectManager.Register/GType.Register/ (LookupGType): Make this protected internal so GType can access it. * glib/ObjectManager.cs (RegisterType): deprecate in favor of GType.Register. (LookupType): moved to GType * glib/TypeConverter.cs (LookupType): now a deprecated wrapper around GType.LookupGType. * glib/Value.cs: Use GType casts rather than TypeConverter * gtk/NodeStore.cs (ScanType): * gtk/ListStore.custom (ListStore): * gtk/TreeStore.custom (TreeStore): Use (GType) cast rather than TypeConverter. Remove the error check and exception, since the cast never returns GType.Invalid. (The check probably predates GLib.ManagedValue.) * gnome/PanelAppletFactory.cs (Register): Use a GType cast rather than GLib.Object.LookupGType (which is no longer accessible after an mcs bugfix) * sample/GtkDemo/DemoIconView.cs (CreateStore): use the Type[] constructor rather than the GType[] constructor, since it translates typeof(Gdk.Pixbuf) correctly now. svn path=/trunk/gtk-sharp/; revision=44038
2005-05-04 18:54:24 +02:00
[Obsolete ("Replaced by GType.Register (GType, Type)")]
2002-08-19 Rachel Hestilow <hestilow@ximian.com> * art/Makefile.in (clean): Change to avoid bugging out on generated/CVS. * glib/ObjectManager.cs: Added. Used to be auto-generated, but now it can infer names, and relies on per-namespace ObjectManager classes to inform it of oddly-named classes. * generator/IGeneratable.cs, GenBase.cs: New "DoGenerate" property. * generator/*Gen.cs: Honor DoGenerate. * generator/CodeGenerator.cs: Support including dependency files which will not be generated. * generator/ObjectGen.cs: Generate mapping file per-namespace, as one that calls back to the one in glib. Only generate if the name does not follow the normal conventions, otherwise, GtkSharp.ObjectManager can infer the name. * generator/Parser.cs: Accept 'generate' flag to pass on to the IGeneratables. Parse a new toplevel element, "symbol", which adds a type to the SymbolTable (instead of hard-coding it). * generator/SignalHandler.cs: Do not optimize signal handler creation, instead creating them in their own namespaces. Do not generate if the calling Signal told us not to. * generator/Signal.cs: Do not generate handlers if container's DoGenerate is false. Adjust to the marshaller name being in a sub-namespace. * generator/SymbolTable.cs (AddSimpleType, AddManualType): Used to add simple and manually wrapped types at runtime instead of compile-time. (FromNative): Remove hard-coded cases for manually wrapped types, use a generic case instead. * api: Added. Move api files and generation targets here. * source: Added. Move source parsing here. * generator/makefile: Move actual generation to api/. * glib/Makefile.in: Remove generated/* target. * glue/Makefile.am: Fix to include canvas-marshal. Move canvas stuff to GNOME target. * gnome/CanvasProxy.cs: Update to work with SignalHandlers being namespace-specific. * parser/Metadata.pm: Moved to GAPI/Metadata.pm, renamed, etc. * parser/gapi2xml.pl: Use GAPI::Metadata. * parser/makefile: Install scripts, remove source parse build target. Rename formatXML to gapi_format_xml. svn path=/trunk/gtk-sharp/; revision=6818
2002-08-20 21:56:18 +02:00
public static void RegisterType (string native_name, string managed_name, string assembly)
{
RegisterType (native_name, managed_name + "," + assembly);
2002-08-19 Rachel Hestilow <hestilow@ximian.com> * art/Makefile.in (clean): Change to avoid bugging out on generated/CVS. * glib/ObjectManager.cs: Added. Used to be auto-generated, but now it can infer names, and relies on per-namespace ObjectManager classes to inform it of oddly-named classes. * generator/IGeneratable.cs, GenBase.cs: New "DoGenerate" property. * generator/*Gen.cs: Honor DoGenerate. * generator/CodeGenerator.cs: Support including dependency files which will not be generated. * generator/ObjectGen.cs: Generate mapping file per-namespace, as one that calls back to the one in glib. Only generate if the name does not follow the normal conventions, otherwise, GtkSharp.ObjectManager can infer the name. * generator/Parser.cs: Accept 'generate' flag to pass on to the IGeneratables. Parse a new toplevel element, "symbol", which adds a type to the SymbolTable (instead of hard-coding it). * generator/SignalHandler.cs: Do not optimize signal handler creation, instead creating them in their own namespaces. Do not generate if the calling Signal told us not to. * generator/Signal.cs: Do not generate handlers if container's DoGenerate is false. Adjust to the marshaller name being in a sub-namespace. * generator/SymbolTable.cs (AddSimpleType, AddManualType): Used to add simple and manually wrapped types at runtime instead of compile-time. (FromNative): Remove hard-coded cases for manually wrapped types, use a generic case instead. * api: Added. Move api files and generation targets here. * source: Added. Move source parsing here. * generator/makefile: Move actual generation to api/. * glib/Makefile.in: Remove generated/* target. * glue/Makefile.am: Fix to include canvas-marshal. Move canvas stuff to GNOME target. * gnome/CanvasProxy.cs: Update to work with SignalHandlers being namespace-specific. * parser/Metadata.pm: Moved to GAPI/Metadata.pm, renamed, etc. * parser/gapi2xml.pl: Use GAPI::Metadata. * parser/makefile: Install scripts, remove source parse build target. Rename formatXML to gapi_format_xml. svn path=/trunk/gtk-sharp/; revision=6818
2002-08-20 21:56:18 +02:00
}
* parser/gapi2xml.pl: make note of _get_type methods for enums * */*-api.xml: Regen, adding gtype="..." to many enum types * generator/EnumGen.cs (Generate): if the enum has the "gtype" property, add a GTypeAttribute pointing to an internal FooGType class whose GType property can be used to get the enum's GType. * generator/ObjectGen.cs: s/ObjectManager.RegisterType/GType.Register/ * glib/GTypeAttribute.cs: attribute for indicating a property that will return the GType of a type (particularly for enums, which can't have GType properties added to them). * glib/GType.cs: renamed from Type.cs to match the type name (public static readonly GType ...): add a few missing types. (Register): moved from ObjectManager.RegisterType (LookupGType): moved from TypeConverter.LookupType and extended to handle GTypeAttribute. Also, fix mappings for sbyte/byte/char, and return specific GTypes for Object subclasses rather than always returning GType.Object. [Fixes #74699] (LookupType): moved from ObjectWrapper.LookupType (ToString): return the type name * glib/Object.cs (RegisterGType): s/ObjectManager.Register/GType.Register/ (LookupGType): Make this protected internal so GType can access it. * glib/ObjectManager.cs (RegisterType): deprecate in favor of GType.Register. (LookupType): moved to GType * glib/TypeConverter.cs (LookupType): now a deprecated wrapper around GType.LookupGType. * glib/Value.cs: Use GType casts rather than TypeConverter * gtk/NodeStore.cs (ScanType): * gtk/ListStore.custom (ListStore): * gtk/TreeStore.custom (TreeStore): Use (GType) cast rather than TypeConverter. Remove the error check and exception, since the cast never returns GType.Invalid. (The check probably predates GLib.ManagedValue.) * gnome/PanelAppletFactory.cs (Register): Use a GType cast rather than GLib.Object.LookupGType (which is no longer accessible after an mcs bugfix) * sample/GtkDemo/DemoIconView.cs (CreateStore): use the Type[] constructor rather than the GType[] constructor, since it translates typeof(Gdk.Pixbuf) correctly now. svn path=/trunk/gtk-sharp/; revision=44038
2005-05-04 18:54:24 +02:00
[Obsolete ("Replaced by GType.Register (GType, Type)")]
2002-08-19 Rachel Hestilow <hestilow@ximian.com> * art/Makefile.in (clean): Change to avoid bugging out on generated/CVS. * glib/ObjectManager.cs: Added. Used to be auto-generated, but now it can infer names, and relies on per-namespace ObjectManager classes to inform it of oddly-named classes. * generator/IGeneratable.cs, GenBase.cs: New "DoGenerate" property. * generator/*Gen.cs: Honor DoGenerate. * generator/CodeGenerator.cs: Support including dependency files which will not be generated. * generator/ObjectGen.cs: Generate mapping file per-namespace, as one that calls back to the one in glib. Only generate if the name does not follow the normal conventions, otherwise, GtkSharp.ObjectManager can infer the name. * generator/Parser.cs: Accept 'generate' flag to pass on to the IGeneratables. Parse a new toplevel element, "symbol", which adds a type to the SymbolTable (instead of hard-coding it). * generator/SignalHandler.cs: Do not optimize signal handler creation, instead creating them in their own namespaces. Do not generate if the calling Signal told us not to. * generator/Signal.cs: Do not generate handlers if container's DoGenerate is false. Adjust to the marshaller name being in a sub-namespace. * generator/SymbolTable.cs (AddSimpleType, AddManualType): Used to add simple and manually wrapped types at runtime instead of compile-time. (FromNative): Remove hard-coded cases for manually wrapped types, use a generic case instead. * api: Added. Move api files and generation targets here. * source: Added. Move source parsing here. * generator/makefile: Move actual generation to api/. * glib/Makefile.in: Remove generated/* target. * glue/Makefile.am: Fix to include canvas-marshal. Move canvas stuff to GNOME target. * gnome/CanvasProxy.cs: Update to work with SignalHandlers being namespace-specific. * parser/Metadata.pm: Moved to GAPI/Metadata.pm, renamed, etc. * parser/gapi2xml.pl: Use GAPI::Metadata. * parser/makefile: Install scripts, remove source parse build target. Rename formatXML to gapi_format_xml. svn path=/trunk/gtk-sharp/; revision=6818
2002-08-20 21:56:18 +02:00
public static void RegisterType (string native_name, string mangled)
{
RegisterType (GType.FromName (native_name), Type.GetType (mangled));
2002-08-19 Rachel Hestilow <hestilow@ximian.com> * art/Makefile.in (clean): Change to avoid bugging out on generated/CVS. * glib/ObjectManager.cs: Added. Used to be auto-generated, but now it can infer names, and relies on per-namespace ObjectManager classes to inform it of oddly-named classes. * generator/IGeneratable.cs, GenBase.cs: New "DoGenerate" property. * generator/*Gen.cs: Honor DoGenerate. * generator/CodeGenerator.cs: Support including dependency files which will not be generated. * generator/ObjectGen.cs: Generate mapping file per-namespace, as one that calls back to the one in glib. Only generate if the name does not follow the normal conventions, otherwise, GtkSharp.ObjectManager can infer the name. * generator/Parser.cs: Accept 'generate' flag to pass on to the IGeneratables. Parse a new toplevel element, "symbol", which adds a type to the SymbolTable (instead of hard-coding it). * generator/SignalHandler.cs: Do not optimize signal handler creation, instead creating them in their own namespaces. Do not generate if the calling Signal told us not to. * generator/Signal.cs: Do not generate handlers if container's DoGenerate is false. Adjust to the marshaller name being in a sub-namespace. * generator/SymbolTable.cs (AddSimpleType, AddManualType): Used to add simple and manually wrapped types at runtime instead of compile-time. (FromNative): Remove hard-coded cases for manually wrapped types, use a generic case instead. * api: Added. Move api files and generation targets here. * source: Added. Move source parsing here. * generator/makefile: Move actual generation to api/. * glib/Makefile.in: Remove generated/* target. * glue/Makefile.am: Fix to include canvas-marshal. Move canvas stuff to GNOME target. * gnome/CanvasProxy.cs: Update to work with SignalHandlers being namespace-specific. * parser/Metadata.pm: Moved to GAPI/Metadata.pm, renamed, etc. * parser/gapi2xml.pl: Use GAPI::Metadata. * parser/makefile: Install scripts, remove source parse build target. Rename formatXML to gapi_format_xml. svn path=/trunk/gtk-sharp/; revision=6818
2002-08-20 21:56:18 +02:00
}
* parser/gapi2xml.pl: make note of _get_type methods for enums * */*-api.xml: Regen, adding gtype="..." to many enum types * generator/EnumGen.cs (Generate): if the enum has the "gtype" property, add a GTypeAttribute pointing to an internal FooGType class whose GType property can be used to get the enum's GType. * generator/ObjectGen.cs: s/ObjectManager.RegisterType/GType.Register/ * glib/GTypeAttribute.cs: attribute for indicating a property that will return the GType of a type (particularly for enums, which can't have GType properties added to them). * glib/GType.cs: renamed from Type.cs to match the type name (public static readonly GType ...): add a few missing types. (Register): moved from ObjectManager.RegisterType (LookupGType): moved from TypeConverter.LookupType and extended to handle GTypeAttribute. Also, fix mappings for sbyte/byte/char, and return specific GTypes for Object subclasses rather than always returning GType.Object. [Fixes #74699] (LookupType): moved from ObjectWrapper.LookupType (ToString): return the type name * glib/Object.cs (RegisterGType): s/ObjectManager.Register/GType.Register/ (LookupGType): Make this protected internal so GType can access it. * glib/ObjectManager.cs (RegisterType): deprecate in favor of GType.Register. (LookupType): moved to GType * glib/TypeConverter.cs (LookupType): now a deprecated wrapper around GType.LookupGType. * glib/Value.cs: Use GType casts rather than TypeConverter * gtk/NodeStore.cs (ScanType): * gtk/ListStore.custom (ListStore): * gtk/TreeStore.custom (TreeStore): Use (GType) cast rather than TypeConverter. Remove the error check and exception, since the cast never returns GType.Invalid. (The check probably predates GLib.ManagedValue.) * gnome/PanelAppletFactory.cs (Register): Use a GType cast rather than GLib.Object.LookupGType (which is no longer accessible after an mcs bugfix) * sample/GtkDemo/DemoIconView.cs (CreateStore): use the Type[] constructor rather than the GType[] constructor, since it translates typeof(Gdk.Pixbuf) correctly now. svn path=/trunk/gtk-sharp/; revision=44038
2005-05-04 18:54:24 +02:00
[Obsolete ("Replaced by GType.Register (GType, Type)")]
public static void RegisterType (GType native_type, System.Type type)
2002-08-19 Rachel Hestilow <hestilow@ximian.com> * art/Makefile.in (clean): Change to avoid bugging out on generated/CVS. * glib/ObjectManager.cs: Added. Used to be auto-generated, but now it can infer names, and relies on per-namespace ObjectManager classes to inform it of oddly-named classes. * generator/IGeneratable.cs, GenBase.cs: New "DoGenerate" property. * generator/*Gen.cs: Honor DoGenerate. * generator/CodeGenerator.cs: Support including dependency files which will not be generated. * generator/ObjectGen.cs: Generate mapping file per-namespace, as one that calls back to the one in glib. Only generate if the name does not follow the normal conventions, otherwise, GtkSharp.ObjectManager can infer the name. * generator/Parser.cs: Accept 'generate' flag to pass on to the IGeneratables. Parse a new toplevel element, "symbol", which adds a type to the SymbolTable (instead of hard-coding it). * generator/SignalHandler.cs: Do not optimize signal handler creation, instead creating them in their own namespaces. Do not generate if the calling Signal told us not to. * generator/Signal.cs: Do not generate handlers if container's DoGenerate is false. Adjust to the marshaller name being in a sub-namespace. * generator/SymbolTable.cs (AddSimpleType, AddManualType): Used to add simple and manually wrapped types at runtime instead of compile-time. (FromNative): Remove hard-coded cases for manually wrapped types, use a generic case instead. * api: Added. Move api files and generation targets here. * source: Added. Move source parsing here. * generator/makefile: Move actual generation to api/. * glib/Makefile.in: Remove generated/* target. * glue/Makefile.am: Fix to include canvas-marshal. Move canvas stuff to GNOME target. * gnome/CanvasProxy.cs: Update to work with SignalHandlers being namespace-specific. * parser/Metadata.pm: Moved to GAPI/Metadata.pm, renamed, etc. * parser/gapi2xml.pl: Use GAPI::Metadata. * parser/makefile: Install scripts, remove source parse build target. Rename formatXML to gapi_format_xml. svn path=/trunk/gtk-sharp/; revision=6818
2002-08-20 21:56:18 +02:00
{
* parser/gapi2xml.pl: make note of _get_type methods for enums * */*-api.xml: Regen, adding gtype="..." to many enum types * generator/EnumGen.cs (Generate): if the enum has the "gtype" property, add a GTypeAttribute pointing to an internal FooGType class whose GType property can be used to get the enum's GType. * generator/ObjectGen.cs: s/ObjectManager.RegisterType/GType.Register/ * glib/GTypeAttribute.cs: attribute for indicating a property that will return the GType of a type (particularly for enums, which can't have GType properties added to them). * glib/GType.cs: renamed from Type.cs to match the type name (public static readonly GType ...): add a few missing types. (Register): moved from ObjectManager.RegisterType (LookupGType): moved from TypeConverter.LookupType and extended to handle GTypeAttribute. Also, fix mappings for sbyte/byte/char, and return specific GTypes for Object subclasses rather than always returning GType.Object. [Fixes #74699] (LookupType): moved from ObjectWrapper.LookupType (ToString): return the type name * glib/Object.cs (RegisterGType): s/ObjectManager.Register/GType.Register/ (LookupGType): Make this protected internal so GType can access it. * glib/ObjectManager.cs (RegisterType): deprecate in favor of GType.Register. (LookupType): moved to GType * glib/TypeConverter.cs (LookupType): now a deprecated wrapper around GType.LookupGType. * glib/Value.cs: Use GType casts rather than TypeConverter * gtk/NodeStore.cs (ScanType): * gtk/ListStore.custom (ListStore): * gtk/TreeStore.custom (TreeStore): Use (GType) cast rather than TypeConverter. Remove the error check and exception, since the cast never returns GType.Invalid. (The check probably predates GLib.ManagedValue.) * gnome/PanelAppletFactory.cs (Register): Use a GType cast rather than GLib.Object.LookupGType (which is no longer accessible after an mcs bugfix) * sample/GtkDemo/DemoIconView.cs (CreateStore): use the Type[] constructor rather than the GType[] constructor, since it translates typeof(Gdk.Pixbuf) correctly now. svn path=/trunk/gtk-sharp/; revision=44038
2005-05-04 18:54:24 +02:00
GType.Register (native_type, type);
}
static Type GetTypeOrParent (IntPtr obj)
{
IntPtr typeid = GType.ValFromInstancePtr (obj);
if (typeid == GType.Invalid.Val)
return null;
* parser/gapi2xml.pl: make note of _get_type methods for enums * */*-api.xml: Regen, adding gtype="..." to many enum types * generator/EnumGen.cs (Generate): if the enum has the "gtype" property, add a GTypeAttribute pointing to an internal FooGType class whose GType property can be used to get the enum's GType. * generator/ObjectGen.cs: s/ObjectManager.RegisterType/GType.Register/ * glib/GTypeAttribute.cs: attribute for indicating a property that will return the GType of a type (particularly for enums, which can't have GType properties added to them). * glib/GType.cs: renamed from Type.cs to match the type name (public static readonly GType ...): add a few missing types. (Register): moved from ObjectManager.RegisterType (LookupGType): moved from TypeConverter.LookupType and extended to handle GTypeAttribute. Also, fix mappings for sbyte/byte/char, and return specific GTypes for Object subclasses rather than always returning GType.Object. [Fixes #74699] (LookupType): moved from ObjectWrapper.LookupType (ToString): return the type name * glib/Object.cs (RegisterGType): s/ObjectManager.Register/GType.Register/ (LookupGType): Make this protected internal so GType can access it. * glib/ObjectManager.cs (RegisterType): deprecate in favor of GType.Register. (LookupType): moved to GType * glib/TypeConverter.cs (LookupType): now a deprecated wrapper around GType.LookupGType. * glib/Value.cs: Use GType casts rather than TypeConverter * gtk/NodeStore.cs (ScanType): * gtk/ListStore.custom (ListStore): * gtk/TreeStore.custom (TreeStore): Use (GType) cast rather than TypeConverter. Remove the error check and exception, since the cast never returns GType.Invalid. (The check probably predates GLib.ManagedValue.) * gnome/PanelAppletFactory.cs (Register): Use a GType cast rather than GLib.Object.LookupGType (which is no longer accessible after an mcs bugfix) * sample/GtkDemo/DemoIconView.cs (CreateStore): use the Type[] constructor rather than the GType[] constructor, since it translates typeof(Gdk.Pixbuf) correctly now. svn path=/trunk/gtk-sharp/; revision=44038
2005-05-04 18:54:24 +02:00
Type result = GType.LookupType (typeid);
while (result == null) {
* parser/gapi2xml.pl: make note of _get_type methods for enums * */*-api.xml: Regen, adding gtype="..." to many enum types * generator/EnumGen.cs (Generate): if the enum has the "gtype" property, add a GTypeAttribute pointing to an internal FooGType class whose GType property can be used to get the enum's GType. * generator/ObjectGen.cs: s/ObjectManager.RegisterType/GType.Register/ * glib/GTypeAttribute.cs: attribute for indicating a property that will return the GType of a type (particularly for enums, which can't have GType properties added to them). * glib/GType.cs: renamed from Type.cs to match the type name (public static readonly GType ...): add a few missing types. (Register): moved from ObjectManager.RegisterType (LookupGType): moved from TypeConverter.LookupType and extended to handle GTypeAttribute. Also, fix mappings for sbyte/byte/char, and return specific GTypes for Object subclasses rather than always returning GType.Object. [Fixes #74699] (LookupType): moved from ObjectWrapper.LookupType (ToString): return the type name * glib/Object.cs (RegisterGType): s/ObjectManager.Register/GType.Register/ (LookupGType): Make this protected internal so GType can access it. * glib/ObjectManager.cs (RegisterType): deprecate in favor of GType.Register. (LookupType): moved to GType * glib/TypeConverter.cs (LookupType): now a deprecated wrapper around GType.LookupGType. * glib/Value.cs: Use GType casts rather than TypeConverter * gtk/NodeStore.cs (ScanType): * gtk/ListStore.custom (ListStore): * gtk/TreeStore.custom (TreeStore): Use (GType) cast rather than TypeConverter. Remove the error check and exception, since the cast never returns GType.Invalid. (The check probably predates GLib.ManagedValue.) * gnome/PanelAppletFactory.cs (Register): Use a GType cast rather than GLib.Object.LookupGType (which is no longer accessible after an mcs bugfix) * sample/GtkDemo/DemoIconView.cs (CreateStore): use the Type[] constructor rather than the GType[] constructor, since it translates typeof(Gdk.Pixbuf) correctly now. svn path=/trunk/gtk-sharp/; revision=44038
2005-05-04 18:54:24 +02:00
typeid = g_type_parent (typeid);
if (typeid == IntPtr.Zero)
return null;
* parser/gapi2xml.pl: make note of _get_type methods for enums * */*-api.xml: Regen, adding gtype="..." to many enum types * generator/EnumGen.cs (Generate): if the enum has the "gtype" property, add a GTypeAttribute pointing to an internal FooGType class whose GType property can be used to get the enum's GType. * generator/ObjectGen.cs: s/ObjectManager.RegisterType/GType.Register/ * glib/GTypeAttribute.cs: attribute for indicating a property that will return the GType of a type (particularly for enums, which can't have GType properties added to them). * glib/GType.cs: renamed from Type.cs to match the type name (public static readonly GType ...): add a few missing types. (Register): moved from ObjectManager.RegisterType (LookupGType): moved from TypeConverter.LookupType and extended to handle GTypeAttribute. Also, fix mappings for sbyte/byte/char, and return specific GTypes for Object subclasses rather than always returning GType.Object. [Fixes #74699] (LookupType): moved from ObjectWrapper.LookupType (ToString): return the type name * glib/Object.cs (RegisterGType): s/ObjectManager.Register/GType.Register/ (LookupGType): Make this protected internal so GType can access it. * glib/ObjectManager.cs (RegisterType): deprecate in favor of GType.Register. (LookupType): moved to GType * glib/TypeConverter.cs (LookupType): now a deprecated wrapper around GType.LookupGType. * glib/Value.cs: Use GType casts rather than TypeConverter * gtk/NodeStore.cs (ScanType): * gtk/ListStore.custom (ListStore): * gtk/TreeStore.custom (TreeStore): Use (GType) cast rather than TypeConverter. Remove the error check and exception, since the cast never returns GType.Invalid. (The check probably predates GLib.ManagedValue.) * gnome/PanelAppletFactory.cs (Register): Use a GType cast rather than GLib.Object.LookupGType (which is no longer accessible after an mcs bugfix) * sample/GtkDemo/DemoIconView.cs (CreateStore): use the Type[] constructor rather than the GType[] constructor, since it translates typeof(Gdk.Pixbuf) correctly now. svn path=/trunk/gtk-sharp/; revision=44038
2005-05-04 18:54:24 +02:00
result = GType.LookupType (typeid);
}
return result;
2002-08-19 Rachel Hestilow <hestilow@ximian.com> * art/Makefile.in (clean): Change to avoid bugging out on generated/CVS. * glib/ObjectManager.cs: Added. Used to be auto-generated, but now it can infer names, and relies on per-namespace ObjectManager classes to inform it of oddly-named classes. * generator/IGeneratable.cs, GenBase.cs: New "DoGenerate" property. * generator/*Gen.cs: Honor DoGenerate. * generator/CodeGenerator.cs: Support including dependency files which will not be generated. * generator/ObjectGen.cs: Generate mapping file per-namespace, as one that calls back to the one in glib. Only generate if the name does not follow the normal conventions, otherwise, GtkSharp.ObjectManager can infer the name. * generator/Parser.cs: Accept 'generate' flag to pass on to the IGeneratables. Parse a new toplevel element, "symbol", which adds a type to the SymbolTable (instead of hard-coding it). * generator/SignalHandler.cs: Do not optimize signal handler creation, instead creating them in their own namespaces. Do not generate if the calling Signal told us not to. * generator/Signal.cs: Do not generate handlers if container's DoGenerate is false. Adjust to the marshaller name being in a sub-namespace. * generator/SymbolTable.cs (AddSimpleType, AddManualType): Used to add simple and manually wrapped types at runtime instead of compile-time. (FromNative): Remove hard-coded cases for manually wrapped types, use a generic case instead. * api: Added. Move api files and generation targets here. * source: Added. Move source parsing here. * generator/makefile: Move actual generation to api/. * glib/Makefile.in: Remove generated/* target. * glue/Makefile.am: Fix to include canvas-marshal. Move canvas stuff to GNOME target. * gnome/CanvasProxy.cs: Update to work with SignalHandlers being namespace-specific. * parser/Metadata.pm: Moved to GAPI/Metadata.pm, renamed, etc. * parser/gapi2xml.pl: Use GAPI::Metadata. * parser/makefile: Install scripts, remove source parse build target. Rename formatXML to gapi_format_xml. svn path=/trunk/gtk-sharp/; revision=6818
2002-08-20 21:56:18 +02:00
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_type_parent(IntPtr typ);
2018-01-18 22:54:45 +01:00
static d_g_type_parent g_type_parent = FuncLoader.LoadFunction<d_g_type_parent>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_type_parent"));
2002-08-19 Rachel Hestilow <hestilow@ximian.com> * art/Makefile.in (clean): Change to avoid bugging out on generated/CVS. * glib/ObjectManager.cs: Added. Used to be auto-generated, but now it can infer names, and relies on per-namespace ObjectManager classes to inform it of oddly-named classes. * generator/IGeneratable.cs, GenBase.cs: New "DoGenerate" property. * generator/*Gen.cs: Honor DoGenerate. * generator/CodeGenerator.cs: Support including dependency files which will not be generated. * generator/ObjectGen.cs: Generate mapping file per-namespace, as one that calls back to the one in glib. Only generate if the name does not follow the normal conventions, otherwise, GtkSharp.ObjectManager can infer the name. * generator/Parser.cs: Accept 'generate' flag to pass on to the IGeneratables. Parse a new toplevel element, "symbol", which adds a type to the SymbolTable (instead of hard-coding it). * generator/SignalHandler.cs: Do not optimize signal handler creation, instead creating them in their own namespaces. Do not generate if the calling Signal told us not to. * generator/Signal.cs: Do not generate handlers if container's DoGenerate is false. Adjust to the marshaller name being in a sub-namespace. * generator/SymbolTable.cs (AddSimpleType, AddManualType): Used to add simple and manually wrapped types at runtime instead of compile-time. (FromNative): Remove hard-coded cases for manually wrapped types, use a generic case instead. * api: Added. Move api files and generation targets here. * source: Added. Move source parsing here. * generator/makefile: Move actual generation to api/. * glib/Makefile.in: Remove generated/* target. * glue/Makefile.am: Fix to include canvas-marshal. Move canvas stuff to GNOME target. * gnome/CanvasProxy.cs: Update to work with SignalHandlers being namespace-specific. * parser/Metadata.pm: Moved to GAPI/Metadata.pm, renamed, etc. * parser/gapi2xml.pl: Use GAPI::Metadata. * parser/makefile: Install scripts, remove source parse build target. Rename formatXML to gapi_format_xml. svn path=/trunk/gtk-sharp/; revision=6818
2002-08-20 21:56:18 +02:00
}
}