From 36ac43ba86564991eafa15f8c6be7d196767c3c1 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Wed, 9 Sep 2026 20:51:11 +0000 Subject: [PATCH] ze: stop doubling the zex namespace in class names Every other namespace drops its prefix from the class name, because the class already carries it: zet_metric_properties_t -> ZETMetricProperties. zex was left out of the strip pattern, so its four classes kept the prefix and then had it added again -- ZEXZexWaitOnMemDesc. The comment said this was on purpose because it "is what the generated bindings already spell", which describes the output rather than giving a reason for it. With x added, the strip pattern and the namespace pattern say the same thing twice, so there is one left: the prefix that names a type's namespace is the prefix a class name drops. The capture group the namespace lookup needs is ignored by the strip's sub. The rename reaches the two places that must agree with it or pretty-printing raises NameError at trace time: babeltrace_ze_lib.rb and the :be_class in btx_ze_model.yaml. All 247 ZE:: constants referenced by those two files resolve, and the four classes construct with unchanged sizes. Generated: ze_library.rb, ze_bindings.rb, babeltrace_ze_lib.rb and btx_ze_model.yaml change by this rename and nothing else. Co-Authored-By: Claude Opus 5 (1M context) --- backends/ze/gen_ze_library_base.rb | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/backends/ze/gen_ze_library_base.rb b/backends/ze/gen_ze_library_base.rb index 6b78ec3f1..ba8d56560 100644 --- a/backends/ze/gen_ze_library_base.rb +++ b/backends/ze/gen_ze_library_base.rb @@ -2,12 +2,9 @@ require_relative '../../utils/gen_probe_base' require_relative '../../utils/gen_library_base' -# Which namespaces ze traces. zex and zer are absent from the class-name strip -# below on purpose: their typedefs keep the namespace in the class name -# (zex_wait_on_mem_desc_t -> ZEXZexWaitOnMemDesc), which is what the generated -# bindings already spell. -ZE_NAMESPACE_PATTERN = /\A(ze[xstlr]?)_/ -ZE_CLASS_STRIP_PATTERN = /\Aze[stl]?_/ +# Regex for finding the namespace prefix: zet_metric_properties_t -> zet_ +# No zer_, the raytracing types are spelled ze_rtas_*. +ZE_NAMESPACE_PATTERN = /\A(ze[xstl]?)_/ # The initialisms the word split would otherwise lower-case. ZE_INITIALISMS = { 'Uuid' => 'UUID', 'Dditable' => 'DDITable', @@ -20,7 +17,7 @@ strict: true, upcase_namespace: true, class_namer: lambda { |naming, name| - word_split_class_name(name, naming.name_space(name), ZE_CLASS_STRIP_PATTERN, + word_split_class_name(name, naming.name_space(name), ZE_NAMESPACE_PATTERN, word_case: :downcase, initialisms: ZE_INITIALISMS) } )