mirror of
https://github.com/mappu/miqt.git
synced 2024-12-22 08:58:37 +00:00
genbindings: replace const_cast<>(self) with const self*
This commit is contained in:
parent
cf6dc40a1f
commit
0689949bc2
@ -460,7 +460,7 @@ extern "C" {
|
||||
}
|
||||
|
||||
for _, m := range c.Methods {
|
||||
ret.WriteString(fmt.Sprintf("%s %s_%s(%s);\n", emitReturnTypeCabi(m.ReturnType), cClassName, m.SafeMethodName(), emitParametersCabi(m, cClassName+"*")))
|
||||
ret.WriteString(fmt.Sprintf("%s %s_%s(%s);\n", emitReturnTypeCabi(m.ReturnType), cClassName, m.SafeMethodName(), emitParametersCabi(m, ifv(m.IsConst, "const ", "")+cClassName+"*")))
|
||||
|
||||
if m.IsSignal {
|
||||
ret.WriteString(fmt.Sprintf("%s %s_connect_%s(%s* self, void* slot);\n", emitReturnTypeCabi(m.ReturnType), cClassName, m.SafeMethodName(), cClassName))
|
||||
@ -687,8 +687,6 @@ extern "C" {
|
||||
if m.IsStatic {
|
||||
callTarget = c.ClassName + "::"
|
||||
|
||||
} else if m.IsConst {
|
||||
callTarget = "const_cast<const " + c.ClassName + "*>(self)->"
|
||||
}
|
||||
|
||||
if m.LinuxOnly {
|
||||
@ -704,7 +702,7 @@ extern "C" {
|
||||
"#endif\n"+
|
||||
"}\n"+
|
||||
"\n",
|
||||
emitReturnTypeCabi(m.ReturnType), cClassName, m.SafeMethodName(), emitParametersCabi(m, cClassName+"*"),
|
||||
emitReturnTypeCabi(m.ReturnType), cClassName, m.SafeMethodName(), emitParametersCabi(m, ifv(m.IsConst, "const ", "")+cClassName+"*"),
|
||||
preamble,
|
||||
shouldReturn, callTarget, nativeMethodName, forwarding,
|
||||
afterCall,
|
||||
@ -720,7 +718,7 @@ extern "C" {
|
||||
"%s"+
|
||||
"}\n"+
|
||||
"\n",
|
||||
emitReturnTypeCabi(m.ReturnType), cClassName, m.SafeMethodName(), emitParametersCabi(m, cClassName+"*"),
|
||||
emitReturnTypeCabi(m.ReturnType), cClassName, m.SafeMethodName(), emitParametersCabi(m, ifv(m.IsConst, "const ", "")+cClassName+"*"),
|
||||
preamble,
|
||||
shouldReturn, callTarget, nativeMethodName, forwarding,
|
||||
afterCall,
|
||||
|
@ -27,3 +27,10 @@ func prettyPrint(obj interface{}) {
|
||||
|
||||
log.Println(string(jb))
|
||||
}
|
||||
|
||||
func ifv[T any](condition bool, trueval T, falseval T) T {
|
||||
if condition {
|
||||
return trueval
|
||||
}
|
||||
return falseval
|
||||
}
|
Loading…
Reference in New Issue
Block a user