diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2020-10-23 15:07:10 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-23 15:07:10 -0400 |
| commit | 051b20c218124e9ffc72ae31b95529b35aa9a43c (patch) | |
| tree | ea73a5ad64d29e6fb01ad4b8f7e34d4444f9b24e /source/slang/slang-ast-dump.cpp | |
| parent | 6d1fe29cdcbca18d559e302d6427a504d1762173 (diff) | |
C++ extractor fix for access modifiers (#1586)
* #include an absolute path didn't work - because paths were taken to always be relative.
* Fix handling of access modifiers inside type definition.
* Fix access problem for AST node.
Make dumping produce a single function with switch, to potentially make available without Dump specific access.
* Remove project references to previously generated files.
Diffstat (limited to 'source/slang/slang-ast-dump.cpp')
| -rw-r--r-- | source/slang/slang-ast-dump.cpp | 39 |
1 files changed, 12 insertions, 27 deletions
diff --git a/source/slang/slang-ast-dump.cpp b/source/slang/slang-ast-dump.cpp index 552c97d7f..38dfa9c2f 100644 --- a/source/slang/slang-ast-dump.cpp +++ b/source/slang/slang-ast-dump.cpp @@ -616,37 +616,26 @@ struct ASTDumpContext struct ASTDumpAccess { -#define SLANG_AST_DUMP_FIELD(FIELD_NAME, TYPE, param) context.dumpField(#FIELD_NAME, node->FIELD_NAME); + +#define SLANG_AST_DUMP_FIELD(FIELD_NAME, TYPE, param) context.dumpField(#FIELD_NAME, static_cast<param*>(base)->FIELD_NAME); #define SLANG_AST_DUMP_FIELDS_IMPL(NAME, SUPER, ORIGIN, LAST, MARKER, TYPE, param) \ -static void dumpFields_##NAME(NAME* node, ASTDumpContext& context) \ +case ASTNodeType::NAME: \ { \ - SLANG_UNUSED(node); \ - SLANG_UNUSED(context); \ - SLANG_FIELDS_ASTNode_##NAME(SLANG_AST_DUMP_FIELD, _) \ + SLANG_FIELDS_ASTNode_##NAME(SLANG_AST_DUMP_FIELD, NAME) \ + break; \ } -SLANG_ALL_ASTNode_NodeBase(SLANG_AST_DUMP_FIELDS_IMPL, _) - -}; - -#define SLANG_AST_GET_DUMP_FUNC(NAME, SUPER, ORIGIN, LAST, MARKER, TYPE, param) m_funcs[Index(ASTNodeType::NAME)] = (DumpFieldsFunc)&ASTDumpAccess::dumpFields_##NAME; - -typedef void (*DumpFieldsFunc)(NodeBase* obj, ASTDumpContext& context); - -struct DumpFieldFuncs -{ - DumpFieldFuncs() + static void dump(ASTNodeType type, NodeBase* base, ASTDumpContext& context) { - memset(m_funcs, 0, sizeof(m_funcs)); - SLANG_ALL_ASTNode_NodeBase(SLANG_AST_GET_DUMP_FUNC, _) + switch (type) + { + SLANG_ALL_ASTNode_NodeBase(SLANG_AST_DUMP_FIELDS_IMPL, _) + default: break; + } } - - DumpFieldsFunc m_funcs[Index(ASTNodeType::CountOf)]; }; -static const DumpFieldFuncs s_funcs; - void ASTDumpContext::dumpObjectReference(const ReflectClassInfo& type, NodeBase* obj, Index objIndex) { SLANG_UNUSED(obj); @@ -678,11 +667,7 @@ void ASTDumpContext::dumpObjectFull(const ReflectClassInfo& type, NodeBase* obj, for (Index i = allTypes.getCount() - 1; i >= 0; --i) { const ReflectClassInfo* curType = allTypes[i]; - DumpFieldsFunc func = s_funcs.m_funcs[Index(curType->m_classId)]; - if (func) - { - func(obj, *this); - } + ASTDumpAccess::dump(ASTNodeType(curType->m_classId), obj, *this); } m_writer->dedent(); |
