Example #1
0
// g_constant_info_get_value
func (ci *ConstantInfo) Value() interface{} {
	var arg C.GIArgument
	C.g_constant_info_get_value((*C.GIConstantInfo)(ci.c), &arg)

	ti := ci.Type()
	switch ti.Tag() {
	case TYPE_TAG_BOOLEAN:
		return *(*C.gboolean)(unsafe.Pointer(&arg)) != 0
	case TYPE_TAG_INT8:
		return *(*int8)(unsafe.Pointer(&arg))
	case TYPE_TAG_UINT8:
		return *(*uint8)(unsafe.Pointer(&arg))
	case TYPE_TAG_INT16:
		return *(*int16)(unsafe.Pointer(&arg))
	case TYPE_TAG_UINT16:
		return *(*uint16)(unsafe.Pointer(&arg))
	case TYPE_TAG_INT32:
		return *(*int32)(unsafe.Pointer(&arg))
	case TYPE_TAG_UINT32:
		return *(*uint32)(unsafe.Pointer(&arg))
	case TYPE_TAG_INT64:
		return *(*int64)(unsafe.Pointer(&arg))
	case TYPE_TAG_UINT64:
		return *(*uint64)(unsafe.Pointer(&arg))
	case TYPE_TAG_FLOAT:
		return *(*float32)(unsafe.Pointer(&arg))
	case TYPE_TAG_DOUBLE:
		return *(*float64)(unsafe.Pointer(&arg))
	case TYPE_TAG_UTF8, TYPE_TAG_FILENAME:
		return C.GoString(*(**C.char)(unsafe.Pointer(&arg)))
	}
	panic("unsupported constant value")
	return nil
}
Example #2
0
File: dump.go Project: reusee/ggi
func DumpConstantInfo(info *C.GIConstantInfo) {
	var value C.GIArgument
	C.g_constant_info_get_value(info, &value)
	defer C.g_constant_info_free_value(info, &value)
	p("value %v\n", value)
	t := C.g_constant_info_get_type(info)
	DumpTypeInfo(t)
}