2002-05-23 23:43:25 +00:00
// GtkSharp.Generation.Signal.cs - The Signal Generatable.
//
// Author: Mike Kestner <mkestner@speakeasy.net>
//
2004-06-25 16:35:15 +00:00
// Copyright (c) 2001-2003 Mike Kestner
2005-03-28 18:26:00 +00:00
// Copyright (c) 2003-2005 Novell, Inc.
2007-03-06 21:45:51 +00:00
// Copyright (c) 2007 Novell, Inc.
2004-06-25 16:35:15 +00:00
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the 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
// General Public License for more details.
//
// You should have received a copy of the GNU 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-05-23 23:43:25 +00:00
namespace GtkSharp.Generation {
using System ;
using System.Collections ;
using System.IO ;
using System.Xml ;
public class Signal {
2008-11-06 02:23:21 +00:00
bool marshaled ;
string name ;
XmlElement elem ;
ReturnValue retval ;
Parameters parms ;
2009-04-13 17:44:48 +00:00
ObjectBase container_type ;
2002-05-23 23:43:25 +00:00
2009-04-13 17:44:48 +00:00
public Signal ( XmlElement elem , ObjectBase container_type )
2002-05-23 23:43:25 +00:00
{
this . elem = elem ;
2005-01-26 19:17:07 +00:00
name = elem . GetAttribute ( "name" ) ;
2008-11-06 02:23:21 +00:00
marshaled = elem . GetAttribute ( "manual" ) = = "true" ;
2005-01-26 19:17:07 +00:00
retval = new ReturnValue ( elem [ "return-type" ] ) ;
2009-04-13 17:44:48 +00:00
parms = new Parameters ( elem [ "parameters" ] , container_type . ParserVersion = = 1 ? true : false ) ;
2002-07-13 Rachel Hestilow <hestilow@ximian.com>
* parser/Gnome.metadata, Gtk.metadata: More conflict
fixes.
* parser/build.pl: Fully qualify all lib names. (Gtk+ packages
are now LFS-compliant in Debian...)
* parser/gapi2xml.pl: Fix for whitespace in fields, defines,
and docs.
* generator/BoxedGen.cs: Remove extraneous CallByName definition,
add "override" keyword to FromNative.
(Generate): Generate methods after fields.
* generator/ClassBase.cs: Change CallByName, FromNative to virtual.
(.ctor): Ignore "hidden" nodes. Set container on signal.
(GenSignals, GenMethods): Add "implementor" argument for interface
use.
(Get(Method|Signal|Property)Recursively): Rework to correctly
recurse interfaces.
(Implements): Added.
* generator/Ctor.cs (Initialize): Move clash initialization completely
out of Generate, so we can check for collisions.
* generator/Method.cs (GenerateDeclCommon): Check for duplicates,
for "new" keyword.
(Generate): Add "implementor" argument.
* generator/ObjectGen.cs (Generate): Initialize ctor clashes on
this and all parents, before generating.
(Ctors, InitializeCtors): Added.
* generator/Signal.cs: Store the container_type, check for
collisions.
* generator/StructGen.cs: Add "override" keyword to overriden methods.
* gtk/FileSelection.custom (ActionArea): Add "new" keyword.
svn path=/trunk/gtk-sharp/; revision=5782
2002-07-13 20:31:23 +00:00
this . container_type = container_type ;
2002-05-23 23:43:25 +00:00
}
2008-11-06 02:23:21 +00:00
bool Marshaled {
get { return marshaled ; }
}
2002-05-23 23:43:25 +00:00
public string Name {
get {
2002-06-21 Rachel Hestilow <hestilow@ximian.com>
* generator/ClassBase.cs: New base class for classes and interfaces.
* generator/InterfaceGen.cs: Inherit from ClassBase, generate declarations.
* generator/ObjectGen.cs: Move half of this into ClassBase.
* generator/Method.cs: Turn all applicable Get/Set functions into .NET
accessors. Remove redundant == overload and move into Equals, as
it was confusing "!= null".
* generator/Parameters.cs: Alter signature creation to accept "is_set"
option, add support for variable arguments. Add properties "Count",
"IsVarArgs", "VAType".
* generator/Ctor.cs: Fixup for changes in Parameters (indenting,
signature creation).
* generator/Signal.cs: Support generating declarations.
* generator/SymbolTable: Change GetObjectGen to GetClassGen.
* glib/IWrapper.cs: Move "Handle" declaration to here, so
both classes and interfaces can benefit from it.
* glib/Object.cs: Inherit from IWrapper.cs
* parser/Metadata.pm: Support attribute changes on constructors,
methods, signals, and paramater lists.
* parser/gapi2xml.pl: Parse init funcs for interfaces. Ignore "_"
functions here.
* parser/gapi_pp.pl: Remove boxed_type_register check, as it will
be caught in the init funcs.
* parser/Atk.metadata: Added.
* parser/Gtk.metadata: Add all needed signal/method collision
renames. Rename GtkEditable.Editable accessors to IsEditable,
as .NET does not like accessors with the same name as their
declaring type. Tag TreeStore constructor as varargs.
* samples/ButtonApp.cs: s/EmitAdd/Add.
* samples/Menu.cs: s/EmitAdd/Add, s/Activate/Activated.
svn path=/trunk/gtk-sharp/; revision=5394
2002-06-21 17:15:19 +00:00
return name ;
}
set {
name = value ;
2002-05-23 23:43:25 +00:00
}
}
2011-02-20 18:11:08 +00:00
public bool Validate ( LogWriter log )
2002-05-23 23:43:25 +00:00
{
2011-02-20 18:11:08 +00:00
log . Member = Name ;
2005-02-02 21:57:15 +00:00
if ( Name = = "" ) {
2011-02-20 18:11:08 +00:00
log . Warn ( "Nameless signal found. Add name attribute with fixup." ) ;
2002-05-23 23:43:25 +00:00
Statistics . ThrottledCount + + ;
return false ;
2011-02-20 18:11:08 +00:00
} else if ( ! parms . Validate ( log ) | | ! retval . Validate ( log ) ) {
2005-06-30 17:09:39 +00:00
Statistics . ThrottledCount + + ;
2004-11-17 15:57:17 +00:00
return false ;
2005-06-30 17:09:39 +00:00
}
2002-05-23 23:43:25 +00:00
return true ;
}
2002-07-16 23:14:35 +00:00
public void GenerateDecl ( StreamWriter sw )
{
2002-07-13 Rachel Hestilow <hestilow@ximian.com>
* parser/Gnome.metadata, Gtk.metadata: More conflict
fixes.
* parser/build.pl: Fully qualify all lib names. (Gtk+ packages
are now LFS-compliant in Debian...)
* parser/gapi2xml.pl: Fix for whitespace in fields, defines,
and docs.
* generator/BoxedGen.cs: Remove extraneous CallByName definition,
add "override" keyword to FromNative.
(Generate): Generate methods after fields.
* generator/ClassBase.cs: Change CallByName, FromNative to virtual.
(.ctor): Ignore "hidden" nodes. Set container on signal.
(GenSignals, GenMethods): Add "implementor" argument for interface
use.
(Get(Method|Signal|Property)Recursively): Rework to correctly
recurse interfaces.
(Implements): Added.
* generator/Ctor.cs (Initialize): Move clash initialization completely
out of Generate, so we can check for collisions.
* generator/Method.cs (GenerateDeclCommon): Check for duplicates,
for "new" keyword.
(Generate): Add "implementor" argument.
* generator/ObjectGen.cs (Generate): Initialize ctor clashes on
this and all parents, before generating.
(Ctors, InitializeCtors): Added.
* generator/Signal.cs: Store the container_type, check for
collisions.
* generator/StructGen.cs: Add "override" keyword to overriden methods.
* gtk/FileSelection.custom (ActionArea): Add "new" keyword.
svn path=/trunk/gtk-sharp/; revision=5782
2002-07-13 20:31:23 +00:00
if ( elem . HasAttribute ( "new_flag" ) | | ( container_type ! = null & & container_type . GetSignalRecursively ( Name ) ! = null ) )
2002-06-21 Rachel Hestilow <hestilow@ximian.com>
* generator/ClassBase.cs: New base class for classes and interfaces.
* generator/InterfaceGen.cs: Inherit from ClassBase, generate declarations.
* generator/ObjectGen.cs: Move half of this into ClassBase.
* generator/Method.cs: Turn all applicable Get/Set functions into .NET
accessors. Remove redundant == overload and move into Equals, as
it was confusing "!= null".
* generator/Parameters.cs: Alter signature creation to accept "is_set"
option, add support for variable arguments. Add properties "Count",
"IsVarArgs", "VAType".
* generator/Ctor.cs: Fixup for changes in Parameters (indenting,
signature creation).
* generator/Signal.cs: Support generating declarations.
* generator/SymbolTable: Change GetObjectGen to GetClassGen.
* glib/IWrapper.cs: Move "Handle" declaration to here, so
both classes and interfaces can benefit from it.
* glib/Object.cs: Inherit from IWrapper.cs
* parser/Metadata.pm: Support attribute changes on constructors,
methods, signals, and paramater lists.
* parser/gapi2xml.pl: Parse init funcs for interfaces. Ignore "_"
functions here.
* parser/gapi_pp.pl: Remove boxed_type_register check, as it will
be caught in the init funcs.
* parser/Atk.metadata: Added.
* parser/Gtk.metadata: Add all needed signal/method collision
renames. Rename GtkEditable.Editable accessors to IsEditable,
as .NET does not like accessors with the same name as their
declaring type. Tag TreeStore constructor as varargs.
* samples/ButtonApp.cs: s/EmitAdd/Add.
* samples/Menu.cs: s/EmitAdd/Add, s/Activate/Activated.
svn path=/trunk/gtk-sharp/; revision=5394
2002-06-21 17:15:19 +00:00
sw . Write ( "new " ) ;
2002-07-13 Rachel Hestilow <hestilow@ximian.com>
* parser/Gnome.metadata, Gtk.metadata: More conflict
fixes.
* parser/build.pl: Fully qualify all lib names. (Gtk+ packages
are now LFS-compliant in Debian...)
* parser/gapi2xml.pl: Fix for whitespace in fields, defines,
and docs.
* generator/BoxedGen.cs: Remove extraneous CallByName definition,
add "override" keyword to FromNative.
(Generate): Generate methods after fields.
* generator/ClassBase.cs: Change CallByName, FromNative to virtual.
(.ctor): Ignore "hidden" nodes. Set container on signal.
(GenSignals, GenMethods): Add "implementor" argument for interface
use.
(Get(Method|Signal|Property)Recursively): Rework to correctly
recurse interfaces.
(Implements): Added.
* generator/Ctor.cs (Initialize): Move clash initialization completely
out of Generate, so we can check for collisions.
* generator/Method.cs (GenerateDeclCommon): Check for duplicates,
for "new" keyword.
(Generate): Add "implementor" argument.
* generator/ObjectGen.cs (Generate): Initialize ctor clashes on
this and all parents, before generating.
(Ctors, InitializeCtors): Added.
* generator/Signal.cs: Store the container_type, check for
collisions.
* generator/StructGen.cs: Add "override" keyword to overriden methods.
* gtk/FileSelection.custom (ActionArea): Add "new" keyword.
svn path=/trunk/gtk-sharp/; revision=5782
2002-07-13 20:31:23 +00:00
2003-10-06 20:12:09 +00:00
sw . WriteLine ( "\t\tevent " + EventHandlerQualifiedName + " " + Name + ";" ) ;
2002-07-16 23:14:35 +00:00
}
2005-02-02 21:57:15 +00:00
public string CName {
get {
return "\"" + elem . GetAttribute ( "cname" ) + "\"" ;
}
}
2008-11-06 02:23:21 +00:00
string CallbackSig {
get {
string result = "" ;
for ( int i = 0 ; i < parms . Count ; i + + ) {
if ( i > 0 )
result + = ", " ;
Parameter p = parms [ i ] ;
if ( p . PassAs ! = "" & & ! ( p . Generatable is StructBase ) )
result + = p . PassAs + " " ;
result + = ( p . MarshalType + " arg" + i ) ;
}
return result ;
}
}
string CallbackName {
get { return Name + "SignalCallback" ; }
}
string DelegateName {
get { return Name + "SignalDelegate" ; }
}
2003-10-06 20:12:09 +00:00
private string EventArgsName {
get {
2005-02-02 21:57:15 +00:00
if ( IsEventHandler )
2003-10-06 20:12:09 +00:00
return "EventArgs" ;
else
return Name + "Args" ;
}
}
private string EventArgsQualifiedName {
get {
2005-02-02 21:57:15 +00:00
if ( IsEventHandler )
2003-10-06 20:12:09 +00:00
return "System.EventArgs" ;
else
2004-02-10 20:35:40 +00:00
return container_type . NS + "." + Name + "Args" ;
2003-10-06 20:12:09 +00:00
}
}
private string EventHandlerName {
get {
2005-02-02 21:57:15 +00:00
if ( IsEventHandler )
2003-10-06 20:12:09 +00:00
return "EventHandler" ;
2004-02-10 20:35:40 +00:00
else if ( SymbolTable . Table [ container_type . NS + Name + "Handler" ] ! = null )
return Name + "EventHandler" ;
else
2003-10-06 20:12:09 +00:00
return Name + "Handler" ;
}
}
private string EventHandlerQualifiedName {
get {
2005-02-02 21:57:15 +00:00
if ( IsEventHandler )
2003-10-06 20:12:09 +00:00
return "System.EventHandler" ;
else
2004-02-10 20:35:40 +00:00
return container_type . NS + "." + EventHandlerName ;
2003-10-06 20:12:09 +00:00
}
}
2008-04-30 20:15:45 +00:00
private bool IsEventHandler {
2005-02-02 21:57:15 +00:00
get {
2009-04-13 17:44:48 +00:00
return retval . CSType = = "void" & & parms . Count = = 0 ;
2004-01-14 18:05:50 +00:00
}
}
2008-11-06 02:23:21 +00:00
public string GenArgsInitialization ( StreamWriter sw )
{
2009-04-13 17:44:48 +00:00
if ( parms . Count > 0 )
sw . WriteLine ( "\t\t\t\targs.Args = new object[" + parms . Count + "];" ) ;
2008-11-06 02:23:21 +00:00
string finish = "" ;
2009-04-13 17:44:48 +00:00
for ( int idx = 0 ; idx < parms . Count ; idx + + ) {
2008-11-06 02:23:21 +00:00
Parameter p = parms [ idx ] ;
IGeneratable igen = p . Generatable ;
if ( p . PassAs ! = "out" ) {
if ( igen is ManualGen ) {
sw . WriteLine ( "\t\t\t\tif (arg{0} == IntPtr.Zero)" , idx ) ;
2009-04-13 17:44:48 +00:00
sw . WriteLine ( "\t\t\t\t\targs.Args[{0}] = null;" , idx ) ;
2008-11-06 02:23:21 +00:00
sw . WriteLine ( "\t\t\t\telse {" ) ;
2009-04-13 17:44:48 +00:00
sw . WriteLine ( "\t\t\t\t\targs.Args[" + idx + "] = " + p . FromNative ( "arg" + idx ) + ";" ) ;
2008-11-06 02:23:21 +00:00
sw . WriteLine ( "\t\t\t\t}" ) ;
} else
2009-04-13 17:44:48 +00:00
sw . WriteLine ( "\t\t\t\targs.Args[" + idx + "] = " + p . FromNative ( "arg" + idx ) + ";" ) ;
2008-11-06 02:23:21 +00:00
}
2009-08-13 14:46:33 +00:00
if ( ( igen is StructBase | | igen is ByRefGen ) & & p . PassAs ! = "" )
2009-06-08 13:21:01 +00:00
finish + = "\t\t\t\tif (arg" + idx + " != IntPtr.Zero) System.Runtime.InteropServices.Marshal.StructureToPtr (args.Args[" + idx + "], arg" + idx + ", false);\n" ;
2009-08-13 14:46:33 +00:00
else if ( igen is IManualMarshaler & & p . PassAs ! = "" )
finish + = String . Format ( "\t\t\t\targ{0} = {1};\n" , idx , ( igen as IManualMarshaler ) . AllocNative ( "args.Args[" + idx + "]" ) ) ;
2008-11-06 02:23:21 +00:00
else if ( p . PassAs ! = "" )
2009-08-13 14:46:33 +00:00
finish + = "\t\t\t\targ" + idx + " = " + igen . CallByName ( "((" + p . CSType + ")args.Args[" + idx + "])" ) + ";\n" ;
2008-11-06 02:23:21 +00:00
}
return finish ;
}
public void GenArgsCleanup ( StreamWriter sw , string finish )
{
2009-04-13 17:44:48 +00:00
if ( retval . IsVoid & & finish . Length = = 0 )
2008-11-06 02:23:21 +00:00
return ;
sw . WriteLine ( "\n\t\t\ttry {" ) ;
sw . Write ( finish ) ;
2009-04-13 17:44:48 +00:00
if ( ! retval . IsVoid ) {
2008-11-06 02:23:21 +00:00
if ( retval . CSType = = "bool" ) {
sw . WriteLine ( "\t\t\t\tif (args.RetVal == null)" ) ;
sw . WriteLine ( "\t\t\t\t\treturn false;" ) ;
}
2009-08-13 14:46:33 +00:00
sw . WriteLine ( "\t\t\t\treturn {0};" , retval . ToNative ( String . Format ( "(({0}) args.RetVal)" , retval . CSType ) ) ) ;
2008-11-06 02:23:21 +00:00
}
sw . WriteLine ( "\t\t\t} catch (Exception) {" ) ;
sw . WriteLine ( "\t\t\t\tException ex = new Exception (\"args.RetVal or 'out' property unset or set to incorrect type in " + EventHandlerQualifiedName + " callback\");" ) ;
sw . WriteLine ( "\t\t\t\tGLib.ExceptionManager.RaiseUnhandledException (ex, true);" ) ;
sw . WriteLine ( "\t\t\t\t// NOTREACHED: above call doesn't return." ) ;
sw . WriteLine ( "\t\t\t\tthrow ex;" ) ;
sw . WriteLine ( "\t\t\t}" ) ;
}
public void GenCallback ( StreamWriter sw )
{
if ( IsEventHandler )
return ;
2009-04-13 17:44:48 +00:00
string native_signature = "IntPtr inst" ;
if ( parms . Count > 0 )
native_signature + = ", " + CallbackSig ;
native_signature + = ", IntPtr gch" ;
2009-09-03 19:50:53 +00:00
sw . WriteLine ( "\t\t[UnmanagedFunctionPointer (CallingConvention.Cdecl)]" ) ;
2009-04-13 17:44:48 +00:00
sw . WriteLine ( "\t\tdelegate {0} {1} ({2});" , retval . ToNativeType , DelegateName , native_signature ) ;
2008-11-06 02:23:21 +00:00
sw . WriteLine ( ) ;
2009-04-13 17:44:48 +00:00
sw . WriteLine ( "\t\tstatic {0} {1} ({2})" , retval . ToNativeType , CallbackName , native_signature ) ;
2008-11-06 02:23:21 +00:00
sw . WriteLine ( "\t\t{" ) ;
sw . WriteLine ( "\t\t\t{0} args = new {0} ();" , EventArgsQualifiedName ) ;
sw . WriteLine ( "\t\t\ttry {" ) ;
sw . WriteLine ( "\t\t\t\tGLib.Signal sig = ((GCHandle) gch).Target as GLib.Signal;" ) ;
sw . WriteLine ( "\t\t\t\tif (sig == null)" ) ;
sw . WriteLine ( "\t\t\t\t\tthrow new Exception(\"Unknown signal GC handle received \" + gch);" ) ;
sw . WriteLine ( ) ;
string finish = GenArgsInitialization ( sw ) ;
sw . WriteLine ( "\t\t\t\t{0} handler = ({0}) sig.Handler;" , EventHandlerQualifiedName ) ;
2009-04-13 17:44:48 +00:00
sw . WriteLine ( "\t\t\t\thandler (GLib.Object.GetObject (inst), args);" ) ;
2008-11-06 02:23:21 +00:00
sw . WriteLine ( "\t\t\t} catch (Exception e) {" ) ;
sw . WriteLine ( "\t\t\t\tGLib.ExceptionManager.RaiseUnhandledException (e, false);" ) ;
sw . WriteLine ( "\t\t\t}" ) ;
GenArgsCleanup ( sw , finish ) ;
sw . WriteLine ( "\t\t}" ) ;
sw . WriteLine ( ) ;
}
2009-04-13 17:44:48 +00:00
private bool NeedNew ( ObjectBase implementor )
2004-12-21 18:46:42 +00:00
{
return elem . HasAttribute ( "new_flag" ) | |
( container_type ! = null & & container_type . GetSignalRecursively ( Name ) ! = null ) | |
( implementor ! = null & & implementor . GetSignalRecursively ( Name ) ! = null ) ;
}
2003-10-06 20:12:09 +00:00
public void GenEventHandler ( GenerationInfo gen_info )
2002-07-16 23:14:35 +00:00
{
2005-02-02 21:57:15 +00:00
if ( IsEventHandler )
2003-10-06 20:12:09 +00:00
return ;
2002-07-16 23:14:35 +00:00
2003-05-08 04:44:13 +00:00
string ns = container_type . NS ;
2002-07-16 23:14:35 +00:00
2004-02-10 20:35:40 +00:00
StreamWriter sw = gen_info . OpenStream ( EventHandlerName ) ;
2002-07-16 23:14:35 +00:00
2004-02-10 20:35:40 +00:00
sw . WriteLine ( "namespace " + ns + " {" ) ;
2002-07-16 23:14:35 +00:00
sw . WriteLine ( ) ;
sw . WriteLine ( "\tusing System;" ) ;
sw . WriteLine ( ) ;
2003-10-06 20:12:09 +00:00
sw . WriteLine ( "\tpublic delegate void " + EventHandlerName + "(object o, " + EventArgsName + " args);" ) ;
2002-07-16 23:14:35 +00:00
sw . WriteLine ( ) ;
2004-05-05 18:24:04 +00:00
sw . WriteLine ( "\tpublic class " + EventArgsName + " : GLib.SignalArgs {" ) ;
2009-04-13 17:44:48 +00:00
for ( int i = 0 ; i < parms . Count ; i + + ) {
2005-01-26 19:17:07 +00:00
sw . WriteLine ( "\t\tpublic " + parms [ i ] . CSType + " " + parms [ i ] . StudlyName + "{" ) ;
if ( parms [ i ] . PassAs ! = "out" ) {
sw . WriteLine ( "\t\t\tget {" ) ;
2009-11-23 17:19:46 +00:00
if ( SymbolTable . Table . IsInterface ( parms [ i ] . CType ) )
sw . WriteLine ( "\t\t\t\treturn {0}Adapter.GetObject (Args [{1}] as GLib.Object);" , parms [ i ] . CSType , i ) ;
else
sw . WriteLine ( "\t\t\t\treturn ({0}) Args [{1}];" , parms [ i ] . CSType , i ) ;
2005-01-26 19:17:07 +00:00
sw . WriteLine ( "\t\t\t}" ) ;
2002-07-16 23:14:35 +00:00
}
2005-01-26 19:17:07 +00:00
if ( parms [ i ] . PassAs ! = "" ) {
sw . WriteLine ( "\t\t\tset {" ) ;
2009-11-23 17:19:46 +00:00
if ( SymbolTable . Table . IsInterface ( parms [ i ] . CType ) )
sw . WriteLine ( "\t\t\t\tArgs [{0}] = value is {1}Adapter ? (value as {1}Adapter).Implementor : value;" , i , parms [ i ] . CSType ) ;
else
sw . WriteLine ( "\t\t\t\tArgs[" + i + "] = (" + parms [ i ] . CSType + ")value;" ) ;
2005-01-26 19:17:07 +00:00
sw . WriteLine ( "\t\t\t}" ) ;
}
sw . WriteLine ( "\t\t}" ) ;
sw . WriteLine ( ) ;
2002-07-16 23:14:35 +00:00
}
sw . WriteLine ( "\t}" ) ;
sw . WriteLine ( "}" ) ;
sw . Close ( ) ;
}
2009-04-13 17:44:48 +00:00
public void GenEvent ( StreamWriter sw , ObjectBase implementor , string target )
2002-06-24 22:04:10 +00:00
{
2008-04-30 20:15:45 +00:00
string args_type = IsEventHandler ? "" : ", typeof (" + EventArgsQualifiedName + ")" ;
2008-11-06 02:23:21 +00:00
if ( Marshaled ) {
GenCallback ( sw ) ;
args_type = ", new " + DelegateName + "(" + CallbackName + ")" ;
}
2002-07-16 23:14:35 +00:00
2005-02-02 21:57:15 +00:00
sw . WriteLine ( "\t\t[GLib.Signal(" + CName + ")]" ) ;
2002-05-23 23:43:25 +00:00
sw . Write ( "\t\tpublic " ) ;
2004-12-21 18:46:42 +00:00
if ( NeedNew ( implementor ) )
2002-05-23 23:43:25 +00:00
sw . Write ( "new " ) ;
2003-10-06 20:12:09 +00:00
sw . WriteLine ( "event " + EventHandlerQualifiedName + " " + Name + " {" ) ;
2002-05-23 23:43:25 +00:00
sw . WriteLine ( "\t\t\tadd {" ) ;
2011-03-24 23:11:10 +00:00
sw . WriteLine ( "\t\t\t\t{0}.AddSignalHandler ({1}, value{2});" , target , CName , args_type ) ;
2002-05-23 23:43:25 +00:00
sw . WriteLine ( "\t\t\t}" ) ;
sw . WriteLine ( "\t\t\tremove {" ) ;
2011-03-24 23:11:10 +00:00
sw . WriteLine ( "\t\t\t\t{0}.RemoveSignalHandler ({1}, value);" , target , CName ) ;
2002-05-23 23:43:25 +00:00
sw . WriteLine ( "\t\t\t}" ) ;
sw . WriteLine ( "\t\t}" ) ;
sw . WriteLine ( ) ;
2007-10-02 15:57:45 +00:00
}
2009-04-13 17:44:48 +00:00
public void Generate ( GenerationInfo gen_info , ObjectBase implementor )
2007-10-02 15:57:45 +00:00
{
StreamWriter sw = gen_info . Writer ;
if ( implementor = = null )
GenEventHandler ( gen_info ) ;
GenEvent ( sw , implementor , "this" ) ;
2002-05-23 23:43:25 +00:00
Statistics . SignalCount + + ;
}
}
}