From 2eac75ea4db21126be794b38ae3bbd955ea90235 Mon Sep 17 00:00:00 2001 From: "Stefanos A." Date: Fri, 1 Nov 2013 08:59:20 +0100 Subject: [PATCH] Avoid using singletons The IBind generator and the Settings class are now passed directly as parameters. This allows us to run multiple generators in a single process. --- Source/Bind/EnumProcessor.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Source/Bind/EnumProcessor.cs b/Source/Bind/EnumProcessor.cs index ec24c308..5ac6e297 100644 --- a/Source/Bind/EnumProcessor.cs +++ b/Source/Bind/EnumProcessor.cs @@ -42,11 +42,17 @@ namespace Bind const string Path = "/signatures/replace/enum[@name='{0}']"; string Overrides { get; set; } - public EnumProcessor(string overrides) + IBind Generator { get; set; } + Settings Settings { get { return Generator.Settings; } } + + public EnumProcessor(IBind generator, string overrides) { + if (generator == null) + throw new ArgumentNullException("generator"); if (overrides == null) throw new ArgumentNullException("overrides"); + Generator = generator; Overrides = overrides; } @@ -94,7 +100,7 @@ namespace Bind if (String.IsNullOrEmpty(name)) return name; - if (Utilities.Keywords.Contains(name)) + if (Utilities.Keywords(Settings.Language).Contains(name)) return name; if (Char.IsDigit(name[0])) @@ -217,7 +223,7 @@ namespace Bind } } - public static string TranslateConstantName(string s, bool isValue) + public string TranslateConstantName(string s, bool isValue) { if (String.IsNullOrEmpty(s)) return s; @@ -277,7 +283,7 @@ namespace Bind return translator.ToString(); } - public static string TranslateConstantValue(string value) + public string TranslateConstantValue(string value) { // Remove decorations to get a pure number (e.g. 0x80u -> 80). if (value.ToLower().StartsWith("0x"))