-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1119 from gircore/improve-alias-support
Improve alias support
- Loading branch information
Showing
52 changed files
with
469 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...neration/Generator/Renderer/Internal/ReturnType/Converter/PrimitiveValueTypeAliasArray.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System; | ||
using Type = Generator.Model.Type; | ||
|
||
namespace Generator.Renderer.Internal.ReturnType; | ||
|
||
internal class PrimitiveValueTypeAliasArray : ReturnTypeConverter | ||
{ | ||
public bool Supports(GirModel.ReturnType returnType) | ||
{ | ||
return returnType.AnyType.IsArrayAlias<GirModel.PrimitiveValueType>(); | ||
} | ||
|
||
public RenderableReturnType Convert(GirModel.ReturnType returnType) | ||
{ | ||
if (!returnType.IsPointer) | ||
throw new NotImplementedException("Only primitive value types alias arrays which are pointer based are supported."); | ||
|
||
return new RenderableReturnType(Type.Pointer); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/Generation/Generator/Renderer/Public/CallableExpressions/CallableData.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Generator.Renderer.Public; | ||
|
||
public record CallableData( | ||
ReturnTypeToManagedData ReturnTypeToManagedData, | ||
IReadOnlyCollection<ParameterToNativeData> ParameterToNativeDatas | ||
); |
12 changes: 12 additions & 0 deletions
12
src/Generation/Generator/Renderer/Public/CallableExpressions/CallableExpressions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace Generator.Renderer.Public; | ||
|
||
public class CallableExpressions | ||
{ | ||
public static CallableData Initialize(GirModel.Callable callable) | ||
{ | ||
var parameters = ParameterToNativeExpression.Initialize(callable.Parameters); | ||
var returnType = ReturnTypeToManagedExpression.Initialize(callable.ReturnType, parameters); | ||
|
||
return new CallableData(returnType, parameters); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...Generation/Generator/Renderer/Public/ReturnType/Converter/PrimitiveValueTypeAliasArray.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
|
||
namespace Generator.Renderer.Public.ReturnType; | ||
|
||
internal class PrimitiveValueTypeAliasArray : ReturnTypeConverter | ||
{ | ||
public RenderableReturnType Create(GirModel.ReturnType returnType) | ||
{ | ||
if (!returnType.IsPointer) | ||
throw new NotImplementedException("Only primitive value types alias arrays which are pointer based are supported."); | ||
|
||
var alias = (GirModel.Alias) returnType.AnyType.AsT1.AnyType.AsT0; | ||
return new RenderableReturnType($"{Model.Namespace.GetPublicName(alias.Namespace)}.{Model.ArrayType.GetName(returnType.AnyType.AsT1)}"); | ||
} | ||
|
||
public bool Supports(GirModel.ReturnType returnType) | ||
=> returnType.AnyType.IsArrayAlias<GirModel.PrimitiveValueType>(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.