genbindings/typedefs: refactor extract single method helper

This commit is contained in:
mappu 2024-11-15 14:23:41 +13:00
parent 0ffb24d11a
commit 6ae2235cb4

View File

@ -34,6 +34,25 @@ func applyTypedefs(p CppParameter) CppParameter {
return p
}
func applyTypedefs_Method(m *CppMethod) {
for k, p := range m.Parameters {
transformed := applyTypedefs(p)
m.Parameters[k] = transformed
if LinuxWindowsCompatCheck(transformed) {
m.LinuxOnly = true
}
}
m.ReturnType = applyTypedefs(m.ReturnType)
// Also apply OS compatibility rules
if LinuxWindowsCompatCheck(m.ReturnType) {
m.LinuxOnly = true
}
}
// astTransformTypedefs replaces the ParameterType with any known typedef value.
func astTransformTypedefs(parsed *CppParsedHeader) {
@ -41,36 +60,13 @@ func astTransformTypedefs(parsed *CppParsedHeader) {
for j, m := range c.Methods {
for k, p := range m.Parameters {
transformed := applyTypedefs(p)
m.Parameters[k] = transformed
if LinuxWindowsCompatCheck(transformed) {
m.LinuxOnly = true
}
}
m.ReturnType = applyTypedefs(m.ReturnType)
// Also apply OS compatibility rules
if LinuxWindowsCompatCheck(m.ReturnType) {
m.LinuxOnly = true
}
applyTypedefs_Method(&m)
c.Methods[j] = m
}
for j, m := range c.Ctors {
for k, p := range m.Parameters {
transformed := applyTypedefs(p)
m.Parameters[k] = transformed
if LinuxWindowsCompatCheck(transformed) {
m.LinuxOnly = true
}
}
applyTypedefs_Method(&m)
c.Ctors[j] = m
}
parsed.Classes[i] = c