cgen: fix _to_Interface_INAME conversion fns generation

pull/4716/head
Delyan Angelov 2020-05-05 00:01:54 +03:00
parent b5fda6e410
commit 1c945faa15
1 changed files with 3 additions and 2 deletions

View File

@ -3422,9 +3422,10 @@ fn (g &Gen) interface_table() string {
// i.e. cctype is always just Cat, not Cat_ptr: // i.e. cctype is always just Cat, not Cat_ptr:
cctype := g.cc_type(st) cctype := g.cc_type(st)
// Speaker_Cat_index = 0 // Speaker_Cat_index = 0
interface_index_name := '_${interface_name}_${cctype}_index' interface_index_name := '_${interface_name}_${cctype}_index'
cast_functions.writeln(' cast_functions.writeln('
_Interface I_${cctype}_to_Interface(${cctype}* x) { _Interface I_${cctype}_to_Interface_${interface_name}(${cctype}* x) {
return (_Interface) { return (_Interface) {
._object = (void*) memdup(x, sizeof(${cctype})), ._object = (void*) memdup(x, sizeof(${cctype})),
._interface_idx = ${interface_index_name} ._interface_idx = ${interface_index_name}
@ -3535,7 +3536,7 @@ fn (mut g Gen) array_init(it ast.ArrayInit) {
fn (g &Gen) interface_call(typ, interface_type table.Type) { fn (g &Gen) interface_call(typ, interface_type table.Type) {
interface_styp := g.cc_type(interface_type) interface_styp := g.cc_type(interface_type)
styp := g.cc_type(typ) styp := g.cc_type(typ)
g.write('/* $interface_styp */ I_${styp}_to_Interface(') g.write('/* $interface_styp */ I_${styp}_to_Interface_${interface_styp}(')
if !typ.is_ptr() { if !typ.is_ptr() {
g.write('&') g.write('&')
} }