Updated mustache template to support argument modifiers

このコミットが含まれているのは:
Sergio Pedri committed 2019-09-04 23:21:42 +02:00
1 親 a3bc07e88d
コミット 131123ec32
3ファイル変更
+12 -3

検索条件に一致するファイルはありません

+8 -1
ファイルの表示
@@ -5,6 +5,11 @@
/// </summary>
internal class ParameterInfo
{
/// <summary>
/// Gets the modifier to use for the current parameter
/// </summary>
public string ParameterModifier { get; }
/// <summary>
/// Gets the type of the current parameter
/// </summary>
@@ -23,11 +28,13 @@
/// <summary>
/// Creates a new <see cref="ParameterInfo"/> instance with the specified parameters
/// </summary>
/// <param name="parameterModifier">The modifier to use for the current parameter</param>
/// <param name="parameterType">The type of the current parameter</param>
/// <param name="parameterName">The name of the current parameter</param>
/// <param name="last">Indicates whether or not the current parameter is the last one</param>
public ParameterInfo(string parameterType, string parameterName, bool last)
public ParameterInfo(string parameterModifier, string parameterType, string parameterName, bool last)
{
ParameterModifier = parameterModifier;
ParameterType = parameterType;
ParameterName = parameterName;
IsLastParameter = last;
+1 -1
ファイルの表示
@@ -42,7 +42,7 @@ cbuffer _{{FieldName}} : register(b{{BufferIndex}})
{{!Shader private functions}}
{{#FunctionsList}}
// {{FunctionCsharpReturnType}} {{FunctionFullName}}({{FunctionCsharpParameters}})
{{ReturnType}} {{FunctionName}}({{#ParametersList}}{{ParameterType}} {{ParameterName}}{{^IsLastParameter}}, {{/IsLastParameter}}{{/ParametersList}})
{{ReturnType}} {{FunctionName}}({{#ParametersList}}{{ParameterModifier}} {{ParameterType}} {{ParameterName}}{{^IsLastParameter}}, {{/IsLastParameter}}{{/ParametersList}})
{{FunctionBody}}
{{/FunctionsList}}
+3 -1
ファイルの表示
@@ -13,6 +13,7 @@ using ComputeSharp.Shaders.Renderer.Models.Functions;
using ComputeSharp.Shaders.Translation.Enums;
using ComputeSharp.Shaders.Translation.Models;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Vortice.Direct3D12;
using ParameterInfo = ComputeSharp.Shaders.Renderer.Models.Functions.ParameterInfo;
@@ -311,10 +312,11 @@ namespace ComputeSharp.Shaders.Translation
// Get the function parameters
IReadOnlyList<ParameterInfo> parameters = (
from parameter in root.ParameterList.Parameters.Select((p, i) => (Node: p, Index: i))
let modifier = parameter.Node.Modifiers.Any(token => token.IsKind(SyntaxKind.OutKeyword)) ? "out" : "in"
let type = parameter.Node.Type.ToFullString()
let parameterName = parameter.Node.Identifier.ToFullString()
let last = parameter.Index == root.ParameterList.Parameters.Count - 1
select new ParameterInfo(type, parameterName, last)).ToArray();
select new ParameterInfo(modifier, type, parameterName, last)).ToArray();
// Get the function body
string body = root.Body.ToFullString();