From 354d3b97a5b639ea79a5de0987ac4cb34dafb23f Mon Sep 17 00:00:00 2001 From: Zachary Snow Date: Tue, 10 Sep 2024 21:25:57 +0200 Subject: [PATCH] Move resultIsOutput into result --- tools/codegen/SDL/functions.ts | 4 ++-- tools/codegen/generators.ts | 8 ++++---- tools/codegen/types.ts | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tools/codegen/SDL/functions.ts b/tools/codegen/SDL/functions.ts index 84eaa55..9236f61 100644 --- a/tools/codegen/SDL/functions.ts +++ b/tools/codegen/SDL/functions.ts @@ -487,8 +487,8 @@ export const functions: CodeGenFunctions = { }, result: { type: "Uint8*", + isOutput: true, }, - resultIsOutput: true, implementation: GET_KEYBOARD_STATE, }, SDL_GetRendererInfo: { @@ -1041,9 +1041,9 @@ export const functions: CodeGenFunctions = { }, result: { type: "SDL_AudioSpec*", + isOutput: true, }, checkForError: true, - resultIsOutput: true, implementation: LOADWAV_RW, }, SDL_LockSurface: { diff --git a/tools/codegen/generators.ts b/tools/codegen/generators.ts index 5813bf8..66454de 100644 --- a/tools/codegen/generators.ts +++ b/tools/codegen/generators.ts @@ -1624,7 +1624,7 @@ import { f32, f64, i32, InitOptions, int, Int, TypedArray, u16, u32, U32, u64, u outputParams[0][1] ); - if (func.resultIsOutput) { + if (func.result.isOutput) { returnType = "[" + returnType + ", " + outputParam + "]"; } else { returnType = outputParam; @@ -1632,7 +1632,7 @@ import { f32, f64, i32, InitOptions, int, Int, TypedArray, u16, u32, U32, u64, u } else if (outputParams.length > 1) { returnType = "[" + - (func.resultIsOutput ? returnType + ", " : "") + + (func.result.isOutput ? returnType + ", " : "") + outputParams .map(([_, outputParam]) => mapFunctionReturnTypeFromOutputParam( @@ -1793,7 +1793,7 @@ import { f32, f64, i32, InitOptions, int, Int, TypedArray, u16, u32, U32, u64, u if (outputParams.length === 0) { lines.push("return _result;"); } else if (outputParams.length === 1) { - if (func.resultIsOutput) { + if (func.result.isOutput) { lines.push(`return [_result, ${outputParams[0][0]}];`); } else { lines.push(`return ${outputParams[0][0]};`); @@ -1803,7 +1803,7 @@ import { f32, f64, i32, InitOptions, int, Int, TypedArray, u16, u32, U32, u64, u .map(([paramName, _]) => `${paramName}.value`) .join(", "); - if (func.resultIsOutput) { + if (func.result.isOutput) { lines.push(`return [_result, ${outputParamNames}];`); } else { lines.push(`return [${outputParamNames}];`); diff --git a/tools/codegen/types.ts b/tools/codegen/types.ts index 1e38746..e31fdb7 100644 --- a/tools/codegen/types.ts +++ b/tools/codegen/types.ts @@ -51,6 +51,11 @@ export interface CodeGenFunctionResult { // If set this type will be used as the script type. overrideType?: string; + + // If any parameter is marked as an output parameter than the return value + // will generally be discarded. This flag specifies that the return value + // should not be discarded when there are output parameters. + isOutput?: boolean; } export interface CodeGenFunction { @@ -65,11 +70,6 @@ export interface CodeGenFunction { result: CodeGenFunctionResult; - // If any parameter is marked as an output parameter than the return value - // will generally be discarded. This flag specifies that the return value - // should not be discarded when there are output parameters. - resultIsOutput?: boolean; - overloads?: ReadonlyArray<{ parameters?: Record>; result?: Partial;