From 5bb5b80df3707d2338e52c1a0b454e19f4a418f4 Mon Sep 17 00:00:00 2001 From: tareksander <57038324+tareksander@users.noreply.github.com> Date: Sat, 9 Nov 2024 12:14:49 +0100 Subject: [PATCH] Fixed linker error --- include/slang-deprecated.h | 1 + source/slang/slang-reflection-json.cpp | 10 ++++++++++ .../slang-reflection-test-main.cpp | 12 +++++------- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/include/slang-deprecated.h b/include/slang-deprecated.h index 1c1350f9f8..bbcc8deb04 100644 --- a/include/slang-deprecated.h +++ b/include/slang-deprecated.h @@ -498,6 +498,7 @@ extern "C" SLANG_API SlangReflectionGeneric* spReflectionType_GetGenericContainer( SlangReflectionType* type); + SLANG_API SlangResult spReflection_ToJson(SlangReflection* reflection, SlangCompileRequest* request, ISlangBlob** outBlob); // Type Layout Reflection SLANG_API SlangReflectionType* spReflectionTypeLayout_GetType(SlangReflectionTypeLayout* type); diff --git a/source/slang/slang-reflection-json.cpp b/source/slang/slang-reflection-json.cpp index 2ca68d8c8c..9be615b862 100644 --- a/source/slang/slang-reflection-json.cpp +++ b/source/slang/slang-reflection-json.cpp @@ -2,6 +2,7 @@ #include "slang-reflection-json.h" #include "slang.h" +#include "../core/slang-blob.h" template struct Range @@ -1196,3 +1197,12 @@ void emitReflectionJSON( } } // namespace Slang + + +extern "C" SLANG_API SlangResult spReflection_ToJson(SlangReflection* reflection, SlangCompileRequest* request, ISlangBlob** outBlob) { + using namespace Slang; + PrettyWriter writer; + emitReflectionJSON(request, reflection, writer); + *outBlob = StringBlob::moveCreate(writer.getBuilder()); + return SLANG_OK; +} diff --git a/tools/slang-reflection-test/slang-reflection-test-main.cpp b/tools/slang-reflection-test/slang-reflection-test-main.cpp index ed19f6343c..90e9308dfb 100644 --- a/tools/slang-reflection-test/slang-reflection-test-main.cpp +++ b/tools/slang-reflection-test/slang-reflection-test-main.cpp @@ -5,7 +5,8 @@ #include "../../source/core/slang-string-escape-util.h" #include "../../source/core/slang-string-util.h" #include "../../source/core/slang-test-tool-util.h" -#include "../../source/slang/slang-reflection-json.h" +#include "../../source/core/slang-blob.h" +#include "slang-deprecated.h" #include "slang-com-helper.h" #include "slang.h" @@ -18,15 +19,12 @@ using namespace Slang; void emitReflectionJSON(SlangCompileRequest* request, SlangReflection* reflection) { - PrettyWriter writer; + ISlangBlob* b; - emitReflectionJSON(request, reflection, writer); - - // Get the contents of the writer - const auto slice = writer.getBuilder().getUnownedSlice(); + spReflection_ToJson(reflection, request, &b); // Output the writer content to out stream - StdWriters::getOut().write(slice.begin(), slice.getLength()); + StdWriters::getOut().write((const char*) b->getBufferPointer(), b->getBufferSize()); } static SlangResult maybeDumpDiagnostic(SlangResult res, SlangCompileRequest* request)