Ejemplo n.º 1
0
//export setScreen
func setScreen(scale int) {
	C.uname(&C.sysInfo)
	name := C.GoString(&C.sysInfo.machine[0])

	var v float32

	switch {
	case strings.HasPrefix(name, "iPhone"):
		v = 163
	case strings.HasPrefix(name, "iPad"):
		// TODO: is there a better way to distinguish the iPad Mini?
		switch name {
		case "iPad2,5", "iPad2,6", "iPad2,7", "iPad4,4", "iPad4,5", "iPad4,6", "iPad4,7":
			v = 163 // iPad Mini
		default:
			v = 132
		}
	default:
		v = 163 // names like i386 and x86_64 are the simulator
	}

	if v == 0 {
		log.Printf("unknown machine: %s", name)
		v = 163 // emergency fallback
	}

	pixelsPerPt = v * float32(scale) / 72
	screenScale = scale
}
Ejemplo n.º 2
0
func (self *SystemInfo) getFromUname() {
	var unameBuf C.struct_utsname
	C.uname(&unameBuf)

	self.Version = C.GoString(&unameBuf.release[0])
	self.VendorName = C.GoString(&unameBuf.sysname[0])
	self.Name = C.GoString(&unameBuf.sysname[0])
	self.Machine = C.GoString(&unameBuf.machine[0])
	self.Arch = C.GoString(&unameBuf.machine[0])
	self.PatchLevel = "unknown"
}
Ejemplo n.º 3
0
// uname returns strings similar to the Unix uname command:
// sysname, nodename, release, version, machine
func uname() (string, string, string, string, string, error) {
	var name C.struct_utsname
	_, err := C.uname(&name)
	if err != nil {
		var errno syscall.Errno = err.(syscall.Errno)
		return "", "", "", "", "", fmt.Errorf("Failed to call uname: %s", errno)
	}

	return C.GoString(&name.sysname[0]), C.GoString(&name.nodename[0]),
		C.GoString(&name.release[0]), C.GoString(&name.version[0]),
		C.GoString(&name.machine[0]), nil
}
Ejemplo n.º 4
0
func Uname(utsname *Utsname) error {
	var cstruct C.struct_utsname
	if err := C.uname(&cstruct); err != 0 {
		return errors.New("utsname error")
	}

	// XXX: this may crash if any value is exactly 256 characters (no 0 terminator)
	utsname.Sysname = C.GoString(&cstruct.sysname[0])
	utsname.Nodename = C.GoString(&cstruct.nodename[0])
	utsname.Release = C.GoString(&cstruct.release[0])
	utsname.Version = C.GoString(&cstruct.version[0])
	utsname.Machine = C.GoString(&cstruct.machine[0])

	return nil
}
Ejemplo n.º 5
0
func OSRelease() string {
	var utsname C.struct_utsname
	C.uname(&utsname)
	return C.GoString(&utsname.release[0])
}