From 7e68e452d36c3b0278d7d839ed6e49d15b87e4e3 Mon Sep 17 00:00:00 2001 From: James Cherry Date: Thu, 7 May 2026 11:11:32 -0700 Subject: [PATCH] mv is_object to Util.i Signed-off-by: James Cherry --- tcl/StaTclTypes.i | 39 --------------------------------------- util/Util.i | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 39 deletions(-) diff --git a/tcl/StaTclTypes.i b/tcl/StaTclTypes.i index 8136bd60..c5eb3420 100644 --- a/tcl/StaTclTypes.i +++ b/tcl/StaTclTypes.i @@ -265,45 +265,6 @@ using namespace sta; %} -//////////////////////////////////////////////////////////////// - -%inline %{ - -bool -is_object(const char *obj) -{ - // _hexaddress_p_type - const std::string s(obj); - if (s.empty() || s[0] != '_') - return false; - const size_t hex_digits = sizeof(void *) * 2; - if (s.size() < 1 + hex_digits + 3) - return false; - for (size_t i = 1; i < 1 + hex_digits; i++) { - if (!std::isxdigit(static_cast(s[i]))) - return false; - } - if (s.compare(1 + hex_digits, 3, "_p_") != 0) - return false; - for (size_t i = 1 + hex_digits + 3; i < s.size(); i++) { - char ch = s[i]; - if (!(std::isalnum(ch) || ch == '_')) - return false; - } - return true; -} - -// Assumes is_object is true. -const char * -object_type(const char *obj) -{ - if (is_object(obj)) - return &obj[1 + sizeof(void*) * 2 + 3]; - return ""; -} - -%} - //////////////////////////////////////////////////////////////// // // SWIG type definitions. diff --git a/util/Util.i b/util/Util.i index ce128f5e..3a64c735 100644 --- a/util/Util.i +++ b/util/Util.i @@ -504,4 +504,39 @@ fuzzy_equal(float value1, return fuzzyEqual(value1, value2); } +//////////////////////////////////////////////////////////////// + +bool +is_object(const char *obj) +{ + // _hexaddress_p_type + const std::string s(obj); + if (s.empty() || s[0] != '_') + return false; + const size_t hex_digits = sizeof(void *) * 2; + if (s.size() < 1 + hex_digits + 3) + return false; + for (size_t i = 1; i < 1 + hex_digits; i++) { + if (!std::isxdigit(static_cast(s[i]))) + return false; + } + if (s.compare(1 + hex_digits, 3, "_p_") != 0) + return false; + for (size_t i = 1 + hex_digits + 3; i < s.size(); i++) { + char ch = s[i]; + if (!(std::isalnum(ch) || ch == '_')) + return false; + } + return true; +} + +// Assumes is_object is true. +const char * +object_type(const char *obj) +{ + if (is_object(obj)) + return &obj[1 + sizeof(void*) * 2 + 3]; + return ""; +} + %} // inline