[bgen] Make the Frameworks class instance based.
This commit is contained in:
Родитель
15d47aeac7
Коммит
62e98c84cb
|
@ -51,6 +51,7 @@ public class BindingTouch {
|
|||
List<string> libs = new List<string> ();
|
||||
|
||||
public Universe universe;
|
||||
public Frameworks Frameworks;
|
||||
|
||||
public TargetFramework TargetFramework {
|
||||
get { return target_framework.Value; }
|
||||
|
@ -515,6 +516,7 @@ public class BindingTouch {
|
|||
|
||||
AttributeManager.BindingTouch = this;
|
||||
Stret.BindingTouch = this;
|
||||
Frameworks = new Frameworks (CurrentPlatform);
|
||||
|
||||
Assembly corlib_assembly = universe.LoadFile (LocateAssembly ("mscorlib"));
|
||||
Assembly platform_assembly = baselib;
|
||||
|
|
|
@ -26,7 +26,7 @@ Console.WriteLine ("partial class Frameworks {");
|
|||
for (int i = 0; i < names.Length; i++) {
|
||||
var name = names [i];
|
||||
var frameworks = allframeworks [i];
|
||||
Console.Write ($"\tstatic readonly HashSet<string> {name} = new HashSet<string> {{\"");
|
||||
Console.Write ($"\treadonly HashSet<string> {name} = new HashSet<string> {{\"");
|
||||
Console.Write (string.Join ("\", \"", frameworks));
|
||||
Console.WriteLine ("\"};");
|
||||
}
|
||||
|
@ -34,8 +34,8 @@ for (int i = 0; i < names.Length; i++) {
|
|||
var allArray = all.ToArray ();
|
||||
Array.Sort (allArray);
|
||||
foreach (var fw in allArray)
|
||||
Console.WriteLine ($"\tstatic bool? _{fw.Replace (".", "")};");
|
||||
Console.WriteLine ($"\tbool? _{fw.Replace (".", "")};");
|
||||
foreach (var fw in allArray)
|
||||
Console.WriteLine ($"\tpublic static bool Have{fw} {{ get {{ if (!_{fw}.HasValue) _{fw} = GetValue (\"{fw}\"); return _{fw}.Value; }} }}");
|
||||
Console.WriteLine ($"\tpublic bool Have{fw} {{ get {{ if (!_{fw}.HasValue) _{fw} = GetValue (\"{fw}\"); return _{fw}.Value; }} }}");
|
||||
Console.WriteLine ("}");
|
||||
Environment.Exit (0);
|
|
@ -5,6 +5,7 @@ using Type = IKVM.Reflection.Type;
|
|||
|
||||
public static class TypeManager {
|
||||
public static BindingTouch BindingTouch;
|
||||
static Frameworks Frameworks { get { return BindingTouch.Frameworks; } }
|
||||
public static Type System_Attribute;
|
||||
public static Type System_Boolean;
|
||||
public static Type System_Byte;
|
||||
|
|
|
@ -641,6 +641,7 @@ public class NamespaceManager
|
|||
public BindingTouch BindingTouch;
|
||||
PlatformName CurrentPlatform { get { return BindingTouch.CurrentPlatform; } }
|
||||
bool UnifiedAPI { get { return BindingTouch.Unified; } }
|
||||
Frameworks Frameworks { get { return BindingTouch.Frameworks; } }
|
||||
|
||||
public string Prefix { get; private set; }
|
||||
|
||||
|
@ -808,11 +809,17 @@ public enum EnumMode {
|
|||
}
|
||||
|
||||
public partial class Frameworks {
|
||||
static HashSet<string> frameworks;
|
||||
static bool GetValue (string framework)
|
||||
HashSet<string> frameworks;
|
||||
readonly PlatformName CurrentPlatform;
|
||||
public Frameworks (PlatformName current_platform)
|
||||
{
|
||||
CurrentPlatform = current_platform;
|
||||
}
|
||||
|
||||
bool GetValue (string framework)
|
||||
{
|
||||
if (frameworks == null) {
|
||||
switch (Generator.CurrentPlatform) {
|
||||
switch (CurrentPlatform) {
|
||||
case PlatformName.iOS:
|
||||
frameworks = iosframeworks;
|
||||
break;
|
||||
|
@ -826,7 +833,7 @@ public partial class Frameworks {
|
|||
frameworks = macosframeworks;
|
||||
break;
|
||||
default:
|
||||
throw new BindingException (1047, "Unsupported platform: {0}. Please file a bug report (https://github.com/xamarin/xamarin-macios/issues/new) with a test case.", Generator.CurrentPlatform);
|
||||
throw new BindingException (1047, "Unsupported platform: {0}. Please file a bug report (https://github.com/xamarin/xamarin-macios/issues/new) with a test case.", CurrentPlatform);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -839,6 +846,7 @@ public partial class Generator : IMemberGatherer {
|
|||
|
||||
static NamespaceManager ns;
|
||||
static BindingTouch BindingTouch;
|
||||
static Frameworks Frameworks { get { return BindingTouch.Frameworks; } }
|
||||
Dictionary<Type,IEnumerable<string>> selectors = new Dictionary<Type,IEnumerable<string>> ();
|
||||
Dictionary<Type,bool> need_static = new Dictionary<Type,bool> ();
|
||||
Dictionary<Type,bool> need_abstract = new Dictionary<Type,bool> ();
|
||||
|
|
Загрузка…
Ссылка в новой задаче