Skip to content

Commit

Permalink
CNZSL: nzslSerializeShader now returns a boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
SirLynix committed Sep 28, 2024
1 parent 4e71c2b commit a3670e7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion include/CNZSL/Serializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ typedef struct nzslDeserializer nzslDeserializer;

CNZSL_API nzslSerializer* nzslSerializerCreate(void);
CNZSL_API void nzslSerializerDestroy(nzslSerializer* serializerPtr);
CNZSL_API void nzslSerializeShader(nzslSerializer* serializerPtr, const nzslModule* modulePtr);
CNZSL_API nzslBool nzslSerializeShader(nzslSerializer* serializerPtr, const nzslModule* modulePtr);
CNZSL_API const char* nzslSerializerGetLastError(const nzslSerializer* serializerPtr);

CNZSL_API nzslDeserializer* nzslDeserializerCreate(const void* data, size_t dataSize);
Expand Down
7 changes: 6 additions & 1 deletion src/CNZSL/Serializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ extern "C"
delete serializerPtr;
}

CNZSL_API void nzslSerializeShader(nzslSerializer* serializerPtr, const nzslModule* modulePtr)
CNZSL_API nzslBool nzslSerializeShader(nzslSerializer* serializerPtr, const nzslModule* modulePtr)
{
assert(serializerPtr);
assert(modulePtr);
Expand All @@ -34,11 +34,16 @@ extern "C"
catch(std::exception& e)
{
serializerPtr->lastError = fmt::format("nzslSerializeShader failed: {}", e.what());
return false;
}
catch(...)
{
serializerPtr->lastError = "nzslSerializeShader failed with unknown error";
return false;
}

return true;
}
}

CNZSL_API const char* nzslSerializerGetLastError(const nzslSerializer* serializerPtr)
Expand Down

0 comments on commit a3670e7

Please sign in to comment.