2002-01-06 13:33:25 +00:00
|
|
|
// GtkSharp.Generation.ObjectGen.cs - The Object Generatable.
|
|
|
|
//
|
2004-03-18 20:56:32 +00:00
|
|
|
// Author: Mike Kestner <mkestner@ximian.com>
|
2002-01-06 13:33:25 +00:00
|
|
|
//
|
2004-06-25 16:35:15 +00:00
|
|
|
// Copyright (c) 2001-2003 Mike Kestner
|
|
|
|
// Copyright (c) 2003-2004 Novell, Inc.
|
|
|
|
//
|
|
|
|
// 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-01-06 13:33:25 +00:00
|
|
|
|
|
|
|
namespace GtkSharp.Generation {
|
|
|
|
|
|
|
|
using System;
|
2002-02-03 03:44:10 +00:00
|
|
|
using System.Collections;
|
2002-01-06 13:33:25 +00:00
|
|
|
using System.IO;
|
2002-08-19 Rachel Hestilow <hestilow@ximian.com>
* art/Makefile.in (clean): Change to avoid bugging out on generated/CVS.
* glib/ObjectManager.cs: Added. Used to be auto-generated, but
now it can infer names, and relies on per-namespace ObjectManager
classes to inform it of oddly-named classes.
* generator/IGeneratable.cs, GenBase.cs: New "DoGenerate" property.
* generator/*Gen.cs: Honor DoGenerate.
* generator/CodeGenerator.cs: Support including dependency files
which will not be generated.
* generator/ObjectGen.cs: Generate mapping file per-namespace, as one
that calls back to the one in glib. Only generate if the name does
not follow the normal conventions, otherwise, GtkSharp.ObjectManager
can infer the name.
* generator/Parser.cs: Accept 'generate' flag to pass on to the
IGeneratables. Parse a new toplevel element, "symbol", which adds
a type to the SymbolTable (instead of hard-coding it).
* generator/SignalHandler.cs: Do not optimize signal handler creation,
instead creating them in their own namespaces. Do not generate
if the calling Signal told us not to.
* generator/Signal.cs: Do not generate handlers if container's DoGenerate
is false. Adjust to the marshaller name being in a sub-namespace.
* generator/SymbolTable.cs (AddSimpleType, AddManualType): Used
to add simple and manually wrapped types at runtime instead of
compile-time.
(FromNative): Remove hard-coded cases for manually wrapped types, use
a generic case instead.
* api: Added. Move api files and generation targets here.
* source: Added. Move source parsing here.
* generator/makefile: Move actual generation to api/.
* glib/Makefile.in: Remove generated/* target.
* glue/Makefile.am: Fix to include canvas-marshal. Move canvas stuff
to GNOME target.
* gnome/CanvasProxy.cs: Update to work with SignalHandlers being
namespace-specific.
* parser/Metadata.pm: Moved to GAPI/Metadata.pm, renamed, etc.
* parser/gapi2xml.pl: Use GAPI::Metadata.
* parser/makefile: Install scripts, remove source parse build target.
Rename formatXML to gapi_format_xml.
svn path=/trunk/gtk-sharp/; revision=6818
2002-08-20 19:56:18 +00:00
|
|
|
using System.Text;
|
2002-01-06 13:33:25 +00:00
|
|
|
using System.Xml;
|
|
|
|
|
2004-12-26 19:33:34 +00:00
|
|
|
public class ObjectGen : ClassBase {
|
2002-01-06 13:33:25 +00:00
|
|
|
|
2002-07-06 07:08:19 +00:00
|
|
|
private ArrayList strings = new ArrayList();
|
2004-03-18 20:56:32 +00:00
|
|
|
private ArrayList vm_nodes = new ArrayList();
|
2004-11-22 17:52:17 +00:00
|
|
|
private Hashtable childprops = new Hashtable();
|
2003-10-06 18:18:49 +00:00
|
|
|
private static Hashtable dirs = new Hashtable ();
|
2002-05-23 23:43:25 +00:00
|
|
|
|
2002-06-21 20:25:43 +00:00
|
|
|
public ObjectGen (XmlElement ns, XmlElement elem) : base (ns, elem)
|
2002-05-23 23:43:25 +00:00
|
|
|
{
|
2002-01-06 13:33:25 +00:00
|
|
|
foreach (XmlNode node in elem.ChildNodes) {
|
2004-11-22 17:52:17 +00:00
|
|
|
string name;
|
2002-05-23 23:43:25 +00:00
|
|
|
|
2002-06-26 13:10:48 +00:00
|
|
|
if (!(node is XmlElement)) continue;
|
2002-01-06 13:33:25 +00:00
|
|
|
XmlElement member = (XmlElement) node;
|
|
|
|
|
|
|
|
switch (node.Name) {
|
|
|
|
case "field":
|
|
|
|
case "callback":
|
2002-02-19 03:12:47 +00:00
|
|
|
Statistics.IgnoreCount++;
|
2002-01-06 13:33:25 +00:00
|
|
|
break;
|
2002-05-23 23:43:25 +00:00
|
|
|
|
2004-03-18 20:56:32 +00:00
|
|
|
case "virtual_method":
|
2004-03-31 16:34:08 +00:00
|
|
|
Statistics.IgnoreCount++;
|
2004-03-18 20:56:32 +00:00
|
|
|
break;
|
|
|
|
|
2002-07-06 07:08:19 +00:00
|
|
|
case "static-string":
|
|
|
|
strings.Add (node);
|
|
|
|
break;
|
|
|
|
|
2004-11-22 17:52:17 +00:00
|
|
|
case "childprop":
|
|
|
|
name = member.GetAttribute ("name");
|
|
|
|
while (childprops.ContainsKey (name))
|
|
|
|
name += "mangled";
|
|
|
|
childprops.Add (name, new ChildProperty (member, this));
|
|
|
|
break;
|
|
|
|
|
2002-01-06 13:33:25 +00:00
|
|
|
default:
|
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 (!IsNodeNameHandled (node.Name))
|
|
|
|
Console.WriteLine ("Unexpected node " + node.Name + " in " + CName);
|
2002-01-06 13:33:25 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2002-05-23 23:43:25 +00:00
|
|
|
}
|
|
|
|
|
2004-06-01 18:00:09 +00:00
|
|
|
private bool DisableVoidCtor {
|
|
|
|
get {
|
|
|
|
return Elem.HasAttribute ("disable_void_ctor");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-11-09 14:22:39 +00:00
|
|
|
private bool DisableGTypeCtor {
|
|
|
|
get {
|
|
|
|
return Elem.HasAttribute ("disable_gtype_ctor");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-10-06 18:18:49 +00:00
|
|
|
private class DirectoryInfo {
|
|
|
|
public string assembly_name;
|
|
|
|
public Hashtable objects;
|
|
|
|
|
|
|
|
public DirectoryInfo (string assembly_name) {
|
|
|
|
this.assembly_name = assembly_name;
|
|
|
|
objects = new Hashtable ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private static DirectoryInfo GetDirectoryInfo (string dir, string assembly_name)
|
|
|
|
{
|
|
|
|
DirectoryInfo result;
|
|
|
|
|
|
|
|
if (dirs.ContainsKey (dir)) {
|
|
|
|
result = dirs [dir] as DirectoryInfo;
|
|
|
|
if (result.assembly_name != assembly_name) {
|
|
|
|
Console.WriteLine ("Can't put multiple assemblies in one directory.");
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
result = new DirectoryInfo (assembly_name);
|
|
|
|
dirs.Add (dir, result);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2004-12-26 19:33:34 +00:00
|
|
|
public override void Generate (GenerationInfo gen_info)
|
2003-10-05 00:20:17 +00:00
|
|
|
{
|
2005-04-04 16:27:08 +00:00
|
|
|
gen_info.CurrentType = Name;
|
|
|
|
|
2003-10-06 18:18:49 +00:00
|
|
|
DirectoryInfo di = GetDirectoryInfo (gen_info.Dir, gen_info.AssemblyName);
|
|
|
|
|
2003-10-05 00:20:17 +00:00
|
|
|
StreamWriter sw = gen_info.Writer = gen_info.OpenStream (Name);
|
2002-02-15 01:08:57 +00:00
|
|
|
|
2003-10-05 00:20:17 +00:00
|
|
|
sw.WriteLine ("namespace " + NS + " {");
|
|
|
|
sw.WriteLine ();
|
|
|
|
sw.WriteLine ("\tusing System;");
|
2002-05-23 23:43:25 +00:00
|
|
|
sw.WriteLine ("\tusing System.Collections;");
|
|
|
|
sw.WriteLine ("\tusing System.Runtime.InteropServices;");
|
|
|
|
sw.WriteLine ();
|
|
|
|
|
2003-05-19 02:45:17 +00:00
|
|
|
SymbolTable table = SymbolTable.Table;
|
2003-01-05 23:51:37 +00:00
|
|
|
|
2004-11-15 13:56:34 +00:00
|
|
|
sw.WriteLine ("#region Autogenerated code");
|
|
|
|
if (IsDeprecated)
|
2004-10-29 20:33:07 +00:00
|
|
|
sw.WriteLine ("\t[Obsolete]");
|
|
|
|
sw.Write ("\tpublic {0} class " + Name, IsAbstract ? "abstract" : "");
|
2003-05-19 02:45:17 +00:00
|
|
|
string cs_parent = table.GetCSType(Elem.GetAttribute("parent"));
|
2005-03-24 22:47:50 +00:00
|
|
|
if (cs_parent != "") {
|
|
|
|
di.objects.Add (CName, QualifiedName);
|
2002-05-23 23:43:25 +00:00
|
|
|
sw.Write (" : " + cs_parent);
|
2005-03-24 22:47:50 +00:00
|
|
|
}
|
2005-04-11 20:35:56 +00:00
|
|
|
foreach (string iface in interfaces) {
|
|
|
|
if (Parent != null && Parent.Implements (iface))
|
|
|
|
continue;
|
|
|
|
sw.Write (", " + table.GetCSType (iface));
|
|
|
|
}
|
|
|
|
foreach (string iface in managed_interfaces) {
|
|
|
|
if (Parent != null && Parent.Implements (iface))
|
|
|
|
continue;
|
|
|
|
sw.Write (", " + iface);
|
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
|
|
|
}
|
2002-05-23 23:43:25 +00:00
|
|
|
sw.WriteLine (" {");
|
|
|
|
sw.WriteLine ();
|
|
|
|
|
2003-10-05 00:20:17 +00:00
|
|
|
GenCtors (gen_info);
|
|
|
|
GenProperties (gen_info);
|
2004-11-18 20:31:22 +00:00
|
|
|
GenChildProperties (gen_info);
|
2002-06-23 03:38:02 +00:00
|
|
|
|
2003-10-07 22:21:45 +00:00
|
|
|
bool has_sigs = (sigs != null && sigs.Count > 0);
|
2005-04-11 20:35:56 +00:00
|
|
|
if (!has_sigs) {
|
2002-06-23 03:38:02 +00:00
|
|
|
foreach (string iface in interfaces) {
|
2003-05-19 02:45:17 +00:00
|
|
|
ClassBase igen = table.GetClassGen (iface);
|
2003-10-07 22:21:45 +00:00
|
|
|
if (igen != null && igen.Signals != null) {
|
2002-06-23 03:38:02 +00:00
|
|
|
has_sigs = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-16 19:43:04 +00:00
|
|
|
if (has_sigs && Elem.HasAttribute("parent")) {
|
2003-10-05 00:20:17 +00:00
|
|
|
GenSignals (gen_info, null);
|
2002-06-23 03:38:02 +00:00
|
|
|
}
|
|
|
|
|
2004-03-18 20:56:32 +00:00
|
|
|
if (vm_nodes.Count > 0) {
|
|
|
|
if (gen_info.GlueEnabled) {
|
|
|
|
GenVirtualMethods (gen_info);
|
|
|
|
} else {
|
|
|
|
Statistics.VMIgnored = true;
|
|
|
|
Statistics.ThrottledCount += vm_nodes.Count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-10-05 00:20:17 +00:00
|
|
|
GenMethods (gen_info, null, 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
|
|
|
|
2005-04-11 20:35:56 +00:00
|
|
|
if (interfaces.Count != 0) {
|
2002-06-23 03:38:02 +00:00
|
|
|
Hashtable all_methods = new Hashtable ();
|
|
|
|
Hashtable collisions = new Hashtable ();
|
|
|
|
foreach (string iface in interfaces) {
|
2003-05-19 02:45:17 +00:00
|
|
|
ClassBase igen = table.GetClassGen (iface);
|
2002-06-23 03:38:02 +00:00
|
|
|
foreach (Method m in igen.Methods.Values) {
|
|
|
|
if (all_methods.Contains (m.Name))
|
|
|
|
collisions[m.Name] = true;
|
|
|
|
else
|
|
|
|
all_methods[m.Name] = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
foreach (string iface in interfaces) {
|
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 (Parent != null && Parent.Implements (iface))
|
|
|
|
continue;
|
2003-05-19 02:45:17 +00:00
|
|
|
ClassBase igen = table.GetClassGen (iface);
|
2003-10-05 00:20:17 +00:00
|
|
|
igen.GenMethods (gen_info, collisions, this);
|
|
|
|
igen.GenSignals (gen_info, this);
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-07-06 07:08:19 +00:00
|
|
|
foreach (XmlElement str in strings) {
|
|
|
|
sw.Write ("\t\tpublic static string " + str.GetAttribute ("name"));
|
|
|
|
sw.WriteLine (" {\n\t\t\t get { return \"" + str.GetAttribute ("value") + "\"; }\n\t\t}");
|
|
|
|
}
|
2003-01-05 23:51:37 +00:00
|
|
|
|
2005-03-24 22:47:50 +00:00
|
|
|
if (cs_parent != String.Empty && GetExpected (CName) != QualifiedName) {
|
2004-05-18 02:46:17 +00:00
|
|
|
sw.WriteLine ();
|
|
|
|
sw.WriteLine ("\t\tstatic " + Name + " ()");
|
|
|
|
sw.WriteLine ("\t\t{");
|
|
|
|
sw.WriteLine ("\t\t\tGtkSharp." + Studlify (gen_info.AssemblyName) + ".ObjectManager.Initialize ();");
|
|
|
|
sw.WriteLine ("\t\t}");
|
|
|
|
}
|
|
|
|
|
2003-01-05 23:51:37 +00:00
|
|
|
sw.WriteLine ("#endregion");
|
2003-10-05 00:20:17 +00:00
|
|
|
AppendCustom (sw, gen_info.CustomDir);
|
2002-05-23 23:43:25 +00:00
|
|
|
|
2002-01-06 13:33:25 +00:00
|
|
|
sw.WriteLine ("\t}");
|
2003-10-05 00:20:17 +00:00
|
|
|
sw.WriteLine ("}");
|
2002-05-23 23:43:25 +00:00
|
|
|
|
2003-10-05 00:20:17 +00:00
|
|
|
sw.Close ();
|
|
|
|
gen_info.Writer = null;
|
2002-02-19 03:12:47 +00:00
|
|
|
Statistics.ObjectCount++;
|
2002-01-12 02:08:16 +00:00
|
|
|
}
|
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
|
|
|
|
2003-10-05 00:20:17 +00:00
|
|
|
protected override void GenCtors (GenerationInfo gen_info)
|
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("parent"))
|
|
|
|
return;
|
2002-07-26 06:08:52 +00:00
|
|
|
|
2003-10-05 00:20:17 +00:00
|
|
|
gen_info.Writer.WriteLine("\t\t~" + Name + "()");
|
|
|
|
gen_info.Writer.WriteLine("\t\t{");
|
|
|
|
gen_info.Writer.WriteLine("\t\t\tDispose();");
|
|
|
|
gen_info.Writer.WriteLine("\t\t}");
|
|
|
|
gen_info.Writer.WriteLine();
|
2004-11-09 14:22:39 +00:00
|
|
|
if (!DisableGTypeCtor) {
|
|
|
|
gen_info.Writer.WriteLine("\t\t[Obsolete]");
|
|
|
|
gen_info.Writer.WriteLine("\t\tprotected " + Name + "(GLib.GType gtype) : base(gtype) {}");
|
|
|
|
}
|
2003-10-05 00:20:17 +00:00
|
|
|
gen_info.Writer.WriteLine("\t\tpublic " + Name + "(IntPtr raw) : base(raw) {}");
|
2004-06-01 18:00:09 +00:00
|
|
|
if (ctors.Count == 0 && !DisableVoidCtor) {
|
|
|
|
gen_info.Writer.WriteLine();
|
|
|
|
gen_info.Writer.WriteLine("\t\tprotected " + Name + "() : base(IntPtr.Zero)");
|
|
|
|
gen_info.Writer.WriteLine("\t\t{");
|
|
|
|
gen_info.Writer.WriteLine("\t\t\tCreateNativeObject (new string [0], new GLib.Value [0]);");
|
|
|
|
gen_info.Writer.WriteLine("\t\t}");
|
|
|
|
}
|
2003-10-05 00:20:17 +00:00
|
|
|
gen_info.Writer.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
|
|
|
|
2003-10-05 00:20:17 +00:00
|
|
|
base.GenCtors (gen_info);
|
2002-05-23 23:43:25 +00:00
|
|
|
}
|
2002-08-08 04:48:41 +00:00
|
|
|
|
2004-11-22 17:52:17 +00:00
|
|
|
protected void GenChildProperties (GenerationInfo gen_info)
|
|
|
|
{
|
|
|
|
if (childprops.Count == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
StreamWriter sw = gen_info.Writer;
|
|
|
|
|
2005-02-15 21:52:21 +00:00
|
|
|
ObjectGen child_ancestor = Parent as ObjectGen;
|
|
|
|
while (child_ancestor.CName != "GtkContainer" &&
|
|
|
|
child_ancestor.childprops.Count == 0)
|
|
|
|
child_ancestor = child_ancestor.Parent as ObjectGen;
|
|
|
|
|
|
|
|
sw.WriteLine ("\t\tpublic class " + Name + "Child : " + child_ancestor.NS + "." + child_ancestor.Name + "." + child_ancestor.Name + "Child {");
|
2005-01-13 14:54:22 +00:00
|
|
|
sw.WriteLine ("\t\t\tprotected internal " + Name + "Child (Gtk.Container parent, Gtk.Widget child) : base (parent, child) {}");
|
2004-11-22 17:52:17 +00:00
|
|
|
sw.WriteLine ("");
|
|
|
|
|
|
|
|
foreach (ChildProperty prop in childprops.Values) {
|
|
|
|
if (prop.Validate ())
|
|
|
|
prop.Generate (gen_info, "\t\t\t");
|
|
|
|
else
|
|
|
|
Console.WriteLine("in Object " + QualifiedName);
|
|
|
|
}
|
|
|
|
|
|
|
|
sw.WriteLine ("\t\t}");
|
|
|
|
sw.WriteLine ("");
|
|
|
|
|
|
|
|
sw.WriteLine ("\t\tpublic override Gtk.Container.ContainerChild this [Gtk.Widget child] {");
|
|
|
|
sw.WriteLine ("\t\t\tget {");
|
|
|
|
sw.WriteLine ("\t\t\t\treturn new " + Name + "Child (this, child);");
|
|
|
|
sw.WriteLine ("\t\t\t}");
|
|
|
|
sw.WriteLine ("\t\t}");
|
|
|
|
sw.WriteLine ("");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2004-03-18 20:56:32 +00:00
|
|
|
private void GenVMGlue (GenerationInfo gen_info, XmlElement elem)
|
|
|
|
{
|
|
|
|
StreamWriter sw = gen_info.GlueWriter;
|
|
|
|
|
|
|
|
string vm_name = elem.GetAttribute ("cname");
|
|
|
|
string method = gen_info.GluelibName + "_" + NS + Name + "_override_" + vm_name;
|
|
|
|
sw.WriteLine ();
|
|
|
|
sw.WriteLine ("void " + method + " (GType type, gpointer cb);");
|
|
|
|
sw.WriteLine ();
|
|
|
|
sw.WriteLine ("void");
|
|
|
|
sw.WriteLine (method + " (GType type, gpointer cb)");
|
|
|
|
sw.WriteLine ("{");
|
|
|
|
sw.WriteLine ("\t{0} *klass = ({0} *) g_type_class_peek (type);", NS + Name + "Class");
|
|
|
|
sw.WriteLine ("\tklass->" + vm_name + " = cb;");
|
|
|
|
sw.WriteLine ("}");
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool vmhdrs_needed = true;
|
|
|
|
|
|
|
|
private void GenVirtualMethods (GenerationInfo gen_info)
|
|
|
|
{
|
|
|
|
if (vmhdrs_needed) {
|
|
|
|
gen_info.GlueWriter.WriteLine ("#include <glib-object.h>");
|
|
|
|
gen_info.GlueWriter.WriteLine ("#include \"vmglueheaders.h\"");
|
|
|
|
gen_info.GlueWriter.WriteLine ();
|
|
|
|
vmhdrs_needed = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach (XmlElement elem in vm_nodes) {
|
|
|
|
GenVMGlue (gen_info, elem);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-08-19 Rachel Hestilow <hestilow@ximian.com>
* art/Makefile.in (clean): Change to avoid bugging out on generated/CVS.
* glib/ObjectManager.cs: Added. Used to be auto-generated, but
now it can infer names, and relies on per-namespace ObjectManager
classes to inform it of oddly-named classes.
* generator/IGeneratable.cs, GenBase.cs: New "DoGenerate" property.
* generator/*Gen.cs: Honor DoGenerate.
* generator/CodeGenerator.cs: Support including dependency files
which will not be generated.
* generator/ObjectGen.cs: Generate mapping file per-namespace, as one
that calls back to the one in glib. Only generate if the name does
not follow the normal conventions, otherwise, GtkSharp.ObjectManager
can infer the name.
* generator/Parser.cs: Accept 'generate' flag to pass on to the
IGeneratables. Parse a new toplevel element, "symbol", which adds
a type to the SymbolTable (instead of hard-coding it).
* generator/SignalHandler.cs: Do not optimize signal handler creation,
instead creating them in their own namespaces. Do not generate
if the calling Signal told us not to.
* generator/Signal.cs: Do not generate handlers if container's DoGenerate
is false. Adjust to the marshaller name being in a sub-namespace.
* generator/SymbolTable.cs (AddSimpleType, AddManualType): Used
to add simple and manually wrapped types at runtime instead of
compile-time.
(FromNative): Remove hard-coded cases for manually wrapped types, use
a generic case instead.
* api: Added. Move api files and generation targets here.
* source: Added. Move source parsing here.
* generator/makefile: Move actual generation to api/.
* glib/Makefile.in: Remove generated/* target.
* glue/Makefile.am: Fix to include canvas-marshal. Move canvas stuff
to GNOME target.
* gnome/CanvasProxy.cs: Update to work with SignalHandlers being
namespace-specific.
* parser/Metadata.pm: Moved to GAPI/Metadata.pm, renamed, etc.
* parser/gapi2xml.pl: Use GAPI::Metadata.
* parser/makefile: Install scripts, remove source parse build target.
Rename formatXML to gapi_format_xml.
svn path=/trunk/gtk-sharp/; revision=6818
2002-08-20 19:56:18 +00:00
|
|
|
/* Keep this in sync with the one in glib/ObjectManager.cs */
|
2003-10-06 18:18:49 +00:00
|
|
|
private static string GetExpected (string cname)
|
2002-08-08 04:48:41 +00:00
|
|
|
{
|
2005-03-24 22:47:50 +00:00
|
|
|
for (int i = 1; i < cname.Length; i++) {
|
|
|
|
if (Char.IsUpper (cname[i])) {
|
|
|
|
if (i == 1 && cname[0] == 'G')
|
|
|
|
return "GLib." + cname.Substring (1);
|
|
|
|
else
|
|
|
|
return cname.Substring (0, i) + "." + cname.Substring (i);
|
2002-08-19 Rachel Hestilow <hestilow@ximian.com>
* art/Makefile.in (clean): Change to avoid bugging out on generated/CVS.
* glib/ObjectManager.cs: Added. Used to be auto-generated, but
now it can infer names, and relies on per-namespace ObjectManager
classes to inform it of oddly-named classes.
* generator/IGeneratable.cs, GenBase.cs: New "DoGenerate" property.
* generator/*Gen.cs: Honor DoGenerate.
* generator/CodeGenerator.cs: Support including dependency files
which will not be generated.
* generator/ObjectGen.cs: Generate mapping file per-namespace, as one
that calls back to the one in glib. Only generate if the name does
not follow the normal conventions, otherwise, GtkSharp.ObjectManager
can infer the name.
* generator/Parser.cs: Accept 'generate' flag to pass on to the
IGeneratables. Parse a new toplevel element, "symbol", which adds
a type to the SymbolTable (instead of hard-coding it).
* generator/SignalHandler.cs: Do not optimize signal handler creation,
instead creating them in their own namespaces. Do not generate
if the calling Signal told us not to.
* generator/Signal.cs: Do not generate handlers if container's DoGenerate
is false. Adjust to the marshaller name being in a sub-namespace.
* generator/SymbolTable.cs (AddSimpleType, AddManualType): Used
to add simple and manually wrapped types at runtime instead of
compile-time.
(FromNative): Remove hard-coded cases for manually wrapped types, use
a generic case instead.
* api: Added. Move api files and generation targets here.
* source: Added. Move source parsing here.
* generator/makefile: Move actual generation to api/.
* glib/Makefile.in: Remove generated/* target.
* glue/Makefile.am: Fix to include canvas-marshal. Move canvas stuff
to GNOME target.
* gnome/CanvasProxy.cs: Update to work with SignalHandlers being
namespace-specific.
* parser/Metadata.pm: Moved to GAPI/Metadata.pm, renamed, etc.
* parser/gapi2xml.pl: Use GAPI::Metadata.
* parser/makefile: Install scripts, remove source parse build target.
Rename formatXML to gapi_format_xml.
svn path=/trunk/gtk-sharp/; revision=6818
2002-08-20 19:56:18 +00:00
|
|
|
}
|
2002-08-08 04:48:41 +00:00
|
|
|
}
|
2004-02-07 23:24:15 +00:00
|
|
|
|
2005-03-24 22:47:50 +00:00
|
|
|
throw new ArgumentException ("cname doesn't follow the NamespaceType capitalization style: " + cname);
|
2002-08-19 Rachel Hestilow <hestilow@ximian.com>
* art/Makefile.in (clean): Change to avoid bugging out on generated/CVS.
* glib/ObjectManager.cs: Added. Used to be auto-generated, but
now it can infer names, and relies on per-namespace ObjectManager
classes to inform it of oddly-named classes.
* generator/IGeneratable.cs, GenBase.cs: New "DoGenerate" property.
* generator/*Gen.cs: Honor DoGenerate.
* generator/CodeGenerator.cs: Support including dependency files
which will not be generated.
* generator/ObjectGen.cs: Generate mapping file per-namespace, as one
that calls back to the one in glib. Only generate if the name does
not follow the normal conventions, otherwise, GtkSharp.ObjectManager
can infer the name.
* generator/Parser.cs: Accept 'generate' flag to pass on to the
IGeneratables. Parse a new toplevel element, "symbol", which adds
a type to the SymbolTable (instead of hard-coding it).
* generator/SignalHandler.cs: Do not optimize signal handler creation,
instead creating them in their own namespaces. Do not generate
if the calling Signal told us not to.
* generator/Signal.cs: Do not generate handlers if container's DoGenerate
is false. Adjust to the marshaller name being in a sub-namespace.
* generator/SymbolTable.cs (AddSimpleType, AddManualType): Used
to add simple and manually wrapped types at runtime instead of
compile-time.
(FromNative): Remove hard-coded cases for manually wrapped types, use
a generic case instead.
* api: Added. Move api files and generation targets here.
* source: Added. Move source parsing here.
* generator/makefile: Move actual generation to api/.
* glib/Makefile.in: Remove generated/* target.
* glue/Makefile.am: Fix to include canvas-marshal. Move canvas stuff
to GNOME target.
* gnome/CanvasProxy.cs: Update to work with SignalHandlers being
namespace-specific.
* parser/Metadata.pm: Moved to GAPI/Metadata.pm, renamed, etc.
* parser/gapi2xml.pl: Use GAPI::Metadata.
* parser/makefile: Install scripts, remove source parse build target.
Rename formatXML to gapi_format_xml.
svn path=/trunk/gtk-sharp/; revision=6818
2002-08-20 19:56:18 +00:00
|
|
|
}
|
2002-08-08 04:48:41 +00:00
|
|
|
|
2004-02-07 23:24:15 +00:00
|
|
|
private static bool NeedsMap (Hashtable objs, string assembly_name)
|
2002-08-19 Rachel Hestilow <hestilow@ximian.com>
* art/Makefile.in (clean): Change to avoid bugging out on generated/CVS.
* glib/ObjectManager.cs: Added. Used to be auto-generated, but
now it can infer names, and relies on per-namespace ObjectManager
classes to inform it of oddly-named classes.
* generator/IGeneratable.cs, GenBase.cs: New "DoGenerate" property.
* generator/*Gen.cs: Honor DoGenerate.
* generator/CodeGenerator.cs: Support including dependency files
which will not be generated.
* generator/ObjectGen.cs: Generate mapping file per-namespace, as one
that calls back to the one in glib. Only generate if the name does
not follow the normal conventions, otherwise, GtkSharp.ObjectManager
can infer the name.
* generator/Parser.cs: Accept 'generate' flag to pass on to the
IGeneratables. Parse a new toplevel element, "symbol", which adds
a type to the SymbolTable (instead of hard-coding it).
* generator/SignalHandler.cs: Do not optimize signal handler creation,
instead creating them in their own namespaces. Do not generate
if the calling Signal told us not to.
* generator/Signal.cs: Do not generate handlers if container's DoGenerate
is false. Adjust to the marshaller name being in a sub-namespace.
* generator/SymbolTable.cs (AddSimpleType, AddManualType): Used
to add simple and manually wrapped types at runtime instead of
compile-time.
(FromNative): Remove hard-coded cases for manually wrapped types, use
a generic case instead.
* api: Added. Move api files and generation targets here.
* source: Added. Move source parsing here.
* generator/makefile: Move actual generation to api/.
* glib/Makefile.in: Remove generated/* target.
* glue/Makefile.am: Fix to include canvas-marshal. Move canvas stuff
to GNOME target.
* gnome/CanvasProxy.cs: Update to work with SignalHandlers being
namespace-specific.
* parser/Metadata.pm: Moved to GAPI/Metadata.pm, renamed, etc.
* parser/gapi2xml.pl: Use GAPI::Metadata.
* parser/makefile: Install scripts, remove source parse build target.
Rename formatXML to gapi_format_xml.
svn path=/trunk/gtk-sharp/; revision=6818
2002-08-20 19:56:18 +00:00
|
|
|
{
|
2003-10-06 18:18:49 +00:00
|
|
|
foreach (string key in objs.Keys)
|
2005-03-24 22:47:50 +00:00
|
|
|
if (GetExpected (key) != ((string) objs[key]))
|
2003-10-06 18:18:49 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2002-08-08 04:48:41 +00:00
|
|
|
|
2003-10-06 18:18:49 +00:00
|
|
|
private static string Studlify (string name)
|
|
|
|
{
|
|
|
|
string result = "";
|
|
|
|
|
|
|
|
string[] subs = name.Split ('-');
|
|
|
|
foreach (string sub in subs)
|
|
|
|
result += Char.ToUpper (sub[0]) + sub.Substring (1);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void GenerateMappers ()
|
|
|
|
{
|
|
|
|
foreach (string dir in dirs.Keys) {
|
|
|
|
|
|
|
|
DirectoryInfo di = dirs[dir] as DirectoryInfo;
|
|
|
|
|
2004-02-07 23:24:15 +00:00
|
|
|
if (!NeedsMap (di.objects, di.assembly_name))
|
2002-08-19 Rachel Hestilow <hestilow@ximian.com>
* art/Makefile.in (clean): Change to avoid bugging out on generated/CVS.
* glib/ObjectManager.cs: Added. Used to be auto-generated, but
now it can infer names, and relies on per-namespace ObjectManager
classes to inform it of oddly-named classes.
* generator/IGeneratable.cs, GenBase.cs: New "DoGenerate" property.
* generator/*Gen.cs: Honor DoGenerate.
* generator/CodeGenerator.cs: Support including dependency files
which will not be generated.
* generator/ObjectGen.cs: Generate mapping file per-namespace, as one
that calls back to the one in glib. Only generate if the name does
not follow the normal conventions, otherwise, GtkSharp.ObjectManager
can infer the name.
* generator/Parser.cs: Accept 'generate' flag to pass on to the
IGeneratables. Parse a new toplevel element, "symbol", which adds
a type to the SymbolTable (instead of hard-coding it).
* generator/SignalHandler.cs: Do not optimize signal handler creation,
instead creating them in their own namespaces. Do not generate
if the calling Signal told us not to.
* generator/Signal.cs: Do not generate handlers if container's DoGenerate
is false. Adjust to the marshaller name being in a sub-namespace.
* generator/SymbolTable.cs (AddSimpleType, AddManualType): Used
to add simple and manually wrapped types at runtime instead of
compile-time.
(FromNative): Remove hard-coded cases for manually wrapped types, use
a generic case instead.
* api: Added. Move api files and generation targets here.
* source: Added. Move source parsing here.
* generator/makefile: Move actual generation to api/.
* glib/Makefile.in: Remove generated/* target.
* glue/Makefile.am: Fix to include canvas-marshal. Move canvas stuff
to GNOME target.
* gnome/CanvasProxy.cs: Update to work with SignalHandlers being
namespace-specific.
* parser/Metadata.pm: Moved to GAPI/Metadata.pm, renamed, etc.
* parser/gapi2xml.pl: Use GAPI::Metadata.
* parser/makefile: Install scripts, remove source parse build target.
Rename formatXML to gapi_format_xml.
svn path=/trunk/gtk-sharp/; revision=6818
2002-08-20 19:56:18 +00:00
|
|
|
continue;
|
|
|
|
|
2003-10-06 18:18:49 +00:00
|
|
|
GenerationInfo gen_info = new GenerationInfo (dir, di.assembly_name);
|
|
|
|
|
|
|
|
GenerateMapper (di, gen_info);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private static void GenerateMapper (DirectoryInfo dir_info, GenerationInfo gen_info)
|
|
|
|
{
|
|
|
|
StreamWriter sw = gen_info.OpenStream ("ObjectManager");
|
|
|
|
|
|
|
|
sw.WriteLine ("namespace GtkSharp." + Studlify (dir_info.assembly_name) + " {");
|
|
|
|
sw.WriteLine ();
|
|
|
|
sw.WriteLine ("\tpublic class ObjectManager {");
|
|
|
|
sw.WriteLine ();
|
2004-05-18 02:46:17 +00:00
|
|
|
sw.WriteLine ("\t\tstatic bool initialized = false;");
|
2003-10-06 18:18:49 +00:00
|
|
|
sw.WriteLine ("\t\t// Call this method from the appropriate module init function.");
|
|
|
|
sw.WriteLine ("\t\tpublic static void Initialize ()");
|
|
|
|
sw.WriteLine ("\t\t{");
|
2004-05-18 02:46:17 +00:00
|
|
|
sw.WriteLine ("\t\t\tif (initialized)");
|
|
|
|
sw.WriteLine ("\t\t\t\treturn;");
|
|
|
|
sw.WriteLine ("");
|
|
|
|
sw.WriteLine ("\t\t\tinitialized = true;");
|
2002-08-19 Rachel Hestilow <hestilow@ximian.com>
* art/Makefile.in (clean): Change to avoid bugging out on generated/CVS.
* glib/ObjectManager.cs: Added. Used to be auto-generated, but
now it can infer names, and relies on per-namespace ObjectManager
classes to inform it of oddly-named classes.
* generator/IGeneratable.cs, GenBase.cs: New "DoGenerate" property.
* generator/*Gen.cs: Honor DoGenerate.
* generator/CodeGenerator.cs: Support including dependency files
which will not be generated.
* generator/ObjectGen.cs: Generate mapping file per-namespace, as one
that calls back to the one in glib. Only generate if the name does
not follow the normal conventions, otherwise, GtkSharp.ObjectManager
can infer the name.
* generator/Parser.cs: Accept 'generate' flag to pass on to the
IGeneratables. Parse a new toplevel element, "symbol", which adds
a type to the SymbolTable (instead of hard-coding it).
* generator/SignalHandler.cs: Do not optimize signal handler creation,
instead creating them in their own namespaces. Do not generate
if the calling Signal told us not to.
* generator/Signal.cs: Do not generate handlers if container's DoGenerate
is false. Adjust to the marshaller name being in a sub-namespace.
* generator/SymbolTable.cs (AddSimpleType, AddManualType): Used
to add simple and manually wrapped types at runtime instead of
compile-time.
(FromNative): Remove hard-coded cases for manually wrapped types, use
a generic case instead.
* api: Added. Move api files and generation targets here.
* source: Added. Move source parsing here.
* generator/makefile: Move actual generation to api/.
* glib/Makefile.in: Remove generated/* target.
* glue/Makefile.am: Fix to include canvas-marshal. Move canvas stuff
to GNOME target.
* gnome/CanvasProxy.cs: Update to work with SignalHandlers being
namespace-specific.
* parser/Metadata.pm: Moved to GAPI/Metadata.pm, renamed, etc.
* parser/gapi2xml.pl: Use GAPI::Metadata.
* parser/makefile: Install scripts, remove source parse build target.
Rename formatXML to gapi_format_xml.
svn path=/trunk/gtk-sharp/; revision=6818
2002-08-20 19:56:18 +00:00
|
|
|
|
2004-02-07 23:24:15 +00:00
|
|
|
foreach (string key in dir_info.objects.Keys) {
|
2005-03-24 22:47:50 +00:00
|
|
|
if (GetExpected(key) != ((string) dir_info.objects[key]))
|
|
|
|
sw.WriteLine ("\t\t\tGLib.ObjectManager.RegisterType({0}.GType, typeof ({0}));", dir_info.objects [key]);
|
2004-02-07 23:24:15 +00:00
|
|
|
}
|
2002-08-19 Rachel Hestilow <hestilow@ximian.com>
* art/Makefile.in (clean): Change to avoid bugging out on generated/CVS.
* glib/ObjectManager.cs: Added. Used to be auto-generated, but
now it can infer names, and relies on per-namespace ObjectManager
classes to inform it of oddly-named classes.
* generator/IGeneratable.cs, GenBase.cs: New "DoGenerate" property.
* generator/*Gen.cs: Honor DoGenerate.
* generator/CodeGenerator.cs: Support including dependency files
which will not be generated.
* generator/ObjectGen.cs: Generate mapping file per-namespace, as one
that calls back to the one in glib. Only generate if the name does
not follow the normal conventions, otherwise, GtkSharp.ObjectManager
can infer the name.
* generator/Parser.cs: Accept 'generate' flag to pass on to the
IGeneratables. Parse a new toplevel element, "symbol", which adds
a type to the SymbolTable (instead of hard-coding it).
* generator/SignalHandler.cs: Do not optimize signal handler creation,
instead creating them in their own namespaces. Do not generate
if the calling Signal told us not to.
* generator/Signal.cs: Do not generate handlers if container's DoGenerate
is false. Adjust to the marshaller name being in a sub-namespace.
* generator/SymbolTable.cs (AddSimpleType, AddManualType): Used
to add simple and manually wrapped types at runtime instead of
compile-time.
(FromNative): Remove hard-coded cases for manually wrapped types, use
a generic case instead.
* api: Added. Move api files and generation targets here.
* source: Added. Move source parsing here.
* generator/makefile: Move actual generation to api/.
* glib/Makefile.in: Remove generated/* target.
* glue/Makefile.am: Fix to include canvas-marshal. Move canvas stuff
to GNOME target.
* gnome/CanvasProxy.cs: Update to work with SignalHandlers being
namespace-specific.
* parser/Metadata.pm: Moved to GAPI/Metadata.pm, renamed, etc.
* parser/gapi2xml.pl: Use GAPI::Metadata.
* parser/makefile: Install scripts, remove source parse build target.
Rename formatXML to gapi_format_xml.
svn path=/trunk/gtk-sharp/; revision=6818
2002-08-20 19:56:18 +00:00
|
|
|
|
2003-10-06 18:18:49 +00:00
|
|
|
sw.WriteLine ("\t\t}");
|
|
|
|
sw.WriteLine ("\t}");
|
|
|
|
sw.WriteLine ("}");
|
|
|
|
sw.Close ();
|
2002-08-08 04:48:41 +00:00
|
|
|
}
|
2002-01-06 13:33:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|