Commit dc997904

dc9979041919Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 2 files · +1 added · ~1 modified

Description

Merge pull request #187 from mame/pr/subclass-parent-prefix

fix(codegen): resolve subclass parent through enclosing module chain

Details

Commit
dc9979041919
Parent
013dff7b0140
Merge parent
313a87a3eb28

spinel_codegen.rbmodifiedView file

@@ -5082,7 +5082,34 @@
50825082 end
50835083 end
50845084 else
5085- parent = @nd_name[sp]
5085+ parent = const_ref_flat_name(sp)
5086+ if parent == ""
5087+ parent = @nd_name[sp]
5088+ end
5089+ # Resolve the parent class name against the same module-prefix
5090+ # chain that was used to register the child. `class Sub < Base`
5091+ # inside `module M` should land on `M_Base` (the registered
5092+ # name), not bare "Base", or `emit_class_fields` later fails
5093+ # `find_class_idx` and silently drops every inherited field.
5094+ if module_prefix != "" && const_ref_is_relative(sp) == 1
5095+ if find_class_idx(parent) < 0
5096+ mp = module_prefix
5097+ while mp != ""
5098+ cand = mp + "_" + parent
5099+ if find_class_idx(cand) >= 0
5100+ parent = cand
5101+ mp = ""
5102+ else
5103+ idx = mp.rindex("_")
5104+ if idx < 0
5105+ mp = ""
5106+ else
5107+ mp = mp[0, idx]
5108+ end
5109+ end
5110+ end
5111+ end
5112+ end
50865113 end
50875114 end
50885115