Skip to content

Commit

Permalink
(#354) CodeGen: improve validation of vararg CLI imports
Browse files Browse the repository at this point in the history
  • Loading branch information
ForNeVeR committed Nov 18, 2023
1 parent 862f518 commit 12b22d4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Cesium.CodeGen/Contexts/TranslationUnitContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,15 @@ private FunctionInfo ProcessCliImport(FunctionInfo declaration, MethodReference

List<ParameterInfo> ProcessParameters(ICollection<ParameterInfo> parameters)
{
// For now, only wrap the interop types.
if (implementation.Parameters.Count != parameters.Count)
var areParametersValid =
implementation.Parameters.Count == parameters.Count
|| declaration.Parameters.IsVarArg; // TODO: A better check for interop functions + vararg.
if (!areParametersValid)
{
throw new CompilationException(
$"Parameter count for function {declaration.CliImportMember} " +
$"doesn't match the parameter count of imported CLI method {implementation.FullName}.");
}

return parameters.Zip(implementation.Parameters)
.Select(pair =>
Expand Down

0 comments on commit 12b22d4

Please sign in to comment.