[Generator] Remove method that just added an indirection. (#17456)
This commit is contained in:
Родитель
8e4f22d20e
Коммит
4e5c1081fd
|
@ -86,7 +86,7 @@ public partial class Generator {
|
||||||
var fields = new Dictionary<FieldInfo, FieldAttribute> ();
|
var fields = new Dictionary<FieldInfo, FieldAttribute> ();
|
||||||
Tuple<FieldInfo, FieldAttribute> null_field = null;
|
Tuple<FieldInfo, FieldAttribute> null_field = null;
|
||||||
Tuple<FieldInfo, FieldAttribute> default_symbol = null;
|
Tuple<FieldInfo, FieldAttribute> default_symbol = null;
|
||||||
var underlying_type = GetCSharpTypeName (TypeManager.GetUnderlyingEnumType (type));
|
var underlying_type = GetCSharpTypeName (type.GetEnumUnderlyingType ());
|
||||||
var is_internal = AttributeManager.HasAttribute<InternalAttribute> (type);
|
var is_internal = AttributeManager.HasAttribute<InternalAttribute> (type);
|
||||||
var visibility = is_internal ? "internal" : "public";
|
var visibility = is_internal ? "internal" : "public";
|
||||||
print ("{0} enum {1} : {2} {{", visibility, type.Name, underlying_type);
|
print ("{0} enum {1} : {2} {{", visibility, type.Name, underlying_type);
|
||||||
|
|
|
@ -307,7 +307,7 @@ public partial class Generator : IMemberGatherer {
|
||||||
if (t.IsEnum) {
|
if (t.IsEnum) {
|
||||||
var enumType = t;
|
var enumType = t;
|
||||||
|
|
||||||
t = TypeManager.GetUnderlyingEnumType (t);
|
t = t.GetEnumUnderlyingType ();
|
||||||
|
|
||||||
if (IsNativeEnum (enumType, out var _, out var nativeType))
|
if (IsNativeEnum (enumType, out var _, out var nativeType))
|
||||||
return nativeType;
|
return nativeType;
|
||||||
|
@ -722,7 +722,7 @@ public partial class Generator : IMemberGatherer {
|
||||||
if (originalReturnType == TypeManager.NSNumber) {
|
if (originalReturnType == TypeManager.NSNumber) {
|
||||||
if (!NSNumberReturnMap.TryGetValue (retType, out append)) {
|
if (!NSNumberReturnMap.TryGetValue (retType, out append)) {
|
||||||
if (retType.IsEnum) {
|
if (retType.IsEnum) {
|
||||||
var enumType = TypeManager.GetUnderlyingEnumType (retType);
|
var enumType = retType.GetEnumUnderlyingType ();
|
||||||
if (!NSNumberReturnMap.TryGetValue (enumType, out append))
|
if (!NSNumberReturnMap.TryGetValue (enumType, out append))
|
||||||
throw GetBindAsException ("unbox", retType.Name, originalReturnType.Name, "container", minfo.mi);
|
throw GetBindAsException ("unbox", retType.Name, originalReturnType.Name, "container", minfo.mi);
|
||||||
} else
|
} else
|
||||||
|
@ -1314,7 +1314,7 @@ public partial class Generator : IMemberGatherer {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var renderedEnumType = RenderType (enumType);
|
var renderedEnumType = RenderType (enumType);
|
||||||
var underlyingEnumType = TypeManager.GetUnderlyingEnumType (enumType);
|
var underlyingEnumType = enumType.GetEnumUnderlyingType ();
|
||||||
var underlyingTypeName = RenderType (underlyingEnumType);
|
var underlyingTypeName = RenderType (underlyingEnumType);
|
||||||
string itype;
|
string itype;
|
||||||
string intermediateType;
|
string intermediateType;
|
||||||
|
@ -1382,7 +1382,7 @@ public partial class Generator : IMemberGatherer {
|
||||||
if (attrib is null)
|
if (attrib is null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var underlyingEnumType = TypeManager.GetUnderlyingEnumType (enumType);
|
var underlyingEnumType = enumType.GetEnumUnderlyingType ();
|
||||||
if (TypeManager.System_Int64 == underlyingEnumType) {
|
if (TypeManager.System_Int64 == underlyingEnumType) {
|
||||||
nativeType = "IntPtr";
|
nativeType = "IntPtr";
|
||||||
} else if (TypeManager.System_UInt64 == underlyingEnumType) {
|
} else if (TypeManager.System_UInt64 == underlyingEnumType) {
|
||||||
|
@ -2131,7 +2131,7 @@ public partial class Generator : IMemberGatherer {
|
||||||
bool isNativeEnum = false;
|
bool isNativeEnum = false;
|
||||||
|
|
||||||
if (pi.PropertyType.IsEnum) {
|
if (pi.PropertyType.IsEnum) {
|
||||||
fetchType = TypeManager.GetUnderlyingEnumType (pi.PropertyType);
|
fetchType = pi.PropertyType.GetEnumUnderlyingType ();
|
||||||
castToUnderlying = "(" + fetchType + "?)";
|
castToUnderlying = "(" + fetchType + "?)";
|
||||||
castToEnum = "(" + FormatType (dictType, pi.PropertyType) + "?)";
|
castToEnum = "(" + FormatType (dictType, pi.PropertyType) + "?)";
|
||||||
isNativeEnum = IsNativeEnum (pi.PropertyType);
|
isNativeEnum = IsNativeEnum (pi.PropertyType);
|
||||||
|
@ -2404,7 +2404,7 @@ public partial class Generator : IMemberGatherer {
|
||||||
else if (propertyType == TypeManager.System_String_Array) {
|
else if (propertyType == TypeManager.System_String_Array) {
|
||||||
print ("return CFArray.StringArrayFromHandle (value)!;");
|
print ("return CFArray.StringArrayFromHandle (value)!;");
|
||||||
} else {
|
} else {
|
||||||
Type underlying = propertyType.IsEnum ? TypeManager.GetUnderlyingEnumType (propertyType) : propertyType;
|
Type underlying = propertyType.IsEnum ? propertyType.GetEnumUnderlyingType () : propertyType;
|
||||||
string cast = propertyType.IsEnum ? "(" + propertyType.FullName + ") " : "";
|
string cast = propertyType.IsEnum ? "(" + propertyType.FullName + ") " : "";
|
||||||
|
|
||||||
if (underlying == TypeManager.System_Int32)
|
if (underlying == TypeManager.System_Int32)
|
||||||
|
|
|
@ -157,11 +157,6 @@ public class TypeManager {
|
||||||
return pi.IsOut;
|
return pi.IsOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Type GetUnderlyingEnumType (Type type)
|
|
||||||
{
|
|
||||||
return type.GetEnumUnderlyingType ();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Initialize (BindingTouch binding_touch, Assembly api, Assembly corlib, Assembly platform)
|
public void Initialize (BindingTouch binding_touch, Assembly api, Assembly corlib, Assembly platform)
|
||||||
{
|
{
|
||||||
BindingTouch = binding_touch;
|
BindingTouch = binding_touch;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче