当前位置: 首页>>代码示例>>Golang>>正文


Golang gi.BaseInfo类代码示例

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


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


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