cutego/internal/binding/templater/enum_cpp.go
therecipe 9cb2c840ec initial update to Qt 5.8 + breaking changes + new speech module
1. the qt api changed in various places
2. dropped the "_minimal" suffix for the deployment folders
3. to keep using older versions of Qt (5.7.1 for example), one would
now need to explicit export "QT_VERSION=5.7.1" and also
"QT_DIR=/path/to/Qt5.7.1"
2017-02-10 18:18:44 +01:00

42 lines
1.1 KiB
Go
Executable file

package templater
import (
"fmt"
"strings"
"github.com/therecipe/qt/internal/binding/parser"
)
func cppEnum(enum *parser.Enum, value *parser.Value) string {
return fmt.Sprintf("%v\n{\n\t%v\n}", cppEnumHeader(enum, value), cppEnumBody(enum, value))
}
func cppEnumHeader(enum *parser.Enum, value *parser.Value) string {
return fmt.Sprintf("int %v_%v_Type()", enum.ClassName(), value.Name)
}
func cppEnumBody(enum *parser.Enum, value *parser.Value) string {
//TODO: check for "since" tag in enums
//needed for sailfish with 5.6 docs
if strings.HasPrefix(value.Name, "MV_") || strings.HasPrefix(value.Name, "PM_") ||
strings.HasPrefix(value.Name, "SH_") || strings.HasPrefix(value.Name, "ISODate") {
return fmt.Sprintf(`#if QT_VERSION >= 0x056000
return %v::%v;
#else
return 0;
#endif`, enum.ClassName(), value.Name)
}
//needed for msys2 with 5.7 docs
if strings.HasPrefix(value.Name, "PE_") || strings.HasPrefix(value.Name, "SE_") {
return fmt.Sprintf(`#if QT_VERSION >= 0x057000
return %v::%v;
#else
return 0;
#endif`, enum.ClassName(), value.Name)
}
return fmt.Sprintf("return %v::%v;", enum.ClassName(), value.Name)
}