Beispiel #1
0
func DumpCallableInfo(info *C.GICallableInfo) {
	throwsError := C.g_callable_info_can_throw_gerror(info) == C.gboolean(1)
	p("can throws error %v\n", throwsError)
	nArgs := C.g_callable_info_get_n_args(info)
	for i := C.gint(0); i < nArgs; i++ {
		argInfo := C.g_callable_info_get_arg(info, i)
		DumpArgInfo(argInfo)
	}
	returnOwnership := C.g_callable_info_get_caller_owns(info)
	p("return value ownership %s\n", TransferGetName(returnOwnership))
	returnType := C.g_callable_info_get_return_type(info)
	defer C.g_base_info_unref(asBaseInfo(returnType))
	p("return type %v\n", returnType)
	DumpTypeInfo(returnType)
	isMethod := C.g_callable_info_is_method(info) == C.gboolean(1)
	p("is method %v\n", isMethod)
	var iter C.GIAttributeIter
	var key, value *C.char
	for C.g_callable_info_iterate_return_attributes(info, &iter, &key, &value) == C.gboolean(1) {
		p("Attr %s = %s\n", C.GoString(key), C.GoString(value))
	}
	mayReturnNull := C.g_callable_info_may_return_null(info) == C.gboolean(1)
	p("may return null %v\n", mayReturnNull)
	skipReturn := C.g_callable_info_skip_return(info) == C.gboolean(1)
	p("skip return %v\n", skipReturn)
}
Beispiel #2
0
// g_base_info_unref
func (bi *BaseInfo) Unref() {
	C.g_base_info_unref(bi.c)
}
Beispiel #3
0
func dump() {
	repo := C.g_irepository_get_default()
	lib := os.Args[1]

	var err *C.GError
	C.g_irepository_require(repo, toGStr(lib), nil, 0, &err)
	if err != nil {
		log.Fatal(fromGStr(err.message))
	}

	nInfos := C.g_irepository_get_n_infos(repo, toGStr(lib))
	var nObjects int
	for i := C.gint(0); i < nInfos; i++ {
		baseInfo := C.g_irepository_get_info(repo, toGStr(lib), i)
		if C.g_base_info_is_deprecated(baseInfo) == C.gboolean(1) { // skip deprecated
			continue
		}
		name := fromGStr(C.g_base_info_get_name(baseInfo)) // name
		p("=> %s\n", name)
		var iter C.GIAttributeIter
		var key, value *C.char
		for C.g_base_info_iterate_attributes(baseInfo, &iter, &key, &value) == C.gboolean(1) {
			p("Attr %s = %s\n", C.GoString(key), C.GoString(value))
		}
		t := C.g_base_info_get_type(baseInfo) // type
		p("%s\n", fromGStr(C.g_info_type_to_string(t)))
		switch t { // dump
		case C.GI_INFO_TYPE_OBJECT:
			info := (*C.GIObjectInfo)(unsafe.Pointer(baseInfo))
			p("Object\n")
			DumpObjectInfo(info)
			nObjects++
		case C.GI_INFO_TYPE_STRUCT:
			p("Struct\n")
			info := (*C.GIStructInfo)(unsafe.Pointer(baseInfo))
			DumpStructInfo(info)
		case C.GI_INFO_TYPE_FLAGS:
			p("Flags\n")
			info := (*C.GIEnumInfo)(unsafe.Pointer(baseInfo))
			DumpEnumInfo(info)
		case C.GI_INFO_TYPE_CALLBACK:
			p("Callback\n")
			info := (*C.GIFunctionInfo)(unsafe.Pointer(baseInfo))
			DumpFunctionInfo(info)
		case C.GI_INFO_TYPE_INTERFACE:
			p("Interface\n")
			info := (*C.GIInterfaceInfo)(unsafe.Pointer(baseInfo))
			DumpInterfaceInfo(info)
		case C.GI_INFO_TYPE_UNION:
			p("Union\n")
			info := (*C.GIUnionInfo)(unsafe.Pointer(baseInfo))
			DumpUnionInfo(info)
		case C.GI_INFO_TYPE_ENUM:
			p("Enum\n")
			info := (*C.GIEnumInfo)(unsafe.Pointer(baseInfo))
			DumpEnumInfo(info)
		case C.GI_INFO_TYPE_FUNCTION:
			p("Function\n")
			info := (*C.GIFunctionInfo)(unsafe.Pointer(baseInfo))
			DumpFunctionInfo(info)
		case C.GI_INFO_TYPE_CONSTANT:
			p("Constant\n")
			info := (*C.GIConstantInfo)(unsafe.Pointer(baseInfo))
			DumpConstantInfo(info)
		default:
			panic(fmt.Sprintf("unknown type %d", t))
		}
		C.g_base_info_unref(baseInfo)
		p(strings.Repeat("-", 64))
		p("\n")
	}
	p("%d\n", nInfos)
	p("%d object types\n", nObjects)
}
Beispiel #4
0
func (info *GiInfo) Free() {
	C.g_base_info_unref(info.ptr)
}