From 812e478989e27983b8dea7ab11964de751654ba2 Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 4 Jun 2025 13:05:58 -0700 Subject: Make interface types non c-style in Slang2026. (#7260) * Make interface types non c-style. * Make Optional work with autodiff and existential types. * Fix. * patch behind slang 2026. * Fix warnings. * cleanup. * Fix tests. * Fix. * Fix com interface lowering. * Add comment to test. * regenerate command line reference * Add test for passing `none` to autodiff function. * Fix recording of `getDynamicObjectRTTIBytes`. * Fix nested Optional types. --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> --- source/slang/slang.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'source/slang/slang.cpp') diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index 9aa8c56a7..065b9de93 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -2029,6 +2029,31 @@ SLANG_NO_THROW SlangResult SLANG_MCALL Linkage::getTypeConformanceWitnessSequent return SLANG_OK; } +SLANG_NO_THROW SlangResult SLANG_MCALL Linkage::getDynamicObjectRTTIBytes( + slang::TypeReflection* type, + slang::TypeReflection* interfaceType, + uint32_t* outBuffer, + uint32_t bufferSize) +{ + // Slang RTTI header format: + // byte 0-7: pointer to RTTI struct describing the type. (not used for now, set to 1 for valid + // types, and 0 to represent null). + // byte 8-11: 32-bit sequential ID of the type conformance witness. + // byte 12-15: unused. + + if (bufferSize < 16) + return SLANG_E_BUFFER_TOO_SMALL; + + SLANG_AST_BUILDER_RAII(getASTBuilder()); + + SLANG_RETURN_ON_FAIL(getTypeConformanceWitnessSequentialID(type, interfaceType, outBuffer + 2)); + + // Make the RTTI part non zero. + outBuffer[0] = 1; + + return SLANG_OK; +} + SLANG_NO_THROW SlangResult SLANG_MCALL Linkage::createTypeConformanceComponentType( slang::TypeReflection* type, slang::TypeReflection* interfaceType, -- cgit v1.2.3