When dealing with several namespaces there might be classes with the same name
(especially Global which is autogenerated in g-i based bindings). On generation
the file would be overriden by the last occurence in the xml. To encounter
this every namespace has it's own directory now. This also improves structure
a lot when dealing with big libraries.
Also do the necessary adaption for the build and the csproj files.
A similar situation to what is described in commit e48ac63d54 also
happens with signal callbacks: some signals are passed a native object
that is wrapped in an IDisposable managed object, which is then passed
as an argument to the signal handler. We need to dispose those objects
when the signal handler is done.
Those parameters will now be disposed in a finally {...} block, after
the signal handler has returned. This means that handlers should not
keep a reference to such a parameter, as it will be disposed right after
they return.
This change only affects the Cairo.Context parameter of the Widget.Drawn
signal, but it was badly needed, as shown by the Pixbuf demo in the
GtkDemo sample, which was leaking tens of MBs of memory.
To be able to do this, Name property of GenBase class is now virtual, so
that it can be overriden in InterfaceGen with the new name.
Adapters, however, are still classes and then need special care as such
(cannot use the 'Name' property anymore), but this improves a bit the
readability of some parts of the code as the *Implementor and *Adapter
suffixes are now concentrated in just two new properties of GenBase and
not repeated all over the place.
In a lot of places, we were only checking the presence of boolean
attributes, like "array", automatically assuming they were true. This
meant that we didn't allow setting them explicitly to false, which
apparently is needed for some bindings.
For all boolean attributes, we now use the GetAttributeAsBoolean method
added in the previous commit, to correctly check the value of the
attribute. As before, if the attribute is not present, it is considered
to be false.
Thanks to Stephan Sundermann for noticing this issue.
* gdk/Display.custom: rework signal connection
* gdk/Window.custom: rework signal connection
* generator/Signal.cs: generate for new API.
* glib/Object.cs: add (Add|Remove)SignalHandler methods and use
them for the Notify connections. Move to generic collections for
everything but the Data hash.
* glib/Signal.cs: kill Lookup methods and add delegate fields
* glib/ToggleRef.cs: remove Signals hash, it doesn't belong here.
* gtk/Clipboard.custom: rework signal connection
* gtk/ListStore.custom: rework signal connection
* gtk/TextView.custom: remove obsolete signal
* gtk/TreeModelAdapter.custom: rework signal connection
* gtk/TreeModelFilter.custom: rework signal connection
* gtk/TreeModelSort.custom: rework signal connection
* gtk/TreeStore.custom: rework signal connection
* gtk/Widget.custom: rework signal connection
* gtk/Window.custom: remove obsolete signal
* generator/*.cs: Add a LogWriter class which formats warnings
consistently on the console. Supports the concept of non-fatal
validation warnings, since it doesn't rely on the unrolling of the
validation stack to associate a warning to a given type.
Main purpose was to add a non-fatal warning for missing element_type
attributes on list return values, though it results in cleaner log
output, and also updates some warning messages to be more helpful in
how to resolve them.
* generator/Signal.cs: Return a GInterfaceAdapter in the signalargs's
accessor properties instead of trying to return the implementor as stored in
the arguments array.
svn path=/trunk/gtk-sharp/; revision=146744
* 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
* generator/IGeneratable.cs: Remove MarshalReturnType, ToNativeReturnType,
FromNativeReturn and ToNativeReturn as they never returned something else
than MarshalType, FromNative/AllocNative and CallByName, respectively.
* generator/Signal.cs: Use AllocNative for IManualMarshalers.
svn path=/trunk/gtk-sharp/; revision=139849
* configure.in.in: Target .net 2.0 profile
* gapi-cdecl-insert: Kill. We are now using the UnmanagedFunctionPointerAttribute
for callbacks.
* glib/CdeclCallback: Mark obsolete.
* generator/*.cs:
* *.custom: Use [UnmanagedFunctionPointer (CallingConvention.Cdecl)] instead of
[GLib.CDeclCallback].
svn path=/trunk/gtk-sharp/; revision=137323
* generator/Signal.cs: Fix indexing of the signal arguments array for
"out" and "ref" parameters. [Fixes#508572]
svn path=/trunk/gtk-sharp/; revision=135661
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
* generator/Signal.cs: remove ref int workaround now that we fallback
to signal-specific marshalers for G_TYPE_POINTER using signals.
Fixes#450119.
svn path=/trunk/gtk-sharp/; revision=120254
* atk/atk-api-2.12.raw: regen
* gtk/gtk-api-2.12.raw: regen
* generator/Signal.cs: reinstate old custom marshaler generation and
generate custom marshaling when 'manual' attr is set.
* parser/gapi2xml.pl: set manual attr on sigs that have G_TYPE_POINTER
parameters since the generic closure can't cope with them.
svn path=/trunk/gtk-sharp/; revision=118068
* bootstrap-2.12: bump svn version.
* generator/Signal.cs: add a workaround for G_TYPE_POINTER usage
in the GtkEditable::text_inserted signal. The signal parameter
received by the closure will be an IntPtr, which we then have to
use to read/write the value directly from unmanaged memory.
[Fixes#427588]
svn path=/trunk/gtk-sharp/; revision=113547
Patch from Christian Hoff with a few minor tweaks.
* generator/CallbackGen.cs: refactor to use ManagedCallString
and drop a ton of redundant, half-baked code.
* generator/ManagedCallString.cs: add Unconditional setup
method for stuff that has to happen before the try block.
Add "drop_first" concept so it can be reused by CallbackGen
which doesn't drop first params.
* generator/Signal.cs: use Unconditional method for prep.
* generator/VirtualMethod.cs: use Unconditional method for prep.
* gtk/Gtk.metadata: mark a ref param. [Fixes#394352]
svn path=/trunk/gtk-sharp/; revision=107494
* generator/GenerationInfo.cs: refactor glue writer implementation
so that GlueEnabled means there is a valid glue writer available.
Avoids crashes in scenarios where an unwriteable glue path is provided
to the generator. Generate a glue function which scans the type
hierarchy of an object for the most-derived unmanaged ancestor so
that we can invoke class methods on it, avoiding infinite recursions.
* generator/Signal.cs: revamp the default handler vm overriding
mechanism. When class fields exist which can be directly hooked into,
we now generate glue to override and chain up to unmanaged base funcs.
This avoids some strangeness in the g_signal_override_class_closure
and g_signal_chain_from_overridden reported in #332300 and also lays
the groundwork for automated generation of non-signal VMs.
* gtk/Gtk.metadata: block signal glue generation for a few types which
don't seem to install headers.
svn path=/trunk/gtk-sharp/; revision=102350
* generator/InterfaceGen.cs: use CName and mangle it. ClassFieldName
is not guaranteed to be set now.
* generator/Signal.cs: read ClassFieldName from the api xml. Move
glue writer lookup inside the block to avoid exceptions for now.
svn path=/trunk/gtk-sharp/; revision=102276
* generator/InterfaceGen.cs:
* generator/Signal.cs: use generic signal marshaling instead of
generating signature specific marshaling callbacks.
* glib/glue/closure.c: glue for new closure impl.
* glib/Object.cs: open up a couple hashes internally.
* glib/Signal.cs: hook in closure based connection and expose
EmissionHook functionality for atk usage.
* glib/SignalClosure.cs: new generic signal marshaling mechanism.
* glib/ToggleRef.cs: null guarding in Target and let Signal remove
itself from hash when it disposes itself.
svn path=/trunk/gtk-sharp/; revision=102241
* generator/*.cs: implement the interfaces on the adapters too.
Generate an Implementor interface for users which exposes the
methods to implement. Register based on the Implementor sub-iface.
* gtk/*Adapter.custom: custom implementations for the custom
interface members.
* gtk/TreeIter.custom: make UserData public.
* sample/TreeModelDemo.cs: sample for implementing a TreeModel
interface.
svn path=/trunk/gtk-sharp/; revision=86753
* generator/*.cs : switch to IntPtr marshaling for struct types
in the managed to native direction.
* gtk/*.custom : adjust to new gapi struct pinvoke sigs.
svn path=/trunk/gtk-sharp/; revision=83961
* generator/NativeCallbackSignature.cs :
* generator/Signal.cs : don't use ref IntPtr in native callback sigs
for struct parameters. Use IntPtr and StructureToPtr. Fixes the
layout issues in MD introduced by the structure marshaling rework.
svn path=/trunk/gtk-sharp/; revision=76433
* generator/CallbackGen.cs : switch to NativeCallbackSignature.
* generator/GenBase.cs : add NativeCallbackType member.
* generator/IGeneratable.cs : add NativeCallbackType member.
* generator/ManagedCallString.cs : add guarded post call struct
marshaling back to the native struct.
* generator/NativeCallbackSignature.cs : new parallel to ImportSignature
but using NativeCallbackType instead of MarshalType.
* generator/Signal.cs : switch vm and sig marshaler callbacks to
NativeCallbackSignature. Perform guarding post call struct marshaling
back to the native struct.
* generator/Parameters.cs : add NativeCallbackType member.
* generator/SimpleBase.cs : add NativeCallbackType member.
* generator/StructBase.cs : add NativeCallbackType member using IntPtr
to support NULL handling.
* gtk/NodeCellDataFunc.cs : update native marshaler sig.
svn path=/trunk/gtk-sharp/; revision=76011
* generator/Signal.cs : add try/catch blocks to native callback
delegates so that exceptions are not propagated across the native
boundary. Now raises GLib.ExceptionManager.UnhandledException.
* glib/ExceptionManager.cs : new class with UnhandledException
event and a static method to raise it.
* glib/Signal.cs : wrap the generic EventHandler callback delegate
with try/catch blocks and raise the UnhandledException event.
svn path=/trunk/gtk-sharp/; revision=73840
* generator/Signal.cs : virtual method enum retvals must be case to
Enum before casting to their ultimate type. Also dispose retval
gvalues to avoid reference leaks.
svn path=/trunk/gtk-sharp/; revision=56529
* generator/Signal.cs : pass byte cnt for autogenerated string length
parameters. Thanks to Itamar Rogel for the report and a candidate
patch. [Fixes#76952]
svn path=/trunk/gtk-sharp/; revision=54239
parent class and interfaces (because we don't want to see the
warnings about certain GtkWidget methods in every single library
that defines a widget, etc). Instead, use the new
ValidateForSubclass() method.
(ValidateForSubclass): only validate the signals
* generator/InterfaceGen.cs (ValidateForSubclass): for interfaces
we need to validate the methods too.
* generator/ObjectGen.cs (Generate): Check for interface method
collisions against the class's own methods too, not just its other
interfaces. Also, it's only a collision if the methods' signatures
have the same types.
* generator/Signal.cs (GenDefaultHandlerDelegate): Use
"{0}_managed" rather than "obj" for the internal variable name, to
avoid compile problems with signals that have a parameter named
"obj".
* generator/SymbolTable.cs (MangleName): mangle "internal" to
"_internal".
svn path=/trunk/gtk-sharp/; revision=48184
* glib/Opaque.cs (Owned): new property saying whether or not gtk#
owns the memory.
(Opaque): Set Owned to true in the void ctor and false in the
IntPtr one.
(GetOpaque): add a new overload that can also create opaques, a la
GLib.Object.GetObject.
(Ref, Unref, Free): empty virtual methods to be overridden by
subclasses.
(set_Raw): Unref() and possibly Free() the old value, Ref() the
new one.
(~Opaque, Dispose): set Raw to IntPtr.Zero (triggering Free/Unref
if needed)
* parser/gapi2xml.pl (addReturnElem): if the method is named Copy
and returns a pointer, set the "owned" attribute on the
return-type.
* */*-api.raw: Regen
* generator/HandleBase.cs (FromNative): Add new
FromNative/FromNativeReturn overloads that takes a "bool owned"
param. Implement the 1-arg FromNative and FromNativeReturn in
terms of that.
* generator/ObjectBase.cs (FromNative): Implement HandleBase's new
overload. Use the two-arg version of GLib.Object.GetObject when
"owned" is true.
* generator/OpaqueGen.cs (Generate): Pull out Ref, Unref, and
Free/Destroy/Dispose methods and handle them specially by
overriding Opaque.Ref, .Unref, and .Free appropriately. (If any
of the methods are marked deprecated, output a deprecated
do-nothing method as well, to save us from having to write all
those deprecated methods by hand.)
(FromNative): use GetOpaque, passing "owned".
* generator/ReturnValue.cs (FromNative): if the value is a
HandleBase, pass Owned to its FromNative().
* generator/Parameters.cs (Owned): new property (for use on out
params)
(FromNative): Call FromNative() on the generatable, handling Owned
in the case of HandleBase.
* generator/ManagedCallString.cs:
* generator/MethodBody.cs:
* generator/Signal.cs: use param.FromNative() rather than
param.Generatable.FromNative(), to get ownership right.
* */*.metadata: Mark opaque ref/unref/free methods deprecated
(except where we were hiding them before). Add "owned" attributes
to return values and out params as needed.
* pango/AttrIterator.custom (GetFont): work around a
memory-management oddity of the underlying method.
* pango/AttrFontDesc.cs (AttrFontDesc): copy the passed-in
FontDescriptor, since the attribute will assume ownership of it.
* gtk/TreeView.custom (GetPathAtPos): set the "owned" flag on the
returned TreePaths.
* gtk/TargetList.custom: Remove refcounting stuff, which is
now handled automatically
* gtk/NodeStore.cs (GetPath): clear the Owned flag on the created
TreePath so that the underlying structure doesn't get freed when
the function returns
* gtkhtml/HTMLStream.custom (Destroy): hide this and then
reimplement it by hand to keep OpaqueGen from using it in
Dispose(), since calling it after an HTMLStream.Close() will
result in a crash.
svn path=/trunk/gtk-sharp/; revision=47928
(They're always allowed now.)
* generator/Signal.cs (GenVirtualMethod): Fix up the use of CSType
vs MarshalType in the ref/out-handling code so that this can
marshal any type.
svn path=/trunk/gtk-sharp/; revision=47412
* generator/CallbackGen.cs : remove an old workaround that put
the native wrapper class into the implementor's *Sharp namespace.
Use new ImportSignature sig.
* generator/ImportSignature.cs : don't mangle the callback wrapper
namespace any more. Remove impl_ns ctor param and field.
* generator/MethodBase.cs : use new MethodBody and ImportSignature
ctor sigs.
* generator/MethodBody.cs : drop the impl_ns ctor param.
* generator/Signal.cs : use new ImportSignature ctor sig.
* generator/VirtualMethod.cs : use new ImportSignature ctor sig.
svn path=/trunk/gtk-sharp/; revision=46877
whether or not to allow "complex" ref/out args.
(Validate): update for that
* generator/Signal.cs: set AllowComplexRefs false on the params.
(Validate): fix the messages
(GenCallback, GenEventHandler): properly handle ref/out args, by
manually pointerifying them (except for boxed args, which are
already pointers).
* glib/Marshaller.cs (StructureToPtrAlloc): Rename from
PtrToStructureAlloc, since it wraps Marshal.StructureToPtr.
svn path=/trunk/gtk-sharp/; revision=46773
* generator/Signal.cs : Dispose the values passed to
g_signal_chain_from_overriden in base VM invocations. [Fixes#73522]
svn path=/trunk/gtk-sharp/; revision=42312
* generator/Makefile.am : remove source file.
* generator/Signal.cs : generate marshaling callbacks and use new
GLib.Signal marshaling class for events.
* generator/SignalHandler.cs : kill. byebye SignalCallback subclasses.
* glib/Makefile.am : update source files.
* glib/GLibSharp.voidObjectIntPtrSignal.cs : kill.
* glib/Object.cs : mark the old Before/After props Obsolete. Use
GLib.Signal for the notify prop methods.
* glib/Signal.cs : new signal marshaling class. It manages all the
ConnectBefore/After stuff internally and connects itself to the native
object using GCHandles and DestroyNotify lifecycle management.
* glib/SignalCallback.cs : mark Obsolete.
[Fixes#72018 and #69847]
svn path=/trunk/gtk-sharp/; revision=40007
* generator/ReturnValue.cs : use ToNativeReturnType for ToNativeType
instead of MarshalType.
* generator/Signal.cs : deal with boxed return values. beef up return
handling in the default handler generation code.
* generator/SignalHandler.cs : use ToNative return types for native
callbacks. Remove redundant casting/conversion in callback impl.
[Fixes#71899]
svn path=/trunk/gtk-sharp/; revision=39724
* generator/*.cs : refactoring of Parameters class. Added IEnumerable
to Parameters and gracefully handle elem == null instead of special
casing parms == null all over the place. Parameter logic is now Count
driven. [Fixes#71750]
svn path=/trunk/gtk-sharp/; revision=39594
resulted in there being 2 blank lines before every property).
* generator/Signal.cs (Generate): s/Write/WriteLine/ to fix a
weirdly-formatted if statement in the generated code.
svn path=/trunk/gtk-sharp/; revision=39584
* generator/CodeGenerator.cs:
* generator/ManagedCallString.cs:
* generator/Property.cs: Remove unused vars
* generator/Method.cs (GetHashCode): have to implement this since
we're overriding Equals.
* generator/CallbackGen.cs: print a message when generating a
broken struct-returning callback. (Currently affects
GtkSharp.TextSegSplitFuncNative and
GtkSharp.TextSegCleanupFuncNative)
* gdk/glue/device.c:
* gdk/glue/dragcontext.c: Add missing prototypes
* gtk/Gtk.metadata: Mark SeparatorToolItem.Draw "new". Re-rename
CheckMenuItem.Toggled to EmitToggled rather than Toggle, since
that's a better description of what it does.
* gtk/CheckMenuItem.custom: implement a "Toggle" method that does
what the documentation claims it does.
* gtk/NodeStore.cs: remove unused var
* gnome/Gnome.metadata: mark DateEdit.Flags, Dialog.Default, and
PropertyBox.State "new". Hide GnomePixmapEntry.GnomeEntry and
GnomePixmapEntry.GtkEntry since they do exactly the same thing as
the methods of the same names inherited from GnomeFileEntry.
* gnome/glue/canvas-proxy.c:
* gnome/glue/canvas-proxy.h:
* gnome/glue/canvas-proxy-marshal.c:
* gnome/glue/canvas-proxy-marshal.h:
* gnome/glue/canvas-proxy-marshal.list: Remove unused code
* gnome/glue/Makefile.am (libgnomesharpglue_2_la_SOURCES): update
* panelapplet/PanelApplet.metadata: mark PanelApplet.Flags "new"
* sample/CanvasExample.cs:
* sample/CustomCellRenderer.cs:
* sample/CustomNotebook.cs:
* sample/DrawingSample.cs:
* sample/Fifteen.cs:
* sample/GladeTest.cs:
* sample/GtkDemo/DemoHyperText.cs:
* sample/GtkDemo/DemoPixbuf.cs:
* sample/ScribbleXInput.cs: remove unused vars, use
GLib.Timeout.Add rather than the deprecated Gtk.Timeout.Add
svn path=/trunk/gtk-sharp/; revision=38043
new methods to allow arbitrary setup and teardown code around the
managed call. When passing a type with "complicated" marshalling
requirements as a ref or out param, first assign the value to a
temporary variable (in Setup), then pass the temp as the ref or
out param (in ToString), and then assign the new value back to the
original argument (in Finish).
* generator/Signal.cs:
* generator/SignalHandler.cs: Update to generate correct glue for
signals with "ref" or "out" params. (#70566)
* generator/VirtualMethod.cs: Update for ManagedCallString change
* generator/IGeneratable.cs: add comments explaining what each
member does
* gtk/Gtk.metadata: mark Editable.InsertText's "position" arg
* pass-by-ref
* sample/Size.cs: connect to the SizeRequested event and override
it, to test/demo the changes
svn path=/trunk/gtk-sharp/; revision=37854