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

Golang gi.BaseInfo类代码示例

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

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



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

示例1: CairoCgoToGoForInterface

func CairoCgoToGoForInterface(bi *gi.BaseInfo, arg1, arg2 string, flags ConvFlags) string {
	var out bytes.Buffer
	p := PrinterTo(&out)
	name := bi.Name()

	switch name {
	case "Path", "FontOptions":
		if flags&ConvPointer == 0 {
			panic("unexpected non-pointer type")
		}

		p("%s = (*cairo.%s)(cairo.%sWrap(unsafe.Pointer(%s)))", arg2, name, name, arg1)
	case "Surface", "Region", "Pattern", "Context", "FontFace", "ScaledFont":
		if flags&ConvPointer == 0 {
			panic("unexpected non-pointer type")
		}

		grab := "true"
		if flags&ConvOwnEverything != 0 {
			grab = "false"
		}
		p("%s = (*cairo.%s)(cairo.%sWrap(unsafe.Pointer(%s), %s))", arg2, name, name, arg1, grab)
	default:
		gotype := GoTypeForInterface(bi, TypeReturn)
		if flags&ConvPointer != 0 {
			p("%s = (*%s)(unsafe.Pointer(%s))",
				arg2, gotype, arg1)
		} else {
			p("%s = *(*%s)(unsafe.Pointer(&%s))",
				arg2, gotype, arg1)
		}
	}

	return out.String()
}
开发者ID:gnanderson,项目名称:gogobject,代码行数:35,代码来源:cairo.go


示例2: CForwardDeclaration20

func CForwardDeclaration20(bi *gi.BaseInfo) {
	switch bi.Type() {
	case gi.INFO_TYPE_FUNCTION:
		fi := gi.ToFunctionInfo(bi)
		CFuncForwardDeclaration(fi, nil)
	case gi.INFO_TYPE_OBJECT:
		oi := gi.ToObjectInfo(bi)
		for i, n := 0, oi.NumMethod(); i < n; i++ {
			meth := oi.Method(i)
			CFuncForwardDeclaration(meth, bi)
		}
		printf("extern GType %s();\n", oi.TypeInit())
	case gi.INFO_TYPE_INTERFACE:
		ii := gi.ToInterfaceInfo(bi)
		for i, n := 0, ii.NumMethod(); i < n; i++ {
			meth := ii.Method(i)
			CFuncForwardDeclaration(meth, bi)
		}
		printf("extern GType %s();\n", ii.TypeInit())
	case gi.INFO_TYPE_STRUCT:
		si := gi.ToStructInfo(bi)
		for i, n := 0, si.NumMethod(); i < n; i++ {
			meth := si.Method(i)
			CFuncForwardDeclaration(meth, bi)
		}
	case gi.INFO_TYPE_UNION:
		ui := gi.ToUnionInfo(bi)
		for i, n := 0, ui.NumMethod(); i < n; i++ {
			meth := ui.Method(i)
			CFuncForwardDeclaration(meth, bi)
		}
	}
}
开发者ID:gnanderson,项目名称:gogobject,代码行数:33,代码来源:binding_generator.go


示例3: CairoGoToCgoForInterface

func CairoGoToCgoForInterface(bi *gi.BaseInfo, arg0, arg1 string, flags ConvFlags) string {
	var out bytes.Buffer
	p := PrinterTo(&out)
	name := bi.Name()

	switch name {
	case "Surface", "Pattern":
		p("if %s != nil {\n", arg0)
		p("\t%s = (*C.cairo%s)(%s.InheritedFromCairo%s().C)\n", arg1, name, arg0, name)
		p("}")
	case "RectangleInt", "Rectangle", "TextCluster", "Matrix":
		ctype := CgoTypeForInterface(bi, TypeNone)
		if flags&ConvPointer != 0 {
			p("%s = (*%s)(unsafe.Pointer(%s))",
				arg1, ctype, arg0)
		} else {
			p("%s = *(*%s)(unsafe.Pointer(&%s))",
				arg1, ctype, arg0)
		}
	default:
		p("if %s != nil {\n", arg0)
		p("\t%s = (*C.cairo%s)(%s.C)\n", arg1, name, arg0)
		p("}")
	}

	return out.String()
}
开发者ID:gnanderson,项目名称:gogobject,代码行数:27,代码来源:cairo.go


示例4: c_forward_declaration20

func (this *binding_generator) c_forward_declaration20(bi *gi.BaseInfo) {
	p := printer_to(this.out_h)
	switch bi.Type() {
	case gi.INFO_TYPE_FUNCTION:
		fi := gi.ToFunctionInfo(bi)
		this.c_func_forward_declaration(fi)
	case gi.INFO_TYPE_OBJECT:
		oi := gi.ToObjectInfo(bi)
		for i, n := 0, oi.NumMethod(); i < n; i++ {
			meth := oi.Method(i)
			this.c_func_forward_declaration(meth)
		}
		p("extern GType %s();\n", oi.TypeInit())
	case gi.INFO_TYPE_INTERFACE:
		ii := gi.ToInterfaceInfo(bi)
		for i, n := 0, ii.NumMethod(); i < n; i++ {
			meth := ii.Method(i)
			this.c_func_forward_declaration(meth)
		}
		p("extern GType %s();\n", ii.TypeInit())
	case gi.INFO_TYPE_STRUCT:
		si := gi.ToStructInfo(bi)
		for i, n := 0, si.NumMethod(); i < n; i++ {
			meth := si.Method(i)
			this.c_func_forward_declaration(meth)
		}
	case gi.INFO_TYPE_UNION:
		ui := gi.ToUnionInfo(bi)
		for i, n := 0, ui.NumMethod(); i < n; i++ {
			meth := ui.Method(i)
			this.c_func_forward_declaration(meth)
		}
	}
}
开发者ID:nsf,项目名称:gogobject,代码行数:34,代码来源:binding_generator.go


示例5: process_base_info

func (this *binding_generator) process_base_info(bi *gi.BaseInfo) {
	p := printer_to(&this.go_bindings)

	if config.is_object_blacklisted(bi) {
		p("// blacklisted: %s (%s)\n", bi.Name(), bi.Type())
		return
	}

	switch bi.Type() {
	case gi.INFO_TYPE_UNION:
		this.process_union_info(gi.ToUnionInfo(bi))
	case gi.INFO_TYPE_STRUCT:
		this.process_struct_info(gi.ToStructInfo(bi))
	case gi.INFO_TYPE_ENUM, gi.INFO_TYPE_FLAGS:
		this.process_enum_info(gi.ToEnumInfo(bi))
	case gi.INFO_TYPE_CONSTANT:
		this.process_constant_info(gi.ToConstantInfo(bi))
	case gi.INFO_TYPE_CALLBACK:
		this.process_callback_info(gi.ToCallableInfo(bi))
	case gi.INFO_TYPE_FUNCTION:
		this.process_function_info(gi.ToFunctionInfo(bi))
	case gi.INFO_TYPE_INTERFACE:
		this.process_interface_info(gi.ToInterfaceInfo(bi))
	case gi.INFO_TYPE_OBJECT:
		this.process_object_info(gi.ToObjectInfo(bi))
	default:
		p("// TODO: %s (%s)\n", bi.Name(), bi.Type())
	}
}
开发者ID:nsf,项目名称:gogobject,代码行数:29,代码来源:binding_generator.go


示例6: CairoGoTypeForInterface

func CairoGoTypeForInterface(bi *gi.BaseInfo, flags TypeFlags) string {
	var out bytes.Buffer
	p := PrinterTo(&out)
	name := bi.Name()

	switch name {
	case "Surface", "Pattern":
		if flags&(TypeReturn) == 0 {
			p("cairo.%sLike", name)
			break
		}
		fallthrough
	default:
		if flags&TypePointer != 0 {
			p("*")
		}
		p("cairo.%s", name)
	}

	return out.String()
}
开发者ID:gnanderson,项目名称:gogobject,代码行数:21,代码来源:cairo.go


示例7: c_forward_declaration10

func (this *binding_generator) c_forward_declaration10(bi *gi.BaseInfo) {
	p := printer_to(this.out_h)
	switch bi.Type() {
	case gi.INFO_TYPE_OBJECT:
		cctype := c_type_for_interface(bi, type_none)
		p("typedef struct _%s %s;\n", cctype, cctype)
	case gi.INFO_TYPE_FLAGS, gi.INFO_TYPE_ENUM:
		ei := gi.ToEnumInfo(bi)
		p("typedef %s %s;\n", c_type_for_tag(ei.StorageType(), type_none),
			c_type_for_interface(bi, type_none))
	case gi.INFO_TYPE_STRUCT, gi.INFO_TYPE_INTERFACE, gi.INFO_TYPE_UNION:
		fullnm := strings.ToLower(bi.Namespace()) + "." + bi.Name()
		cctype := c_type_for_interface(bi, type_none)
		if config.is_disguised(fullnm) {
			p("typedef void *%s;\n", cctype)
		} else {
			p("typedef struct _%s %s;\n", cctype, cctype)
		}
	case gi.INFO_TYPE_CALLBACK:
		pc := printer_to(this.out_c)
		ctype := c_type_for_interface(bi, type_none)

		// type doesn't matter here, it's just a pointer after all
		p("typedef void* %s;\n", ctype)

		// and wrapper declarations for .c file only (cgo has problems
		// with that)
		pc("extern void _%s_c_wrapper();\n", ctype)
		pc("extern void _%s_c_wrapper_once();\n", ctype)
	}
}
开发者ID:nsf,项目名称:gogobject,代码行数:31,代码来源:binding_generator.go


示例8: CForwardDeclaration10

func CForwardDeclaration10(bi *gi.BaseInfo) {
	switch bi.Type() {
	case gi.INFO_TYPE_OBJECT:
		cctype := CTypeForInterface(bi, TypeNone)
		printf("typedef struct _%s %s;\n", cctype, cctype)
	case gi.INFO_TYPE_FLAGS, gi.INFO_TYPE_ENUM:
		ei := gi.ToEnumInfo(bi)
		printf("typedef %s %s;\n", CTypeForTag(ei.StorageType(), TypeNone),
			CTypeForInterface(bi, TypeNone))
	case gi.INFO_TYPE_STRUCT, gi.INFO_TYPE_INTERFACE, gi.INFO_TYPE_UNION:
		fullnm := strings.ToLower(bi.Namespace()) + "." + bi.Name()
		cctype := CTypeForInterface(bi, TypeNone)
		if _, ok := GConfig.Sys.DisguisedTypes[fullnm]; ok {
			printf("typedef void *%s;\n", cctype)
		} else {
			printf("typedef struct _%s %s;\n", cctype, cctype)
		}
	case gi.INFO_TYPE_CALLBACK:
		ctype := CTypeForInterface(bi, TypeNone)
		// type doesn't matter here, it's just a pointer after all
		printf("typedef void* %s;\n", ctype)
		// also generate wrapper declarations
		printf("extern void _%s_c_wrapper();\n", ctype)
		printf("extern void _%s_c_wrapper_once();\n", ctype)
	}
}
开发者ID:gnanderson,项目名称:gogobject,代码行数:26,代码来源:binding_generator.go


示例9: CForwardDeclaration30

func CForwardDeclaration30(bi *gi.BaseInfo) {
	fullnm := strings.ToLower(bi.Namespace()) + "." + bi.Name()

	switch bi.Type() {
	case gi.INFO_TYPE_STRUCT:
		si := gi.ToStructInfo(bi)
		size := si.Size()
		if _, ok := GConfig.Sys.DisguisedTypes[fullnm]; ok {
			return
		}
		cctype := CTypeForInterface(bi, TypeNone)
		if size == 0 {
			printf("struct _%s {};\n", cctype)
		} else {
			printf("struct _%s { uint8_t _data[%d]; };\n", cctype, size)
		}
	case gi.INFO_TYPE_UNION:
		ui := gi.ToUnionInfo(bi)
		size := ui.Size()
		cctype := CTypeForInterface(bi, TypeNone)
		if size == 0 {
			printf("struct _%s {};\n", cctype)
		} else {
			printf("struct _%s { uint8_t _data[%d]; };\n", cctype, size)
		}
	}
}
开发者ID:gnanderson,项目名称:gogobject,代码行数:27,代码来源:binding_generator.go


示例10: c_forward_declaration30

func (this *binding_generator) c_forward_declaration30(bi *gi.BaseInfo) {
	p := printer_to(this.out_h)
	fullnm := strings.ToLower(bi.Namespace()) + "." + bi.Name()

	switch bi.Type() {
	case gi.INFO_TYPE_STRUCT:
		si := gi.ToStructInfo(bi)
		size := si.Size()
		if config.is_disguised(fullnm) {
			return
		}
		cctype := c_type_for_interface(bi, type_none)
		if size == 0 {
			p("struct _%s {};\n", cctype)
		} else {
			p("struct _%s { uint8_t _data[%d]; };\n", cctype, size)
		}
	case gi.INFO_TYPE_UNION:
		ui := gi.ToUnionInfo(bi)
		size := ui.Size()
		cctype := c_type_for_interface(bi, type_none)
		if size == 0 {
			p("struct _%s {};\n", cctype)
		} else {
			p("struct _%s { uint8_t _data[%d]; };\n", cctype, size)
		}
	}
}
开发者ID:nsf,项目名称:gogobject,代码行数:28,代码来源:binding_generator.go


示例11: TypeSizeForInterface

func TypeSizeForInterface(bi *gi.BaseInfo, flags TypeFlags) int {
	ptrsize := int(unsafe.Sizeof(unsafe.Pointer(nil)))
	if flags&TypePointer != 0 {
		return ptrsize
	}

	switch t := bi.Type(); t {
	case gi.INFO_TYPE_OBJECT, gi.INFO_TYPE_INTERFACE:
		return ptrsize
	case gi.INFO_TYPE_STRUCT:
		si := gi.ToStructInfo(bi)
		return si.Size()
	case gi.INFO_TYPE_UNION:
		ui := gi.ToUnionInfo(bi)
		return ui.Size()
	case gi.INFO_TYPE_ENUM, gi.INFO_TYPE_FLAGS:
		ei := gi.ToEnumInfo(bi)
		return TypeSizeForTag(ei.StorageType(), flags)
	case gi.INFO_TYPE_CALLBACK:
		return ptrsize
	}
	panic("unreachable: " + bi.Type().String())
}
开发者ID:gnanderson,项目名称:gogobject,代码行数:23,代码来源:type.go


示例12: cgo_type_for_interface

func cgo_type_for_interface(bi *gi.BaseInfo, flags type_flags) string {
	var out bytes.Buffer

	switch bi.Type() {
	case gi.INFO_TYPE_CALLBACK:
		out.WriteString("unsafe.Pointer")
	default:
		ns := bi.Namespace()
		nm := bi.Name()
		fullnm := strings.ToLower(ns) + "." + nm

		if flags&type_pointer != 0 && !config.is_disguised(fullnm) {
			out.WriteString("*")
		}

		out.WriteString("C.")
		out.WriteString(gi.DefaultRepository().CPrefix(ns))
		out.WriteString(bi.Name())
	}
	return out.String()
}
开发者ID:nsf,项目名称:gogobject,代码行数:21,代码来源:type.go


示例13: CgoTypeForInterface

func CgoTypeForInterface(bi *gi.BaseInfo, flags TypeFlags) string {
	var out bytes.Buffer

	switch bi.Type() {
	case gi.INFO_TYPE_CALLBACK:
		out.WriteString("unsafe.Pointer")
	default:
		ns := bi.Namespace()
		nm := bi.Name()
		fullnm := strings.ToLower(ns) + "." + nm

		_, disguised := GConfig.Sys.DisguisedTypes[fullnm]
		if flags&TypePointer != 0 && !disguised {
			out.WriteString("*")
		}

		out.WriteString("C.")
		out.WriteString(gi.DefaultRepository().CPrefix(ns))
		out.WriteString(bi.Name())
	}
	return out.String()
}
开发者ID:gnanderson,项目名称:gogobject,代码行数:22,代码来源:type.go


示例14: CgoToGoForInterface

func CgoToGoForInterface(bi *gi.BaseInfo, arg1, arg2 string, flags ConvFlags) string {
	var out bytes.Buffer
	printf := PrinterTo(&out)

	switch bi.Type() {
	case gi.INFO_TYPE_OBJECT, gi.INFO_TYPE_INTERFACE:
		gotype := GoTypeForInterface(bi, TypeReturn)
		if flags&ConvOwnEverything != 0 {
			printf("%s = (*%s)(%sObjectWrap(unsafe.Pointer(%s), false))",
				arg2, gotype, Config.Sys.GNS, arg1)
		} else {
			printf("%s = (*%s)(%sObjectWrap(unsafe.Pointer(%s), true))",
				arg2, gotype, Config.Sys.GNS, arg1)
		}
	case gi.INFO_TYPE_ENUM, gi.INFO_TYPE_FLAGS:
		gotype := GoTypeForInterface(bi, TypeReturn)
		printf("%s = %s(%s)", arg2, gotype, arg1)
	case gi.INFO_TYPE_STRUCT, gi.INFO_TYPE_UNION:
		ns := bi.Namespace()
		if ns == "cairo" {
			printf(CairoCgoToGoForInterface(bi, arg1, arg2, flags))
			break
		}

		fullnm := strings.ToLower(ns) + "." + bi.Name()
		gotype := GoTypeForInterface(bi, TypeReturn)

		if flags&ConvListMember != 0 {
			printf("%s = *(*%s)(unsafe.Pointer(%s))",
				arg2, gotype, arg1)
			break
		}

		if _, ok := GConfig.Sys.DisguisedTypes[fullnm]; ok {
			printf("%s = %s{unsafe.Pointer(%s)}",
				arg2, gotype, arg1)
			break
		}

		if flags&ConvPointer != 0 {
			printf("%s = (*%s)(unsafe.Pointer(%s))",
				arg2, gotype, arg1)
		} else {
			printf("%s = *(*%s)(unsafe.Pointer(&%s))",
				arg2, gotype, arg1)
		}
	}
	return out.String()
}
开发者ID:gnanderson,项目名称:gogobject,代码行数:49,代码来源:typeconv.go


示例15: c_type_for_interface

func c_type_for_interface(bi *gi.BaseInfo, flags type_flags) string {
	var out bytes.Buffer

	ns := bi.Namespace()
	nm := bi.Name()
	fullnm := strings.ToLower(ns) + "." + nm
	out.WriteString(gi.DefaultRepository().CPrefix(ns))
	out.WriteString(bi.Name())

	if flags&type_pointer != 0 && !config.is_disguised(fullnm) {
		out.WriteString("*")
	}

	return out.String()
}
开发者ID:nsf,项目名称:gogobject,代码行数:15,代码来源:type.go


示例16: CTypeForInterface

func CTypeForInterface(bi *gi.BaseInfo, flags TypeFlags) string {
	var out bytes.Buffer

	ns := bi.Namespace()
	nm := bi.Name()
	fullnm := strings.ToLower(ns) + "." + nm
	out.WriteString(gi.DefaultRepository().CPrefix(ns))
	out.WriteString(bi.Name())

	_, disguised := GConfig.Sys.DisguisedTypes[fullnm]
	if flags&TypePointer != 0 && !disguised {
		out.WriteString("*")
	}

	return out.String()
}
开发者ID:gnanderson,项目名称:gogobject,代码行数:16,代码来源:type.go


示例17: ProcessBaseInfo

func ProcessBaseInfo(bi *gi.BaseInfo) {
	switch bi.Type() {
	case gi.INFO_TYPE_UNION:
		if IsBlacklisted("unions", bi.Name()) {
			goto blacklisted
		}
		ProcessUnionInfo(gi.ToUnionInfo(bi))
	case gi.INFO_TYPE_STRUCT:
		if IsBlacklisted("structs", bi.Name()) {
			goto blacklisted
		}
		ProcessStructInfo(gi.ToStructInfo(bi))
	case gi.INFO_TYPE_ENUM, gi.INFO_TYPE_FLAGS:
		if IsBlacklisted("enums", bi.Name()) {
			goto blacklisted
		}
		ProcessEnumInfo(gi.ToEnumInfo(bi))
	case gi.INFO_TYPE_CONSTANT:
		if IsBlacklisted("constants", bi.Name()) {
			goto blacklisted
		}
		ProcessConstantInfo(gi.ToConstantInfo(bi))
	case gi.INFO_TYPE_CALLBACK:
		if IsBlacklisted("callbacks", bi.Name()) {
			goto blacklisted
		}
		ProcessCallbackInfo(gi.ToCallableInfo(bi))
	case gi.INFO_TYPE_FUNCTION:
		if IsBlacklisted("functions", bi.Name()) {
			goto blacklisted
		}
		ProcessFunctionInfo(gi.ToFunctionInfo(bi), nil)
	case gi.INFO_TYPE_INTERFACE:
		if IsBlacklisted("interfaces", bi.Name()) {
			goto blacklisted
		}
		ProcessInterfaceInfo(gi.ToInterfaceInfo(bi))
	case gi.INFO_TYPE_OBJECT:
		if IsBlacklisted("objects", bi.Name()) {
			goto blacklisted
		}
		ProcessObjectInfo(gi.ToObjectInfo(bi))
	default:
		printf("// TODO: %s (%s)\n", bi.Name(), bi.Type())
	}
	return

blacklisted:
	printf("// blacklisted: %s (%s)\n", bi.Name(), bi.Type())
}
开发者ID:gnanderson,项目名称:gogobject,代码行数:50,代码来源:binding_generator.go


示例18: ProcessFunctionInfo

func ProcessFunctionInfo(fi *gi.FunctionInfo, container *gi.BaseInfo) {
	var fullnm string
	flags := fi.Flags()
	name := fi.Name()

	// --- header
	fb := NewFunctionBuilder(fi)
	printf("func ")
	if flags&gi.FUNCTION_IS_METHOD != 0 {
		// add receiver if it's a method
		printf("(this0 %s) ",
			GoTypeForInterface(container, TypePointer|TypeReceiver))
		fullnm = container.Name() + "."
	}
	switch {
	case flags&gi.FUNCTION_IS_CONSTRUCTOR != 0:
		// special names for constructors
		name = fmt.Sprintf("New%s%s", container.Name(), CtorSuffix(name))
	case flags&gi.FUNCTION_IS_METHOD == 0 && container != nil:
		name = fmt.Sprintf("%s%s", container.Name(), LowerCaseToCamelCase(name))
	default:
		name = fmt.Sprintf("%s", LowerCaseToCamelCase(name))
	}
	fullnm += name
	name = Rename(fullnm, name)
	printf("%s(", name)
	for i, arg := range fb.Args {
		printf("%s0 %s", arg.ArgInfo.Name(), GoType(arg.TypeInfo, TypeNone))
		if i != len(fb.Args)-1 {
			printf(", ")
		}
	}
	printf(")")
	switch len(fb.Rets) {
	case 0:
		// do nothing if there are not return values
	case 1:
		if flags&gi.FUNCTION_IS_CONSTRUCTOR != 0 {
			// override return types for constructors, We can't
			// return generic widget here as C does. Go's type
			// system is stronger.
			printf(" %s",
				GoTypeForInterface(container, TypePointer|TypeReturn))
			break
		}
		if fb.Rets[0].Index == -2 {
			printf(" error")
		} else {
			printf(" %s", GoType(fb.Rets[0].TypeInfo, TypeReturn))
		}
	default:
		printf(" (")
		for i, ret := range fb.Rets {
			if ret.Index == -2 {
				// special error type in Go to represent GError
				printf("error")
				continue
			}
			printf(GoType(ret.TypeInfo, TypeReturn))
			if i != len(fb.Rets)-1 {
				printf(", ")
			}
		}
		printf(")")
	}
	printf(" {\n")

	// --- body stage 1 (Go to C conversions)

	// var declarations
	if flags&gi.FUNCTION_IS_METHOD != 0 {
		printf("\tvar this1 %s\n", CgoTypeForInterface(container, TypePointer))
	}
	for _, arg := range fb.Args {
		printf("\tvar %s1 %s\n", arg.ArgInfo.Name(),
			CgoType(arg.TypeInfo, TypeNone))
		if al := arg.TypeInfo.ArrayLength(); al != -1 {
			arg := fb.OrigArgs[al]
			printf("\tvar %s1 %s\n", arg.Name(),
				CgoType(arg.Type(), TypeNone))
		}
	}

	for _, ret := range fb.Rets {
		if ret.Index == -1 {
			continue
		}

		if ret.Index == -2 {
			printf("\tvar err1 *C.GError\n")
			continue
		}

		if ret.ArgInfo.Direction() == gi.DIRECTION_INOUT {
			continue
		}

		printf("\tvar %s1 %s\n", ret.ArgInfo.Name(),
			CgoType(ret.TypeInfo, TypeNone))
		if al := ret.TypeInfo.ArrayLength(); al != -1 {
//.........这里部分代码省略.........
开发者ID:gnanderson,项目名称:gogobject,代码行数:101,代码来源:binding_generator.go


示例19: go_type_for_interface

func go_type_for_interface(bi *gi.BaseInfo, flags type_flags) string {
	var out bytes.Buffer
	printf := printer_to(&out)
	ns := bi.Namespace()
	fullnm := strings.ToLower(ns) + "." + bi.Name()

	if flags&type_list_member != 0 {
		switch bi.Type() {
		case gi.INFO_TYPE_OBJECT, gi.INFO_TYPE_INTERFACE:
			return go_type_for_interface(bi, type_pointer|type_return)
		default:
			return go_type_for_interface(bi, type_return)
		}
	}

	switch t := bi.Type(); t {
	case gi.INFO_TYPE_OBJECT, gi.INFO_TYPE_INTERFACE:
		if flags&type_exact != 0 {
			// exact type for object/interface is always an unsafe.Pointer
			printf("unsafe.Pointer")
			break
		}

		if flags&(type_return|type_receiver) != 0 && flags&type_pointer != 0 {
			// receivers and return values are actual types,
			// and a pointer most likely
			printf("*")
		}
		if ns != config.namespace {
			// prepend foreign types with appropriate namespace
			printf("%s.", strings.ToLower(ns))
		}
		printf(bi.Name())
		if flags&(type_return|type_receiver) == 0 {
			// ordinary function arguments are substituted by their *Like
			// counterparts
			printf("Like")
		}
		if flags&type_receiver != 0 && t == gi.INFO_TYPE_INTERFACE {
			// special case for interfaces, we use *Impl structures
			// as receivers
			printf("Impl")
		}
	case gi.INFO_TYPE_CALLBACK:
		if flags&type_exact != 0 {
			printf("unsafe.Pointer")
			break
		}
		goto handle_default
	case gi.INFO_TYPE_STRUCT:
		if ns == "cairo" {
			printf(cairo_go_type_for_interface(bi, flags))
			break
		}
		goto handle_default
	default:
		goto handle_default
	}
	return out.String()
handle_default:
	if flags&type_pointer != 0 && !config.is_disguised(fullnm) {
		printf("*")
	}
	if ns != config.namespace {
		printf("%s.", strings.ToLower(ns))
	}
	printf(bi.Name())
	return out.String()
}
开发者ID:nsf,项目名称:gogobject,代码行数:69,代码来源:type.go


示例20: GoToCgoForInterface

func GoToCgoForInterface(bi *gi.BaseInfo, arg0, arg1 string, flags ConvFlags) string {
	var out bytes.Buffer
	printf := PrinterTo(&out)

	switch bi.Type() {
	case gi.INFO_TYPE_OBJECT:
		prefix := gi.DefaultRepository().CPrefix(bi.Namespace())
		printf("if %s != nil {\n", arg0)
		printf("\t%s = %s.InheritedFrom%s%s()\n",
			arg1, arg0, prefix, bi.Name())
		printf("}")
	case gi.INFO_TYPE_ENUM, gi.INFO_TYPE_FLAGS:
		ctype := CgoTypeForInterface(bi, TypeNone)
		printf("%s = %s(%s)", arg1, ctype, arg0)
	case gi.INFO_TYPE_INTERFACE:
		prefix := gi.DefaultRepository().CPrefix(bi.Namespace())
		printf("if %s != nil {\n", arg0)
		printf("\t%s = %s.Implements%s%s()",
			arg1, arg0, prefix, bi.Name())
		printf("}")
	case gi.INFO_TYPE_STRUCT:
		ns := bi.Namespace()
		if ns == "cairo" {
			printf(CairoGoToCgoForInterface(bi, arg0, arg1, flags))
			break
		}

		fullnm := strings.ToLower(ns) + "." + bi.Name()
		if _, ok := GConfig.Sys.DisguisedTypes[fullnm]; ok {
			flags &^= ConvPointer
		}
		ctype := CgoTypeForInterface(bi, TypeNone)
		if flags&ConvPointer != 0 {
			printf("%s = (*%s)(unsafe.Pointer(%s))",
				arg1, ctype, arg0)
		} else {
			printf("%s = *(*%s)(unsafe.Pointer(&%s))",
				arg1, ctype, arg0)
		}
	case gi.INFO_TYPE_CALLBACK:
		printf("if %s != nil {\n", arg0)
		printf("\t%s = unsafe.Pointer(&%s)", arg1, arg0)
		printf("}")
	}

	return out.String()
}
开发者ID:gnanderson,项目名称:gogobject,代码行数:47,代码来源:typeconv.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang gi.TypeInfo类代码示例发布时间:2022-05-28
下一篇:
Golang gob.NewEncoder函数代码示例发布时间: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