Skip to content

Commit

Permalink
bloody format tool.
Browse files Browse the repository at this point in the history
  • Loading branch information
mandel-macaque committed Jan 23, 2025
1 parent db167d5 commit 66016ce
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/rgen/Microsoft.Macios.Generator/DataModel/TypeInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,24 +228,31 @@ public override int GetHashCode ()

public string? ToMarshallType (ReferenceKind referenceKind)
{
#pragma warning disable format
var type = this switch {
// special cases based on name
{ Name: "nfloat" or "NFloat" } => "nfloat", { Name: "nint" or "nuint" } => MetadataName,
{ Name: "nfloat" or "NFloat" } => "nfloat",
{ Name: "nint" or "nuint" } => MetadataName,
// special string case
{ SpecialType: SpecialType.System_String } => NativeHandle, // use a NSString when we get a string

// NSObject should use the native handle
{ IsNSObject: true } => NativeHandle, { IsINativeObject: true } => NativeHandle,
{ IsNSObject: true } => NativeHandle,
{ IsINativeObject: true } => NativeHandle,

// structs will use their name
{ IsStruct: true, SpecialType: SpecialType.System_Double } => "Double", { IsStruct: true } => Name,
{ IsStruct: true, SpecialType: SpecialType.System_Double } => "Double",
{ IsStruct: true } => Name,

// enums:
// IsSmartEnum: We are using a nsstring, so it should be a native handle.
// IsNativeEnum: Depends on the enum backing field kind.
// GeneralEnum: Depends on the EnumUnderlyingType

{ IsSmartEnum: true } => NativeHandle, { IsNativeEnum: true, EnumUnderlyingType: SpecialType.System_Int64 } => IntPtr, { IsNativeEnum: true, EnumUnderlyingType: SpecialType.System_UInt64 } => UIntPtr, { IsEnum: true, EnumUnderlyingType: not null } => EnumUnderlyingType.GetKeyword (),
{ IsSmartEnum: true } => NativeHandle,
{ IsNativeEnum: true, EnumUnderlyingType: SpecialType.System_Int64 } => IntPtr,
{ IsNativeEnum: true, EnumUnderlyingType: SpecialType.System_UInt64 } => UIntPtr,
{ IsEnum: true, EnumUnderlyingType: not null } => EnumUnderlyingType.GetKeyword (),

// special type that is a keyword (none would be a ref type)
{ SpecialType: SpecialType.System_Void } => SpecialType.GetKeyword (),
Expand All @@ -256,6 +263,7 @@ public override int GetHashCode ()

_ => null,
};
#pragma warning restore format
return type;
}

Expand Down

0 comments on commit 66016ce

Please sign in to comment.