summaryrefslogtreecommitdiffstats
path: root/tools/slang-cpp-extractor/slang-cpp-extractor-main.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2020-05-08 14:31:40 -0400
committerGitHub <noreply@github.com>2020-05-08 14:31:40 -0400
commit798f3bc2236ce81499b05662dc11e7c071e7cde8 (patch)
treefbfa2ef90d4cfdace9ce3667cf441e22137792fb /tools/slang-cpp-extractor/slang-cpp-extractor-main.cpp
parentc16abd4fe1bda5ebcd50dbb22f30c6be43bb885f (diff)
AST nodes using C++ Extractor (#1341)
* Extractor builds without any reference to syntax (as it will be helping to produce this!). * Change macros to include the super class. * WIP replacing defs files. * Added indexOf(const UnownedSubString& in) to UnownedSubString. Refactored extractor * Output a macro for each type with the extracted info - can be used during injection in class * Simplify the header file - as can get super type and last from macro now * Store the 'origin' of a definition * Some small tidy ups to the extractor. * Improve comments on the extractor options. * Made CPPExtractor own SourceOrigins * Small fixes around SourceOrigin. * Small tidy up around macroOrign * WIP Visitor seems now to work correctly. Split out types used by ast into slang-ast-support-types.h * Fix remaining problems with C++ extractor being used with AST nodes. Add CountOf to extractor type ids. Added ReflectClassInfo::getInfo to turn an ASTNodeType into a ReflectClassInfo * Fix compiling on linux. Fix typo in memset. * Small tidy up around comments/layout. Moved NodeBase casting to NodeBase. * Make premake generate project that builds with cpp-extractor for AST. * Get the source directory from the filter in premake. * Fix typo in source path * Explicitly set the source path for premake generation for AST. * Special case handling of override to apease Clang. * Use a more general way to find the slang-ast-reflect.h file to run the extractor. * Appveyor is not triggering slang-cpp-extractor - try putting dependson together. * Put building slang-cpp-extractor first. * Disable some project options to stop MSBuild producing internal compiler errors. * Try reordering the projects in premake5.lua * Hack to try and make slang-cpp-extractor built on appveyor. * Disable flags - not required for MSBuild on appveyor. * Disable flags not required for build on AppVeyor. * Updated Visual Studio projects with slang-cpp-extractor. * Added Visual Studio slang-cpp-extractor project.
Diffstat (limited to 'tools/slang-cpp-extractor/slang-cpp-extractor-main.cpp')
-rw-r--r--tools/slang-cpp-extractor/slang-cpp-extractor-main.cpp27
1 files changed, 26 insertions, 1 deletions
diff --git a/tools/slang-cpp-extractor/slang-cpp-extractor-main.cpp b/tools/slang-cpp-extractor/slang-cpp-extractor-main.cpp
index f5724b7b6..9dd05ac78 100644
--- a/tools/slang-cpp-extractor/slang-cpp-extractor-main.cpp
+++ b/tools/slang-cpp-extractor/slang-cpp-extractor-main.cpp
@@ -1889,6 +1889,9 @@ SlangResult CPPExtractorApp::calcHeader(CPPExtractor& extractor, StringBuilder&
typeIndex++;
}
+ _indent(1, out);
+ out << "CountOf\n";
+
out << "};\n\n";
}
@@ -1968,7 +1971,7 @@ SlangResult CPPExtractorApp::calcHeader(CPPExtractor& extractor, StringBuilder&
// Output all of the definitions for each type
for (Node* node : nodes)
{
- out << "#define SLANG_" << reflectTypeName << "_" << node->m_name.Content << "(x, param) ";
+ out << "#define " << m_options.m_prefixMark << reflectTypeName << "_" << node->m_name.Content << "(x, param) ";
// Output the X macro part
_indent(1, out);
@@ -2027,6 +2030,7 @@ SlangResult CPPExtractorApp::calcHeader(CPPExtractor& extractor, StringBuilder&
}
}
+
// Now pop the scope in revers
for (Index j = baseScopePath.getCount() - 1; j >= 0; j--)
{
@@ -2035,6 +2039,27 @@ SlangResult CPPExtractorApp::calcHeader(CPPExtractor& extractor, StringBuilder&
}
}
+ // Do macros by origin
+
+ out << "// Origin macros\n\n";
+
+ for (SourceOrigin* origin : extractor.getSourceOrigins())
+ {
+ out << "#define " << m_options.m_prefixMark << "ORIGIN_" << origin->m_macroOrigin << "_" << reflectTypeName << "(x, param) \\\n";
+
+ for (Node* node : origin->m_nodes)
+ {
+ if (!(node->m_isReflected && node->isClassLike()))
+ {
+ continue;
+ }
+
+ _indent(1, out);
+ out << "x(" << node->m_name.Content << ", param) \\\n";
+ }
+ out << "/* */\n\n";
+ }
+
return SLANG_OK;
}