Skip to content

Commit

Permalink
Fixed linker error
Browse files Browse the repository at this point in the history
  • Loading branch information
tareksander committed Nov 9, 2024
1 parent b4cc69e commit 97181f6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
1 change: 1 addition & 0 deletions include/slang-deprecated.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 10 additions & 0 deletions source/slang/slang-reflection-json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "slang-reflection-json.h"

#include "slang.h"
#include "../core/slang-blob.h"

template<typename T>
struct Range
Expand Down Expand Up @@ -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;
}
12 changes: 5 additions & 7 deletions tools/slang-reflection-test/slang-reflection-test-main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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)
Expand Down

0 comments on commit 97181f6

Please sign in to comment.