Commit graph

532 commits

Author SHA1 Message Date
Master T 08f4ae2eb4 glib: Check for self-assignment of Opaque.Raw property
This avoids unnecessary work, and prevents the IntPtr from being
freed when assigned to itself.

Signed-off-by: Bertrand Lorentz <bertrand.lorentz@gmail.com>
2014-09-21 16:13:31 +02:00
Antonius Riha 2034648ec2 csproj: Fix assembly names and include *.dll.config in output
Signed-off-by: Bertrand Lorentz <bertrand.lorentz@gmail.com>
2014-09-21 15:07:38 +02:00
Stephan Sundermann 69ea133855 glib: In Value.Update, check if val is null before updating
Signed-off-by: Bertrand Lorentz <bertrand.lorentz@gmail.com>
2014-09-21 14:29:53 +02:00
Stephan Sundermann 961b9ef348 glib: Add binding for GBytes
This patch adds bindings for GBytes https://developer.gnome.org/glib/stable/glib-Byte-Arrays.html

The code was first generated using gobject-introspection and then
refactored. The new type is also added to the generator SymbolTable.
2014-08-10 18:20:32 +02: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 280087e431 Value: Don't try to marshal if type has no StructLayout
If the StructLayout is not set, StructureToPtr will throw an exception.
In these cases the type is probably wrapped using a handle and thus
needs no update.
2014-08-10 15:36:40 +02:00
Stephan Sundermann 1fab57eeac Value: First try to invoke a constructor with IntPtr, bool
In Cairo there the default constructor does not take a ref to the native
object making the object invalid when trying to access it.

This commit changes the behaviour to search for another constructor that
takes an owner variable which is set to false when invoked to indicate
that the managed side should take a ref.
2014-08-10 15:33:50 +02:00
Bertrand Lorentz 7ea0c4afaf glib: Fix native GLib warnings when disposing SourceProxy objects
When an instance of SourceProxy was finalized, we would try to remove
the corresponding source, even if it was already removed. This now
causes native GLib to print out warnings because it can't find the
source ID.

Now Source.Remove only calls g_source_remove if we really had a handler
registered for the ID we're removing.
2014-07-05 16:16:58 +02:00
Bertrand Lorentz f5211acb74 glib: Have SourceProxy implement the Dispose pattern
Its 2 subclasses, IdleProxy and TimeoutProxy, were already implementing
it, so we factor this implementation into the base class.
2014-07-05 16:07:39 +02:00
Bertrand Lorentz 813f56e00a glib: Refactor Source, Idle and Timeout classes
Turn Source.source_handlers into a private generic Dictionary, and add
the necessary methods to allow Idle and Timeout to add and remove
entries from it.

This improves the encapsulation of the Source class, and factors
into it some code that was previously duplicated in Idle and Timeout.
2014-07-05 16:07:28 +02:00
Bertrand Lorentz 11920f2add glib: Re-organize code in Source for better readability
Move stuff around to have them in a reasonable order: fields, then
constructors, then destructor, then static methods, then instance stuff.
Also remove a commented out method, which would not be correct anyway.

No real code change here, just cosmetic changes.
2014-07-05 13:00:50 +02:00
Xavier Claessens 9559f579e6 Variant: Fix crash when casting a Variant to string
If we don't pass NULL to the length argument it makes C
code write the length at random places in memory and bad
things happens.
2014-06-17 21:16:38 +02:00
Bertrand Lorentz a1636d306b Variant: Add a NewArray (Variant[] children) convenience method
This allows you to avoid ugly calls like "NewArray (null, some_array)"
when you want the child type to be determined by the first element of
the children array.

Also throw specific exceptions when both type and children parameters
would be null.
2014-06-13 13:10:48 +02:00
Bertrand Lorentz b605b42540 Variant: Small code formatting fix 2014-06-13 13:10:02 +02:00
Xavier Claessens c271fe235b VariantType: Fix typo 2014-06-12 16:57:42 -04:00
Xavier Claessens 4158bc99f8 Variant: Add Type property 2014-06-12 16:48:03 -04:00
Xavier Claessens dc0f50729a Variant: Add ToArray() and ToAsv() helpers 2014-06-12 16:08:36 -04:00
Xavier Claessens 893703018f Variant: Add wrapper to construct "a{sv}" variant 2014-06-12 13:22:44 -04:00
Xavier Claessens cef9b13d72 Variant: Add wrapper for g_variant_new_dict_entry() 2014-06-12 13:22:44 -04:00
Xavier Claessens 58fb7aa378 Variant: Add wrapper for g_variant_new_array() 2014-06-12 13:22:43 -04:00
Xavier Claessens 24f8cede19 Variant: Add wrapper for g_variant_new_tuple() 2014-06-12 13:22:43 -04:00
Xavier Claessens b5062a8c7d Variant: Add wrapper for g_variant_new_variant() 2014-06-12 13:22:43 -04:00
Xavier Claessens b357aaef84 Variant: Add wrapper for g_variant_new_strv() 2014-06-12 12:30:29 -04:00
Xavier Claessens c1fbe27b32 Variant: Add wrapper for g_variant_print() 2014-06-12 12:05:35 -04:00
Bertrand Lorentz bc40506cab Merge pull request #107 from xDarkice/ambiguousmatch
glib.Value: Make GetMethod more specific to avoid ambiguous matches
2014-06-10 18:32:06 +02:00
Stephan Sundermann 839a32d797 Value: Make GetMethod more specific to avoid ambigous matches
This patch prevents GetMethod from throwing an AmbiguousMatchException because several constructors were found.
2014-06-10 15:25:39 +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
Bertrand Lorentz 8885fa98af build: Fix references to AssemblyInfo.cs in makefiles on Windows
On Windows with MinGW, csc.exe is confused by paths like
"../AssemblyInfo.cs", so we need some trickery to have something that
works on both Linux and Windows.

This isn't pretty, but it's the best solution I could find right now.
The other approach would have been to go back to copying AssemblyInfo.cs
around, but that has it's own set of issues.
2014-02-23 19:17:05 +01:00
Bertrand Lorentz 85443823e9 build: Enclose gacutil calls in double quotes
On Windows, gacutil.exe is often installed in a path with spaces, like
"C:\Program Files...". This causes problem when trying to call it during
"make install". Enclosing in double quotes fixes this, and has no impact
on Linux.
2014-02-23 17:07:10 +01:00
Bertrand Lorentz 2d48906523 glib: Use Marshaller methods in Argv for g_malloc and g_free 2013-11-17 16:27:39 +01:00
Bertrand Lorentz ced6f5e677 glib: Avoid unnecessary qualifier in Marshaller.PtrToStringArrayGFree 2013-11-17 16:26:02 +01:00
Bertrand Lorentz 32d10bd319 Use GLib.Marshaller.Free instead of calling g_free directly
Using the GLib.Marshaller.Free method means we don't need to have the
g_free function definition duplicated all over the place.
2013-11-17 16:20:02 +01:00
Bertrand Lorentz f067f5112d glib: Remove obsolete Argv-related methods in Marshaller
The ArgvToArrayPtr and ArrayPtrToArgv have been marked obsolete since
2004, and removing them allows us to remove some more code.
2013-11-17 15:05:36 +01:00
Bertrand Lorentz ee06530b52 glib: Avoid doing the same cast twice in KeyFile.ToData
The cast from UIntPtr to int can fail at runtime, but if your config
file is more than 2^31 bytes, you probably have bigger problems...
2013-11-17 13:27:04 +01: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
Stephan Sundermann cfdbb3b9a7 glib: fix IntPtr.Zero being dereferenced in GLib.Value.ToBoxed() 2013-11-02 16:52:25 +01:00
Bertrand Lorentz 21ef50ec48 Merge pull request #83 from knocte/msbuild_tweaks
Various tweaks and updates to the .csproj files
2013-10-22 12:55:30 -07:00
Bertrand Lorentz bd9cde5e61 Merge pull request #82 from knocte/cleanup
Various small cleanups in generator and glib
2013-10-22 12:52:08 -07:00
Andrés G. Aragoneses 8eca15e8bd glib: fix warning
`t` was not being used.
2013-10-22 14:06:12 +02:00
Andrés G. Aragoneses 3a45406665 glib: include recent files committed in master to the MSBuild csproj 2013-10-22 12:34:08 +02:00
Andrés G. Aragoneses e9d5d1803d glib: install properties before class_init finishes
Recently glib started to warn about the future deprecation of adding
interfaces after class_init, which we fixed here [1].

Now, a similar warning has started to happen for the addition of
properties, example:

(Nereid:23225): GLib-GObject-WARNING **: Attempt to add property __gtksharp_33_Banshee_Widgets_TileView::gtk-sharp-managed-instance after class was initialised

So we need to add them before class_init finishes too, and this
change makes it this way.

[1] 9ff7ec8b2c
2013-10-21 00:37:29 +02:00
Andrés G. Aragoneses 8b998861e1 Convert some dynamic casts to static casts
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.
2013-10-13 19:10:03 +02:00
Bertrand Lorentz b2fb84d14b Clean up .gitignore files 2013-10-13 18:38:33 +02:00
Andrés G. Aragoneses b15f2eede1 generator: provide a GType static property for adapters
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".
2013-10-13 17:45:09 +02:00
Stephan Sundermann f978c8f705 GLib.Object: Fixed FindClassProperty
g_object_class_find_property takes a GObjectClass which can be retrieved by
reading an IntPtr from the GObject's Handle
2013-10-11 11:13:08 +02:00
Andrés G. Aragoneses 7d75adf68c glib: fix FindClassProperty()'s copy-paste error
The implementation of FindClassProperty() was the same as the
implementation of FindInterfaceProperty(), both receiving an iface
instead of a GObjectClass* [1].

The reason of this oversight can well be explained by the fact that
FindClassProperty() is private and not used, actually. However, we
may need it soonish as a good bind to g_object_class_find_property.

[1] https://developer.gnome.org/gobject/unstable/gobject-The-Base-Object-Type.html#g-object-class-find-property
2013-10-10 20:25:23 +02:00
Stephan Sundermann 53312d5fc0 generator: fixed optional array parameters 2013-10-09 20:35:02 +02:00
Stephan Sundermann b868b80dee glib,generator: map MainContext type and expose members
This is needed to reference a MainContext from
external bindings, which need to create a
MainContext using a Handle
2013-10-09 19:44:50 +02:00
Stephan Sundermann 6ab620d689 generator,glib: added GPollFD and GSource types
GSource type was already there (but was not mapped by
the generator yet) so then the autogenerated methods
have been added manually inside the class after the
custom methods.

Other Source-related class are also generated and added
(but not mapped in the SymbolTable) to glib.
2013-10-09 19:41:21 +02:00
Stephan Sundermann 8b101d5525 glib: Mutex is actually opaque
This means that we're modifying the generated code that
we checked in, so then we increase the future TODO about
more information about what we need to fix later.

The changes to Cond are a consequence of the changes to
Mutex because the former uses the latter.
2013-10-09 18:44:04 +02:00