From 939688e963fde7a0485f210ef2674c27692021a4 Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Tue, 7 Nov 2017 14:05:22 -0800 Subject: Add reflection API to get type name (#263) This is currently only useful for `struct` types. I implemented a special-case exception so that the auto-generated `struct` types used for `cbuffer` members don't show their internal name. I did *not* implement any logic to avoid returning the name `vector` for a vector type, etc., since they are all `DeclRefType`s and it seemed easiest to just let the user access information they can't really use. --- tools/slang-reflection-test/main.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'tools/slang-reflection-test/main.cpp') diff --git a/tools/slang-reflection-test/main.cpp b/tools/slang-reflection-test/main.cpp index f604ca1aa..b0d970ba3 100644 --- a/tools/slang-reflection-test/main.cpp +++ b/tools/slang-reflection-test/main.cpp @@ -460,11 +460,17 @@ static void emitReflectionTypeLayoutInfoJSON( case slang::TypeReflection::Kind::Struct: { + auto structTypeLayout = typeLayout; + write(writer, "\"kind\": \"struct\",\n"); + if( auto name = structTypeLayout->getName() ) + { + emitReflectionNameInfoJSON(writer, structTypeLayout->getName()); + write(writer, ",\n"); + } write(writer, "\"fields\": [\n"); indent(writer); - auto structTypeLayout = typeLayout; auto fieldCount = structTypeLayout->getFieldCount(); for( uint32_t ff = 0; ff < fieldCount; ++ff ) { -- cgit v1.2.3