예제 #1
0
파일: dump.go 프로젝트: reusee/ggi
func DumpUnionInfo(info *C.GIUnionInfo) {
	nFields := C.g_union_info_get_n_fields(info)
	p("%d fields\n", nFields)
	for i := C.gint(0); i < nFields; i++ {
		field := C.g_union_info_get_field(info, i)
		DumpFieldInfo(field)
	}
	nMethods := C.g_union_info_get_n_methods(info)
	p("%d methods\n", nMethods)
	for i := C.gint(0); i < nMethods; i++ {
		method := C.g_union_info_get_method(info, i)
		DumpFunctionInfo(method)
	}
	isDiscriminated := C.g_union_info_is_discriminated(info) == C.gboolean(1)
	p("is discriminated %v\n", isDiscriminated)
	if isDiscriminated {
		offset := C.g_union_info_get_discriminator_offset(info)
		p("discriminated offset %d\n", offset)
		discriminatedType := C.g_union_info_get_discriminator_type(info)
		p("discriminated type %d\n", discriminatedType)
		DumpTypeInfo(discriminatedType)
		for i := C.gint(0); i < nFields; i++ {
			discriminator := C.g_union_info_get_discriminator(info, i)
			DumpConstantInfo(discriminator)
		}
	}
	size := C.g_union_info_get_size(info)
	p("size %d bytes\n", size)
	align := C.g_union_info_get_alignment(info)
	p("alignment %d bytes\n", align)
}
예제 #2
0
파일: gi.go 프로젝트: bytbox/gogobject
// g_union_info_is_discriminated
func (ui *UnionInfo) IsDiscriminated() bool {
	return C.g_union_info_is_discriminated((*C.GIUnionInfo)(ui.c)) != 0
}