yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

Lauro OyenMove c++ parsing code from slang-cpp-extractor to static library (#5675)eaa8dcfcc

master
2.3 KiB63 linesraw
1#pragma once
2
3#include "slang/slang-diagnostics.h"
4
5namespace CppParse
6{
7using namespace Slang;
8
9
10// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Options !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
11
12struct Options
13{
14    void reset() { *this = Options(); }
15
16    Options()
17    {
18        m_markPrefix = "SLANG_";
19        m_markSuffix = "_CLASS";
20    }
21
22    bool m_defs = false; ///< If set will output a '-defs.h' file for each of the input files, that
23                         ///< corresponds to previous defs files (although doesn't have fields/RAW)
24    bool m_dump =
25        false; ///< If true will dump to stderr the types/fields and hierarchy it extracted
26    bool m_runUnitTests = false; ///< If true will run internal unit tests
27    bool m_extractDoc = true;    ///< If set will try to extract documentation associated with nodes
28
29    bool m_outputFields = false; ///< When dumping macros also dump field definitions
30    bool m_requireMark = true;
31
32    List<String> m_inputPaths; ///< The input paths to the files to be processed
33
34    String m_outputPath; ///< The output path. Note that the extractor can generate multiple output
35                         ///< files, and this will actually be the 'stem' of several files
36
37    String m_inputDirectory;  ///< The input directory that is by default used for reading
38                              ///< m_inputPaths from.
39    String m_markPrefix;      ///< The prefix of the 'marker' used to identify a reflected type
40    String m_markSuffix;      ///< The postfix of the 'marker' used to identify a reflected type
41    String m_stripFilePrefix; ///< Used for the 'origin' information, this is stripped from the
42                              ///< source filename, and the remainder of the filename (without
43                              ///< extension) is 'macroized'
44};
45
46struct OptionsParser
47{
48    /// Parse the parameters. NOTE! Must have the program path removed
49    SlangResult parse(int argc, const char* const* argv, DiagnosticSink* sink, Options& outOptions);
50
51    SlangResult _parseArgWithValue(const char* option, String& outValue);
52    SlangResult _parseArgReplaceValue(const char* option, String& outValue);
53    SlangResult _parseArgFlag(const char* option, bool& outFlag);
54
55    String m_reflectType;
56
57    Index m_index;
58    Int m_argCount;
59    const char* const* m_args;
60    DiagnosticSink* m_sink;
61};
62
63} // namespace CppParse