From 339731cc5c47d78306fa15c7df153cfd4adefb77 Mon Sep 17 00:00:00 2001 From: Christian Sarofeen Date: Thu, 25 Dec 2025 21:29:27 -0500 Subject: [PATCH 01/23] M8 Task 1a: Move PolymorphicValue alias to detail namespace Preparatory refactor for wrapper class conversion. No behavior change - just moves the DynamicType alias into detail::DynamicTypeAlias and re-exports as PolymorphicValue. --- csrc/polymorphic_value.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/csrc/polymorphic_value.h b/csrc/polymorphic_value.h index 49b42555d79..a2c194eaf23 100644 --- a/csrc/polymorphic_value.h +++ b/csrc/polymorphic_value.h @@ -212,7 +212,8 @@ class StructHandle { inline Accessor operator->*(const std::string& key) const; }; -using PolymorphicValue = dynamic_type::DynamicType< +namespace detail { +using DynamicTypeAlias = dynamic_type::DynamicType< dynamic_type::Containers, StructHandle, Pointer, @@ -222,6 +223,9 @@ using PolymorphicValue = dynamic_type::DynamicType< double, int64_t, bool>; +} // namespace detail + +using PolymorphicValue = detail::DynamicTypeAlias; namespace PolymorphicValue_functions { From 8bbb51fef0687da588c86a09e115a23a00106c5d Mon Sep 17 00:00:00 2001 From: Christian Sarofeen Date: Tue, 30 Dec 2025 10:14:54 -0500 Subject: [PATCH 02/23] Revert "M8 Task 1a: Move PolymorphicValue alias to detail namespace" This reverts commit 339731cc5c47d78306fa15c7df153cfd4adefb77. --- csrc/polymorphic_value.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/csrc/polymorphic_value.h b/csrc/polymorphic_value.h index a2c194eaf23..49b42555d79 100644 --- a/csrc/polymorphic_value.h +++ b/csrc/polymorphic_value.h @@ -212,8 +212,7 @@ class StructHandle { inline Accessor operator->*(const std::string& key) const; }; -namespace detail { -using DynamicTypeAlias = dynamic_type::DynamicType< +using PolymorphicValue = dynamic_type::DynamicType< dynamic_type::Containers, StructHandle, Pointer, @@ -223,9 +222,6 @@ using DynamicTypeAlias = dynamic_type::DynamicType< double, int64_t, bool>; -} // namespace detail - -using PolymorphicValue = detail::DynamicTypeAlias; namespace PolymorphicValue_functions { From b2999ee1835029a52624894ff386e5e5ad170a94 Mon Sep 17 00:00:00 2001 From: Christian Sarofeen Date: Tue, 30 Dec 2025 10:29:49 -0500 Subject: [PATCH 03/23] M8 Task 2a: Create DynamicType split header structure (decl.h, impl.h, wrapper dynamic_type.h) --- lib/dynamic_type/src/dynamic_type/decl.h | 969 ++++++++++++++++++ .../src/dynamic_type/dynamic_type.h | 963 +---------------- lib/dynamic_type/src/dynamic_type/impl.h | 18 + 3 files changed, 991 insertions(+), 959 deletions(-) create mode 100644 lib/dynamic_type/src/dynamic_type/decl.h create mode 100644 lib/dynamic_type/src/dynamic_type/impl.h diff --git a/lib/dynamic_type/src/dynamic_type/decl.h b/lib/dynamic_type/src/dynamic_type/decl.h new file mode 100644 index 00000000000..13be1ab8aa4 --- /dev/null +++ b/lib/dynamic_type/src/dynamic_type/decl.h @@ -0,0 +1,969 @@ +// clang-format off +/* + * SPDX-FileCopyrightText: Copyright (c) 2023-present NVIDIA CORPORATION & AFFILIATES. + * All rights reserved. + * SPDX-License-Identifier: BSD-3-Clause + */ +// clang-format on +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "error.h" +#include "type_traits.h" + +namespace dynamic_type { + +// We must disable a lot of compiler warnings to make this work. The reason for +// the need to disable these warnings is not because the code quality in this +// file is bad, but because these apparently "bad" practices are necessary. For +// example, if you have a dynamic type that can be either a bool or a class +// SomeType{}, then we should support the ~ operator on it, because in the C++ +// standard bool supports it. Usually, when people write code like ~bool, they +// are making a mistake, and the compiler will want you to use !bool instead. +// However, in our case here we will allow everything that the C++ standard +// allows. The compiler should yell at the user who uses DynamicType with ~ +// but not at us for implementing it. + +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunused-comparison" +#pragma clang diagnostic ignored "-Wbitwise-instead-of-logical" +#pragma clang diagnostic ignored "-Wliteral-conversion" +#pragma clang diagnostic ignored "-Wunused-lambda-capture" +#pragma clang diagnostic ignored "-Wunknown-warning-option" +#pragma clang diagnostic ignored "-Wbool-operation" +#endif + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wbool-operation" +// gcc, even the latest version (13.1.1), is complaining about the following +// code: +// std::optional ret = std::nullopt; +// ... +// DYNAMIC_TYPE_CHECK(ret.has_value(), ...); +// return ret.value(); +// saying that ret.value() is used uninitialized. This complaint is totoally +// nonsense. +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif + +template