HlslTools icon indicating copy to clipboard operation
HlslTools copied to clipboard

#224 #231 Macro VariadicArgument operator improves with stringification.

Open TIMONz1535 opened this issue 1 year ago • 0 comments

Based on @Jasonchan35 pull request.

  • Checking token.ContextualKind instead of token.Kind.
  • Insert commas between variadic arguments into the parsing result list.
  • Don't report missing localize string NoVariadicArgumentParameter (causes a crash lol). Instead let the parser make the decision.
  • So macro parameter name __VA_ARGS__ consider to be valid. It doesn't actually have to be an ellipsis ....
  • Add stringification operation for variadic operator #__VA_ARGS__.
  • Huge variadic operator test with stringification and keyword as parameter. Correlates with the latest DXC release.
  • Tiny test for stringify with skipped parameters because I wanted to make sure.
#define CTR(...) = {__VA_ARGS__}
#define CTR3(x, ...) = float3(x, __VA_ARGS__)
float x CTR(0.0f);
float3 y CTR(1.0f, 2.0f, 3.0f);
float3 z CTR3(4.0f, 5.0f, 6.0f);
#define CTR_WTF(__VA_ARGS__) = float(__VA_ARGS__)
float3 w CTR_WTF(0.0f);
#define STRING(x, ...) #__VA_ARGS__
string Bar = STRING(7, Pass, 8);

produces

float x = {0.0f};
float3 y = {1.0f, 2.0f, 3.0f};
float3 z = float3(4.0f, 5.0f, 6.0f);

float3 w = float(0.0f);

string Bar = "Pass, 8";

TIMONz1535 avatar Apr 19 '24 17:04 TIMONz1535