2002-05-23 23:43:25 +00:00
|
|
|
// GtkSharp.Generation.Ctor.cs - The Constructor Generation Class.
|
|
|
|
//
|
|
|
|
// Author: Mike Kestner <mkestner@speakeasy.net>
|
|
|
|
//
|
|
|
|
// (c) 2001-2002 Mike Kestner
|
|
|
|
|
|
|
|
namespace GtkSharp.Generation {
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Collections;
|
|
|
|
using System.IO;
|
|
|
|
using System.Xml;
|
|
|
|
|
|
|
|
public class Ctor {
|
|
|
|
|
2002-06-21 20:25:43 +00:00
|
|
|
private string libname;
|
2002-05-23 23:43:25 +00:00
|
|
|
private XmlElement elem;
|
|
|
|
private Parameters parms;
|
2003-12-03 23:08:14 +00:00
|
|
|
private Signature sig = null;
|
|
|
|
private ImportSignature isig = null;
|
|
|
|
private MethodBody body = null;
|
2002-06-24 22:04:10 +00:00
|
|
|
private bool preferred;
|
2004-02-02 20:19:43 +00:00
|
|
|
private string clashName = null;
|
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
|
|
|
private ClassBase container_type;
|
2002-07-30 23:02:12 +00:00
|
|
|
private bool force_static;
|
2004-05-07 13:42:59 +00:00
|
|
|
private bool needs_chaining = false;
|
2002-05-23 23:43:25 +00:00
|
|
|
|
2002-06-24 22:04:10 +00:00
|
|
|
public bool Preferred {
|
|
|
|
get { return preferred; }
|
|
|
|
set { preferred = value; }
|
|
|
|
}
|
2002-07-30 23:02:12 +00:00
|
|
|
|
|
|
|
public bool ForceStatic {
|
|
|
|
get { return force_static; }
|
|
|
|
set { force_static = value; }
|
|
|
|
}
|
|
|
|
|
2003-04-06 09:21:15 +00:00
|
|
|
public Parameters Params {
|
|
|
|
get { return parms; }
|
|
|
|
}
|
|
|
|
|
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
|
|
|
public Ctor (string libname, XmlElement elem, ClassBase container_type) {
|
2002-06-21 20:25:43 +00:00
|
|
|
this.libname = libname;
|
2002-05-23 23:43:25 +00:00
|
|
|
this.elem = elem;
|
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
|
|
|
XmlElement parms_elem = elem ["parameters"];
|
|
|
|
if (parms_elem != null)
|
2003-06-14 17:30:32 +00:00
|
|
|
parms = new Parameters (parms_elem, container_type.NS);
|
2002-06-24 22:04:10 +00:00
|
|
|
if (elem.HasAttribute ("preferred"))
|
|
|
|
preferred = true;
|
2004-05-07 13:42:59 +00:00
|
|
|
if (container_type is ObjectGen)
|
|
|
|
needs_chaining = true;
|
2002-05-23 23:43:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public bool Validate ()
|
|
|
|
{
|
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
|
|
|
if (parms != null) {
|
|
|
|
if (!parms.Validate ()) {
|
2004-01-22 11:27:29 +00:00
|
|
|
Console.Write("in ctor ");
|
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
|
|
|
Statistics.ThrottledCount++;
|
|
|
|
return false;
|
|
|
|
}
|
2002-05-23 23:43:25 +00:00
|
|
|
}
|
2003-12-03 23:08:14 +00:00
|
|
|
sig = new Signature (parms);
|
|
|
|
isig = new ImportSignature (parms, container_type.NS);
|
|
|
|
body = new MethodBody (parms, container_type.NS);
|
2002-05-23 23:43:25 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2002-06-24 22:04:10 +00:00
|
|
|
public void InitClashMap (Hashtable clash_map)
|
|
|
|
{
|
2003-12-03 23:08:14 +00:00
|
|
|
if (clash_map.ContainsKey (sig.Types)) {
|
|
|
|
int num = (int) clash_map[sig.Types];
|
|
|
|
clash_map[sig.Types] = ++num;
|
2002-06-24 22:04:10 +00:00
|
|
|
}
|
|
|
|
else
|
2003-12-03 23:08:14 +00:00
|
|
|
clash_map[sig.Types] = 0;
|
2002-06-24 22:04:10 +00:00
|
|
|
}
|
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
|
|
|
|
|
|
|
public void Initialize (Hashtable clash_map)
|
|
|
|
{
|
2003-12-03 23:08:14 +00:00
|
|
|
int clashes = (int) clash_map[sig.Types];
|
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
|
|
|
string cname = elem.GetAttribute("cname");
|
2002-07-30 23:02:12 +00:00
|
|
|
if (force_static || (clashes > 0 && !Preferred)) {
|
2003-12-03 23:08:14 +00:00
|
|
|
string mname = cname.Substring(cname.IndexOf("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
|
|
|
mname = mname.Substring(0,1).ToUpper() + mname.Substring(1);
|
|
|
|
int idx;
|
|
|
|
while ((idx = mname.IndexOf("_")) > 0) {
|
|
|
|
mname = mname.Substring(0, idx) + mname.Substring(idx+1, 1).ToUpper() + mname.Substring(idx+2);
|
|
|
|
}
|
2003-12-03 23:08:14 +00:00
|
|
|
clashName = mname + "(" + sig.ToString () + ")";
|
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
|
|
|
}
|
|
|
|
}
|
2002-06-24 22:04:10 +00:00
|
|
|
|
2003-10-05 00:20:17 +00:00
|
|
|
public void Generate (GenerationInfo gen_info)
|
2002-05-23 23:43:25 +00:00
|
|
|
{
|
2003-10-05 00:20:17 +00:00
|
|
|
StreamWriter sw = gen_info.Writer;
|
2002-05-23 23:43:25 +00:00
|
|
|
|
|
|
|
string cname = elem.GetAttribute("cname");
|
|
|
|
string name = ((XmlElement)elem.ParentNode).GetAttribute("name");
|
2002-06-14 Rachel Hestilow <hestilow@ximian.com>
* glib/GException.cs: Added.
* generator/Ctor.cs, Method.cs: Tag function as unsafe if it throws
an exception. Call parms.HandleException.
* generator/Paramaters.cs: Add property ThrowsException (based
on a trailing GError**). If ThrowsException, mask GError in the
signature, initialize a GError in Initialize, and add new method
HandleException to throw an exception if error != null.
* generator/SymbolTable.cs: Add gdk-pixbuf DLL, and GError type.
* gdk.imaging, gdk.imaging/Makefile.in, gdk.imaging/makefile.win32:
Added.
* configure.in, Makefile, makefile.win32: Build gdk.imaging.
* gtk/Makefile.in, gtk/makefile.win32: Link against gdk.imaging.
* parser/gapi2xml.pl: Support namespace renaming.
* parser/build.pl: Build gdk-pixbuf as gdk.imaging.
svn path=/trunk/gtk-sharp/; revision=5281
2002-06-14 18:27:04 +00:00
|
|
|
string safety;
|
2003-12-03 23:08:14 +00:00
|
|
|
if (body.ThrowsException)
|
2002-06-14 Rachel Hestilow <hestilow@ximian.com>
* glib/GException.cs: Added.
* generator/Ctor.cs, Method.cs: Tag function as unsafe if it throws
an exception. Call parms.HandleException.
* generator/Paramaters.cs: Add property ThrowsException (based
on a trailing GError**). If ThrowsException, mask GError in the
signature, initialize a GError in Initialize, and add new method
HandleException to throw an exception if error != null.
* generator/SymbolTable.cs: Add gdk-pixbuf DLL, and GError type.
* gdk.imaging, gdk.imaging/Makefile.in, gdk.imaging/makefile.win32:
Added.
* configure.in, Makefile, makefile.win32: Build gdk.imaging.
* gtk/Makefile.in, gtk/makefile.win32: Link against gdk.imaging.
* parser/gapi2xml.pl: Support namespace renaming.
* parser/build.pl: Build gdk-pixbuf as gdk.imaging.
svn path=/trunk/gtk-sharp/; revision=5281
2002-06-14 18:27:04 +00:00
|
|
|
safety = "unsafe ";
|
|
|
|
else
|
|
|
|
safety = "";
|
|
|
|
|
2004-05-07 13:42:59 +00:00
|
|
|
SymbolTable table = SymbolTable.Table;
|
|
|
|
|
2002-06-21 20:25:43 +00:00
|
|
|
sw.WriteLine("\t\t[DllImport(\"" + libname + "\")]");
|
2003-12-03 23:08:14 +00:00
|
|
|
sw.WriteLine("\t\tstatic extern " + safety + "IntPtr " + cname + "(" + isig.ToString () + ");");
|
2002-05-23 23:43:25 +00:00
|
|
|
sw.WriteLine();
|
|
|
|
|
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 (clashName != null) {
|
|
|
|
string modifiers = "";
|
|
|
|
Ctor dup = null;
|
|
|
|
ObjectGen parent = (ObjectGen) container_type.Parent;
|
|
|
|
while (dup == null && parent != null) {
|
|
|
|
foreach (Ctor c in parent.Ctors) {
|
|
|
|
if (c.clashName == clashName) {
|
|
|
|
dup = c;
|
|
|
|
modifiers = "new ";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
parent = (ObjectGen) parent.Parent;
|
2002-05-23 23:43:25 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
sw.WriteLine("\t\tpublic static " + safety + modifiers + name + " " + clashName);
|
2002-05-23 23:43:25 +00:00
|
|
|
sw.WriteLine("\t\t{");
|
2002-07-30 23:02:12 +00:00
|
|
|
|
2003-12-03 23:08:14 +00:00
|
|
|
body.Initialize(gen_info, false, false, "");
|
2002-07-30 23:02:12 +00:00
|
|
|
|
|
|
|
sw.Write("\t\t\treturn ");
|
|
|
|
if (container_type is StructBase)
|
|
|
|
sw.Write ("{0}.New (", name);
|
|
|
|
else
|
|
|
|
sw.Write ("new {0} (", name);
|
2003-12-03 23:08:14 +00:00
|
|
|
sw.WriteLine (cname + "(" + body.GetCallString (false) + "));");
|
2002-05-23 23:43:25 +00:00
|
|
|
} else {
|
2004-05-07 13:42:59 +00:00
|
|
|
sw.WriteLine("\t\tpublic {0}{1} ({2}) {3}", safety, name, sig.ToString(), needs_chaining ? ": base (IntPtr.Zero)" : "");
|
2002-05-23 23:43:25 +00:00
|
|
|
sw.WriteLine("\t\t{");
|
2002-07-30 23:02:12 +00:00
|
|
|
|
2004-05-07 13:42:59 +00:00
|
|
|
if (needs_chaining) {
|
|
|
|
sw.WriteLine ("\t\t\tif (GetType () != typeof (" + name + ")) {");
|
|
|
|
|
|
|
|
if (Params == null || Params.Count == 0) {
|
|
|
|
sw.WriteLine ("\t\t\t\tCreateNativeObject (new string [0], new GLib.Value[0]);");
|
|
|
|
sw.WriteLine ("\t\t\t\treturn;");
|
|
|
|
} else {
|
|
|
|
ArrayList names = new ArrayList ();
|
|
|
|
ArrayList values = new ArrayList ();
|
|
|
|
for (int i = 0; i < Params.Count; i++) {
|
|
|
|
Parameter p = Params[i];
|
|
|
|
if (container_type.GetPropertyRecursively (p.StudlyName) != null) {
|
|
|
|
names.Add (p.Name);
|
|
|
|
values.Add (p.Name);
|
|
|
|
} else if (p.PropertyName != String.Empty) {
|
|
|
|
names.Add (p.PropertyName);
|
|
|
|
values.Add (p.Name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (names.Count == Params.Count) {
|
|
|
|
sw.WriteLine ("\t\t\t\tArrayList vals = new ArrayList();");
|
|
|
|
sw.WriteLine ("\t\t\t\tArrayList names = new ArrayList();");
|
|
|
|
for (int i = 0; i < names.Count; i++) {
|
|
|
|
Parameter p = Params [i];
|
|
|
|
string indent = "\t\t\t\t";
|
|
|
|
if (p.NullOk && p.Generatable is ObjectGen) {
|
|
|
|
sw.WriteLine (indent + "if (" + p.Name + " != null) {");
|
|
|
|
indent += "\t";
|
|
|
|
}
|
|
|
|
sw.WriteLine (indent + "names.Add (\"" + names [i] + "\");");
|
|
|
|
sw.Write (indent + "vals.Add (");
|
|
|
|
|
|
|
|
if (table.IsEnum (p.CType))
|
|
|
|
sw.WriteLine ("new GLib.Value (this, \"" + names[i] + "\", new GLib.EnumWrapper ((int)" + values[i] + ", " + (table.IsEnumFlags (p.CType) ? "true" : "false") + ")));");
|
|
|
|
else
|
|
|
|
sw.WriteLine ("new GLib.Value (" + values[i] + "));");
|
|
|
|
|
|
|
|
if (p.NullOk && p.Generatable is ObjectGen)
|
|
|
|
sw.WriteLine ("\t\t\t\t}");
|
|
|
|
}
|
|
|
|
|
|
|
|
sw.WriteLine ("\t\t\t\tCreateNativeObject ((string[])names.ToArray (typeof (string)), (GLib.Value[])vals.ToArray (typeof (GLib.Value)));");
|
|
|
|
sw.WriteLine ("\t\t\t\treturn;");
|
|
|
|
} else
|
|
|
|
sw.WriteLine ("\t\t\t\tthrow new InvalidOperationException (\"Can't override this constructor.\");");
|
|
|
|
}
|
|
|
|
|
|
|
|
sw.WriteLine ("\t\t\t}");
|
|
|
|
}
|
|
|
|
|
2003-12-03 23:08:14 +00:00
|
|
|
body.Initialize(gen_info, false, false, "");
|
|
|
|
sw.WriteLine("\t\t\t{0} = {1}({2});", container_type.AssignToName, cname, body.GetCallString (false));
|
|
|
|
body.HandleException (sw, "");
|
2002-05-23 23:43:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sw.WriteLine("\t\t}");
|
|
|
|
sw.WriteLine();
|
|
|
|
|
|
|
|
Statistics.CtorCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|