2002-01-06 14:33:25 +01:00
|
|
|
// GtkSharp.Generation.ObjectGen.cs - The Object Generatable.
|
|
|
|
//
|
2004-03-18 21:56:32 +01:00
|
|
|
// Author: Mike Kestner <mkestner@ximian.com>
|
2002-01-06 14:33:25 +01:00
|
|
|
//
|
2003-10-06 20:18:49 +02:00
|
|
|
// (c) 2001-2003 Mike Kestner and Ximian Inc.
|
2004-03-18 21:56:32 +01:00
|
|
|
// (c) 2004 Novell, Inc.
|
2002-01-06 14:33:25 +01:00
|
|
|
|
|
|
|
namespace GtkSharp.Generation {
|
|
|
|
|
|
|
|
using System;
|
2002-02-03 04:44:10 +01:00
|
|
|
using System.Collections;
|
2002-01-06 14:33:25 +01: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 21:56:18 +02:00
|
|
|
using System.Text;
|
2002-01-06 14:33:25 +01:00
|
|
|
using System.Xml;
|
|
|
|
|
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 19:15:19 +02:00
|
|
|
public class ObjectGen : ClassBase, IGeneratable {
|
2002-01-06 14:33:25 +01:00
|
|
|
|
2002-07-06 09:08:19 +02:00
|
|
|
private ArrayList strings = new ArrayList();
|
2004-03-18 21:56:32 +01:00
|
|
|
private ArrayList vm_nodes = new ArrayList();
|
2003-10-06 20:18:49 +02:00
|
|
|
private static Hashtable dirs = new Hashtable ();
|
2002-05-24 01:43:25 +02:00
|
|
|
|
2002-06-21 22:25:43 +02:00
|
|
|
public ObjectGen (XmlElement ns, XmlElement elem) : base (ns, elem)
|
2002-05-24 01:43:25 +02:00
|
|
|
{
|
2002-01-06 14:33:25 +01:00
|
|
|
foreach (XmlNode node in elem.ChildNodes) {
|
2002-05-24 01:43:25 +02:00
|
|
|
|
2002-06-26 15:10:48 +02:00
|
|
|
if (!(node is XmlElement)) continue;
|
2002-01-06 14:33:25 +01:00
|
|
|
XmlElement member = (XmlElement) node;
|
|
|
|
|
|
|
|
switch (node.Name) {
|
|
|
|
case "field":
|
|
|
|
case "callback":
|
2002-02-19 04:12:47 +01:00
|
|
|
Statistics.IgnoreCount++;
|
2002-01-06 14:33:25 +01:00
|
|
|
break;
|
2002-05-24 01:43:25 +02:00
|
|
|
|
2004-03-18 21:56:32 +01:00
|
|
|
case "virtual_method":
|
2004-03-31 18:34:08 +02:00
|
|
|
Statistics.IgnoreCount++;
|
2004-03-18 21:56:32 +01:00
|
|
|
break;
|
|
|
|
|
2002-07-06 09:08:19 +02:00
|
|
|
case "static-string":
|
|
|
|
strings.Add (node);
|
|
|
|
break;
|
|
|
|
|
2002-01-06 14:33:25 +01: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 19:15:19 +02:00
|
|
|
if (!IsNodeNameHandled (node.Name))
|
|
|
|
Console.WriteLine ("Unexpected node " + node.Name + " in " + CName);
|
2002-01-06 14:33:25 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2002-05-24 01:43:25 +02:00
|
|
|
}
|
|
|
|
|
2004-06-01 20:00:09 +02:00
|
|
|
private bool DisableVoidCtor {
|
|
|
|
get {
|
|
|
|
return Elem.HasAttribute ("disable_void_ctor");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-10-06 20:18:49 +02: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;
|
|
|
|
}
|
|
|
|
|
2002-05-24 01:43:25 +02:00
|
|
|
public void Generate ()
|
|
|
|
{
|
2003-10-05 02:20:17 +02:00
|
|
|
GenerationInfo gen_info = new GenerationInfo (NSElem);
|
|
|
|
Generate (gen_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Generate (GenerationInfo gen_info)
|
|
|
|
{
|
2003-10-06 20:18:49 +02:00
|
|
|
DirectoryInfo di = GetDirectoryInfo (gen_info.Dir, gen_info.AssemblyName);
|
|
|
|
di.objects.Add (CName, QualifiedName);
|
|
|
|
|
2003-10-05 02:20:17 +02:00
|
|
|
StreamWriter sw = gen_info.Writer = gen_info.OpenStream (Name);
|
2002-02-15 02:08:57 +01:00
|
|
|
|
2003-10-05 02:20:17 +02:00
|
|
|
sw.WriteLine ("namespace " + NS + " {");
|
|
|
|
sw.WriteLine ();
|
|
|
|
sw.WriteLine ("\tusing System;");
|
2002-05-24 01:43:25 +02:00
|
|
|
sw.WriteLine ("\tusing System.Collections;");
|
|
|
|
sw.WriteLine ("\tusing System.Runtime.InteropServices;");
|
|
|
|
sw.WriteLine ();
|
|
|
|
|
2003-05-19 04:45:17 +02:00
|
|
|
SymbolTable table = SymbolTable.Table;
|
2003-01-06 00:51:37 +01:00
|
|
|
|
|
|
|
sw.WriteLine ("#region Autogenerated code");
|
2002-05-24 01:43:25 +02:00
|
|
|
sw.Write ("\tpublic class " + Name);
|
2003-05-19 04:45:17 +02:00
|
|
|
string cs_parent = table.GetCSType(Elem.GetAttribute("parent"));
|
2002-05-24 01:43:25 +02:00
|
|
|
if (cs_parent != "")
|
|
|
|
sw.Write (" : " + cs_parent);
|
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 19:15:19 +02:00
|
|
|
if (interfaces != null) {
|
|
|
|
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 22:31:23 +02:00
|
|
|
if (Parent != null && Parent.Implements (iface))
|
|
|
|
continue;
|
2003-05-19 04:45:17 +02:00
|
|
|
sw.Write (", " + table.GetCSType (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 19:15:19 +02:00
|
|
|
}
|
|
|
|
}
|
2002-05-24 01:43:25 +02:00
|
|
|
sw.WriteLine (" {");
|
|
|
|
sw.WriteLine ();
|
|
|
|
|
2003-10-05 02:20:17 +02:00
|
|
|
GenCtors (gen_info);
|
|
|
|
GenProperties (gen_info);
|
2002-06-23 05:38:02 +02:00
|
|
|
|
2003-10-08 00:21:45 +02:00
|
|
|
bool has_sigs = (sigs != null && sigs.Count > 0);
|
|
|
|
if (!has_sigs && interfaces != null) {
|
2002-06-23 05:38:02 +02:00
|
|
|
foreach (string iface in interfaces) {
|
2003-05-19 04:45:17 +02:00
|
|
|
ClassBase igen = table.GetClassGen (iface);
|
2003-10-08 00:21:45 +02:00
|
|
|
if (igen != null && igen.Signals != null) {
|
2002-06-23 05:38:02 +02:00
|
|
|
has_sigs = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-16 20:43:04 +01:00
|
|
|
if (has_sigs && Elem.HasAttribute("parent")) {
|
2003-10-05 02:20:17 +02:00
|
|
|
GenSignals (gen_info, null);
|
2002-06-23 05:38:02 +02:00
|
|
|
}
|
|
|
|
|
2004-03-18 21:56:32 +01: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 02:20:17 +02: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 19:15:19 +02:00
|
|
|
|
|
|
|
if (interfaces != null) {
|
2002-06-23 05:38:02 +02:00
|
|
|
Hashtable all_methods = new Hashtable ();
|
|
|
|
Hashtable collisions = new Hashtable ();
|
|
|
|
foreach (string iface in interfaces) {
|
2003-05-19 04:45:17 +02:00
|
|
|
ClassBase igen = table.GetClassGen (iface);
|
2002-06-23 05:38:02 +02: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 19:15:19 +02: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 22:31:23 +02:00
|
|
|
if (Parent != null && Parent.Implements (iface))
|
|
|
|
continue;
|
2003-05-19 04:45:17 +02:00
|
|
|
ClassBase igen = table.GetClassGen (iface);
|
2003-10-05 02:20:17 +02: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 19:15:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-07-06 09:08:19 +02: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-06 00:51:37 +01:00
|
|
|
|
2004-05-18 04:46:17 +02:00
|
|
|
if (GetExpected (CName) != (QualifiedName + "," + gen_info.AssemblyName)) {
|
|
|
|
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-06 00:51:37 +01:00
|
|
|
sw.WriteLine ("#endregion");
|
2003-10-05 02:20:17 +02:00
|
|
|
AppendCustom (sw, gen_info.CustomDir);
|
2002-05-24 01:43:25 +02:00
|
|
|
|
2002-01-06 14:33:25 +01:00
|
|
|
sw.WriteLine ("\t}");
|
2003-10-05 02:20:17 +02:00
|
|
|
sw.WriteLine ("}");
|
2002-05-24 01:43:25 +02:00
|
|
|
|
2003-10-05 02:20:17 +02:00
|
|
|
sw.Close ();
|
|
|
|
gen_info.Writer = null;
|
2002-02-19 04:12:47 +01:00
|
|
|
Statistics.ObjectCount++;
|
2002-01-12 03:08:16 +01: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 19:15:19 +02:00
|
|
|
|
2003-10-05 02:20:17 +02: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 22:31:23 +02:00
|
|
|
{
|
|
|
|
if (!Elem.HasAttribute("parent"))
|
|
|
|
return;
|
2002-07-26 08:08:52 +02:00
|
|
|
|
2003-10-05 02:20:17 +02: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();
|
2003-12-15 17:59:25 +01:00
|
|
|
gen_info.Writer.WriteLine("\t\tprotected " + Name + "(GLib.GType gtype) : base(gtype) {}");
|
2003-10-05 02:20:17 +02:00
|
|
|
gen_info.Writer.WriteLine("\t\tpublic " + Name + "(IntPtr raw) : base(raw) {}");
|
2004-06-01 20:00:09 +02: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 02:20:17 +02: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 22:31:23 +02:00
|
|
|
|
2003-10-05 02:20:17 +02:00
|
|
|
base.GenCtors (gen_info);
|
2002-05-24 01:43:25 +02:00
|
|
|
}
|
2002-08-08 06:48:41 +02:00
|
|
|
|
2004-03-18 21:56:32 +01: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 21:56:18 +02:00
|
|
|
/* Keep this in sync with the one in glib/ObjectManager.cs */
|
2003-10-06 20:18:49 +02:00
|
|
|
private static string GetExpected (string cname)
|
2002-08-08 06:48:41 +02: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 21:56:18 +02:00
|
|
|
StringBuilder expected = new StringBuilder ();
|
|
|
|
string ns = "";
|
|
|
|
bool needs_dot = true;
|
|
|
|
for (int i = 0; i < cname.Length; i++)
|
|
|
|
{
|
|
|
|
if (needs_dot && i > 0 && Char.IsUpper (cname[i])) {
|
2004-02-08 00:24:15 +01:00
|
|
|
if (expected.Length == 1 && expected[0] == 'G') {
|
|
|
|
ns = "glib";
|
|
|
|
expected = new StringBuilder ("GLib.");
|
|
|
|
} else {
|
|
|
|
ns = expected.ToString ().ToLower ();
|
|
|
|
expected.Append ('.');
|
|
|
|
}
|
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 21:56:18 +02:00
|
|
|
needs_dot = false;
|
|
|
|
}
|
|
|
|
expected.Append (cname[i]);
|
2002-08-08 06:48:41 +02:00
|
|
|
}
|
2004-02-08 00:24:15 +01:00
|
|
|
expected.AppendFormat (",{0}-sharp", ns);
|
|
|
|
|
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 21:56:18 +02:00
|
|
|
return expected.ToString ();
|
|
|
|
}
|
2002-08-08 06:48:41 +02:00
|
|
|
|
2004-02-08 00:24:15 +01: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 21:56:18 +02:00
|
|
|
{
|
2003-10-06 20:18:49 +02:00
|
|
|
foreach (string key in objs.Keys)
|
2004-02-08 00:24:15 +01:00
|
|
|
if (GetExpected (key) != ((string) objs[key] + "," + assembly_name))
|
2003-10-06 20:18:49 +02:00
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2002-08-08 06:48:41 +02:00
|
|
|
|
2003-10-06 20:18:49 +02: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-08 00:24:15 +01: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 21:56:18 +02:00
|
|
|
continue;
|
|
|
|
|
2003-10-06 20:18:49 +02: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 04:46:17 +02:00
|
|
|
sw.WriteLine ("\t\tstatic bool initialized = false;");
|
2003-10-06 20:18:49 +02: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 04:46:17 +02: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 21:56:18 +02:00
|
|
|
|
2004-02-08 00:24:15 +01:00
|
|
|
foreach (string key in dir_info.objects.Keys) {
|
|
|
|
if (GetExpected(key) != ((string) dir_info.objects[key] + "," + dir_info.assembly_name))
|
2004-05-28 18:59:21 +02:00
|
|
|
sw.WriteLine ("\t\t\tGLib.ObjectManager.RegisterType(\"" + key + "\", \"" + dir_info.objects [key] + "," + dir_info.assembly_name + "\");");
|
2004-02-08 00:24:15 +01: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 21:56:18 +02:00
|
|
|
|
2003-10-06 20:18:49 +02:00
|
|
|
sw.WriteLine ("\t\t}");
|
|
|
|
sw.WriteLine ("\t}");
|
|
|
|
sw.WriteLine ("}");
|
|
|
|
sw.Close ();
|
2002-08-08 06:48:41 +02:00
|
|
|
}
|
2002-01-06 14:33:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|