Пример #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
// g_union_info_get_field
func (ui *UnionInfo) Field(n int) FieldInfo {
	return FieldInfo{BaseInfo{
		(*C.GIBaseInfo)(C.g_union_info_get_field((*C.GIUnionInfo)(ui.c), C.gint(n)))}}
}