cgen: remove some nasty replacements

pull/7038/head^2
joe-conigliaro 2020-12-01 21:17:19 +11:00
parent 9b583f51f1
commit 88835a0456
No known key found for this signature in database
GPG Key ID: C12F7136C08206F1
2 changed files with 6 additions and 5 deletions

View File

@ -531,8 +531,6 @@ fn (g &Gen) cc_type2(t table.Type) string {
sgtyps += '_$gts.name' sgtyps += '_$gts.name'
} }
styp += sgtyps styp += sgtyps
} else if styp.contains('<') {
styp = styp.replace_each(['<', '_T_', '>', '', ',', '_'])
} }
} }
return styp return styp
@ -4531,8 +4529,7 @@ fn (mut g Gen) write_types(types []table.TypeSymbol) {
if typ.info.generic_types.len > 0 { if typ.info.generic_types.len > 0 {
continue continue
} }
if name.contains('<') { if name.contains('_T_') {
name = name.replace_each(['<', '_T_', '>', '', ',', '_'])
g.typedefs.writeln('typedef struct $name $name;') g.typedefs.writeln('typedef struct $name $name;')
} }
// TODO avoid buffer manip // TODO avoid buffer manip

View File

@ -343,9 +343,11 @@ pub fn (mut p Parser) parse_generic_template_type(name string) table.Type {
pub fn (mut p Parser) parse_generic_struct_inst_type(name string) table.Type { pub fn (mut p Parser) parse_generic_struct_inst_type(name string) table.Type {
mut bs_name := name mut bs_name := name
mut bs_cname := name
p.next() p.next()
p.in_generic_params = true p.in_generic_params = true
bs_name += '<' bs_name += '<'
bs_cname += '_T_'
mut generic_types := []table.Type{} mut generic_types := []table.Type{}
mut is_instance := false mut is_instance := false
for { for {
@ -355,12 +357,14 @@ pub fn (mut p Parser) parse_generic_struct_inst_type(name string) table.Type {
} }
gts := p.table.get_type_symbol(gt) gts := p.table.get_type_symbol(gt)
bs_name += gts.name bs_name += gts.name
bs_cname += gts.name
generic_types << gt generic_types << gt
if p.tok.kind != .comma { if p.tok.kind != .comma {
break break
} }
p.next() p.next()
bs_name += ',' bs_name += ','
bs_cname += '_'
} }
p.check(.gt) p.check(.gt)
p.in_generic_params = false p.in_generic_params = false
@ -379,7 +383,7 @@ pub fn (mut p Parser) parse_generic_struct_inst_type(name string) table.Type {
kind: .generic_struct_inst kind: .generic_struct_inst
name: bs_name name: bs_name
source_name: bs_name source_name: bs_name
cname: util.no_dots(bs_name) cname: util.no_dots(bs_cname)
mod: p.mod mod: p.mod
info: table.GenericStructInst{ info: table.GenericStructInst{
parent_idx: parent_idx parent_idx: parent_idx