From 778428fecc0548af565e92745cf1344bcf19367f Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Mon, 19 Apr 2021 15:39:42 -0400 Subject: Splitting up C++ extractor (#1800) * #include an absolute path didn't work - because paths were taken to always be relative. * Refactor out ClassLikeNode * WIP around ScopeNode. * Use push and popScope. * Small improvements around C++ extractor. * Adding dynamic casting support. * Made Field another Node type. * Disable command line dumping by default. * Removed comment. * Fix shadowed variable bug found on linux. * Split out node. * Renamed C++ extractor diagnostics to just diagnostics.cpp/.h * Remove C++ extractor Options into separate options.cpp/options.h files. * Split out parser and identifier lookup from C++ extractor. * Put in CppExtract namespace. Simplify some of the class names. * Some simple renaming. * Split out NodeTree from Parser. --- tools/slang-cpp-extractor/options.h | 60 +++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 tools/slang-cpp-extractor/options.h (limited to 'tools/slang-cpp-extractor/options.h') diff --git a/tools/slang-cpp-extractor/options.h b/tools/slang-cpp-extractor/options.h new file mode 100644 index 000000000..ff88a3974 --- /dev/null +++ b/tools/slang-cpp-extractor/options.h @@ -0,0 +1,60 @@ +#ifndef CPP_EXTRACT_OPTIONS_H +#define CPP_EXTRACT_OPTIONS_H + +#include "../../source/slang/slang-diagnostics.h" + +namespace CppExtract { +using namespace Slang; + + +// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Options !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +struct Options +{ + void reset() + { + *this = Options(); + } + + Options() + { + m_markPrefix = "SLANG_"; + m_markSuffix = "_CLASS"; + } + + bool m_defs = false; ///< If set will output a '-defs.h' file for each of the input files, that corresponds to previous defs files (although doesn't have fields/RAW) + bool m_dump = false; ///< If true will dump to stderr the types/fields and hierarchy it extracted + + bool m_outputFields = false; ///< When dumping macros also dump field definitions + + List m_inputPaths; ///< The input paths to the files to be processed + + String m_outputPath; ///< The output path. Note that the extractor can generate multiple output files, and this will actually be the 'stem' of several files + + String m_inputDirectory; ///< The input directory that is by default used for reading m_inputPaths from. + String m_markPrefix; ///< The prefix of the 'marker' used to identify a reflected type + String m_markSuffix; ///< The postfix of the 'marker' used to identify a reflected type + String m_stripFilePrefix; ///< Used for the 'origin' information, this is stripped from the source filename, and the remainder of the filename (without extension) is 'macroized' +}; + +struct OptionsParser +{ + /// Parse the parameters. NOTE! Must have the program path removed + SlangResult parse(int argc, const char*const* argv, DiagnosticSink* sink, Options& outOptions); + + SlangResult _parseArgWithValue(const char* option, String& outValue); + SlangResult _parseArgReplaceValue(const char* option, String& outValue); + SlangResult _parseArgFlag(const char* option, bool& outFlag); + + String m_reflectType; + + Index m_index; + Int m_argCount; + const char*const* m_args; + DiagnosticSink* m_sink; +}; + + +} // CppExtract + +#endif -- cgit v1.2.3