[bgen] Make Generator.TypeManager an instance property.
This commit is contained in:
Родитель
048ab300c6
Коммит
6450390ad8
|
@ -44,17 +44,27 @@ namespace ObjCRuntime {
|
|||
public BindAsAttribute (Type type)
|
||||
{
|
||||
Type = type;
|
||||
#if BGENERATOR
|
||||
var nullable = type.IsArray ? Generator.TypeManager.GetUnderlyingNullableType (type.GetElementType ()) : Generator.TypeManager.GetUnderlyingNullableType (type);
|
||||
IsNullable = nullable != null;
|
||||
IsValueType = IsNullable ? nullable.IsValueType : type.IsValueType;
|
||||
#endif
|
||||
}
|
||||
public Type Type;
|
||||
public Type OriginalType;
|
||||
#if BGENERATOR
|
||||
internal readonly bool IsNullable;
|
||||
internal readonly bool IsValueType;
|
||||
Type nullable;
|
||||
Type GetNullable (Generator generator)
|
||||
{
|
||||
if (nullable == null)
|
||||
nullable = Type.IsArray ? generator.TypeManager.GetUnderlyingNullableType (Type.GetElementType ()) : generator.TypeManager.GetUnderlyingNullableType (Type);
|
||||
return nullable;
|
||||
}
|
||||
|
||||
internal bool IsNullable (Generator generator)
|
||||
{
|
||||
return GetNullable (generator) != null;
|
||||
}
|
||||
internal bool IsValueType (Generator generator)
|
||||
{
|
||||
return IsNullable (generator) ? GetNullable (generator).IsValueType : Type.IsValueType;
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ public static class ReflectionExtensions {
|
|||
public static Type GetBaseType (Type type, Generator generator)
|
||||
{
|
||||
BaseTypeAttribute bta = GetBaseTypeAttribute (type, generator);
|
||||
Type base_type = bta != null ? bta.BaseType : Generator.TypeManager.System_Object;
|
||||
Type base_type = bta != null ? bta.BaseType : generator.TypeManager.System_Object;
|
||||
|
||||
return base_type;
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ public static class ReflectionExtensions {
|
|||
string owrap;
|
||||
string nwrap;
|
||||
|
||||
if (parent_type != Generator.TypeManager.NSObject) {
|
||||
if (parent_type != generator.TypeManager.NSObject) {
|
||||
if (generator.AttributeManager.HasAttribute<ModelAttribute> (parent_type)) {
|
||||
foreach (PropertyInfo pinfo in parent_type.GetProperties (flags)) {
|
||||
bool toadd = true;
|
||||
|
@ -177,7 +177,7 @@ public static class ReflectionExtensions {
|
|||
|
||||
Type parent_type = GetBaseType (type, generator);
|
||||
|
||||
if (parent_type != Generator.TypeManager.NSObject) {
|
||||
if (parent_type != generator.TypeManager.NSObject) {
|
||||
if (generator.AttributeManager.HasAttribute<ModelAttribute> (parent_type))
|
||||
foreach (MethodInfo minfo in parent_type.GetMethods ())
|
||||
if (generator.AttributeManager.HasAttribute<ExportAttribute> (minfo))
|
||||
|
@ -382,7 +382,7 @@ public class GeneratedType {
|
|||
ImplementsAppearance = true;
|
||||
}
|
||||
var btype = ReflectionExtensions.GetBaseType (Type, generator);
|
||||
if (btype != Generator.TypeManager.System_Object){
|
||||
if (btype != generator.TypeManager.System_Object){
|
||||
Parent = btype;
|
||||
// protected against a StackOverflowException - bug #19751
|
||||
// it does not protect against large cycles (but good against copy/paste errors)
|
||||
|
@ -843,7 +843,7 @@ public partial class Generator : IMemberGatherer {
|
|||
NamespaceManager ns;
|
||||
static BindingTouch BindingTouch;
|
||||
Frameworks Frameworks { get { return BindingTouch.Frameworks; } }
|
||||
public static TypeManager TypeManager { get { return BindingTouch.TypeManager; } }
|
||||
public TypeManager TypeManager { get { return BindingTouch.TypeManager; } }
|
||||
public AttributeManager AttributeManager { get { return BindingTouch.AttributeManager; } }
|
||||
Dictionary<Type,IEnumerable<string>> selectors = new Dictionary<Type,IEnumerable<string>> ();
|
||||
Dictionary<Type,bool> need_static = new Dictionary<Type,bool> ();
|
||||
|
@ -1329,7 +1329,7 @@ public partial class Generator : IMemberGatherer {
|
|||
throw new BindingException (1048, true, $"Unsupported type 'ref/out {originalType.Name.Replace ("&", string.Empty)}' decorated with [BindAs]");
|
||||
|
||||
var retType = TypeManager.GetUnderlyingNullableType (attrib.Type) ?? attrib.Type;
|
||||
var isNullable = attrib.IsNullable;
|
||||
var isNullable = attrib.IsNullable (this);
|
||||
var isValueType = retType.IsValueType;
|
||||
var isEnum = retType.IsEnum;
|
||||
var parameterName = pi != null ? pi.Name.GetSafeParamName () : "value";
|
||||
|
@ -1880,7 +1880,7 @@ public partial class Generator : IMemberGatherer {
|
|||
|
||||
var bindAsAtt = GetBindAsAttribute (pi) ?? GetBindAsAttribute (propInfo);
|
||||
if (bindAsAtt != null)
|
||||
return bindAsAtt.IsNullable || !bindAsAtt.IsValueType;
|
||||
return bindAsAtt.IsNullable (this) || !bindAsAtt.IsValueType (this);
|
||||
|
||||
if (IsWrappedType (pi.ParameterType))
|
||||
return true;
|
||||
|
@ -4886,7 +4886,7 @@ public partial class Generator : IMemberGatherer {
|
|||
this.async_initial_params = Generator.DropLast (mi.GetParameters ());
|
||||
|
||||
var lastType = mi.GetParameters ().Last ().ParameterType;
|
||||
if (!lastType.IsSubclassOf (TypeManager.System_Delegate))
|
||||
if (!lastType.IsSubclassOf (generator.TypeManager.System_Delegate))
|
||||
throw new BindingException (1036, true, "The last parameter in the method '{0}.{1}' must be a delegate (it's '{2}').", mi.DeclaringType.FullName, mi.Name, lastType.FullName);
|
||||
var cbParams = lastType.GetMethod ("Invoke").GetParameters ();
|
||||
async_completion_params = cbParams;
|
||||
|
|
Загрузка…
Ссылка в новой задаче