summaryrefslogtreecommitdiff
path: root/tools/slang-cpp-extractor/macro-writer.h
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2021-04-22 09:32:25 -0400
committerGitHub <noreply@github.com>2021-04-22 09:32:25 -0400
commitda0d295d6c8b6fb03245dea0583437c198890349 (patch)
treeed17baba750b15f6ace1427f04cf19690269161e /tools/slang-cpp-extractor/macro-writer.h
parent34fba7b5e726136c6eee8a318ab9a75381399c00 (diff)
C++ extractor improvements (#1803)
* #include an absolute path didn't work - because paths were taken to always be relative. * Split of NodeTree. Split out FileUtil. Split out MacroWriter. * Rename slang-cpp-extractor-main.cpp -> cpp-extractor-main.cpp * First pass at extractor unit-tests * Initial parsing of enum. * Ability to disable/enable parsing of scope types. * Initial support for typedef. * Added operator== != to ArrayVIew. Added test for splitting to unit tests. * Improve comment in StringUtil. * Fix comment. * Fix typo.
Diffstat (limited to 'tools/slang-cpp-extractor/macro-writer.h')
-rw-r--r--tools/slang-cpp-extractor/macro-writer.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/tools/slang-cpp-extractor/macro-writer.h b/tools/slang-cpp-extractor/macro-writer.h
new file mode 100644
index 000000000..b1754741d
--- /dev/null
+++ b/tools/slang-cpp-extractor/macro-writer.h
@@ -0,0 +1,47 @@
+#ifndef CPP_EXTRACT_MACRO_WRITER_H
+#define CPP_EXTRACT_MACRO_WRITER_H
+
+#include "diagnostics.h"
+
+#include "options.h"
+#include "node-tree.h"
+
+#include "../../source/compiler-core/slang-diagnostic-sink.h"
+
+namespace CppExtract {
+using namespace Slang;
+
+/* A class that writes out macros that define type hierarchies, as well as fields of types */
+class MacroWriter
+{
+public:
+
+ /// Write output
+ SlangResult writeOutput(NodeTree* tree);
+
+ /// Write def files
+ SlangResult writeDefs(NodeTree* tree);
+
+ /// Calculate the header
+ SlangResult calcTypeHeader(NodeTree* tree, TypeSet* typeSet, StringBuilder& out);
+ SlangResult calcChildrenHeader(NodeTree* tree, TypeSet* typeSet, StringBuilder& out);
+ SlangResult calcOriginHeader(NodeTree* tree, StringBuilder& out);
+
+ SlangResult calcDef(NodeTree* tree, SourceOrigin* origin, StringBuilder& out);
+
+ /// Ctor.
+ MacroWriter(DiagnosticSink* sink, const Options* options):
+ m_sink(sink),
+ m_options(options)
+ {
+ }
+
+protected:
+
+ const Options* m_options = nullptr;
+ DiagnosticSink* m_sink;
+};
+
+} // CppExtract
+
+#endif