From 11da2fb2051894b3cc873748cfc8f47588d8af93 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Wed, 2 Mar 2022 10:07:26 -0500 Subject: Small fix to use SlangResult (#2149) * Use SlangResult value. Make legacy SLANG_ERROR_ macros use SlangResult values. --- source/slang/slang-reflection-api.cpp | 13 +++++++------ source/slang/slang.cpp | 16 ++++++++-------- 2 files changed, 15 insertions(+), 14 deletions(-) (limited to 'source') diff --git a/source/slang/slang-reflection-api.cpp b/source/slang/slang-reflection-api.cpp index 8919e2ba5..583e000a6 100644 --- a/source/slang/slang-reflection-api.cpp +++ b/source/slang/slang-reflection-api.cpp @@ -265,27 +265,28 @@ SlangReflectionType* spReflectionUserAttribute_GetArgumentType(SlangReflectionUs SLANG_API SlangResult spReflectionUserAttribute_GetArgumentValueInt(SlangReflectionUserAttribute* attrib, unsigned int index, int * rs) { auto userAttr = convert(attrib); - if (!userAttr) return SLANG_ERROR_INVALID_PARAMETER; - if (index >= (unsigned int)userAttr->args.getCount()) return SLANG_ERROR_INVALID_PARAMETER; + if (!userAttr) return SLANG_E_INVALID_ARG; + if (index >= (unsigned int)userAttr->args.getCount()) return SLANG_E_INVALID_ARG; + NodeBase* val = nullptr; if (userAttr->intArgVals.TryGetValue(index, val)) { *rs = (int)as(val)->value; return 0; } - return SLANG_ERROR_INVALID_PARAMETER; + return SLANG_E_INVALID_ARG; } SLANG_API SlangResult spReflectionUserAttribute_GetArgumentValueFloat(SlangReflectionUserAttribute* attrib, unsigned int index, float * rs) { auto userAttr = convert(attrib); - if (!userAttr) return SLANG_ERROR_INVALID_PARAMETER; - if (index >= (unsigned int)userAttr->args.getCount()) return SLANG_ERROR_INVALID_PARAMETER; + if (!userAttr) return SLANG_E_INVALID_ARG; + if (index >= (unsigned int)userAttr->args.getCount()) return SLANG_E_INVALID_ARG; if (auto cexpr = as(userAttr->args[index])) { *rs = (float)cexpr->value; return 0; } - return SLANG_ERROR_INVALID_PARAMETER; + return SLANG_E_INVALID_ARG; } SLANG_API const char* spReflectionUserAttribute_GetArgumentValueString(SlangReflectionUserAttribute* attrib, unsigned int index, size_t* bufLen) { diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index c1834eacb..67908841f 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -4278,7 +4278,7 @@ char const* EndToEndCompileRequest::getDiagnosticOutput() SlangResult EndToEndCompileRequest::getDiagnosticOutputBlob(ISlangBlob** outBlob) { - if (!outBlob) return SLANG_ERROR_INVALID_PARAMETER; + if (!outBlob) return SLANG_E_INVALID_ARG; if (!m_diagnosticOutputBlob) { @@ -4623,14 +4623,14 @@ static SlangResult _getEntryPointResult( Index targetCount = linkage->targets.getCount(); if ((targetIndex < 0) || (targetIndex >= targetCount)) { - return SLANG_ERROR_INVALID_PARAMETER; + return SLANG_E_INVALID_ARG; } auto targetReq = linkage->targets[targetIndex]; Index entryPointCount = req->m_entryPoints.getCount(); if ((entryPointIndex < 0) || (entryPointIndex >= entryPointCount)) { - return SLANG_ERROR_INVALID_PARAMETER; + return SLANG_E_INVALID_ARG; } auto entryPointReq = program->getEntryPoint(entryPointIndex); @@ -4653,7 +4653,7 @@ static SlangResult _getWholeProgramResult( Index targetCount = linkage->targets.getCount(); if ((targetIndex < 0) || (targetIndex >= targetCount)) { - return SLANG_ERROR_INVALID_PARAMETER; + return SLANG_E_INVALID_ARG; } auto targetReq = linkage->targets[targetIndex]; @@ -4666,7 +4666,7 @@ static SlangResult _getWholeProgramResult( SlangResult EndToEndCompileRequest::getEntryPointCodeBlob(int entryPointIndex, int targetIndex, ISlangBlob** outBlob) { - if (!outBlob) return SLANG_ERROR_INVALID_PARAMETER; + if (!outBlob) return SLANG_E_INVALID_ARG; CompileResult* compileResult = nullptr; SLANG_RETURN_ON_FAIL(_getEntryPointResult(this, entryPointIndex, targetIndex, &compileResult)); @@ -4679,7 +4679,7 @@ SlangResult EndToEndCompileRequest::getEntryPointCodeBlob(int entryPointIndex, i SlangResult EndToEndCompileRequest::getEntryPointHostCallable(int entryPointIndex, int targetIndex, ISlangSharedLibrary** outSharedLibrary) { - if (!outSharedLibrary) return SLANG_ERROR_INVALID_PARAMETER; + if (!outSharedLibrary) return SLANG_E_INVALID_ARG; CompileResult* compileResult = nullptr; SLANG_RETURN_ON_FAIL(_getEntryPointResult(this, entryPointIndex, targetIndex, &compileResult)); @@ -4693,7 +4693,7 @@ SlangResult EndToEndCompileRequest::getEntryPointHostCallable(int entryPointInde SlangResult EndToEndCompileRequest::getTargetCodeBlob(int targetIndex, ISlangBlob** outBlob) { if (!outBlob) - return SLANG_ERROR_INVALID_PARAMETER; + return SLANG_E_INVALID_ARG; CompileResult* compileResult = nullptr; SLANG_RETURN_ON_FAIL(_getWholeProgramResult(this, targetIndex, &compileResult)); @@ -4707,7 +4707,7 @@ SlangResult EndToEndCompileRequest::getTargetCodeBlob(int targetIndex, ISlangBlo SlangResult EndToEndCompileRequest::getTargetHostCallable(int targetIndex,ISlangSharedLibrary** outSharedLibrary) { if (!outSharedLibrary) - return SLANG_ERROR_INVALID_PARAMETER; + return SLANG_E_INVALID_ARG; CompileResult* compileResult = nullptr; SLANG_RETURN_ON_FAIL(_getWholeProgramResult(this, targetIndex, &compileResult)); -- cgit v1.2.3