• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang parser.Function类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/therecipe/qt/internal/binding/parser.Function的典型用法代码示例。如果您正苦于以下问题:Golang Function类的具体用法?Golang Function怎么用?Golang Function使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Function类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: CppBodyInput

func CppBodyInput(f *parser.Function) (o string) {

	if f.Meta == "slot" {
		for _, p := range f.Parameters {
			o += fmt.Sprintf(", Q_ARG(%v, %v)", CppBodyInputSlotValue(f, p), cppInput(p.Name, p.Value, f))
		}
		return
	}

	if f.Meta == "signal" {
		for _, p := range f.Parameters {

			if isEnum(f.Class(), cleanValue(p.Value)) {
				o += fmt.Sprintf("%v, ", cppEnum(f, cleanValue(p.Value), true))
			} else {
				o += fmt.Sprintf("%v, ", p.Value)
			}
		}
		return strings.TrimSuffix(o, ", ")
	}

	for _, p := range f.Parameters {
		o += fmt.Sprintf("%v, ", cppInput(p.Name, p.Value, f))
	}

	return strings.TrimSuffix(o, ", ")
}
开发者ID:mouse225,项目名称:qt,代码行数:27,代码来源:body_input.go


示例2: IsPrivateSignal

func IsPrivateSignal(f *parser.Function) bool {

	var fData string

	switch runtime.GOOS {
	case "darwin":
		fData = utils.Load(fmt.Sprintf("/usr/local/Qt5.5.1/5.5/clang_64/lib/%v.framework/Versions/5/Headers/%v", strings.Title(parser.ClassMap[f.Class()].DocModule), filepath.Base(f.Filepath)))

	case "windows":
		fData = utils.Load(fmt.Sprintf("C:\\Qt\\Qt5.5.1\\5.5\\mingw492_32\\include\\%v\\%v", strings.Title(parser.ClassMap[f.Class()].DocModule), filepath.Base(f.Filepath)))

	case "linux":
		switch runtime.GOARCH {
		case "amd64":
			{
				fData = utils.Load(fmt.Sprintf("/usr/local/Qt5.5.1/5.5/gcc_64/include/%v/%v", strings.Title(parser.ClassMap[f.Class()].DocModule), filepath.Base(f.Filepath)))
			}
		case "386":
			{
				fData = utils.Load(fmt.Sprintf("/usr/local/Qt5.5.1/5.5/gcc/include/%v/%v", strings.Title(parser.ClassMap[f.Class()].DocModule), filepath.Base(f.Filepath)))
			}
		}
	}

	if fData != "" {
		return strings.Contains(strings.Split(strings.Split(fData, f.Name+"(")[1], ")")[0], "QPrivateSignal")
	} else {
		fmt.Println("converter.IsPrivateSignal", f.Class())
	}

	return false
}
开发者ID:mouse225,项目名称:qt,代码行数:32,代码来源:body_input.go


示例3: 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
}
开发者ID:xland,项目名称:qt,代码行数:59,代码来源:input.go


示例4: 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
	}
}
开发者ID:mouse225,项目名称:qt,代码行数:56,代码来源:output.go


示例5: 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
}
开发者ID:xland,项目名称:qt,代码行数:55,代码来源:type.go


示例6: isBlocked

func isBlocked(f *parser.Function) bool {
	for _, n := range []string{"relations", "scriptValueFromQMetaObject", "fromScriptValue", "QPlaceProposedSearchResult", "evaluateTo", "detected", "isRecordType", "replace", "insert", "remove", "find", "changedStates", "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
		}
	}

	for _, n := range []string{"QAccessibleInterface::state", "QAccessibleWidget::state"} {
		if f.Fullname == n {
			f.Access = "unsupported_isBlocked"
			return true
		}
	}

	//Android Only
	for _, blockedAndroid := range []string{"setAsDockMenu", "setSelect"} {
		if f.Name == blockedAndroid {
			f.Access = "unsupported_isBlocked_Android"
			return true
		}
	}

	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
}
开发者ID:mouse225,项目名称:qt,代码行数:35,代码来源:templater.go


示例7: CppBodyInputSlotValue

func CppBodyInputSlotValue(f *parser.Function, p *parser.Parameter) string {
	if strings.Contains(p.Value, "*") {
		return fmt.Sprintf("%v*", cleanValue(p.Value))
	}

	if isEnum(f.Class(), p.Value) {
		return cppEnum(f, p.Value, false)
	}

	return cleanValue(p.Value)
}
开发者ID:mouse225,项目名称:qt,代码行数:11,代码来源:body_input.go


示例8: CppBodyInputCallback

func CppBodyInputCallback(f *parser.Function) (o string) {
	for _, p := range f.Parameters {

		if isEnum(f.Class(), cleanValue(p.Value)) {
			o += fmt.Sprintf("%v %v, ", cppEnum(f, cleanValue(p.Value), true), cleanName(p.Name))
		} else {
			o += fmt.Sprintf("%v %v, ", p.Value, cleanName(p.Name))
		}
	}

	return strings.TrimSuffix(o, ", ")
}
开发者ID:mouse225,项目名称:qt,代码行数:12,代码来源:body_input.go


示例9: 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
}
开发者ID:xland,项目名称:qt,代码行数:53,代码来源:output.go


示例10: cppFunction

func cppFunction(f *parser.Function) string {

	if isGeneric(f) {
		var tmp string
		for _, m := range jniGenericModes(f) {
			f.TemplateMode = m
			tmp += fmt.Sprintf("%v{\n\t%v\n}\n", cppFunctionHeader(f), cppFunctionBody(f))
		}
		f.TemplateMode = ""
		return tmp
	}

	return fmt.Sprintf("%v{\n\t%v\n}", cppFunctionHeader(f), cppFunctionBody(f))
}
开发者ID:mouse225,项目名称:qt,代码行数:14,代码来源:function_cpp.go


示例11: goFunction

func goFunction(f *parser.Function) string {
	if f.Meta == "signal" && !f.Overload {
		var tmp string
		for _, signalMode := range []string{"Connect", "Disconnect", "callback"} {
			f.SignalMode = signalMode
			if signalMode == "callback" {
				tmp += fmt.Sprintf("//export callback%v%v\n", f.Class(), strings.Title(f.Name))
			}
			tmp += fmt.Sprintf("%v{\n%v\n}\n\n", goFunctionHeader(f), goFunctionBody(f))
		}
		f.SignalMode = ""
		return tmp
	}
	return fmt.Sprintf("%v{\n%v\n}", goFunctionHeader(f), goFunctionBody(f))
}
开发者ID:xland,项目名称:qt,代码行数:15,代码来源:function_go.go


示例12: 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
}
开发者ID:mouse225,项目名称:qt,代码行数:46,代码来源:type.go


示例13: isDerivedFromSlot

func isDerivedFromSlot(of *parser.Function) bool {

	var c = parser.ClassMap[of.Class()]

	for _, bcName := range c.GetAllBases([]string{}) {
		if bc, exists := parser.ClassMap[bcName]; exists {
			for _, f := range bc.Functions {
				if strings.Contains(f.Virtual, "impure") && f.Output == "void" {
					if of.Name == f.Name && (of.Meta == "slot" || f.Meta == "slot") {
						return true
					}
				}
			}
		}
	}

	return false
}
开发者ID:mouse225,项目名称:qt,代码行数:18,代码来源:templater.go


示例14: CppBodyOutputCallback

func CppBodyOutputCallback(f *parser.Function) (o string) {

	//TODO: parse from docs
	var this = "this"
	if strings.Contains(strings.Split(f.Signature, ")")[1], "const") {
		this = fmt.Sprintf("const_cast<My%v*>(this)", f.Class())
	}

	if parser.ClassMap[f.Class()].IsQObjectSubClass() {
		o += fmt.Sprintf("%v, %v", this, cppOutput("this->objectName()", "QString", f))
	} else {
		o += fmt.Sprintf("%v, %v", this, cppOutput("this->objectNameAbs()", "QString", f))
	}

	for _, p := range f.Parameters {
		o += fmt.Sprintf(", %v", cppOutput(p.Name, p.Value, f))
	}
	return
}
开发者ID:mouse225,项目名称:qt,代码行数:19,代码来源:body_input.go


示例15: isDerivedFromPure

func isDerivedFromPure(of *parser.Function) bool {

	var c = parser.ClassMap[of.Class()]

	for _, bcName := range c.GetAllBases([]string{}) {
		if bc, exists := parser.ClassMap[bcName]; exists {
			for _, f := range bc.Functions {
				if f.Virtual == "impure" && !isDerivedFromSlot(of) {
					return false
				}
				if f.Virtual == "pure" && f.Output == "void" {
					if of.Name == f.Name {
						return true
					}
				}
			}
		}
	}

	return false
}
开发者ID:mouse225,项目名称:qt,代码行数:21,代码来源:templater.go


示例16: 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)
}
开发者ID:mouse225,项目名称:qt,代码行数:39,代码来源:header.go


示例17: 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))
}
开发者ID:mouse225,项目名称:qt,代码行数:47,代码来源:function_go.go


示例18: 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
}
开发者ID:mouse225,项目名称:qt,代码行数:48,代码来源:header.go


示例19: goFunctionBody

func goFunctionBody(f *parser.Function) (o string) {

	if !f.Static && f.Meta != "constructor" && f.SignalMode != "callback" {
		o += fmt.Sprintf("if ptr.Pointer() != nil {\n")
	}

	if converter.GoHeaderOutput(f) != "" {
		o += "return "
	}

	/*
		if (f.Meta == "destructor" && isObjectSubClass(f.Class())) || (f.Meta == "slot" && strings.Contains(f.Name, "deleteLater")) {
			o += "getSignal(ptr.ObjectName(), \"destroyed\").(func(QObject, QObject))(ptr, ptr)\n"
		}
	*/

	if f.SignalMode == "callback" {
		o += fmt.Sprintf("qt.GetSignal(C.GoString(ptrName), \"%v\").(%v)(%v)", f.Name, converter.GoHeaderInputSignalFunction(f), converter.GoBodyInputSignalValues(f))
	} else {
		o += converter.GoBodyOutput(f, fmt.Sprintf("C.%v(%v)", converter.CppHeaderName(f), converter.GoBodyInput(f)))
	}

	if f.SignalMode == "Connect" {
		o += fmt.Sprintf("\nqt.ConnectSignal(ptr.ObjectName(), \"%v\", f)", f.Name)
	}

	if f.SignalMode == "Disconnect" {
		o += fmt.Sprintf("\nqt.DisconnectSignal(ptr.ObjectName(), \"%v\")", f.Name)
	}

	if (f.Meta == "destructor" && isObjectSubClass(f.Class())) || (f.Meta == "slot" && strings.Contains(f.Name, "deleteLater")) {
		o += "\nptr.SetPointer(nil)"
	}

	if !f.Static && f.Meta != "constructor" && f.SignalMode != "callback" {
		o += "\n}"
		if converter.GoHeaderOutput(f) != "" {
			o += fmt.Sprintf("\nreturn %v", converter.GoBodyOutputFailed(f.Output, f))
		}
	}

	if parser.ClassMap[f.Class()].Stub {
		if f.Meta == "constructor" {
			return fmt.Sprintf("\nreturn New%vFromPointer(%v)", f.Class(), converter.GoBodyOutputFailed(f.Class(), f))
		} else {
			return fmt.Sprintf("\nreturn %v", converter.GoBodyOutputFailed(f.Output, f))
		}
	}

	return o
}
开发者ID:xland,项目名称:qt,代码行数:51,代码来源:function_go.go


示例20: 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, ", ")
}
开发者ID:mouse225,项目名称:qt,代码行数:20,代码来源:header.go



注:本文中的github.com/therecipe/qt/internal/binding/parser.Function类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang widgets.QLineEdit类代码示例发布时间:2022-05-28
下一篇:
Golang gui.PointerFromQPainter函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap