Commit Graph

38 Commits

Author SHA1 Message Date
Martin Kupec
a76f60df81 Add possibility to pick glib type name for custom classes
This patch adds TypeName attribute which can be used on custom class
derived from GLib.Object in order to set GLib type name of the class.
2015-10-29 12:25:16 -05:00
Bertrand Lorentz
fe0be81892 build: Require GLib 2.32 or above
GLib 2.32 has been released in March 2012, so we can now require it a
build and run time. This allows us to remove GLib 2.31 conditionals,
mark the Thread.Init as obsolete, and remove all references to
libgthread.

Please note that the API exposed in glib and gio is still from 2.28, but
we will have some API additions in the future. First example is the next
commit, which brings GBytes, an addition in GLib 2.32.
2014-08-10 18:20:01 +02:00
Stephan Sundermann
f38daf0d49 glib: Add GVariant to fundamental types
GVariant is a fundamental type since 2.26, this commit adds it to the
fundamental type list and adds operators to construct and convert from
and to a GValue.

https://developer.gnome.org/gobject/stable/gobject-Type-Information.html#G-TYPE-VARIANT:CAPS

Signed-off-by: Bertrand Lorentz <bertrand.lorentz@gmail.com>
2014-05-29 17:11:47 +02:00
Andrés G. Aragoneses
f1005da47c glib: Make all DllImports in custom code use a common const
This way there's less redundancy, and if the library name changes in the
future, it will be changed only in one place.

Signed-off-by: Bertrand Lorentz <bertrand.lorentz@gmail.com>
2013-11-17 13:05:12 +01:00
Andrés G. Aragoneses
6d626a24a7 glib: avoid a delegate to be GCed which caused a NRE (bxc#13113)
What seemed to be a race condition (because of not happenning 100% of
the times) ended up being an early garbage collection of a delegate that
was still referenced by an unmanaged struct without having a managed
counterpart [1].

The consequence of this was a NullReferenceException happening in a line
which didn't have a dereference of a null object. The way to reproduce it
deterministically 100% of the times was setting the env var MONO_NO_SMP.

[1] http://www.mono-project.com/Interop_with_Native_Libraries#Memory_Boundaries
2013-07-17 14:24:02 +02:00
Andres G. Aragoneses
9ff7ec8b2c glib: install interfaces earlier, override properties in class_init
GObject upstream has started disabling support for installing interfaces
in GTypes after they have already been initialized (class_init) [1], so
we need to add GInterfaces a bit earlier (*before* class_init starts).

As GLib.Object.OverrideProperty() cannot to be called before class_init
(because it receives a GObjectClass, not a GType) or after (because
otherwise class_init would complain about properties of an interface not
being defined), then we need to call it during class_init.

[1] http://bugzilla.gnome.org/687659

A good side-effect of this fix is that we no longer use the hacky uint
field 'idx' to track the properties count for each class; now it gets
moved to the ClassInitializer class, and thus can be non-static, which
makes a bit more sense (we leave the old OverrideProperty overload for
backwards compatibility).

Simplest way to test this is launching the sample/treemodeldemo.exe and
sample/custom-scrollable.exe in Ubuntu 13.04 beta (which has GLib 2.36).
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=11510
2013-04-07 07:51:30 +01:00
Bertrand Lorentz
6e3e73e2ac glib: Use dictionaries to store type information in GType class
Yay, type safety when managing types...
2012-11-04 16:58:49 +01:00
Olivier Dufour
37d15305a3 GInterface: Add properties support 2011-11-20 19:41:56 +01:00
Mike Kestner
6fafc52670 Guard against null native names.
* glib/GType.cs: null guarding for native names
2011-04-27 19:03:02 -05:00
Mike Kestner
a56feb01e3 Some warning fixage.
* glib/GType.cs:
* glib/Makefile.am:
* glib/Object.cs:
* glib/ParamSpec.cs:
* glib/PtrArray.cs:
* glib/SignalClosure.cs:
* glib/Value.cs:
mark private struct fields public to avoid 0169, and remove the nowarn
from the csc command.  fixed one real warning, exposed a bunch of
obsolete usage still to fix.
2011-03-24 18:32:54 -05:00
Mike Kestner
95bd0d6271 2009-10-30 Mike Kestner <mkestner@novell.com>
* glib/GType.cs: avoid another exception on bogus assm.Locations.
	  [Fixes #546045]

svn path=/trunk/gtk-sharp/; revision=145132
2009-10-31 02:18:21 +00:00
Christian Hoff
7b752d233c 2009-09-03 Christian Hoff <christian_hoff@gmx.net>
* glib/Global.cs: Kill the calling convention field again.
	It breaks GLib 2.x compatibility in the generator and there is
	probably no need to make the calling convention configurable.
	* .cs, *.custom: Hardcode Cdecl calling convention instead of
	using GLib's field.

svn path=/trunk/gtk-sharp/; revision=141283
2009-09-03 19:50:53 +00:00
Christian Hoff
58e97c087a 2009-09-02 Christian Hoff <christian_hoff@gmx.net>
* glib/Global.cs: Add a public constant field specifying the
	calling convention used by GLib and depending libraries.
	By now it's hardcoded to Cdecl as every non-Win32 runtime
	should ignore this attribute.
	* *.cs, *.custom: Use GLib.Global.CallingConvention for both
	pinvokes and callbacks. Plugs a stack leak on Win32. All
	pinvokes defaulted to StdCall and thus the stack was never
	cleaned up.

svn path=/trunk/gtk-sharp/; revision=141175
2009-09-02 20:17:37 +00:00
Mike Kestner
7db633218f 2009-08-07 Mike Kestner <mkestner@novell.com>
* configure.in.in: add new dir and autofu for it.
	* Makefile.am: add new dir
	* gapi/*: a small extension method library to add generation-related
	api to GType in 2.0. Access it with -pkg:gapi-2.0-compat to pick up
	the needed refs.
	* generator/GObjectVM.cs: generate new GType getter methods.
	* generator/ObjectGen.cs: generate new GType getter methods.
	* glib/GType.cs: change a few props to methods to make them extension
	method friendly for 2.0 compat.
	* glib/Object.cs: use new GType getter methods.
	* glib/Value.cs: use new GType getter methods.
	* gtk/Widget.custom: use new GetClassPtr method.

svn path=/trunk/gtk-sharp/; revision=139609
2009-08-08 23:42:15 +00:00
Mike Kestner
b3f341768f 2009-08-01 Mike Kestner <mkestner@novell.com>
* glib/GType.cs: lock the types hash to support threaded access and 
	type registration.  Apparently gtype access/registration is threadsafe
	in glib.  [Fixes #526229]

svn path=/trunk/gtk-sharp/; revision=139247
2009-08-01 17:20:35 +00:00
Mike Kestner
c339d40680 2009-07-12 Mike Kestner <mkestner@novell.com>
* glib/GType.cs: add ResolveType event and TypeResolutionHandler delegate
	declarations.  This mechanism supports the lazy registration of type mappings
	by bindings.  Patch from Sebastian with minor naming tweek.  [Fixes #497667]

svn path=/trunk/gtk-sharp/; revision=137759
2009-07-12 23:12:29 +00:00
Mike Kestner
bb2864a9a0 2009-07-12 Mike Kestner <mkestner@novell.com>
* glib/GType.cs: fail gracefully for non-studly-case typename lookups.
	[Fixes #515453]

svn path=/trunk/gtk-sharp/; revision=137756
2009-07-12 21:34:46 +00:00
Mike Kestner
26362ced64 2009-05-05 Mike Kestner <mkestner@novell.com>
* glib/GType.cs: ensure threading is initialized in cctor.
	* gtk/Application.cs: ditto.

svn path=/trunk/gtk-sharp/; revision=133585
2009-05-05 15:15:46 +00:00
Christian Hoff
291ee61b2d 2009-04-13 Christian Hoff <christian_hoff@gmx.net>
Add support for virtual methods(vm) to the generator.

	* parser/gapi2xml.pl: Generate a class_struct element with
	all members of the class structure. Dump the first (instance)
	parameter for signal and vm elements. Bump up parser version.
	* generator/GObjectVM.cs: Added. Support for GObject virtual methods.
	* generator/DefaultSignalHandler.cs: Signal specific part of vm
	generation.
	* generator/InterfaceVM.cs: New class for interface vms.
	* generator/ObjectBase.cs: Parse the class struct.

svn path=/trunk/gtk-sharp/; revision=131604
2009-04-13 17:44:48 +00:00
Andrés G. Aragoneses
8ffc1097fb revert r122505
svn path=/trunk/gtk-sharp/; revision=122553
2009-01-06 15:27:12 +00:00
Andrés G. Aragoneses
1f40330573 2009-01-05 Andrés G. Aragoneses <aaragoneses@novell.com>
* GType.cs: convert GType.Is to a non-static function.
        * Value.cs: track API.
        [Last cosmetic bit from #448009]


svn path=/trunk/gtk-sharp/; revision=122505
2009-01-06 03:36:56 +00:00
Mike Kestner
65f96d21dc 2009-01-04 Mike Kestner <mkestner@novell.com>
* glib/GType.cs: fix incorrect null check noticed by Christian Hoff.
	[Fixes #463445]

svn path=/trunk/gtk-sharp/; revision=122390
2009-01-04 16:52:22 +00:00
Andrés G. Aragoneses
a8b28619be 2008-12-22 Andrés G. Aragoneses <aaragoneses@novell.com>
* glib/GType.cs: simplify, avoiding a static method.  
        * generator/InterfaceGen.cs: track API.
        * glib/Value.cs: reuse g_type_is_a.
        [Improves fix for #448009 in r121990]


svn path=/trunk/gtk-sharp/; revision=121991
2008-12-22 17:16:03 +00:00
Andrés G. Aragoneses
8191911b26 2008-12-22 Andrés G. Aragoneses <aaragoneses@novell.com>
* generator/InterfaceGen.cs: use the new GLib API to detect
	instances that don't implement GInterfaces.
	* glib/GType.cs: add new API for checking if an IntPtr instance
	implements a certain GType.
	[Fixes #448009]


svn path=/trunk/gtk-sharp/; revision=121990
2008-12-22 17:02:09 +00:00
Mike Kestner
89afb3f49f 2008-12-19 Mike Kestner <mkestner@novell.com>
* generator/BoxedGen.cs: don't generate glue dependencies.
	* glib/*.cs: remove glibsharpglue usage except thread.c.
	* glib/glue/*.c: kill all but thread.c. need glib 2.20 to kill
	it eventually.
	* pango/Attr*.cs: kill glue usage.
	* pango/glue/*.c: kill all but generated.c. it's next.
	* gtk/TreeIter.custom: kill a dumb glibsharpglue usage.

svn path=/trunk/gtk-sharp/; revision=121880
2008-12-19 18:57:42 +00:00
Mike Gorse
c9d658f381 2008-11-04 Mike Gorse <mgorse@novell.com>
* glib/PtrArray.cs, glib/glue/ptrarray.c, glib/Makefile.am,
	  glib/glue/Makefile.am, glib/gtype.cs, generator/SymbolTable.cs,
	  generator/ReturnValue.cs: Add PtrArray.
	* glib/Marshaller.cs: Add PtrArrayToArray.

	* atk/Atk.metadata: Specify GetTarget return type.

	* atk/Object.custom, atk/glue/object.c: Support overriding
	  RefRelationSet.

svn path=/trunk/gtk-sharp/; revision=117919
2008-11-04 20:17:00 +00:00
Mike Kestner
d059903d1c 2008-10-24 Mike Kestner <mkestner@novell.com>
* glib/GType.cs: register IntPtr.

svn path=/trunk/gtk-sharp/; revision=116997
2008-10-24 22:03:49 +00:00
Mike Kestner
51299b17bb 2008-09-24 Mike Kestner <mkestner@novell.com>
* glib/GType.cs: kill the FindTypeInReferences recursive loading
	algorithm and instead do a name-based search through the references
	of loaded assemblies only.  Fixes the original bug #400595 and it
	hopefully will have fewer sideeffects that the recursive loading
	approach.

svn path=/trunk/gtk-sharp/; revision=114008
2008-09-24 20:06:47 +00:00
Mike Kestner
ead904c8a3 2008-09-24 Mike Kestner <mkestner@novell.com>
* glib/GType.cs: just fail on location null or empty instead of
	checking the assembly type.  Avoids failures on the ms runtime.

svn path=/trunk/gtk-sharp/; revision=113989
2008-09-24 18:53:05 +00:00
Zoltan Varga
fc871aacca 2008-09-12 Zoltan Varga <vargaz@gmail.com>
* glib/GType.cs (FindTypeInReferences): Put a try-catch around the assembly
	loading as failure to load a referenced assembly is not really an error.

svn path=/trunk/gtk-sharp/; revision=112905
2008-09-12 20:07:13 +00:00
Zoltan Varga
b1a12cf3ec 2008-09-09 Zoltan Varga <vargaz@gmail.com>
* glib/GType.cs (FindTypeInReferences): Skip dynamic assemblies.

svn path=/trunk/gtk-sharp/; revision=112605
2008-09-09 16:50:16 +00:00
Mike Kestner
fdfff5bb60 2008-09-08 Mike Kestner <mkestner@novell.com>
* glib/GType.cs: beef up the referenced assembly loading code to
	handle assemblies located in the same directory as the referring
	assembly.  Fixes #423450.

svn path=/trunk/gtk-sharp/; revision=112545
2008-09-08 20:52:27 +00:00
Mike Kestner
179d4b214f 2008-06-17 Mike Kestner <mkestner@novell.com>
* glib/GType.cs (LookupType): traversed referenced assemblies to
	find types in currently unloaded assemblies.  Fixes #400595.

svn path=/trunk/gtk-sharp/; revision=106027
2008-06-17 16:36:06 +00:00
Andrés G. Aragoneses
52e68fbeb6 * atk/Object.custom: Track API changes in GLib.Signal.
* glib/Signal.cs: AddEmissionHook binding (for closing #386950), and
  change API of Emit to mimic the detailed_signal pattern.
* glib/GType.cs: GType.FromName: new wrapper for native call.
* glib/ObjectManager.cs: Use the new FromName managed method.

svn path=/trunk/gtk-sharp/; revision=103198
2008-05-14 16:03:13 +00:00
Mike Kestner
d5e5c13a1f 2008-04-28 Mike Kestner <mkestner@novell.com>
* glib/GType.cs : Add a few missing static fields.

svn path=/trunk/gtk-sharp/; revision=102063
2008-04-28 18:52:49 +00:00
Mike Kestner
51292d20b3 2008-03-12 Mike Kestner <mkestner@novell.com>
* glib/GType.cs: add an Init method for explicit initialization.

svn path=/trunk/gtk-sharp/; revision=98056
2008-03-12 16:15:06 +00:00
Dan Winship
5743ba2da8 * glib/GType.cs (cctor): call g_type_init(). (Avoids debug spew
when monodocer updates doc/en/GLib/GType.xml.)

svn path=/trunk/gtk-sharp/; revision=45500
2005-06-06 15:09:07 +00:00
Dan Winship
900b14290c * 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 16:54:24 +00:00