-
Notifications
You must be signed in to change notification settings - Fork 237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reflection compiler option #5507
Reflection compiler option #5507
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for putting these together! It all looks good to me. Only minor comments.
Would also be good if we can also get this added to our COM-based compilation API, in the form of IComponentType::getReflectionJson(IBlob** outBlob)
.
source/slang/slang.cpp
Outdated
reflectionPath.appendChar('\0'); | ||
auto bufferWriter = PrettyWriter(); | ||
emitReflectionJSON(this, this->getReflection(), bufferWriter); | ||
if (SLANG_FAILED(OSFileSystem::getMutableSingleton()->saveFile(reflectionPath.getBuffer(), bufferWriter.getBuilder().getBuffer(), bufferWriter.getBuilder().getLength()))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can use File::writeAllText()
.
source/core/slang-pretty-writer.h
Outdated
@@ -0,0 +1,122 @@ | |||
#ifndef SLANG_CORE_PRETTY_WRITER_H |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you put this file under compiler-core
instead of core
?
For formatting, you can post a message in this thread with the content "/format" and you will get a pull request to your branch for the formatting changes. |
writer << ",\n\"bindings\": [\n"; | ||
writer.indent(); | ||
|
||
auto parameterCount = programReflection->getParameterCount(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line has a warning that breaks the build on CI:
warning C4456: declaration of 'parameterCount' hides previous local declaration
It's not necessary to do, but it would be nice if this handled passing |
The code still needs to be formated. |
/format |
There are linking errors. |
/format (@tareksander, I just fixed a bug where non-write users couldn't trigger the formatting bot, I've done it now but it should work for you in the future) |
🌈 Formatted, please merge the changes from this PR |
I don't have enough knowledge of that API to do that.
Weird. |
This is because
Then you will be able to call this from reflection-test. |
Weird, since I'm on Linux, and symbols should be visible by default. That fixed it anyways, thanks. Now I get a segfault in |
…iler option -reflection-json to store the reflection data in a separate file.
… - is used as the path
97181f6
to
5bb5b80
Compare
include/slang.h
Outdated
@@ -884,6 +884,7 @@ typedef uint32_t SlangSizeT; | |||
DumpWarningDiagnostics, | |||
InputFilesRemain, | |||
EmitIr, // bool | |||
EmitReflectionJSON, // bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will break binary compatibility. New enum values should be added at the end.
The failures are due to C++ object lifetime issues. You need to do:
Otherwise the object will be deleted upon return. Also changed the callsite to use
instead of using raw I pushed the changes to your branch. |
/format |
🌈 Formatted, please merge the changes from this PR |
Everything looks good after fixing the memory management issue. |
Fixes #5492
Some questions:
OSFilesystem
the correct API to write a file?saveFile
expect a NULL-terminated string? I kind of just expected it to, since there is no length argument.All the reflection tests still seemed to pass.