Skip to content

Commit

Permalink
GLibPorts: simplified names for native init/deinit
Browse files Browse the repository at this point in the history
  • Loading branch information
smx-smx committed Dec 16, 2017
1 parent 7d9dccf commit 7e7cccc
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
11 changes: 6 additions & 5 deletions GLibPorts/Native/Utils.cs → GLibPorts/GLib.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
using System;
using GLibPorts.Native;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GLibPorts.Native {
public class Utils {
namespace GLibPorts {
public partial class GLib {
/// <summary>
/// Clears up unmanaged resources used through GLib's lifetime
/// </summary>
public static void GLibDispose() {
GLib.FileStream.DisposeStatic();
FileStream.DisposeStatic();
File.DisposeStatic();
}

public static void GLibInitialize() {
File.InitializeStatic();
GLib.FileStream.InitializeStatic();
FileStream.InitializeStatic();
}
}
}
2 changes: 1 addition & 1 deletion GLibPorts/GLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@
<Compile Include="FileUtils.cs" />
<Compile Include="GChar.cs" />
<Compile Include="GEnvironment.cs" />
<Compile Include="GLib.cs" />
<Compile Include="GProcess.cs" />
<Compile Include="gstring.cs" />
<Compile Include="IEnumerableExtensions.cs" />
<Compile Include="Module.cs" />
<Compile Include="ModuleFlags.cs" />
<Compile Include="Native\File.cs" />
<Compile Include="Native\Utils.cs" />
<Compile Include="Native\Varargs.cs" />
<Compile Include="Native\Win32.cs" />
<Compile Include="GPath.cs" />
Expand Down
4 changes: 2 additions & 2 deletions ValaCompiler/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class Program {
private CodeContext context;

static int Main(string[] args) {
GLibPorts.Native.Utils.GLibInitialize();
GLibInitialize();

CompilerOptions opts = new CompilerOptions();
opts.parse_args(args);
Expand Down Expand Up @@ -62,7 +62,7 @@ static int Main(string[] args) {
var compiler = new Compiler(opts);
int result = compiler.run();

GLibPorts.Native.Utils.GLibDispose();
GLibDispose();
return result;
}
}
Expand Down
3 changes: 2 additions & 1 deletion ValaCompilerLib/Compiler.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using CCodeGen;
using CCodeGen.Modules;
using GLibPorts;
using System;
using System.Collections.Generic;
using System.Diagnostics;
Expand Down Expand Up @@ -445,7 +446,7 @@ static int run_source(CompilerOptions opts) {
}

public void Dispose() {
GLibPorts.Native.Utils.GLibDispose();
GLib.GLibDispose();
context = null;
CodeContext.DisposeStatic();
}
Expand Down
7 changes: 6 additions & 1 deletion ValaTests/ValaTestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.IO;
using System.Linq;
using System.Reflection;
using GLibPorts;
using NUnit.Framework;
using ValaCompilerLib;

Expand All @@ -14,7 +15,11 @@ public class ValaTestRunner {
private string vapiDir;

static ValaTestRunner() {
GLibPorts.Native.Utils.GLibInitialize();
GLib.GLibInitialize();
}

~ValaTestRunner() {
GLib.GLibDispose();
}

public ValaTestRunner() {
Expand Down

0 comments on commit 7e7cccc

Please sign in to comment.