2003-10-04 Mike Kestner <mkestner@ximian.com>
* generator/AliasGen.cs : stub new Generate overload. * generator/BoxedGen.cs : implement new Generate overload. * generator/CallbackGen.cs (Generate):implement new overload. * generator/ClassBase.cs : implement new Generate overload and pass around the gen_info. * generator/ClassGen.cs : implement new Generate overload. * generator/Ctor.cs (Generate): s/sw/gen_info. * generator/EnumGen.cs : implement new Generate overload. * generator/GenBase.cs : expose NSElem, add gen_info param to AppendCustom. kill CreateWriter. (GenWrapper): add gen_info param and use it to open stream. * generator/GenerationInfo.cs : new class to pass around generation related information and perform tasks like opening streams. * generator/IGeneratable.cs : add Generate(gen_info) overload. * generator/InterfaceGen.cs : implement new Generate overload. * generator/ManualGen.cs : stub new Generate overload. * generator/Method.cs (Generate): accept gen_info. kill GenerateComments. * generator/ObjectGen.cs : implement new Generate overload. * generator/OpaqueGen.cs : implement new Generate overload. * generator/Parameters.cs (Initialize): s/sw/gen_info. * generator/Property.cs (Generate): accept gen_info. * generator/Signal.cs (Generate): accept gen_info. * generator/SimpleGen.cs : stub new Generate overload. * generator/StructBase.cs : s/sw/gen_info * generator/StructGen.cs : implement new Generate overload. svn path=/trunk/gtk-sharp/; revision=18615
This commit is contained in:
parent
e7f84c070d
commit
460b3e5623
22 changed files with 323 additions and 148 deletions
28
ChangeLog
28
ChangeLog
|
@ -1,3 +1,31 @@
|
|||
2003-10-04 Mike Kestner <mkestner@ximian.com>
|
||||
|
||||
* generator/AliasGen.cs : stub new Generate overload.
|
||||
* generator/BoxedGen.cs : implement new Generate overload.
|
||||
* generator/CallbackGen.cs (Generate):implement new overload.
|
||||
* generator/ClassBase.cs : implement new Generate overload and
|
||||
pass around the gen_info.
|
||||
* generator/ClassGen.cs : implement new Generate overload.
|
||||
* generator/Ctor.cs (Generate): s/sw/gen_info.
|
||||
* generator/EnumGen.cs : implement new Generate overload.
|
||||
* generator/GenBase.cs : expose NSElem, add gen_info param to
|
||||
AppendCustom. kill CreateWriter.
|
||||
(GenWrapper): add gen_info param and use it to open stream.
|
||||
* generator/GenerationInfo.cs : new class to pass around generation
|
||||
related information and perform tasks like opening streams.
|
||||
* generator/IGeneratable.cs : add Generate(gen_info) overload.
|
||||
* generator/InterfaceGen.cs : implement new Generate overload.
|
||||
* generator/ManualGen.cs : stub new Generate overload.
|
||||
* generator/Method.cs (Generate): accept gen_info. kill GenerateComments.
|
||||
* generator/ObjectGen.cs : implement new Generate overload.
|
||||
* generator/OpaqueGen.cs : implement new Generate overload.
|
||||
* generator/Parameters.cs (Initialize): s/sw/gen_info.
|
||||
* generator/Property.cs (Generate): accept gen_info.
|
||||
* generator/Signal.cs (Generate): accept gen_info.
|
||||
* generator/SimpleGen.cs : stub new Generate overload.
|
||||
* generator/StructBase.cs : s/sw/gen_info
|
||||
* generator/StructGen.cs : implement new Generate overload.
|
||||
|
||||
2003-10-03 Mike Kestner <mkestner@ximian.com>
|
||||
|
||||
* generator/GenBase.cs : remove unused do_generate private member.
|
||||
|
|
|
@ -77,6 +77,10 @@ namespace GtkSharp.Generation {
|
|||
{
|
||||
}
|
||||
|
||||
public void Generate (GenerationInfo gen_info)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,9 +14,15 @@ namespace GtkSharp.Generation {
|
|||
|
||||
public BoxedGen (XmlElement ns, XmlElement elem) : base (ns, elem) {}
|
||||
|
||||
public override void Generate ()
|
||||
public void Generate ()
|
||||
{
|
||||
base.Generate ();
|
||||
GenerationInfo gen_info = new GenerationInfo (NSElem);
|
||||
Generate (gen_info);
|
||||
}
|
||||
|
||||
public override void Generate (GenerationInfo gen_info)
|
||||
{
|
||||
base.Generate (gen_info);
|
||||
Statistics.BoxedCount++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
//
|
||||
// Author: Mike Kestner <mkestner@speakeasy.net>
|
||||
//
|
||||
// (c) 2002 Mike Kestner
|
||||
// (c) 2002-2003 Mike Kestner
|
||||
|
||||
namespace GtkSharp.Generation {
|
||||
|
||||
|
@ -54,24 +54,13 @@ namespace GtkSharp.Generation {
|
|||
return CallByName (var);
|
||||
}
|
||||
|
||||
public string GenWrapper (string ns)
|
||||
public string GenWrapper (string ns, GenerationInfo gen_info)
|
||||
{
|
||||
char sep = Path.DirectorySeparatorChar;
|
||||
string dir = ".." + sep + ns.ToLower() + sep + "generated";
|
||||
|
||||
if (!Directory.Exists (dir))
|
||||
Directory.CreateDirectory (dir);
|
||||
|
||||
string wrapper = Name + "Native";
|
||||
string qualname = ns + "Sharp." + wrapper;
|
||||
|
||||
string filename = dir + sep + ns + "Sharp." + wrapper + ".cs";
|
||||
StreamWriter sw = gen_info.OpenStream (qualname);
|
||||
|
||||
FileStream stream = new FileStream (filename, FileMode.Create, FileAccess.Write);
|
||||
StreamWriter sw = new StreamWriter (stream);
|
||||
|
||||
sw.WriteLine ("// This file was generated by the Gtk# code generator.");
|
||||
sw.WriteLine ("// Any changes made will be lost on regeneration.");
|
||||
sw.WriteLine ();
|
||||
sw.WriteLine ("namespace " + ns + "Sharp {");
|
||||
sw.WriteLine ();
|
||||
sw.WriteLine ("\tusing System;");
|
||||
|
@ -111,7 +100,6 @@ namespace GtkSharp.Generation {
|
|||
}
|
||||
|
||||
sw.WriteLine ();
|
||||
|
||||
sw.WriteLine ("\t\tpublic " + m_ret + " NativeCallback (" + import_sig + ")");
|
||||
sw.WriteLine ("\t\t{");
|
||||
|
||||
|
@ -191,6 +179,12 @@ namespace GtkSharp.Generation {
|
|||
}
|
||||
|
||||
public void Generate ()
|
||||
{
|
||||
GenerationInfo gen_info = new GenerationInfo (NSElem);
|
||||
Generate (gen_info);
|
||||
}
|
||||
|
||||
public void Generate (GenerationInfo gen_info)
|
||||
{
|
||||
XmlElement ret_elem = Elem["return-type"];
|
||||
if (ret_elem == null) {
|
||||
|
@ -215,7 +209,7 @@ namespace GtkSharp.Generation {
|
|||
parms = null;
|
||||
}
|
||||
|
||||
StreamWriter sw = CreateWriter ();
|
||||
StreamWriter sw = gen_info.OpenStream (Name);
|
||||
|
||||
string sig = "";
|
||||
if (parms != null) {
|
||||
|
@ -224,11 +218,17 @@ namespace GtkSharp.Generation {
|
|||
sig = parms.Signature;
|
||||
}
|
||||
|
||||
sw.WriteLine ("namespace " + NS + " {");
|
||||
sw.WriteLine ();
|
||||
sw.WriteLine ("\tusing System;");
|
||||
sw.WriteLine ();
|
||||
sw.WriteLine ("\tpublic delegate " + s_ret + " " + Name + "(" + sig + ");");
|
||||
sw.WriteLine ();
|
||||
sw.WriteLine ("}");
|
||||
|
||||
CloseWriter (sw);
|
||||
sw.Close ();
|
||||
|
||||
GenWrapper (NS);
|
||||
GenWrapper (NS, gen_info);
|
||||
|
||||
Statistics.CBCount++;
|
||||
}
|
||||
|
|
|
@ -147,27 +147,27 @@ namespace GtkSharp.Generation {
|
|||
return CallByName (var);
|
||||
}
|
||||
|
||||
protected void GenProperties (StreamWriter sw)
|
||||
protected void GenProperties (GenerationInfo gen_info)
|
||||
{
|
||||
if (props == null)
|
||||
return;
|
||||
|
||||
foreach (Property prop in props.Values) {
|
||||
if (prop.Validate ())
|
||||
prop.Generate (sw);
|
||||
prop.Generate (gen_info);
|
||||
else
|
||||
Console.WriteLine("in Object " + QualifiedName);
|
||||
}
|
||||
}
|
||||
|
||||
public void GenSignals (StreamWriter sw, ClassBase implementor)
|
||||
public void GenSignals (GenerationInfo gen_info, ClassBase implementor)
|
||||
{
|
||||
if (sigs == null)
|
||||
return;
|
||||
|
||||
foreach (Signal sig in sigs.Values) {
|
||||
if (sig.Validate ())
|
||||
sig.Generate (sw, implementor);
|
||||
sig.Generate (gen_info, implementor);
|
||||
else
|
||||
Console.WriteLine("in Object " + QualifiedName);
|
||||
}
|
||||
|
@ -194,7 +194,7 @@ namespace GtkSharp.Generation {
|
|||
(props != null) && props.ContainsKey(mname.Substring(3)));
|
||||
}
|
||||
|
||||
public void GenMethods (StreamWriter sw, Hashtable collisions, ClassBase implementor, bool gen_docs)
|
||||
public void GenMethods (GenerationInfo gen_info, Hashtable collisions, ClassBase implementor)
|
||||
{
|
||||
if (methods == null)
|
||||
return;
|
||||
|
@ -205,7 +205,7 @@ namespace GtkSharp.Generation {
|
|||
|
||||
if (method.Validate ())
|
||||
{
|
||||
String oname = null, oprotection = null;
|
||||
string oname = null, oprotection = null;
|
||||
if (collisions != null && collisions.Contains (method.Name))
|
||||
{
|
||||
oname = method.Name;
|
||||
|
@ -213,7 +213,7 @@ namespace GtkSharp.Generation {
|
|||
method.Name = Name + "." + method.Name;
|
||||
method.Protection = "";
|
||||
}
|
||||
method.Generate (sw, implementor, gen_docs);
|
||||
method.Generate (gen_info, implementor);
|
||||
if (oname != null)
|
||||
{
|
||||
method.Name = oname;
|
||||
|
@ -343,7 +343,7 @@ namespace GtkSharp.Generation {
|
|||
ctors_initted = true;
|
||||
}
|
||||
|
||||
protected virtual void GenCtors (StreamWriter sw)
|
||||
protected virtual void GenCtors (GenerationInfo gen_info)
|
||||
{
|
||||
ClassBase klass = this;
|
||||
while (klass != null) {
|
||||
|
@ -352,11 +352,11 @@ namespace GtkSharp.Generation {
|
|||
}
|
||||
|
||||
foreach (Ctor ctor in ctors)
|
||||
ctor.Generate (sw);
|
||||
ctor.Generate (gen_info);
|
||||
|
||||
if (!clash_map.ContainsKey("") && hasDefaultConstructor) {
|
||||
sw.WriteLine("\t\tprotected " + Name + "() : base(){}");
|
||||
sw.WriteLine();
|
||||
gen_info.Writer.WriteLine("\t\tprotected " + Name + "() : base(){}");
|
||||
gen_info.Writer.WriteLine();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// GtkSharp.Generation.ObjectGen.cs - The Object Generatable.
|
||||
// GtkSharp.Generation.ClassGen.cs - The Class Generatable.
|
||||
//
|
||||
// Author: Mike Kestner <mkestner@speakeasy.net>
|
||||
//
|
||||
|
@ -21,27 +21,36 @@ namespace GtkSharp.Generation {
|
|||
|
||||
public void Generate ()
|
||||
{
|
||||
StreamWriter sw = CreateWriter ();
|
||||
GenerationInfo gen_info = new GenerationInfo (NSElem);
|
||||
Generate (gen_info);
|
||||
}
|
||||
|
||||
public void Generate (GenerationInfo gen_info)
|
||||
{
|
||||
StreamWriter sw = gen_info.Writer = gen_info.OpenStream(Name);
|
||||
|
||||
sw.WriteLine ("namespace " + NS + " {");
|
||||
sw.WriteLine ();
|
||||
sw.WriteLine ("\tusing System;");
|
||||
sw.WriteLine ("\tusing System.Runtime.InteropServices;");
|
||||
sw.WriteLine ();
|
||||
|
||||
SymbolTable table = SymbolTable.Table;
|
||||
|
||||
sw.WriteLine ("#region Autogenerated code");
|
||||
sw.Write ("\tpublic class " + Name);
|
||||
sw.WriteLine (" {");
|
||||
sw.WriteLine ();
|
||||
|
||||
GenProperties (sw);
|
||||
GenMethods (sw, null, null, false);
|
||||
GenProperties (gen_info);
|
||||
GenMethods (gen_info, null, null);
|
||||
|
||||
sw.WriteLine ("#endregion");
|
||||
AppendCustom(sw);
|
||||
AppendCustom(sw, gen_info.CustomDir);
|
||||
|
||||
sw.WriteLine ("\t}");
|
||||
sw.WriteLine ("}");
|
||||
|
||||
CloseWriter (sw);
|
||||
sw.Close ();
|
||||
gen_info.Writer = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,8 +92,9 @@ namespace GtkSharp.Generation {
|
|||
}
|
||||
}
|
||||
|
||||
public void Generate (StreamWriter sw)
|
||||
public void Generate (GenerationInfo gen_info)
|
||||
{
|
||||
StreamWriter sw = gen_info.Writer;
|
||||
string sigtypes = "";
|
||||
string sig = "()";
|
||||
string call = "()";
|
||||
|
@ -136,7 +137,7 @@ namespace GtkSharp.Generation {
|
|||
sw.WriteLine("\t\t{");
|
||||
|
||||
if (parms != null)
|
||||
parms.Initialize(sw, false, false, "");
|
||||
parms.Initialize(gen_info, false, false, "");
|
||||
|
||||
sw.Write("\t\t\treturn ");
|
||||
if (container_type is StructBase)
|
||||
|
@ -149,7 +150,7 @@ namespace GtkSharp.Generation {
|
|||
sw.WriteLine("\t\t{");
|
||||
|
||||
if (parms != null)
|
||||
parms.Initialize(sw, false, false, "");
|
||||
parms.Initialize(gen_info, false, false, "");
|
||||
sw.WriteLine("\t\t\t{0} = {1}{2};", container_type.AssignToName, cname, call);
|
||||
if (parms != null)
|
||||
parms.HandleException (sw, "");
|
||||
|
|
|
@ -49,7 +49,18 @@ namespace GtkSharp.Generation {
|
|||
|
||||
public void Generate ()
|
||||
{
|
||||
StreamWriter sw = CreateWriter ();
|
||||
GenerationInfo gen_info = new GenerationInfo (NSElem);
|
||||
Generate (gen_info);
|
||||
}
|
||||
|
||||
public void Generate (GenerationInfo gen_info)
|
||||
{
|
||||
StreamWriter sw = gen_info.OpenStream (Name);
|
||||
|
||||
sw.WriteLine ("namespace " + NS + " {");
|
||||
sw.WriteLine ();
|
||||
sw.WriteLine ("\tusing System;");
|
||||
sw.WriteLine ();
|
||||
|
||||
if (Elem.GetAttribute("type") == "flags") {
|
||||
sw.WriteLine ();
|
||||
|
@ -104,7 +115,8 @@ namespace GtkSharp.Generation {
|
|||
|
||||
sw.WriteLine ("\t}");
|
||||
sw.WriteLine ("#endregion");
|
||||
CloseWriter (sw);
|
||||
sw.WriteLine ("}");
|
||||
sw.Close ();
|
||||
Statistics.EnumCount++;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,6 +51,12 @@ namespace GtkSharp.Generation {
|
|||
}
|
||||
}
|
||||
|
||||
public XmlElement NSElem {
|
||||
get {
|
||||
return ns;
|
||||
}
|
||||
}
|
||||
|
||||
public string QualifiedName {
|
||||
get {
|
||||
return NS + "." + Name;
|
||||
|
@ -90,10 +96,10 @@ namespace GtkSharp.Generation {
|
|||
sw.Close();
|
||||
}
|
||||
|
||||
public void AppendCustom (StreamWriter sw)
|
||||
public void AppendCustom (StreamWriter sw, string custom_dir)
|
||||
{
|
||||
char sep = Path.DirectorySeparatorChar;
|
||||
string custom = ".." + sep + NS.ToLower() + sep + Name + ".custom";
|
||||
string custom = custom_dir + sep + Name + ".custom";
|
||||
if (File.Exists(custom)) {
|
||||
sw.WriteLine ("#region Customized extensions");
|
||||
sw.WriteLine ("#line 1 \"" + Name + ".custom\"");
|
||||
|
|
75
generator/GenerationInfo.cs
Normal file
75
generator/GenerationInfo.cs
Normal file
|
@ -0,0 +1,75 @@
|
|||
// GtkSharp.Generation.GenerationInfo.cs - Generation information class.
|
||||
//
|
||||
// Author: Mike Kestner <mkestner@ximian.com>
|
||||
//
|
||||
// (c) 2003 Ximian Inc.
|
||||
|
||||
namespace GtkSharp.Generation {
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
|
||||
public class GenerationInfo {
|
||||
|
||||
string dir;
|
||||
string custom_dir;
|
||||
string assembly_name;
|
||||
StreamWriter sw;
|
||||
|
||||
public GenerationInfo (XmlElement ns)
|
||||
{
|
||||
string ns_name = ns.GetAttribute ("name");
|
||||
char sep = Path.DirectorySeparatorChar;
|
||||
dir = ".." + sep + ns_name.ToLower () + sep + "generated";
|
||||
custom_dir = ".." + sep + ns_name.ToLower ();
|
||||
assembly_name = ns_name.ToLower () + "-sharp";
|
||||
}
|
||||
|
||||
public string AssemblyName {
|
||||
get {
|
||||
return assembly_name;
|
||||
}
|
||||
}
|
||||
|
||||
public string CustomDir {
|
||||
get {
|
||||
return custom_dir;
|
||||
}
|
||||
}
|
||||
|
||||
public string Dir {
|
||||
get {
|
||||
return dir;
|
||||
}
|
||||
}
|
||||
|
||||
public StreamWriter Writer {
|
||||
get {
|
||||
return sw;
|
||||
}
|
||||
set {
|
||||
sw = value;
|
||||
}
|
||||
}
|
||||
|
||||
public StreamWriter OpenStream (string name)
|
||||
{
|
||||
char sep = Path.DirectorySeparatorChar;
|
||||
if (!Directory.Exists(dir))
|
||||
Directory.CreateDirectory(dir);
|
||||
string filename = dir + sep + name + ".cs";
|
||||
|
||||
FileStream stream = new FileStream (filename, FileMode.Create, FileAccess.Write);
|
||||
StreamWriter sw = new StreamWriter (stream);
|
||||
|
||||
sw.WriteLine ("// This file was generated by the Gtk# code generator.");
|
||||
sw.WriteLine ("// Any changes made will be lost if regenerated.");
|
||||
sw.WriteLine ();
|
||||
|
||||
return sw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,28 +6,28 @@
|
|||
|
||||
namespace GtkSharp.Generation {
|
||||
|
||||
using System;
|
||||
|
||||
public interface IGeneratable {
|
||||
|
||||
String CName {get;}
|
||||
string CName {get;}
|
||||
|
||||
String MarshalType {get;}
|
||||
string MarshalType {get;}
|
||||
|
||||
String MarshalReturnType {get;}
|
||||
string MarshalReturnType {get;}
|
||||
|
||||
String Name {get;}
|
||||
string Name {get;}
|
||||
|
||||
String QualifiedName {get;}
|
||||
string QualifiedName {get;}
|
||||
|
||||
String CallByName (String var_name);
|
||||
string CallByName (string var_name);
|
||||
|
||||
String FromNative (String var);
|
||||
string FromNative (string var);
|
||||
|
||||
String FromNativeReturn (String var);
|
||||
string FromNativeReturn (string var);
|
||||
|
||||
String ToNativeReturn (String var);
|
||||
string ToNativeReturn (string var);
|
||||
|
||||
void Generate ();
|
||||
|
||||
void Generate (GenerationInfo gen_info);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,8 +16,18 @@ namespace GtkSharp.Generation {
|
|||
|
||||
public void Generate ()
|
||||
{
|
||||
StreamWriter sw = CreateWriter ();
|
||||
GenerationInfo gen_info = new GenerationInfo (NSElem);
|
||||
Generate (gen_info);
|
||||
}
|
||||
|
||||
public void Generate (GenerationInfo gen_info)
|
||||
{
|
||||
StreamWriter sw = gen_info.Writer = gen_info.OpenStream (Name);
|
||||
|
||||
sw.WriteLine ("namespace " + NS + " {");
|
||||
sw.WriteLine ();
|
||||
sw.WriteLine ("\tusing System;");
|
||||
sw.WriteLine ();
|
||||
sw.WriteLine ("#region Autogenerated code");
|
||||
sw.WriteLine ("\tpublic interface " + Name + " : GLib.IWrapper {");
|
||||
sw.WriteLine ();
|
||||
|
@ -35,11 +45,13 @@ namespace GtkSharp.Generation {
|
|||
method.GenerateDecl (sw);
|
||||
}
|
||||
|
||||
AppendCustom (sw);
|
||||
AppendCustom (sw, gen_info.CustomDir);
|
||||
|
||||
sw.WriteLine ("\t}");
|
||||
sw.WriteLine ("#endregion");
|
||||
CloseWriter (sw);
|
||||
sw.WriteLine ("}");
|
||||
sw.Close ();
|
||||
gen_info.Writer = null;
|
||||
Statistics.IFaceCount++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,6 +90,9 @@ namespace GtkSharp.Generation {
|
|||
{
|
||||
}
|
||||
|
||||
public void Generate (GenerationInfo gen_info)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -248,8 +248,6 @@ namespace GtkSharp.Generation {
|
|||
if (elem.HasAttribute("shared"))
|
||||
return;
|
||||
|
||||
GenerateComments (sw);
|
||||
|
||||
if (is_get || is_set)
|
||||
{
|
||||
Method comp = GetComplement ();
|
||||
|
@ -279,32 +277,14 @@ namespace GtkSharp.Generation {
|
|||
Statistics.MethodCount++;
|
||||
}
|
||||
|
||||
void GenerateComments (StreamWriter sw)
|
||||
{
|
||||
string summary, sname;
|
||||
sw.WriteLine();
|
||||
if (is_get || is_set) {
|
||||
summary = "Property";
|
||||
sname = Name.Substring (3);
|
||||
} else {
|
||||
summary = "Method";
|
||||
sname = Name;
|
||||
}
|
||||
}
|
||||
|
||||
public void GenerateImport (StreamWriter sw)
|
||||
{
|
||||
sw.WriteLine("\t\t[DllImport(\"" + libname + "\")]");
|
||||
sw.Write("\t\tstatic extern " + safety + m_ret + " " + cname + isig);
|
||||
sw.WriteLine("\t\tstatic extern " + safety + m_ret + " " + cname + isig);
|
||||
sw.WriteLine();
|
||||
}
|
||||
|
||||
public void Generate (StreamWriter sw, ClassBase implementor)
|
||||
{
|
||||
Generate (sw, implementor, true);
|
||||
}
|
||||
|
||||
public void Generate (StreamWriter sw, ClassBase implementor, bool gen_docs)
|
||||
public void Generate (GenerationInfo gen_info, ClassBase implementor)
|
||||
{
|
||||
Method comp = null;
|
||||
|
||||
|
@ -334,51 +314,49 @@ namespace GtkSharp.Generation {
|
|||
comp = null;
|
||||
}
|
||||
|
||||
GenerateImport (sw);
|
||||
GenerateImport (gen_info.Writer);
|
||||
if (comp != null && s_ret == comp.parms.AccessorReturnType)
|
||||
comp.GenerateImport (sw);
|
||||
comp.GenerateImport (gen_info.Writer);
|
||||
|
||||
if (gen_docs)
|
||||
GenerateComments (sw);
|
||||
|
||||
sw.Write("\t\t");
|
||||
gen_info.Writer.Write("\t\t");
|
||||
if (protection != "")
|
||||
sw.Write("{0} ", protection);
|
||||
GenerateDeclCommon (sw, implementor);
|
||||
gen_info.Writer.Write("{0} ", protection);
|
||||
GenerateDeclCommon (gen_info.Writer, implementor);
|
||||
|
||||
if (is_get || is_set)
|
||||
{
|
||||
sw.Write ("\t\t\t");
|
||||
sw.Write ((is_get) ? "get" : "set");
|
||||
GenerateBody (sw, "\t");
|
||||
gen_info.Writer.Write ("\t\t\t");
|
||||
gen_info.Writer.Write ((is_get) ? "get" : "set");
|
||||
GenerateBody (gen_info, "\t");
|
||||
}
|
||||
else
|
||||
GenerateBody (sw, "");
|
||||
GenerateBody (gen_info, "");
|
||||
|
||||
if (is_get || is_set)
|
||||
{
|
||||
if (comp != null && s_ret == comp.parms.AccessorReturnType)
|
||||
{
|
||||
sw.WriteLine ();
|
||||
sw.Write ("\t\t\tset");
|
||||
comp.GenerateBody (sw, "\t");
|
||||
gen_info.Writer.WriteLine ();
|
||||
gen_info.Writer.Write ("\t\t\tset");
|
||||
comp.GenerateBody (gen_info, "\t");
|
||||
}
|
||||
sw.WriteLine ();
|
||||
sw.WriteLine ("\t\t}");
|
||||
gen_info.Writer.WriteLine ();
|
||||
gen_info.Writer.WriteLine ("\t\t}");
|
||||
}
|
||||
else
|
||||
sw.WriteLine();
|
||||
gen_info.Writer.WriteLine();
|
||||
|
||||
sw.WriteLine();
|
||||
gen_info.Writer.WriteLine();
|
||||
|
||||
Statistics.MethodCount++;
|
||||
}
|
||||
|
||||
public void GenerateBody (StreamWriter sw, string indent)
|
||||
public void GenerateBody (GenerationInfo gen_info, string indent)
|
||||
{
|
||||
StreamWriter sw = gen_info.Writer;
|
||||
sw.WriteLine(" {");
|
||||
if (parms != null)
|
||||
parms.Initialize(sw, is_get, is_set, indent);
|
||||
parms.Initialize(gen_info, is_get, is_set, indent);
|
||||
|
||||
SymbolTable table = SymbolTable.Table;
|
||||
|
||||
|
|
|
@ -53,8 +53,17 @@ namespace GtkSharp.Generation {
|
|||
|
||||
public void Generate ()
|
||||
{
|
||||
StreamWriter sw = CreateWriter ();
|
||||
GenerationInfo gen_info = new GenerationInfo (NSElem);
|
||||
Generate (gen_info);
|
||||
}
|
||||
|
||||
public void Generate (GenerationInfo gen_info)
|
||||
{
|
||||
StreamWriter sw = gen_info.Writer = gen_info.OpenStream (Name);
|
||||
|
||||
sw.WriteLine ("namespace " + NS + " {");
|
||||
sw.WriteLine ();
|
||||
sw.WriteLine ("\tusing System;");
|
||||
sw.WriteLine ("\tusing System.Collections;");
|
||||
sw.WriteLine ("\tusing System.Runtime.InteropServices;");
|
||||
sw.WriteLine ();
|
||||
|
@ -76,8 +85,8 @@ namespace GtkSharp.Generation {
|
|||
sw.WriteLine (" {");
|
||||
sw.WriteLine ();
|
||||
|
||||
GenCtors (sw);
|
||||
GenProperties (sw);
|
||||
GenCtors (gen_info);
|
||||
GenProperties (gen_info);
|
||||
|
||||
bool has_sigs = (sigs != null);
|
||||
if (!has_sigs) {
|
||||
|
@ -93,10 +102,10 @@ namespace GtkSharp.Generation {
|
|||
if (has_sigs && Elem.HasAttribute("parent"))
|
||||
{
|
||||
sw.WriteLine("\t\tprivate Hashtable Signals = new Hashtable();");
|
||||
GenSignals (sw, null);
|
||||
GenSignals (gen_info, null);
|
||||
}
|
||||
|
||||
GenMethods (sw, null, null, true);
|
||||
GenMethods (gen_info, null, null);
|
||||
|
||||
if (interfaces != null) {
|
||||
Hashtable all_methods = new Hashtable ();
|
||||
|
@ -115,8 +124,8 @@ namespace GtkSharp.Generation {
|
|||
if (Parent != null && Parent.Implements (iface))
|
||||
continue;
|
||||
ClassBase igen = table.GetClassGen (iface);
|
||||
igen.GenMethods (sw, collisions, this, false);
|
||||
igen.GenSignals (sw, this);
|
||||
igen.GenMethods (gen_info, collisions, this);
|
||||
igen.GenSignals (gen_info, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,29 +135,31 @@ namespace GtkSharp.Generation {
|
|||
}
|
||||
|
||||
sw.WriteLine ("#endregion");
|
||||
AppendCustom(sw);
|
||||
AppendCustom (sw, gen_info.CustomDir);
|
||||
|
||||
sw.WriteLine ("\t}");
|
||||
sw.WriteLine ("}");
|
||||
|
||||
CloseWriter (sw);
|
||||
sw.Close ();
|
||||
gen_info.Writer = null;
|
||||
Statistics.ObjectCount++;
|
||||
}
|
||||
|
||||
protected override void GenCtors (StreamWriter sw)
|
||||
protected override void GenCtors (GenerationInfo gen_info)
|
||||
{
|
||||
if (!Elem.HasAttribute("parent"))
|
||||
return;
|
||||
|
||||
sw.WriteLine("\t\t~" + Name + "()");
|
||||
sw.WriteLine("\t\t{");
|
||||
sw.WriteLine("\t\t\tDispose();");
|
||||
sw.WriteLine("\t\t}");
|
||||
sw.WriteLine();
|
||||
sw.WriteLine("\t\tprotected " + Name + "(GLib.Type gtype) : base(gtype) {}");
|
||||
sw.WriteLine("\t\tpublic " + Name + "(IntPtr raw) : base(raw) {}");
|
||||
sw.WriteLine();
|
||||
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();
|
||||
gen_info.Writer.WriteLine("\t\tprotected " + Name + "(GLib.Type gtype) : base(gtype) {}");
|
||||
gen_info.Writer.WriteLine("\t\tpublic " + Name + "(IntPtr raw) : base(raw) {}");
|
||||
gen_info.Writer.WriteLine();
|
||||
|
||||
base.GenCtors (sw);
|
||||
base.GenCtors (gen_info);
|
||||
}
|
||||
|
||||
/* Keep this in sync with the one in glib/ObjectManager.cs */
|
||||
|
|
|
@ -29,8 +29,17 @@ namespace GtkSharp.Generation {
|
|||
|
||||
public void Generate ()
|
||||
{
|
||||
StreamWriter sw = CreateWriter ();
|
||||
GenerationInfo gen_info = new GenerationInfo (NSElem);
|
||||
Generate (gen_info);
|
||||
}
|
||||
|
||||
public void Generate (GenerationInfo gen_info)
|
||||
{
|
||||
StreamWriter sw = gen_info.Writer = gen_info.OpenStream (Name);
|
||||
|
||||
sw.WriteLine ("namespace " + NS + " {");
|
||||
sw.WriteLine ();
|
||||
sw.WriteLine ("\tusing System;");
|
||||
sw.WriteLine ("\tusing System.Collections;");
|
||||
sw.WriteLine ("\tusing System.Runtime.InteropServices;");
|
||||
sw.WriteLine ();
|
||||
|
@ -40,15 +49,17 @@ namespace GtkSharp.Generation {
|
|||
sw.WriteLine (" {");
|
||||
sw.WriteLine ();
|
||||
|
||||
GenMethods (sw, null, null, true);
|
||||
GenCtors (sw);
|
||||
GenMethods (gen_info, null, null);
|
||||
GenCtors (gen_info);
|
||||
sw.WriteLine ("#endregion");
|
||||
|
||||
AppendCustom(sw);
|
||||
AppendCustom(sw, gen_info.CustomDir);
|
||||
|
||||
sw.WriteLine ("\t}");
|
||||
sw.WriteLine ("}");
|
||||
|
||||
CloseWriter (sw);
|
||||
sw.Close ();
|
||||
gen_info.Writer = null;
|
||||
Statistics.OpaqueCount++;
|
||||
}
|
||||
|
||||
|
@ -63,12 +74,12 @@ namespace GtkSharp.Generation {
|
|||
return true;
|
||||
}
|
||||
|
||||
protected override void GenCtors (StreamWriter sw)
|
||||
protected override void GenCtors (GenerationInfo gen_info)
|
||||
{
|
||||
sw.WriteLine("\t\tpublic " + Name + "(IntPtr raw) : base(raw) {}");
|
||||
sw.WriteLine();
|
||||
gen_info.Writer.WriteLine("\t\tpublic " + Name + "(IntPtr raw) : base(raw) {}");
|
||||
gen_info.Writer.WriteLine();
|
||||
|
||||
base.GenCtors (sw);
|
||||
base.GenCtors (gen_info);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -329,8 +329,9 @@ namespace GtkSharp.Generation {
|
|||
signature = signature.Remove (signature.Length - 2, 2);
|
||||
}
|
||||
|
||||
public void Initialize (StreamWriter sw, bool is_get, bool is_set, string indent)
|
||||
public void Initialize (GenerationInfo gen_info, bool is_get, bool is_set, string indent)
|
||||
{
|
||||
StreamWriter sw = gen_info.Writer;
|
||||
foreach (Parameter p in param_list) {
|
||||
|
||||
IGeneratable gen = p.Generatable;
|
||||
|
@ -349,7 +350,7 @@ namespace GtkSharp.Generation {
|
|||
|
||||
if (gen is CallbackGen) {
|
||||
CallbackGen cbgen = gen as CallbackGen;
|
||||
string wrapper = cbgen.GenWrapper(impl_ns);
|
||||
string wrapper = cbgen.GenWrapper(impl_ns, gen_info);
|
||||
sw.WriteLine (indent + "\t\t\t{0} {1}_wrapper = null;", wrapper, name);
|
||||
sw.Write (indent + "\t\t\t");
|
||||
if (p.NullOk)
|
||||
|
|
|
@ -50,9 +50,10 @@ namespace GtkSharp.Generation {
|
|||
return true;
|
||||
}
|
||||
|
||||
public void Generate (StreamWriter sw)
|
||||
public void Generate (GenerationInfo gen_info)
|
||||
{
|
||||
SymbolTable table = SymbolTable.Table;
|
||||
StreamWriter sw = gen_info.Writer;
|
||||
|
||||
string c_type = elem.GetAttribute("type");
|
||||
string cs_type = table.GetCSType(c_type);
|
||||
|
@ -112,7 +113,7 @@ namespace GtkSharp.Generation {
|
|||
sw.WriteLine("\t\tpublic " + modifiers + cs_type + " " + name + " {");
|
||||
if (has_getter) {
|
||||
sw.Write("\t\t\tget ");
|
||||
getter.GenerateBody(sw, "\t");
|
||||
getter.GenerateBody(gen_info, "\t");
|
||||
sw.WriteLine();
|
||||
} else if (elem.HasAttribute("readable")) {
|
||||
sw.WriteLine("\t\t\tget {");
|
||||
|
@ -140,7 +141,7 @@ namespace GtkSharp.Generation {
|
|||
|
||||
if (has_setter) {
|
||||
sw.Write("\t\t\tset ");
|
||||
setter.GenerateBody(sw, "\t");
|
||||
setter.GenerateBody(gen_info, "\t");
|
||||
sw.WriteLine();
|
||||
} else if (elem.HasAttribute("writeable") && !elem.HasAttribute("construct-only")) {
|
||||
sw.WriteLine("\t\t\tset {");
|
||||
|
|
|
@ -122,8 +122,9 @@ namespace GtkSharp.Generation {
|
|||
return ns + "Sharp." + handler;
|
||||
}
|
||||
|
||||
public void Generate (StreamWriter sw, ClassBase implementor)
|
||||
public void Generate (GenerationInfo gen_info, ClassBase implementor)
|
||||
{
|
||||
StreamWriter sw = gen_info.Writer;
|
||||
string cname = "\"" + elem.GetAttribute("cname") + "\"";
|
||||
string ns;
|
||||
if (implementor == null)
|
||||
|
|
|
@ -77,6 +77,9 @@ namespace GtkSharp.Generation {
|
|||
{
|
||||
}
|
||||
|
||||
public void Generate (GenerationInfo gen_info)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -206,10 +206,13 @@ namespace GtkSharp.Generation {
|
|||
return true;
|
||||
}
|
||||
|
||||
public virtual void Generate ()
|
||||
public virtual void Generate (GenerationInfo gen_info)
|
||||
{
|
||||
StreamWriter sw = CreateWriter ();
|
||||
StreamWriter sw = gen_info.Writer = gen_info.OpenStream (Name);
|
||||
|
||||
sw.WriteLine ("namespace " + NS + " {");
|
||||
sw.WriteLine ();
|
||||
sw.WriteLine ("\tusing System;");
|
||||
sw.WriteLine ("\tusing System.Collections;");
|
||||
sw.WriteLine ("\tusing System.Runtime.InteropServices;");
|
||||
sw.WriteLine ();
|
||||
|
@ -221,18 +224,22 @@ namespace GtkSharp.Generation {
|
|||
|
||||
GenFields (sw);
|
||||
sw.WriteLine ();
|
||||
GenCtors (sw);
|
||||
GenMethods (sw, null, null, true);
|
||||
GenCtors (gen_info);
|
||||
GenMethods (gen_info, null, null);
|
||||
|
||||
sw.WriteLine ("#endregion");
|
||||
AppendCustom(sw);
|
||||
AppendCustom(sw, gen_info.CustomDir);
|
||||
|
||||
sw.WriteLine ("\t}");
|
||||
CloseWriter (sw);
|
||||
sw.WriteLine ("}");
|
||||
sw.Close ();
|
||||
gen_info.Writer = null;
|
||||
}
|
||||
|
||||
protected override void GenCtors (StreamWriter sw)
|
||||
protected override void GenCtors (GenerationInfo gen_info)
|
||||
{
|
||||
StreamWriter sw = gen_info.Writer;
|
||||
|
||||
sw.WriteLine ("\t\tpublic static {0} Zero = new {0} ();", QualifiedName);
|
||||
sw.WriteLine();
|
||||
sw.WriteLine ("\t\tpublic static " + QualifiedName + " New(IntPtr raw) {");
|
||||
|
@ -261,7 +268,7 @@ namespace GtkSharp.Generation {
|
|||
ctor.Params.Static = true;
|
||||
}
|
||||
|
||||
base.GenCtors (sw);
|
||||
base.GenCtors (gen_info);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,9 +14,15 @@ namespace GtkSharp.Generation {
|
|||
|
||||
public StructGen (XmlElement ns, XmlElement elem) : base (ns, elem) {}
|
||||
|
||||
public override void Generate ()
|
||||
public void Generate ()
|
||||
{
|
||||
base.Generate ();
|
||||
GenerationInfo gen_info = new GenerationInfo (NSElem);
|
||||
Generate (gen_info);
|
||||
}
|
||||
|
||||
public override void Generate (GenerationInfo gen_info)
|
||||
{
|
||||
base.Generate (gen_info);
|
||||
Statistics.StructCount++;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue