summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2022-03-02 10:07:26 -0500
committerGitHub <noreply@github.com>2022-03-02 10:07:26 -0500
commit11da2fb2051894b3cc873748cfc8f47588d8af93 (patch)
treeae5521fb36793f113f69bb7b251a34cf858e87e1
parent1b0d4259fbe39fbe2cd8482eb30d22a371db0b1a (diff)
Small fix to use SlangResult (#2149)
* Use SlangResult value. Make legacy SLANG_ERROR_ macros use SlangResult values.
-rw-r--r--slang.h5
-rw-r--r--source/slang/slang-reflection-api.cpp13
-rw-r--r--source/slang/slang.cpp16
3 files changed, 17 insertions, 17 deletions
diff --git a/slang.h b/slang.h
index 99d7f0d62..1d4c517b5 100644
--- a/slang.h
+++ b/slang.h
@@ -4471,9 +4471,8 @@ declarations over time.
extern "C" {
#endif
-
-#define SLANG_ERROR_INSUFFICIENT_BUFFER -1
-#define SLANG_ERROR_INVALID_PARAMETER -2
+#define SLANG_ERROR_INSUFFICIENT_BUFFER SLANG_E_BUFFER_TOO_SMALL
+#define SLANG_ERROR_INVALID_PARAMETER SLANG_E_INVALID_ARG
SLANG_API char const* spGetTranslationUnitSource(
SlangCompileRequest* request,
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<ConstantIntVal>(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<FloatingPointLiteralExpr>(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));