Commit fc89c7ae
fc89c7aeb0e6Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 1 file · ~1 modified
Description
codegen: namespace-qualify class names in --emit-symbol-map
The symbol-map's ruby field built the class name from the leaf C name
via class_ruby_name_into (_->::), which dropped the enclosing module
(Tep::Url#save? came out Url#save?) and would mangle a colliding-class
name. Use the enclosing-class chain (class_ruby_name) for the qualified
path; for a name already qualified by the colliding-class pass (#1425),
which encodes the full Mod__Leaf path, demangle __->:: directly
(its enclosing_class still points at the module, so a chain walk would
double-count). Operator / predicate / bang methods stay exact (the
forward map, not a demangle).
Verified: Tep::Url#save? / #<=> / #[] / .find, deep A::B::C#m,
and colliding Web::Response / Chat::Response (no Web::Web__Response).
Fixes #1334
Details
- Commit
- fc89c7aeb0e6
- Parent
- 3c009ddea7bd
src/codegen.cmodifiedView file
buf_puts(&rb, s->name); } else { class_ruby_name_into(&rb, c->classes[s->class_id].name); /* the namespace-qualified Ruby class path (Tep::Url). A class renamed by the colliding-class pass (#1425) already encodes its full path as `Mod__Leaf`, and its enclosing_class still points at the module, so a chain walk would double-count -- demangle `__`->`::` instead. Otherwise walk the enclosing-class chain (the leaf C name drops the module). */ const char *cn = c->classes[s->class_id].name; if (cn && strstr(cn, "__")) { for (const char *p = cn; *p; ) { if (p[0] == '_' && p[1] == '_') { buf_puts(&rb, "::"); p += 2; } else { buf_printf(&rb, "%c", (int)*p); p++; } } } else { const char *qn = class_ruby_name(c, s->class_id); buf_puts(&rb, qn ? qn : (cn ? cn : "")); } buf_puts(&rb, s->is_cmethod ? "." : "#"); buf_puts(&rb, s->name); kind = s->is_cmethod ? "cmeth" : "imeth";