genbindings/containers: fixes for special characters in container names

This commit is contained in:
mappu 2024-11-15 18:40:57 +13:00
parent e1cbcb4629
commit dc39b7ca65
2 changed files with 7 additions and 5 deletions

View File

@ -198,7 +198,8 @@ func emitParametersCABI2CppForwarding(params []CppParameter, indent string) (pre
}
func makeNamePrefix(in string) string {
return strings.Replace(strings.Replace(in, `[`, `_`, -1), `]`, "", -1)
replacer := strings.NewReplacer(`[`, `_`, `]`, "", `.`, `_`)
return replacer.Replace(in)
}
func emitCABI2CppForwarding(p CppParameter, indent string) (preamble string, forwarding string) {

View File

@ -326,9 +326,9 @@ func (gfs *goFileState) emitParameterGo2CABIForwarding(p CppParameter) (preamble
preamble += nameprefix + "_CArray[i] = " + innerRvalue + "\n"
preamble += "}\n"
preamble += p.ParameterName + "_ma := C.struct_miqt_array{len: C.size_t(len(" + p.ParameterName + ")), data: unsafe.Pointer(" + nameprefix + "_CArray)}\n"
preamble += nameprefix + "_ma := C.struct_miqt_array{len: C.size_t(len(" + p.ParameterName + ")), data: unsafe.Pointer(" + nameprefix + "_CArray)}\n"
rvalue = p.ParameterName + "_ma"
rvalue = nameprefix + "_ma"
} else if _, ok := p.QSetOf(); ok {
panic("QSet<> arguments are not yet implemented") // n.b. doesn't seem to exist in QtCore/QtGui/QtWidgets at all
@ -362,9 +362,10 @@ func (gfs *goFileState) emitParameterGo2CABIForwarding(p CppParameter) (preamble
preamble += "}\n"
preamble += p.ParameterName + "_mm := C.struct_miqt_map{\nlen: C.size_t(len(" + p.ParameterName + ")),\nkeys: unsafe.Pointer(" + nameprefix + "_Keys_CArray),\nvalues: unsafe.Pointer(" + nameprefix + "_Values_CArray),\n}\n"
preamble += nameprefix + "_mm := C.struct_miqt_map{\nlen: C.size_t(len(" + p.ParameterName + ")),\nkeys: unsafe.Pointer(" + nameprefix + "_Keys_CArray),\nvalues: unsafe.Pointer(" + nameprefix + "_Values_CArray),\n}\n"
rvalue = nameprefix + "_mm"
rvalue = p.ParameterName + "_mm"
} else if p.Pointer && p.ParameterType == "char" {
// Single char* argument