diff options
| author | Yong He <yonghe@outlook.com> | 2020-06-05 18:34:24 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-05 18:34:24 -0700 |
| commit | 52026c7c26e48921fdf18b3f8cdacad77a792643 (patch) | |
| tree | d439487223ee8ec4a2052d8855db310da878c001 /source/slang/slang-ast-reflect.cpp | |
| parent | 92fc3aaa835315ff08750c7b5a7498b7228e2c33 (diff) | |
| parent | 43c146794aab638924d2ab838d10f8af2ebf02a7 (diff) | |
Merge branch 'master' into findtypebynamefix
Diffstat (limited to 'source/slang/slang-ast-reflect.cpp')
| -rw-r--r-- | source/slang/slang-ast-reflect.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/source/slang/slang-ast-reflect.cpp b/source/slang/slang-ast-reflect.cpp index 689d9d93f..7d4fd0c1a 100644 --- a/source/slang/slang-ast-reflect.cpp +++ b/source/slang/slang-ast-reflect.cpp @@ -46,9 +46,18 @@ bool ReflectClassInfo::isSubClassOfSlow(const ThisType& super) const struct ASTConstructAccess { template <typename T> - struct CreateImpl + struct Impl { - static void* create(ASTBuilder* astBuilder) { return astBuilder->create<T>(); } + static void* create(ASTBuilder* astBuilder) + { + return astBuilder->create<T>(); + } + static void destroy(void* ptr) + { + // Needed because if type has non dtor, Visual Studio claims ptr not used + SLANG_UNUSED(ptr); + reinterpret_cast<T*>(ptr)->~T(); + } }; }; @@ -57,14 +66,13 @@ struct ASTConstructAccess #define SLANG_GET_SUPER_LEAF(SUPER) &SUPER::kReflectClassInfo #define SLANG_GET_CREATE_FUNC_ABSTRACT(NAME) nullptr -#define SLANG_GET_CREATE_FUNC_NONE(NAME) &ASTConstructAccess::CreateImpl<NAME>::create - -#define SLANG_GET_CREATE_FUNC_NON_VISITOR_ABSTRACT(NAME) nullptr -#define SLANG_GET_CREATE_FUNC_NON_VISITOR(NAME) &ASTConstructAccess::CreateImpl<NAME>::create +#define SLANG_GET_CREATE_FUNC_NONE(NAME) &ASTConstructAccess::Impl<NAME>::create +#define SLANG_GET_DESTROY_FUNC_ABSTRACT(NAME) nullptr +#define SLANG_GET_DESTROY_FUNC_NONE(NAME) &ASTConstructAccess::Impl<NAME>::destroy #define SLANG_REFLECT_CLASS_INFO(NAME, SUPER, ORIGIN, LAST, MARKER, TYPE, param) \ - /* static */const ReflectClassInfo NAME::kReflectClassInfo = { uint32_t(ASTNodeType::NAME), uint32_t(ASTNodeType::LAST), SLANG_GET_SUPER_##TYPE(SUPER), #NAME, SLANG_GET_CREATE_FUNC_##MARKER(NAME) }; + /* static */const ReflectClassInfo NAME::kReflectClassInfo = { uint32_t(ASTNodeType::NAME), uint32_t(ASTNodeType::LAST), SLANG_GET_SUPER_##TYPE(SUPER), #NAME, SLANG_GET_CREATE_FUNC_##MARKER(NAME), SLANG_GET_DESTROY_FUNC_##MARKER(NAME) }; SLANG_ALL_ASTNode_NodeBase(SLANG_REFLECT_CLASS_INFO, _) |
