From 72a3e97fe6bfdffee253ad008cab7cdd3b9e796f Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Thu, 13 Jul 2017 08:36:47 -0700 Subject: Allow `spGetEntryPointCode` to return text results too Fixes #77 - The `spGetEntryPointSource` function is now no longer needed, but I'm not going to "deprecate" it just yet --- source/slang/slang.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index 0561f30a9..bfc499c1b 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -880,8 +880,29 @@ SLANG_API void const* spGetEntryPointCode( { auto req = REQ(request); Slang::CompileResult& result = req->entryPoints[entryPointIndex]->result; - if(outSize) *outSize = result.outputBinary.Count(); - return result.outputBinary.Buffer(); + + void const* data = nullptr; + size_t size = 0; + + switch (result.format) + { + case Slang::ResultFormat::None: + default: + break; + + case Slang::ResultFormat::Binary: + data = result.outputBinary.Buffer(); + size = result.outputBinary.Count(); + break; + + case Slang::ResultFormat::Text: + data = result.outputString.Buffer(); + size = result.outputString.Length(); + break; + } + + if(outSize) *outSize = size; + return data; } // Reflection API -- cgit v1.2.3