mirror of
https://github.com/mappu/miqt.git
synced 2025-02-22 20:40:23 +00:00
genbindings: prevent using qt6 qsharedmemory on android
This commit is contained in:
parent
f8e429b362
commit
da874c95ed
@ -105,6 +105,35 @@ func Widgets_AllowHeader(fullpath string) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type AllowedPlatformInfo interface {
|
||||||
|
GoBuildTag() string
|
||||||
|
CxxIf() string
|
||||||
|
}
|
||||||
|
|
||||||
|
type AndroidBlockedPlatform struct{}
|
||||||
|
|
||||||
|
func (abp AndroidBlockedPlatform) GoBuildTag() string {
|
||||||
|
return `!android`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (abp AndroidBlockedPlatform) CxxIf() string {
|
||||||
|
return `! defined(Q_OS_ANDROID)`
|
||||||
|
}
|
||||||
|
|
||||||
|
func HeaderPlatformRestriction(fullpath string) AllowedPlatformInfo {
|
||||||
|
fname := filepath.Base(fullpath)
|
||||||
|
|
||||||
|
if fname == `qsharedmemory.h` {
|
||||||
|
// Not implemented on Android nor iOS
|
||||||
|
// Qt 5: Classes are present but do not work
|
||||||
|
// Qt 6: Class definition is not present and our generated subclass fails to compile
|
||||||
|
return AndroidBlockedPlatform{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// No platform restriction
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func ImportHeaderForClass(className string) bool {
|
func ImportHeaderForClass(className string) bool {
|
||||||
if className[0] != 'Q' {
|
if className[0] != 'Q' {
|
||||||
return false
|
return false
|
||||||
|
@ -931,6 +931,16 @@ func emitBindingCpp(src *CppParsedHeader, filename string) (string, error) {
|
|||||||
ret.WriteString(`#include <` + filename + ">\n")
|
ret.WriteString(`#include <` + filename + ">\n")
|
||||||
ret.WriteString(`#include "gen_` + filename + "\"\n")
|
ret.WriteString(`#include "gen_` + filename + "\"\n")
|
||||||
|
|
||||||
|
// Perform any platform checks
|
||||||
|
// n.b. The Q_OS_ variable is defined usually indirectly from another Qt
|
||||||
|
// header, so it should be checked only after all the other includes,
|
||||||
|
// although that seems suboptimal
|
||||||
|
|
||||||
|
platformRestriction := HeaderPlatformRestriction(filename)
|
||||||
|
if platformRestriction != nil {
|
||||||
|
ret.WriteString(`#if ` + platformRestriction.CxxIf() + "\n\n")
|
||||||
|
}
|
||||||
|
|
||||||
// Write prototypes for functions that the host language bindings should export
|
// Write prototypes for functions that the host language bindings should export
|
||||||
// for virtual function overrides
|
// for virtual function overrides
|
||||||
|
|
||||||
@ -1410,5 +1420,11 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
if platformRestriction != nil {
|
||||||
|
ret.WriteString(`#endif //` + platformRestriction.CxxIf() + "\n\n")
|
||||||
|
}
|
||||||
|
|
||||||
return ret.String(), nil
|
return ret.String(), nil
|
||||||
}
|
}
|
||||||
|
@ -669,6 +669,13 @@ func (gfs *goFileState) emitCabiToGo(assignExpr string, rt CppParameter, rvalue
|
|||||||
func emitGo(src *CppParsedHeader, headerName string, packageName string) (string, string, error) {
|
func emitGo(src *CppParsedHeader, headerName string, packageName string) (string, string, error) {
|
||||||
|
|
||||||
ret := strings.Builder{}
|
ret := strings.Builder{}
|
||||||
|
|
||||||
|
platformRestriction := HeaderPlatformRestriction(headerName)
|
||||||
|
if platformRestriction != nil {
|
||||||
|
ret.WriteString(`//go:build ` + platformRestriction.GoBuildTag() + "\n" +
|
||||||
|
`// +build ` + platformRestriction.GoBuildTag() + "\n\n")
|
||||||
|
}
|
||||||
|
|
||||||
ret.WriteString(`package ` + path.Base(packageName) + `
|
ret.WriteString(`package ` + path.Base(packageName) + `
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user