[Generator] Remove method that just added an indirection. (#17456)

This commit is contained in:
Manuel de la Pena 2023-02-10 17:10:36 -05:00 коммит произвёл GitHub
Родитель 8e4f22d20e
Коммит 4e5c1081fd
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 7 добавлений и 12 удалений

Просмотреть файл

@ -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;