mirror of
https://github.com/mappu/miqt.git
synced 2025-01-08 16:38: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 {
|
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 {
|
if m.IsSignal {
|
||||||
ret.WriteString(fmt.Sprintf("%s %s_connect_%s(%s* self, void* slot);\n", emitReturnTypeCabi(m.ReturnType), cClassName, m.SafeMethodName(), cClassName))
|
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 {
|
if m.IsStatic {
|
||||||
callTarget = c.ClassName + "::"
|
callTarget = c.ClassName + "::"
|
||||||
|
|
||||||
} else if m.IsConst {
|
|
||||||
callTarget = "const_cast<const " + c.ClassName + "*>(self)->"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.LinuxOnly {
|
if m.LinuxOnly {
|
||||||
@ -704,7 +702,7 @@ extern "C" {
|
|||||||
"#endif\n"+
|
"#endif\n"+
|
||||||
"}\n"+
|
"}\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,
|
preamble,
|
||||||
shouldReturn, callTarget, nativeMethodName, forwarding,
|
shouldReturn, callTarget, nativeMethodName, forwarding,
|
||||||
afterCall,
|
afterCall,
|
||||||
@ -720,7 +718,7 @@ extern "C" {
|
|||||||
"%s"+
|
"%s"+
|
||||||
"}\n"+
|
"}\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,
|
preamble,
|
||||||
shouldReturn, callTarget, nativeMethodName, forwarding,
|
shouldReturn, callTarget, nativeMethodName, forwarding,
|
||||||
afterCall,
|
afterCall,
|
||||||
|
@ -27,3 +27,10 @@ func prettyPrint(obj interface{}) {
|
|||||||
|
|
||||||
log.Println(string(jb))
|
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