From 2852b771eadae13f74b512cdf628359d932945e1 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Tue, 3 Oct 2017 10:10:04 -0300 Subject: [PATCH] generator: Use TextWriter instead of StreamWriter in base classes Giving users of the writer more possibility, such as generating the code in strings before actually using it. --- Source/generator/CallbackGen.cs | 2 +- Source/generator/HandleBase.cs | 11 ++++++++++- Source/generator/IAccessor.cs | 2 +- Source/generator/LPGen.cs | 2 +- Source/generator/LPUGen.cs | 2 +- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Source/generator/CallbackGen.cs b/Source/generator/CallbackGen.cs index b9507fc4a..f7554be06 100644 --- a/Source/generator/CallbackGen.cs +++ b/Source/generator/CallbackGen.cs @@ -97,7 +97,7 @@ namespace GtkSharp.Generation { return NS + "Sharp." + Name + "Wrapper.GetManagedDelegate (" + var + ")"; } - public void WriteAccessors (StreamWriter sw, string indent, string var) + public void WriteAccessors (TextWriter sw, string indent, string var) { sw.WriteLine (indent + "get {"); sw.WriteLine (indent + "\treturn " + FromNative (var) + ";"); diff --git a/Source/generator/HandleBase.cs b/Source/generator/HandleBase.cs index c3c45a396..3b9ecd2ae 100644 --- a/Source/generator/HandleBase.cs +++ b/Source/generator/HandleBase.cs @@ -35,6 +35,15 @@ namespace GtkSharp.Generation { } } + public override string GenerateGetSizeOf () { + return NS + "." + Name + ".abi_info.Size"; + } + + public override string GenerateAlign () { + return NS + "." + Name + ".abi_info.Align"; + } + + public override string MarshalType { get { return "IntPtr"; @@ -58,7 +67,7 @@ namespace GtkSharp.Generation { return FromNative (var, false); } - public void WriteAccessors (StreamWriter sw, string indent, string var) + public void WriteAccessors (TextWriter sw, string indent, string var) { sw.WriteLine (indent + "get {"); sw.WriteLine (indent + "\treturn " + FromNative (var, false) + ";"); diff --git a/Source/generator/IAccessor.cs b/Source/generator/IAccessor.cs index 3cfcfc05d..21816d7a8 100644 --- a/Source/generator/IAccessor.cs +++ b/Source/generator/IAccessor.cs @@ -23,7 +23,7 @@ namespace GtkSharp.Generation { public interface IAccessor { - void WriteAccessors (System.IO.StreamWriter sw, string indentation, string field_name); + void WriteAccessors (System.IO.TextWriter sw, string indentation, string field_name); } } diff --git a/Source/generator/LPGen.cs b/Source/generator/LPGen.cs index 84940b5f1..c3ba69e25 100644 --- a/Source/generator/LPGen.cs +++ b/Source/generator/LPGen.cs @@ -44,7 +44,7 @@ namespace GtkSharp.Generation { return "(long) " + var; } - public void WriteAccessors (StreamWriter sw, string indent, string var) + public void WriteAccessors (TextWriter sw, string indent, string var) { sw.WriteLine (indent + "get {"); sw.WriteLine (indent + "\treturn " + FromNative (var) + ";"); diff --git a/Source/generator/LPUGen.cs b/Source/generator/LPUGen.cs index 05fa03a54..ebb459406 100644 --- a/Source/generator/LPUGen.cs +++ b/Source/generator/LPUGen.cs @@ -44,7 +44,7 @@ namespace GtkSharp.Generation { return "(ulong) " + var; } - public void WriteAccessors (StreamWriter sw, string indent, string var) + public void WriteAccessors (TextWriter sw, string indent, string var) { sw.WriteLine (indent + "get {"); sw.WriteLine (indent + "\treturn " + FromNative (var) + ";");