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;
|
|
|
|
|
2005-07-02 15:23:27 +00:00
|
|
|
public class ObjectGen : ObjectBase {
|
2002-01-06 13:33:25 +00:00
|
|
|
|
2007-09-07 14:40:46 +00:00
|
|
|
private ArrayList custom_attrs = new ArrayList();
|
2002-07-06 07:08:19 +00:00
|
|
|
private ArrayList strings = 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
|
|
|
|
2009-04-13 17:44:48 +00:00
|
|
|
public ObjectGen (XmlElement ns, XmlElement elem) : base (ns, elem, false)
|
2002-05-23 23:43:25 +00:00
|
|
|
{
|
2002-01-06 13:33:25 +00:00
|
|
|
foreach (XmlNode node in elem.ChildNodes) {
|
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;
|
2009-04-13 17:44:48 +00:00
|
|
|
if (member.HasAttribute ("hidden") && member.GetAttribute ("hidden") == "1") continue;
|
2002-01-06 13:33:25 +00:00
|
|
|
|
|
|
|
switch (node.Name) {
|
|
|
|
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
|
|
|
|
2007-09-07 14:40:46 +00:00
|
|
|
case "custom-attribute":
|
|
|
|
custom_attrs.Add (member.InnerXml);
|
|
|
|
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":
|
2009-04-13 17:44:48 +00:00
|
|
|
string name = member.GetAttribute ("name");
|
2004-11-22 17:52:17 +00:00
|
|
|
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
|
|
|
}
|
2009-08-05 06:24:27 +00:00
|
|
|
|
|
|
|
public override string CallByName (string var, bool owned)
|
|
|
|
{
|
|
|
|
return String.Format ("{0} == null ? IntPtr.Zero : {0}.{1}", var, owned ? "OwnedHandle" : "Handle");
|
|
|
|
}
|
2002-05-23 23:43:25 +00:00
|
|
|
|
2005-08-05 20:34:45 +00:00
|
|
|
public override bool Validate ()
|
|
|
|
{
|
2011-02-20 18:11:08 +00:00
|
|
|
LogWriter log = new LogWriter (QualifiedName);
|
|
|
|
|
2005-08-05 20:34:45 +00:00
|
|
|
ArrayList invalids = new ArrayList ();
|
|
|
|
|
|
|
|
foreach (ChildProperty prop in childprops.Values) {
|
2011-02-20 18:11:08 +00:00
|
|
|
if (!prop.Validate (log))
|
2005-08-05 20:34:45 +00:00
|
|
|
invalids.Add (prop);
|
|
|
|
}
|
|
|
|
foreach (ChildProperty prop in invalids)
|
|
|
|
childprops.Remove (prop);
|
|
|
|
|
|
|
|
return base.Validate ();
|
|
|
|
}
|
|
|
|
|
2004-06-01 18:00:09 +00:00
|
|
|
private bool DisableVoidCtor {
|
|
|
|
get {
|
|
|
|
return Elem.HasAttribute ("disable_void_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;
|
|
|
|
}
|
2005-08-09 17:33:46 +00:00
|
|
|
|
2004-12-26 19:33:34 +00:00
|
|
|
public override void Generate (GenerationInfo gen_info)
|
2003-10-05 00:20:17 +00:00
|
|
|
{
|
2011-02-20 18:11:08 +00:00
|
|
|
gen_info.CurrentType = QualifiedName;
|
2005-04-04 16:27:08 +00:00
|
|
|
|
2005-05-11 17:37:50 +00:00
|
|
|
string asm_name = gen_info.AssemblyName.Length == 0 ? NS.ToLower () + "-sharp" : gen_info.AssemblyName;
|
|
|
|
DirectoryInfo di = GetDirectoryInfo (gen_info.Dir, asm_name);
|
2003-10-06 18:18:49 +00:00
|
|
|
|
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]");
|
2007-09-07 14:40:46 +00:00
|
|
|
foreach (string attr in custom_attrs)
|
|
|
|
sw.WriteLine ("\t" + attr);
|
2009-08-19 16:13:17 +00:00
|
|
|
sw.Write ("\t{0} partial {1}class " + Name, IsInternal ? "internal" : "public", 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);
|
2005-07-22 18:35:37 +00:00
|
|
|
GenProperties (gen_info, null);
|
* generator/StructBase.cs: update field-generation logic a bit
* generator/CodeGenerator.cs: add a --glue-includes flag
* generator/GenerationInfo.cs: Accept glue_includes value from
Main and output it to the glue_filename.
* generator/FieldBase.cs (Ignored): handle more ignorable cases.
(CheckGlue): New method to figure out what kind of glue we'll need
for a field.
(GenerateImports): generate appropriate imports per CheckGlue.
(GenerateGlue): Generate C glue for accessing a struct field;
either a fully-C-based accessor, or a method to just return the
field's offset in the struct.
(Generate): Use the generated glue to read the field.
* generator/PropertyBase.cs (CType): if the field is a single bit,
set its type to gboolean.
* generator/ObjectGen.cs (Generate):
* generator/OpaqueGen.cs (Generate): Call GenFields.
* generator/StructField.cs: Use FieldBase's glue-generation code
to handle bitfields. [#54489]
* generator/ObjectField.cs: Generates accessors for public fields
of objects and opaque structs. [#69514]
* generator/ClassBase.cs (ClassBase): Parse <fields> nodes and
create ObjectField objects.
(GenFields): Output field properties
(IgnoreMethod): Ignore Get/Set methods that duplicate fields
* generator/Makefile.am (sources): update
* {gdk,gnome,gtk,pango}/*.metadata: Mark some additional fields as
public. Rename/retype some fields for consistency with earlier
hand-coded bindings.
* {gdk,gnome,gtk,pango}/*.custom: Remove custom methods that can
now be autogenerated.
* {gdk,gnome,gtk,pango}/glue/*.c: Remove glue methods that can now
be autogenerated
* {gdk,glade,gnome,gtk,pango,vte}/Makefile.am
* {gdk,glade,gnome,gtk,pango,vte}/glue/Makefile.am
* {gdk,gnome,gtk,pango}/glue/makefile.win32: Update
svn path=/trunk/gtk-sharp/; revision=44563
2005-05-16 14:28:55 +00:00
|
|
|
GenFields (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) {
|
2009-04-13 17:44:48 +00:00
|
|
|
InterfaceGen igen = table.GetClassGen (iface) as InterfaceGen;
|
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
|
|
|
}
|
|
|
|
|
2009-04-13 17:44:48 +00:00
|
|
|
GenClassMembers (gen_info, cs_parent);
|
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 ();
|
2005-08-09 17:33:46 +00:00
|
|
|
foreach (Method m in Methods.Values)
|
|
|
|
all_methods[m.Name] = m;
|
2002-06-23 03:38:02 +00:00
|
|
|
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) {
|
2011-01-22 19:06:01 +00:00
|
|
|
if (m.Name.StartsWith ("Get") || m.Name.StartsWith ("Set")) {
|
|
|
|
if (GetProperty (m.Name.Substring (3)) != null) {
|
|
|
|
collisions[m.Name] = true;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2005-08-09 17:33:46 +00:00
|
|
|
Method collision = all_methods[m.Name] as Method;
|
|
|
|
if (collision != null && collision.Signature.Types == m.Signature.Types)
|
2002-06-23 03:38:02 +00:00
|
|
|
collisions[m.Name] = true;
|
|
|
|
else
|
2005-08-09 17:33:46 +00:00
|
|
|
all_methods[m.Name] = m;
|
2002-06-23 03:38:02 +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
|
|
|
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;
|
2009-04-13 17:44:48 +00:00
|
|
|
InterfaceGen igen = table.GetClassGen (iface) as InterfaceGen;
|
2003-10-05 00:20:17 +00:00
|
|
|
igen.GenMethods (gen_info, collisions, this);
|
2005-07-22 18:35:37 +00:00
|
|
|
igen.GenProperties (gen_info, this);
|
2003-10-05 00:20:17 +00:00
|
|
|
igen.GenSignals (gen_info, this);
|
2009-04-13 17:44:48 +00:00
|
|
|
igen.GenVirtualMethods (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{");
|
2005-05-11 17:37:50 +00:00
|
|
|
sw.WriteLine ("\t\t\tGtkSharp." + Studlify (asm_name) + ".ObjectManager.Initialize ();");
|
2004-05-18 02:46:17 +00:00
|
|
|
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\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 ("");
|
|
|
|
|
2005-08-05 20:34:45 +00:00
|
|
|
foreach (ChildProperty prop in childprops.Values)
|
|
|
|
prop.Generate (gen_info, "\t\t\t", null);
|
2004-11-22 17:52:17 +00:00
|
|
|
|
|
|
|
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 ("");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-04-13 17:44:48 +00:00
|
|
|
void GenClassMembers (GenerationInfo gen_info, string cs_parent)
|
2004-03-18 20:56:32 +00:00
|
|
|
{
|
2009-04-13 17:44:48 +00:00
|
|
|
GenVirtualMethods (gen_info, null);
|
2004-03-18 20:56:32 +00:00
|
|
|
|
2009-05-04 17:39:45 +00:00
|
|
|
if (class_struct_name == null || !CanGenerateClassStruct) return;
|
2009-04-13 17:44:48 +00:00
|
|
|
StreamWriter sw = gen_info.Writer;
|
2009-05-04 17:39:45 +00:00
|
|
|
GenerateClassStruct (gen_info);
|
2009-04-13 17:44:48 +00:00
|
|
|
if (cs_parent == "")
|
|
|
|
sw.WriteLine ("\t\tstatic uint class_offset = 0;");
|
|
|
|
else
|
2009-08-08 23:42:15 +00:00
|
|
|
sw.WriteLine ("\t\tstatic uint class_offset = ((GLib.GType) typeof ({0})).GetClassSize ();", cs_parent);
|
2009-04-13 17:44:48 +00:00
|
|
|
sw.WriteLine ("\t\tstatic Hashtable class_structs;");
|
2004-03-18 20:56:32 +00:00
|
|
|
sw.WriteLine ();
|
2009-04-13 17:44:48 +00:00
|
|
|
sw.WriteLine ("\t\tstatic {0} GetClassStruct (GLib.GType gtype, bool use_cache)", class_struct_name);
|
|
|
|
sw.WriteLine ("\t\t{");
|
|
|
|
sw.WriteLine ("\t\t\tif (class_structs == null)");
|
|
|
|
sw.WriteLine ("\t\t\t\tclass_structs = new Hashtable ();");
|
|
|
|
sw.WriteLine ();
|
|
|
|
sw.WriteLine ("\t\t\tif (use_cache && class_structs.Contains (gtype))");
|
|
|
|
sw.WriteLine ("\t\t\t\treturn ({0}) class_structs [gtype];", class_struct_name);
|
|
|
|
sw.WriteLine ("\t\t\telse {");
|
2009-08-08 23:42:15 +00:00
|
|
|
sw.WriteLine ("\t\t\t\tIntPtr class_ptr = new IntPtr (gtype.GetClassPtr ().ToInt64 () + class_offset);");
|
2009-04-13 17:44:48 +00:00
|
|
|
sw.WriteLine ("\t\t\t\t{0} class_struct = ({0}) Marshal.PtrToStructure (class_ptr, typeof ({0}));", class_struct_name);
|
|
|
|
sw.WriteLine ("\t\t\t\tif (use_cache)");
|
|
|
|
sw.WriteLine ("\t\t\t\t\tclass_structs.Add (gtype, class_struct);");
|
|
|
|
sw.WriteLine ("\t\t\t\treturn class_struct;");
|
|
|
|
sw.WriteLine ("\t\t\t}");
|
|
|
|
sw.WriteLine ("\t\t}");
|
|
|
|
sw.WriteLine ();
|
|
|
|
sw.WriteLine ("\t\tstatic void OverrideClassStruct (GLib.GType gtype, {0} class_struct)", class_struct_name);
|
|
|
|
sw.WriteLine ("\t\t{");
|
2009-08-08 23:42:15 +00:00
|
|
|
sw.WriteLine ("\t\t\tIntPtr class_ptr = new IntPtr (gtype.GetClassPtr ().ToInt64 () + class_offset);");
|
2009-04-13 17:44:48 +00:00
|
|
|
sw.WriteLine ("\t\t\tMarshal.StructureToPtr (class_struct, class_ptr, false);");
|
|
|
|
sw.WriteLine ("\t\t}");
|
2004-03-18 20:56:32 +00:00
|
|
|
sw.WriteLine ();
|
|
|
|
}
|
|
|
|
|
2005-05-04 16:54:24 +00:00
|
|
|
/* Keep this in sync with the one in glib/GType.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]))
|
2005-05-04 16:54:24 +00:00
|
|
|
sw.WriteLine ("\t\t\tGLib.GType.Register ({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
|
|
|
}
|
|
|
|
}
|
|
|
|
|