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>
There is no null check after these casts so if they fail they would
generate a NullReferenceException. By changing them to static casts
we would get a InvalidCastException which are much less misleading.
In the same way all GLib.Object-derived classes provided by the
generator have a GType static property (i.e. Gtk.Widget), we need
the same for the *Adapter classes, to access their GType without having
an instance of it. (The first use case would be GStreamerSharp's
Gst.Bin.IterateAllByInterface ().)
For this, we cannot simply add the property to all adapter classes
and be done, because it would clash with a property which is already
there, but is non-static, that has the same name and same value
(this property is needed for complying GInterfaceAdapter abstract
class), so we rename this property to GInterfaceGType because
using this name for the static one would not be consistent with the
rest of the classes generated which already provide the static one
with the name "GType".
The pointer from native is stored inside of a class which
wraps the structure. Fields can be accessed by marshalling
from and to the pointer. glib: Value.Update does now invoke
a private Update() method which is needed to update the new
structures.
The replaced code fails because sizeof(GValue) is 20 on 32 bit
linux but Marshal.SizeOf(GLib.Value) reported 24. If it aint broke,
don't fix it, and the long works on 32 and 64 in 2.12 and earlier.
* 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.
* glib/Value.cs: support long and ulong gtypes. still can't construct
generically, but can cast to long/ulong and access via Val prop.
[Fixes#539812]
svn path=/trunk/gtk-sharp/; revision=142588
* 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
* 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
* 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
* glib/Value.cs: return int object value for GType.Enum values if
the explicit gtype is not found. [Fixes#503060]
svn path=/trunk/gtk-sharp/; revision=134075
* glib/Value.cs: Add support for ValueArrays inside GLib.Values.
* glib/ValueArray.cs: Add GType property to get the ValueArray GType.
[Fixes#503048]
svn path=/trunk/gtk-sharp/; revision=134073
* glib/Object.cs: get gtype from instance data.
* glib/Value.cs: use instance NativeType when initing for props.
[Fixes#500157] Patch by Sebastian Dröge.
svn path=/trunk/gtk-sharp/; revision=133282
* glib/Value.cs: Support for additional fundamental GTypes. Invoke
constructor of corresponding managed type to convert a GValue into
its managed representation and a SetGValue method to do that vice
versa. Patch contributed by Sebastian Dröge.
svn path=/trunk/gtk-sharp/; revision=131931
* glib/Value.cs: Change the pad fields handling again as the
previous approach didn't work on Win32. [Fixes#478578]
svn path=/trunk/gtk-sharp/; revision=127892
* glib/Value.cs: make the pad fields a blink explicitly sized struct
instead to avoid alignment issues on x86. [Fixes#469135]
svn path=/trunk/gtk-sharp/; revision=124561
* 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
* glib/SignalClosure.cs: post back the gvalues after the closure is
invoked using a new Update method on GLib.Value. This only impacts
boxed types, since they are the only "value types" passed by ref in
the signal marshaling environment. We can't call set_boxed on the
value to update it, since that allocs new memory, we need to marshal
the updated struct out to the existing native memory address using
g_value_get_boxed.
* glib/Value.cs (Update): new update method for writing values to
an existing boxed type instance instead of allocating a new native
struct. Fixes#398929.
svn path=/trunk/gtk-sharp/; revision=106058
* glib/Value.cs : Add GParam support and beef up the Boxed
type marshaling to support types with New methods via reflection.
svn path=/trunk/gtk-sharp/; revision=102064
* glib/Opaque.cs : remove the Opaques hash. As f-spot demonstrated,
we cannot rely on a pointer continuing to point at the same type in
memory, since there is no destroy notification for most opaques.
* glib/Value.cs : use more explicit GetOpaque overload.
* gtk/Style.custom : use more explicit GetOpaque overload.
svn path=/trunk/gtk-sharp/; revision=50884
constructors and casts. Add a new Enum cast.
(Val): Handle Pointer values. Change the handling of Enum/Flags
values to return the value directly rather than returning an
EnumWrapper. Remove the Char (ie, "byte") handling since there
aren't any char properties in all of gtk-sharp and the generator
mistakenly converts them to strings anyway.
* glib/EnumWrapper.cs:
* glib/UnwrappedObject.cs: Mark these Obsolete.
* glib/glue/type.c (gtksharp_get_parent_type,
gtksharp_get_type_name_for_id):
* glib/glue/value.c (gtksharp_value_get_value_type): Remove some
unneeded glue methods.
* generator/Ctor.cs (Generate):
* generator/Property.cs (Generate): Simplify the enum and object
property glue to not use EnumWrapper or UnwrappedObject.
* sample/valtest/*: a regression test for GLib.Value
* configure.in.in: add sample/valtest
svn path=/trunk/gtk-sharp/; revision=47564
string[] (using a G_TYPE_STRV boxed value).
* generator/SymbolTable.cs (SymbolTable): Map GStrv to string[].
(The mapping relies on the above GLib.Value magic, so it only
works correctly for properties, but that's ok, because GStrv isn't
a real type anyway and only shows up in the api files for
G_TYPE_STRV properties.) Makes the Gtk.AboutDialog Artists,
Authors, and Documenters properties show up.
* gtk/Gtk.metadata: hide
AboutDialog.Get/SetArtists/Authors/Documenters, which can't be
used to implement the Artists/Authors/Documenters properties,
because the generated code doesn't know to NULL-terminate the
arrays.
svn path=/trunk/gtk-sharp/; revision=45301
* */*-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
* */*.cs : scrub for StringToPtrAnsi and string usage in DllImports.
* */*.custom : begin the scrub here too.
* generator/ConstStringGen.cs : implement IManualMarshaler and move to
100% IntPtr marshaling.
* generator/Ctor.cs : call Body.Finish too.
* generator/IManualMarshaler.cs : new interface for generatables that
marshal manually and need cleanup.
* generator/Makefile.am : new file.
* generator/MethodBody.cs : use IManualMarshaler if applicable.
svn path=/trunk/gtk-sharp/; revision=41579