From 8533dd2344d8be040a992a86f23e7cf696d59c4a Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Tue, 15 Mar 2022 10:45:24 -0400 Subject: C++ extractor callable support (#2159) * #include an absolute path didn't work - because paths were taken to always be relative. * Split doc extractor such that can be used in C++ extractor. * Compiles. Update the stdlib docs. * Fix issue on release builds. * Add support for extracting documentation to C++ extractor. * Dump out markup. Make enum value backing type take tokens. * Node::Type -> Node::Kind * More improvements around Node::Type -> Node::Kind * Support for parsing callable types. * Fix issue params for callable, and default value for variable. * Add support for static. * Improve handling parsing of contained types. * Small improvements around template consumption. * Improve dumping with markup/static. * Small improvements around reflection. * Add more flexible handling of markers. Allow reflection without markers. --- tools/slang-cpp-extractor/unit-test.cpp | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'tools/slang-cpp-extractor/unit-test.cpp') diff --git a/tools/slang-cpp-extractor/unit-test.cpp b/tools/slang-cpp-extractor/unit-test.cpp index a30a3caa7..c239a2a2c 100644 --- a/tools/slang-cpp-extractor/unit-test.cpp +++ b/tools/slang-cpp-extractor/unit-test.cpp @@ -41,12 +41,26 @@ struct TestState }; static const char someSource[] = +"#define SLANG_REFLECTED\n" +"\n" +"SLANG_REFLECTED\n" +"class ISomeInterface\n" +"{\n" +" public:\n" +" virtual int SLANG_MCALL someMethod(int a, int b) const = 0;\n" +" virtual float SLANG_MCALL anotherMethod(float a) = 0;\n" +"};\n" +"\n" "enum SomeEnum\n" "{\n" " Value,\n" " Another = 10,\n" "};\n" -"typedef SomeEnum AliasEnum;\n"; +"typedef SomeEnum AliasEnum;\n" +"void someFunc(int a, float b) { }\n" +"namespace Blah {\n" +"int add(int a, int b) { return a + b; }\n" +"}\n"; /* static */SlangResult UnitTestUtil::run() @@ -65,6 +79,8 @@ static const char someSource[] = SourceOrigin* sourceOrigin = tree.addSourceOrigin(sourceFile, state.m_options); Parser parser(&tree, &state.m_sink); + // We don't require markers to reflect + parser.setRequireMarker(false); { const Node::Kind enableKinds[] = { Node::Kind::Enum, Node::Kind::EnumClass, Node::Kind::EnumCase, Node::Kind::TypeDef }; @@ -72,6 +88,14 @@ static const char someSource[] = } SLANG_RETURN_ON_FAIL(parser.parse(sourceOrigin, &state.m_options)); + + + { + StringBuilder buf; + tree.getRootNode()->dump(0, buf); + + SLANG_UNUSED(buf); + } } return SLANG_OK; -- cgit v1.2.3