codemaker/Executable_rustmaker.mk         |    2 
 codemaker/source/rustmaker/unoproduce.cxx |   70 ++++++++++++++++--------------
 codemaker/source/rustmaker/unoproduce.hxx |    4 -
 3 files changed, 41 insertions(+), 35 deletions(-)

New commits:
commit 36eeec7eee0a5fe974aa6764e63723dc27db3b6b
Author:     Arnaud VERSINI <[email protected]>
AuthorDate: Sun Nov 16 11:37:07 2025 +0100
Commit:     Arnaud Versini <[email protected]>
CommitDate: Sat Feb 7 18:53:58 2026 +0100

    rust code maker : use constexpr sets and maps
    
    Change-Id: Iffedaf0075abda2c6b1de24dea4c28aa2dd26282
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194067
    Reviewed-by: Arnaud Versini <[email protected]>
    Tested-by: Jenkins

diff --git a/codemaker/Executable_rustmaker.mk 
b/codemaker/Executable_rustmaker.mk
index 1fb006b23e83..7ac3cb6a4cce 100644
--- a/codemaker/Executable_rustmaker.mk
+++ b/codemaker/Executable_rustmaker.mk
@@ -30,4 +30,6 @@ $(eval $(call gb_Executable_add_exception_objects,rustmaker,\
     codemaker/source/rustmaker/cpp_include_manager \
 ))
 
+$(eval $(call gb_Executable_use_external,rustmaker,frozen))
+
 # vim:set noet sw=4 ts=4:
diff --git a/codemaker/source/rustmaker/unoproduce.cxx 
b/codemaker/source/rustmaker/unoproduce.cxx
index 77a5bdab3c40..a700797e36c0 100644
--- a/codemaker/source/rustmaker/unoproduce.cxx
+++ b/codemaker/source/rustmaker/unoproduce.cxx
@@ -8,12 +8,16 @@
  */
 
 #include <iostream>
-#include <set>
 #include <memory>
 
 #include <o3tl/string_view.hxx>
 #include <string_view>
 
+#include <frozen/bits/defines.h>
+#include <frozen/bits/elsa_std.h>
+#include <frozen/unordered_set.h>
+#include <frozen/unordered_map.h>
+
 #include "unoproduce.hxx"
 #include "rustproduce.hxx"
 #include "cpproduce.hxx"
@@ -24,35 +28,39 @@
 #include <unoidl/unoidl.hxx>
 #include <codemaker/unotype.hxx>
 
-const std::unordered_set<std::string_view> UnoProducer::m_reservedKeywords
-    // Rust keywords that need special handling to avoid naming conflicts
-    = { "as",     "break", "const",  "continue", "crate", "else",  "enum",   
"extern",
-        "false",  "fn",    "for",    "if",       "impl",  "in",    "let",    
"loop",
-        "match",  "mod",   "move",   "mut",      "pub",   "ref",   "return", 
"Result",
-        "self",   "Self",  "static", "struct",   "super", "trait", "true",   
"type",
-        "unsafe", "use",   "where",  "while",    "async", "await", "dyn",    
"try" };
-
-const std::unordered_map<std::string_view, OString> UnoProducer::m_baseTypes
-    // Maps UNO basic types to their Rust equivalents
-    // TODO: need to edit the core types Implemented manually
-    = { { "boolean", "bool"_ostr },
-        { "char", "char"_ostr },
-        { "byte", "i8"_ostr },
-        { "short", "i16"_ostr },
-        { "unsigned short", "u16"_ostr },
-        { "long", "i32"_ostr },
-        { "unsigned long", "u32"_ostr },
-        { "hyper", "i64"_ostr },
-        { "unsigned hyper", "u64"_ostr },
-        { "float", "f32"_ostr },
-        { "double", "f64"_ostr },
-        { "string", "String"_ostr },
-        { "void", "()"_ostr },
-        { "type", "uno::type"_ostr }, // TODO:
-        { "any", "uno::any"_ostr }, // TODO:
-        // TODO: These exception types need proper implementation
-        { "com.sun.star.uno.Exception", "com::sun::star::uno::Exception"_ostr 
} };
+namespace
+{
+// Rust keywords that need special handling to avoid naming conflicts
+constexpr auto aReservedKeywords
+    = frozen::make_unordered_set<std::string_view>(
+        { "as",     "break", "const",  "continue", "crate", "else",  "enum",   
"extern",
+          "false",  "fn",    "for",    "if",       "impl",  "in",    "let",    
"loop",
+          "match",  "mod",   "move",   "mut",      "pub",   "ref",   "return", 
"Result",
+          "self",   "Self",  "static", "struct",   "super", "trait", "true",   
"type",
+          "unsafe", "use",   "where",  "while",    "async", "await", "dyn",    
"try" });
+
+// Maps UNO basic types to their Rust equivalents
+// TODO: need to edit the core types Implemented manually
+const auto aBaseTypes = frozen::make_unordered_map<std::string_view, OString>(
+    { { "boolean", "bool"_ostr },
+      { "char", "char"_ostr },
+      { "byte", "i8"_ostr },
+      { "short", "i16"_ostr },
+      { "unsigned short", "u16"_ostr },
+      { "long", "i32"_ostr },
+      { "unsigned long", "u32"_ostr },
+      { "hyper", "i64"_ostr },
+      { "unsigned hyper", "u64"_ostr },
+      { "float", "f32"_ostr },
+      { "double", "f64"_ostr },
+      { "string", "String"_ostr },
+      { "void", "()"_ostr },
+      { "type", "uno::type"_ostr }, // TODO:
+      { "any", "uno::any"_ostr }, // TODO:
+      // TODO: These exception types need proper implementation
+      { "com.sun.star.uno.Exception", "com::sun::star::uno::Exception"_ostr } 
});
 // Note: XInterface removed from baseTypes so it can be generated like other 
interfaces
+}
 
 std::string_view UnoProducer::splitName(std::string_view name)
 {
@@ -98,7 +106,7 @@ OString UnoProducer::getSafeIdentifier(std::string_view 
name, bool istype = fals
 {
     // Add underscore suffix to avoid Rust keyword conflicts
     OString temp = handleName(name, istype);
-    return m_reservedKeywords.contains(temp) ? temp + "_"_ostr : temp;
+    return aReservedKeywords.contains(temp) ? temp + "_"_ostr : temp;
 }
 
 OString UnoProducer::getSafeIdentifier(std::u16string_view name, bool istype = 
false)
@@ -204,7 +212,7 @@ void UnoProducer::produceType(const OString& name)
     m_typesProduced.insert(name);
 
     // Skip built-in types that don't need code generation
-    if (m_baseTypes.contains(name))
+    if (aBaseTypes.contains(name))
         return;
 
     OUString uname(b2u(name));
diff --git a/codemaker/source/rustmaker/unoproduce.hxx 
b/codemaker/source/rustmaker/unoproduce.hxx
index cb532596f569..ebc878188547 100644
--- a/codemaker/source/rustmaker/unoproduce.hxx
+++ b/codemaker/source/rustmaker/unoproduce.hxx
@@ -46,10 +46,6 @@ public:
     // Finalize opaque pointer generation
     void finalizeGeneration();
 
-    // Static lookup tables for Rust keyword conflicts and type mappings
-    static const std::unordered_set<std::string_view> m_reservedKeywords;
-    static const std::unordered_map<std::string_view, OString> m_baseTypes;
-
 private:
     // Main UNO type processor - coordinates opaque generation for all types
     void produceType(const OString& name);

Reply via email to