本文整理汇总了Golang中github.com/therecipe/qt/internal/binding/parser.Function.Access方法的典型用法代码示例。如果您正苦于以下问题:Golang Function.Access方法的具体用法?Golang Function.Access怎么用?Golang Function.Access使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/therecipe/qt/internal/binding/parser.Function
的用法示例。
在下文中一共展示了Function.Access方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: isBlocked
func isBlocked(f *parser.Function) bool {
for _, n := range []string{"scriptValueFromQMetaObject", "fromScriptValue", "QPlaceProposedSearchResult", "evaluateTo", "detected", "isRecordType", "replace", "insert", "remove", "find", "changedStates", "state", "requestTexture", "draw", "setTabPositions", "setExtraSelections", "disconnect", "QJsonObject", "QJsonArray", "QAccessibleStateChangeEvent", "hitTest", "setupUi", "setEditFocus", "toUnicode", "registerConverter", "registerEqualsComparator", "registerComparators", "hasRegisteredConverterFunction", "hasRegisteredComparators", "setNavigationMode", "navigationMode", "setNativeArguments", "setAlphaChannel", "setDefaultAction", "unregisterEventNotifier", "QXmlStreamWriter", "hasEditFocus", "QTextStream", "QStringRef", "QSignalBlocker", "defaultAction", "canConvert", "queryItemValue", "hasQueryItem", "hasEncodedQueryItem", "hasLocalData", "registerEventNotifier", "registerTimer", "setYMD", "nativeArguments"} {
if f.Name == n {
f.Access = "unsupported_isBlocked"
return true
}
}
//Android Only
for _, blockedAndroid := range []string{"setAsDockMenu"} {
if f.Name == blockedAndroid {
f.Access = "unsupported_isBlocked_Android"
return true
}
}
if f.Name == "exec" && runtime.GOOS == "linux" && !strings.Contains(f.Class(), "Sql") {
f.Output = "void"
}
if f.Name == "value" && f.Class() == "QVariant" {
f.Access = "unsupported_goFunction"
return true
}
if f.Class() == "QAudioBuffer" && strings.Contains(f.Output, "T") {
f.Access = "unsupported_goFunction"
return true
}
return false
}
示例2: goInput
func goInput(name string, value string, f *parser.Function) string {
var vOld = value
name = cleanName(name)
value = cleanValue(value)
switch value {
case "QStringList":
{
return fmt.Sprintf("C.CString(strings.Join(%v, \"|\"))", name)
}
case "uchar", "char", "QString":
{
if strings.Contains(vOld, "**") {
return fmt.Sprintf("C.CString(strings.Join(%v, \"|\"))", name)
}
return fmt.Sprintf("C.CString(%v)", name)
}
case "bool":
{
return fmt.Sprintf("C.int(qt.GoBoolToInt(%v))", name)
}
case "int":
{
return fmt.Sprintf("C.int(%v)", name)
}
case "qreal":
{
return fmt.Sprintf("C.double(%v)", name)
}
case "jclass":
{
return name
}
}
switch {
case isEnum(f.Class(), value):
{
return fmt.Sprintf("C.int(%v)", name)
}
case isClass(value):
{
if m := module(parser.ClassMap[value].Module); m != module(f) {
return fmt.Sprintf("%v.PointerFrom%v(%v)", m, strings.Title(value), name)
}
return fmt.Sprintf("PointerFrom%v(%v)", strings.Title(value), name)
}
}
f.Access = "unsupported_goInput"
return f.Access
}
示例3: goOutputFailed
func goOutputFailed(value string, f *parser.Function) string {
var vOld = value
value = cleanValue(value)
switch value {
case "bool":
return "false"
case "int", "qreal", "qint64":
return "0"
case "uchar", "char", "QString":
return "\"\""
case "QStringList":
return "make([]string, 0)"
case "void", "":
if strings.Contains(vOld, "*") {
return "nil"
}
return ""
case "T", "JavaVM", "jclass", "jobject":
switch f.TemplateMode {
case "Int":
{
return "0"
}
case "Boolean":
{
return "false"
}
case "Void":
{
return ""
}
}
return "nil"
}
switch {
case isEnum(f.Class(), value):
return "0"
case isClass(value):
return "nil"
default:
f.Access = "unsupported_GoBodyOutputFailed"
return f.Access
}
}
示例4: cppType
func cppType(f *parser.Function, value string) string {
var vOld = value
value = cleanValue(value)
switch value {
case "uchar", "char", "QString", "QStringList":
{
return "char*"
}
case "bool", "int":
{
return "int"
}
case "void", "":
{
if strings.Contains(vOld, "*") {
return "void*"
}
return "void"
}
case "T", "JavaVM", "jclass":
{
return "void*"
}
case "qreal":
{
return "double"
}
case "...":
{
return ""
}
}
switch {
case isEnum(f.Class(), value):
{
return "int"
}
case isClass(value):
{
return "void*"
}
}
f.Access = "unsupported_cppType"
return f.Access
}
示例5: cgoOutput
func cgoOutput(name string, value string, f *parser.Function) string {
name = cleanName(name)
value = cleanValue(value)
switch value {
case "QStringList":
{
return fmt.Sprintf("strings.Split(%v, \"|\")", cgoOutput(name, "QString", f))
}
case "uchar", "char", "QString":
{
return fmt.Sprintf("C.GoString(%v)", name)
}
case "int":
{
return fmt.Sprintf("int(%v)", name)
}
case "bool":
{
return fmt.Sprintf("%v != 0", cgoOutput(name, "int", f))
}
case "void", "":
{
return ""
}
}
switch {
case isEnum(f.Class(), value):
{
if c, exists := parser.ClassMap[class(cppEnum(f, value, false))]; exists && module(c.Module) != module(f) && module(c.Module) != "" {
return fmt.Sprintf("%v.%v(%v)", module(c.Module), goEnum(f, value), name)
}
return fmt.Sprintf("%v(%v)", goEnum(f, value), name)
}
case isClass(value):
{
if m := module(parser.ClassMap[value].Module); m != module(f) {
return fmt.Sprintf("%v.New%vFromPointer(%v)", m, value, name)
}
return fmt.Sprintf("New%vFromPointer(%v)", value, name)
}
}
f.Access = "unsupported_cgoOutput"
return f.Access
}
示例6: GoHeaderInput
func GoHeaderInput(f *parser.Function) (o string) {
if f.SignalMode == "callback" {
o += "ptr unsafe.Pointer, ptrName *C.char"
for _, p := range f.Parameters {
if v := cgoType(f, p.Value); v != "" {
o += fmt.Sprintf(", %v %v", cleanName(p.Name), v)
}
}
return strings.TrimSuffix(o, ", ")
}
if (f.Meta == "signal" || strings.Contains(f.Virtual, "impure")) && f.SignalMode == "Connect" {
o += "f func ("
}
if (f.Meta == "signal" || strings.Contains(f.Virtual, "impure")) && f.SignalMode != "Connect" {
if strings.Contains(f.Virtual, "impure") && f.SignalMode == "" {
} else {
return
}
}
for _, p := range f.Parameters {
if v := goType(f, p.Value); v != "" {
if isClass(v) {
if (f.Meta == "signal" || strings.Contains(f.Virtual, "impure")) && f.SignalMode == "Connect" {
o += fmt.Sprintf("%v *%v, ", cleanName(p.Name), v)
} else {
o += fmt.Sprintf("%v %v_ITF, ", cleanName(p.Name), v)
}
} else {
o += fmt.Sprintf("%v %v, ", cleanName(p.Name), v)
}
} else {
f.Access = "unsupported_GoHeaderInput"
return f.Access
}
}
o = strings.TrimSuffix(o, ", ")
if (f.Meta == "signal" || strings.Contains(f.Virtual, "impure")) && f.SignalMode == "Connect" {
o += ")"
}
return
}
示例7: cgoType
func cgoType(f *parser.Function, value string) string {
value = cleanValue(value)
switch value {
case "uchar", "char", "QString", "QStringList":
{
return "*C.char"
}
case "bool", "int":
{
return "C.int"
}
case "void", "":
{
return ""
}
case "qreal":
{
return "C.double"
}
case "qint64":
{
return "C.longlong"
}
}
switch {
case isEnum(f.Class(), value):
{
return "C.int"
}
case isClass(value):
{
return "unsafe.Pointer"
}
}
f.Access = "unsupported_cgoType"
return f.Access
}
示例8: CppHeaderInput
func CppHeaderInput(f *parser.Function) (o string) {
if !(f.Static || f.Meta == "constructor") {
o += "void* ptr, "
}
if f.Meta == "signal" {
return strings.TrimSuffix(o, ", ")
}
for _, p := range f.Parameters {
if v := cppType(f, p.Value); !(v == "") {
o += fmt.Sprintf("%v %v, ", v, cleanName(p.Name))
} else {
f.Access = "unsupported_CppHeaderInput"
return f.Access
}
}
return strings.TrimSuffix(o, ", ")
}
示例9: cppEnum
func cppEnum(f *parser.Function, value string, exact bool) string {
if outE, outT := findEnum(class(f), value, false); outE != "" {
if exact {
if outT == "" {
return outE
}
if !strings.Contains(outT, "::") {
outT = fmt.Sprintf("%v::%v", class(outE), outT)
}
return cppEnumExact(value, outE, outT)
}
return outE
}
f.Access = "unsupported_cppEnum"
return f.Access
}
示例10: GoHeaderName
func GoHeaderName(f *parser.Function) (o string) {
if f.SignalMode == "callback" {
var tmp = fmt.Sprintf("callback%v%v", f.Class(), strings.Replace(strings.Title(f.Name), "~", "Destroy", -1))
if f.Overload {
tmp += f.OverloadNumber
}
return tmp
}
if f.Static {
o += fmt.Sprintf("%v_", strings.Split(f.Fullname, "::")[0])
}
switch f.Meta {
case "constructor":
o += "New"
case "destructor":
o += "Destroy"
}
o += f.SignalMode
o += strings.Title(f.Name)
o += f.TemplateMode
if f.Overload {
o += f.OverloadNumber
}
if strings.ContainsAny(o, "&<>=/!()[]{}-^|*+-") || strings.Contains(o, "Operator") {
f.Access = "unsupported_GoHeaderName"
return f.Access
}
return strings.Replace(o, "~", "", -1)
}
示例11: GoHeaderInputSignalFunction
func GoHeaderInputSignalFunction(f *parser.Function) (o string) {
o += "func ("
for _, p := range f.Parameters {
if v := goType(f, p.Value); v != "" {
if isClass(v) {
o += fmt.Sprintf("*%v, ", v)
} else {
o += fmt.Sprintf("%v, ", v)
}
} else {
f.Access = "unsupported_GoHeaderInputSignalFunction"
return f.Access
}
}
o = strings.TrimSuffix(o, ", ")
o += ")"
return
}
示例12: goOutput
func goOutput(name string, value string, f *parser.Function) string {
var vOld = value
name = cleanName(name)
value = cleanValue(value)
switch value {
case "QStringList":
{
return fmt.Sprintf("strings.Split(%v, \"|\")", goOutput(name, "QString", f))
}
case "uchar", "char", "QString":
{
return fmt.Sprintf("C.GoString(%v)", name)
}
case "int":
{
return fmt.Sprintf("int(%v)", name)
}
case "bool":
{
return fmt.Sprintf("%v != 0", name)
}
case "void", "":
{
if strings.Contains(vOld, "*") {
return fmt.Sprintf("unsafe.Pointer(%v)", name)
}
return name
}
case "T", "JavaVM", "jclass", "jobject":
{
switch f.TemplateMode {
case "Int":
{
return fmt.Sprintf("int(%v)", name)
}
case "Boolean":
{
return fmt.Sprintf("int(%v) != 0", name)
}
case "Void":
{
return name
}
}
return fmt.Sprintf("unsafe.Pointer(%v)", name)
}
case "qreal":
{
return fmt.Sprintf("float64(%v)", name)
}
case "qint64":
{
return fmt.Sprintf("int64(%v)", name)
}
}
switch {
case isEnum(f.Class(), value):
{
if c, exists := parser.ClassMap[class(cppEnum(f, value, false))]; exists && module(c.Module) != module(f) && module(c.Module) != "" {
if parser.ClassMap[f.Class()].WeakLink[c.Module] {
return fmt.Sprintf("int64(%v)", name)
}
return fmt.Sprintf("%v.%v(%v)", module(c.Module), goEnum(f, value), name)
}
return fmt.Sprintf("%v(%v)", goEnum(f, value), name)
}
case isClass(value):
{
if m := module(parser.ClassMap[value].Module); m != module(f) {
if parser.ClassMap[f.Class()].WeakLink[parser.ClassMap[value].Module] {
return fmt.Sprintf("unsafe.Pointer(%v)", name)
}
return fmt.Sprintf("%v.New%vFromPointer(%v)", m, value, name)
}
if f.Meta == "constructor" {
return fmt.Sprintf("new%vFromPointer(%v)", value, name)
}
return fmt.Sprintf("New%vFromPointer(%v)", value, name)
}
}
f.Access = "unsupported_goOutput"
return f.Access
}
示例13: cppFunctionBody
func cppFunctionBody(f *parser.Function) (o string) {
/*
for _, p := range f.Parameters {
if strings.Contains(p.Value, "**") && p.Name == "argv" {
o += "QList<QByteArray> aList = QByteArray(argv).split('|');\n"
o += "\tQVarLengthArray<const char*> argvs(argc);\n"
o += "\tstatic int argcs = argc;\n"
o += "\tfor (int i = 0; i < argc; i++)\n"
o += "\t\targvs[i] = static_cast<const char*>(aList[i].constData());\n\n\t"
}
}
*/
for _, p := range f.Parameters {
if strings.Contains(p.Value, "**") && p.Name == "argv" {
o += "QList<QByteArray> aList = QByteArray(argv).split('|');\n"
o += "\tchar *argvs[argc];\n"
o += "\tstatic int argcs = argc;\n"
o += "\tfor (int i = 0; i < argc; i++)\n"
o += "\t\targvs[i] = aList[i].data();\n\n\t"
}
}
if converter.CppHeaderOutput(f) != "void" {
o += "return "
}
switch f.Meta {
case "constructor":
o += fmt.Sprintf("new %v(%v)", f.Class(), converter.CppBodyInput(f))
case "slot":
if f.Static {
o += fmt.Sprintf("QMetaObject::invokeMethod(%v::instance(), \"%v\"%v)", f.Class(), f.Name, converter.CppBodyInput(f))
} else {
o += fmt.Sprintf("QMetaObject::invokeMethod(static_cast<%v*>(ptr), \"%v\"%v)", f.Class(), f.Name, converter.CppBodyInput(f))
}
case "plain", "destructor":
if f.Static {
o += converter.CppBodyOutput(f, fmt.Sprintf("%v::%v(%v)", f.Class(), f.Name, converter.CppBodyInput(f)))
} else {
if f.Output == "T" && f.Class() == "QObject" {
o += converter.CppBodyOutput(f, fmt.Sprintf("static_cast<%v*>(ptr)->%v<QObject*>(%v)", f.Class(), f.Name, converter.CppBodyInput(f)))
} else if f.Output == "T" && f.Class() == "QMediaService" {
o += converter.CppBodyOutput(f, fmt.Sprintf("static_cast<%v*>(ptr)->%v<QMediaControl*>(%v)", f.Class(), f.Name, converter.CppBodyInput(f)))
} else {
o += converter.CppBodyOutput(f, fmt.Sprintf("static_cast<%v*>(ptr)->%v(%v)", f.Class(), f.Name, converter.CppBodyInput(f)))
}
}
case "signal":
if converter.PrivateSignal(f) {
o += fmt.Sprintf("QObject::%v(%v, &%v::%v, static_cast<My%v*>(ptr), static_cast<%v (My%v::*)(%v)>(&My%v::Signal_%v));", strings.ToLower(f.SignalMode), fmt.Sprintf("static_cast<%v*>(%v)", f.Class(), "ptr"), f.Class(), f.Name, f.Class(), f.Output, f.Class(), converter.CppBodyInput(f), f.Class(), strings.Title(f.Name))
} else {
o += fmt.Sprintf("QObject::%v(%v, static_cast<void (%v::*)(%v)>(&%v::%v), static_cast<My%v*>(ptr), static_cast<%v (My%v::*)(%v)>(&My%v::Signal_%v));", strings.ToLower(f.SignalMode), fmt.Sprintf("static_cast<%v*>(%v)", f.Class(), "ptr"), f.Class(), converter.CppBodyInput(f), f.Class(), f.Name, f.Class(), f.Output, f.Class(), converter.CppBodyInput(f), f.Class(), strings.Title(f.Name))
}
default:
f.Access = "unsupported_CppFunctionBody"
return f.Access
}
return fmt.Sprintf("%v;", o)
}
示例14: goType
func goType(f *parser.Function, value string) string {
var vOld = value
value = cleanValue(value)
switch value {
case "uchar", "char", "QString":
{
if strings.Contains(vOld, "**") {
return "[]string"
}
return "string"
}
case "QStringList":
{
return "[]string"
}
case "void":
{
if strings.Contains(vOld, "*") {
return "unsafe.Pointer"
}
return ""
}
case "bool", "int", "":
{
return value
}
case "T", "JavaVM", "jclass":
{
return "unsafe.Pointer"
}
case "qreal":
{
return "float64"
}
case "...":
{
return ""
}
}
switch {
case isEnum(f.Class(), value):
{
if c, exists := parser.ClassMap[class(cppEnum(f, value, false))]; exists && module(c.Module) != module(f) && module(c.Module) != "" {
return module(c.Module) + "." + goEnum(f, value)
}
return goEnum(f, value)
}
case isClass(value):
{
if m := module(parser.ClassMap[value].Module); m != module(f) {
return m + "." + value
}
return value
}
}
f.Access = "unsupported_goType"
return f.Access
}
示例15: cppOutput
func cppOutput(name string, value string, f *parser.Function) string {
var vOld = value
name = cleanName(name)
value = cleanValue(value)
switch value {
case "QStringList":
{
return cppOutput(fmt.Sprintf("%v.join(\"|\")", name), "QString", f)
}
case "QString":
{
if strings.Contains(vOld, "*") {
return fmt.Sprintf("%v->toUtf8().data()", name)
}
return fmt.Sprintf("%v.toUtf8().data()", name)
}
case "bool", "int", "void", "", "T", "JavaVM", "jclass":
{
if value == "void" {
if strings.Contains(vOld, "*") {
if strings.Contains(vOld, "const") {
return fmt.Sprintf("const_cast<%v*>(%v)", value, name)
}
return name
}
}
return name
}
case "qreal":
{
return fmt.Sprintf("static_cast<double>(%v)", name)
}
}
switch {
case isEnum(f.Class(), value):
{
return name
}
case isClass(value):
{
if strings.Contains(vOld, "*") {
if strings.Contains(vOld, "const") {
return fmt.Sprintf("const_cast<%v*>(%v)", value, name)
}
return name
}
switch value {
case "QModelIndex":
{
return fmt.Sprintf("%v.internalPointer()", name)
}
case "QJSValue", "QScriptValue", "QVariant", "QStringRef", "QDateTime", "QTimeZone", "QRegularExpressionMatchIterator", "QRegularExpressionMatch", "QRegularExpression", "QDir", "QByteArray", "QEasingCurve", "QCommandLineOption", "QRegExp", "QJsonObject", "QJsonArray", "QJsonDocument", "QRegion", "QBrush", "QColor":
{
return fmt.Sprintf("new %v(%v)", value, name)
}
case "QAndroidJniObject":
{
return name
}
}
}
}
f.Access = "unsupported_cppOutput"
return f.Access
}