本文整理汇总了Golang中github.com/therecipe/qt/internal/binding/parser.Function.Meta方法的典型用法代码示例。如果您正苦于以下问题:Golang Function.Meta方法的具体用法?Golang Function.Meta怎么用?Golang Function.Meta使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/therecipe/qt/internal/binding/parser.Function
的用法示例。
在下文中一共展示了Function.Meta方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: goFunction
func goFunction(f *parser.Function) string {
if f.Meta == "signal" || strings.Contains(f.Virtual, "impure") && f.Output == "void" {
var tmp string
for _, signalMode := range []string{"Connect", "Disconnect", "callback"} {
f.SignalMode = signalMode
if signalMode == "callback" {
tmp += fmt.Sprintf("//export callback%v%v", f.Class(), strings.Replace(strings.Title(f.Name), "~", "Destroy", -1))
if f.Overload {
tmp += f.OverloadNumber
}
tmp += "\n"
}
tmp += fmt.Sprintf("%v{\n%v\n}\n\n", goFunctionHeader(f), goFunctionBody(f))
}
f.SignalMode = ""
var isPrivate bool
if f.Meta == "signal" {
isPrivate = converter.IsPrivateSignal(f)
}
var tmpMeta = f.Meta
f.Meta = "plain"
if !isPrivate {
tmp += fmt.Sprintf("%v{\n%v\n}\n\n", goFunctionHeader(f), goFunctionBody(f))
if tmpMeta != "signal" {
var tmpTmp = strings.Replace(fmt.Sprintf("%v{\n%v\n}\n\n", goFunctionHeader(f), goFunctionBody(f)), "_"+strings.Title(f.Name)+"(", "_"+strings.Title(f.Name)+"Default(", -1)
tmp += strings.Replace(tmpTmp, ")"+strings.Title(f.Name)+"(", ")"+strings.Title(f.Name)+"Default(", -1)
}
}
f.Meta = tmpMeta
return tmp
}
if isGeneric(f) {
var tmp string
for _, m := range jniGenericModes(f) {
f.TemplateMode = m
tmp += fmt.Sprintf("%v{\n%v\n}\n", goFunctionHeader(f), goFunctionBody(f))
}
f.TemplateMode = ""
return tmp
}
return fmt.Sprintf("%v{\n%v\n}", goFunctionHeader(f), goFunctionBody(f))
}
示例2: 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 f.Name == "objectNameAbs" || f.Name == "setObjectNameAbs" {
o += fmt.Sprintf("if (dynamic_cast<My%v*>(static_cast<%v*>(ptr))) {\n\t\t", f.Class(), f.Class())
}
if converter.CppHeaderOutput(f) != "void" {
o += "return "
}
var tmpMeta string
if strings.Contains(f.Virtual, "impure") {
if isDerivedFromSlot(f) {
tmpMeta = f.Meta
f.Meta = "slot"
}
}
switch f.Meta {
case "constructor":
{
if hasVirtualFunction(parser.ClassMap[f.Class()]) {
o += fmt.Sprintf("new My%v(%v)", f.Class(), converter.CppBodyInput(f))
} else {
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(%v)", f.Class(), f.Name, converter.DeduceGeneric(f), 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 {
if parser.ClassMap[f.Class()].IsQObjectSubClass() {
o += converter.CppBodyOutput(f, fmt.Sprintf("static_cast<%v*>(ptr)->%v%v(%v)", f.Class(), f.Name, converter.DeduceGeneric(f), converter.CppBodyInput(f)))
} else {
if f.Name == "objectNameAbs" || f.Name == "setObjectNameAbs" {
o += converter.CppBodyOutput(f, fmt.Sprintf("static_cast<My%v*>(ptr)->%v%v(%v)", f.Class(), f.Name, converter.DeduceGeneric(f), converter.CppBodyInput(f)))
} else {
o += converter.CppBodyOutput(f, fmt.Sprintf("static_cast<%v*>(ptr)->%v%v(%v)", f.Class(), f.Name, converter.DeduceGeneric(f), converter.CppBodyInput(f)))
}
}
}
}
}
case "signal":
{
if converter.IsPrivateSignal(f) {
o += fmt.Sprintf("QObject::%v(%v, &%v::%v, static_cast<My%v*>(ptr), static_cast<%v (My%v::*)(%v)>(&My%v::Signal_%v%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), cppFunctionSignalOverload(f))
} 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%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), cppFunctionSignalOverload(f))
}
}
default:
{
f.Access = "unsupported_CppFunctionBody"
return f.Access
}
}
if tmpMeta != "" {
f.Meta = tmpMeta
}
if f.Name == "objectNameAbs" {
o += fmt.Sprintf(";\n\t}\n\treturn QString(\"%v_BASE\").toUtf8().data()", f.Class())
//.........这里部分代码省略.........