當前位置: 首頁>>代碼示例>>Golang>>正文


Golang xgb.Pad函數代碼示例

本文整理匯總了Golang中github.com/BurntSushi/xgb.Pad函數的典型用法代碼示例。如果您正苦於以下問題:Golang Pad函數的具體用法?Golang Pad怎麽用?Golang Pad使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Pad函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: unregisterClientsRequest

// Write request to wire for UnregisterClients
// unregisterClientsRequest writes a UnregisterClients request to a byte slice.
func unregisterClientsRequest(c *xgb.Conn, Context Context, NumClientSpecs uint32, ClientSpecs []ClientSpec) []byte {
	size := xgb.Pad((12 + xgb.Pad((int(NumClientSpecs) * 4))))
	b := 0
	buf := make([]byte, size)

	buf[b] = c.Extensions["RECORD"]
	b += 1

	buf[b] = 3 // request opcode
	b += 1

	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
	b += 2

	xgb.Put32(buf[b:], uint32(Context))
	b += 4

	xgb.Put32(buf[b:], NumClientSpecs)
	b += 4

	for i := 0; i < int(NumClientSpecs); i++ {
		xgb.Put32(buf[b:], uint32(ClientSpecs[i]))
		b += 4
	}
	b = xgb.Pad(b)

	return buf
}
開發者ID:rjmcguire,項目名稱:xgb,代碼行數:30,代碼來源:record.go

示例2: queryResourceBytesRequest

// Write request to wire for QueryResourceBytes
// queryResourceBytesRequest writes a QueryResourceBytes request to a byte slice.
func queryResourceBytesRequest(c *xgb.Conn, Client uint32, NumSpecs uint32, Specs []ResourceIdSpec) []byte {
	size := xgb.Pad((12 + xgb.Pad((int(NumSpecs) * 8))))
	b := 0
	buf := make([]byte, size)

	c.ExtLock.RLock()
	buf[b] = c.Extensions["X-Resource"]
	c.ExtLock.RUnlock()
	b += 1

	buf[b] = 5 // request opcode
	b += 1

	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
	b += 2

	xgb.Put32(buf[b:], Client)
	b += 4

	xgb.Put32(buf[b:], NumSpecs)
	b += 4

	b += ResourceIdSpecListBytes(buf[b:], Specs)

	return buf
}
開發者ID:BurntSushi,項目名稱:xgb,代碼行數:28,代碼來源:res.go

示例3: getBuffersWithFormatRequest

// Write request to wire for GetBuffersWithFormat
// getBuffersWithFormatRequest writes a GetBuffersWithFormat request to a byte slice.
func getBuffersWithFormatRequest(c *xgb.Conn, Drawable xproto.Drawable, Count uint32, Attachments []AttachFormat) []byte {
	size := xgb.Pad((12 + xgb.Pad((len(Attachments) * 8))))
	b := 0
	buf := make([]byte, size)

	c.ExtLock.RLock()
	buf[b] = c.Extensions["DRI2"]
	c.ExtLock.RUnlock()
	b += 1

	buf[b] = 7 // request opcode
	b += 1

	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
	b += 2

	xgb.Put32(buf[b:], uint32(Drawable))
	b += 4

	xgb.Put32(buf[b:], Count)
	b += 4

	b += AttachFormatListBytes(buf[b:], Attachments)

	return buf
}
開發者ID:BurntSushi,項目名稱:xgb,代碼行數:28,代碼來源:dri2.go

示例4: getBuffersRequest

// Write request to wire for GetBuffers
// getBuffersRequest writes a GetBuffers request to a byte slice.
func getBuffersRequest(c *xgb.Conn, Drawable xproto.Drawable, Count uint32, Attachments []uint32) []byte {
	size := xgb.Pad((12 + xgb.Pad((len(Attachments) * 4))))
	b := 0
	buf := make([]byte, size)

	buf[b] = c.Extensions["DRI2"]
	b += 1

	buf[b] = 5 // request opcode
	b += 1

	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
	b += 2

	xgb.Put32(buf[b:], uint32(Drawable))
	b += 4

	xgb.Put32(buf[b:], Count)
	b += 4

	for i := 0; i < int(len(Attachments)); i++ {
		xgb.Put32(buf[b:], Attachments[i])
		b += 4
	}
	b = xgb.Pad(b)

	return buf
}
開發者ID:varialus,項目名稱:xgb,代碼行數:30,代碼來源:dri2.go

示例5: setAttributesRequest

// Write request to wire for SetAttributes
// setAttributesRequest writes a SetAttributes request to a byte slice.
func setAttributesRequest(c *xgb.Conn, Drawable xproto.Drawable, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class byte, Depth byte, Visual xproto.Visualid, ValueMask uint32, ValueList []uint32) []byte {
	size := xgb.Pad((24 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask)))))))
	b := 0
	buf := make([]byte, size)

	c.ExtLock.RLock()
	buf[b] = c.Extensions["MIT-SCREEN-SAVER"]
	c.ExtLock.RUnlock()
	b += 1

	buf[b] = 3 // request opcode
	b += 1

	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
	b += 2

	xgb.Put32(buf[b:], uint32(Drawable))
	b += 4

	xgb.Put16(buf[b:], uint16(X))
	b += 2

	xgb.Put16(buf[b:], uint16(Y))
	b += 2

	xgb.Put16(buf[b:], Width)
	b += 2

	xgb.Put16(buf[b:], Height)
	b += 2

	xgb.Put16(buf[b:], BorderWidth)
	b += 2

	buf[b] = Class
	b += 1

	buf[b] = Depth
	b += 1

	xgb.Put32(buf[b:], uint32(Visual))
	b += 4

	xgb.Put32(buf[b:], ValueMask)
	b += 4
	for i := 0; i < xgb.PopCount(int(ValueMask)); i++ {
		xgb.Put32(buf[b:], ValueList[i])
		b += 4
	}
	b = xgb.Pad(b)

	return buf
}
開發者ID:BurntSushi,項目名稱:xgb,代碼行數:55,代碼來源:screensaver.go

示例6: createContextReply

// createContextReply reads a byte slice into a CreateContextReply value.
func createContextReply(buf []byte) *CreateContextReply {
	v := new(CreateContextReply)
	b := 1 // skip reply determinant

	b += 1 // padding

	v.Sequence = xgb.Get16(buf[b:])
	b += 2

	v.Length = xgb.Get32(buf[b:]) // 4-byte units
	b += 4

	v.WidthActual = xgb.Get16(buf[b:])
	b += 2

	v.HeightActual = xgb.Get16(buf[b:])
	b += 2

	v.FlagsReturn = xgb.Get32(buf[b:])
	b += 4

	b += 20 // padding

	v.PrivData = make([]uint32, v.Length)
	for i := 0; i < int(v.Length); i++ {
		v.PrivData[i] = xgb.Get32(buf[b:])
		b += 4
	}
	b = xgb.Pad(b)

	return v
}
開發者ID:varialus,項目名稱:xgb,代碼行數:33,代碼來源:xvmc.go

示例7: ClientIdValueListSize

// ClientIdValueListSize computes the size (bytes) of a list of ClientIdValue values.
func ClientIdValueListSize(list []ClientIdValue) int {
	size := 0
	for _, item := range list {
		size += (12 + xgb.Pad((int(item.Length) * 4)))
	}
	return size
}
開發者ID:BurntSushi,項目名稱:xgb,代碼行數:8,代碼來源:res.go

示例8: sendRequest

// Write request to wire for Send
// sendRequest writes a Send request to a byte slice.
func sendRequest(c *xgb.Conn, Event Event, DataType uint32) []byte {
	size := 104
	b := 0
	buf := make([]byte, size)

	buf[b] = c.Extensions["XEVIE"]
	b += 1

	buf[b] = 3 // request opcode
	b += 1

	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
	b += 2

	{
		structBytes := Event.Bytes()
		copy(buf[b:], structBytes)
		b += xgb.Pad(len(structBytes))
	}

	xgb.Put32(buf[b:], DataType)
	b += 4

	b += 64 // padding

	return buf
}
開發者ID:varialus,項目名稱:xgb,代碼行數:29,代碼來源:xevie.go

示例9: getXIDListReply

// getXIDListReply reads a byte slice into a GetXIDListReply value.
func getXIDListReply(buf []byte) *GetXIDListReply {
	v := new(GetXIDListReply)
	b := 1 // skip reply determinant

	b += 1 // padding

	v.Sequence = xgb.Get16(buf[b:])
	b += 2

	v.Length = xgb.Get32(buf[b:]) // 4-byte units
	b += 4

	v.IdsLen = xgb.Get32(buf[b:])
	b += 4

	b += 20 // padding

	v.Ids = make([]uint32, v.IdsLen)
	for i := 0; i < int(v.IdsLen); i++ {
		v.Ids[i] = xgb.Get32(buf[b:])
		b += 4
	}
	b = xgb.Pad(b)

	return v
}
開發者ID:rjmcguire,項目名稱:xgb,代碼行數:27,代碼來源:xcmisc.go

示例10: ResourceSizeValueListSize

// ResourceSizeValueListSize computes the size (bytes) of a list of ResourceSizeValue values.
func ResourceSizeValueListSize(list []ResourceSizeValue) int {
	size := 0
	for _, item := range list {
		size += (24 + xgb.Pad((int(item.NumCrossReferences) * 20)))
	}
	return size
}
開發者ID:BurntSushi,項目名稱:xgb,代碼行數:8,代碼來源:res.go

示例11: ClientInfoListSize

// ClientInfoListSize computes the size (bytes) of a list of ClientInfo values.
func ClientInfoListSize(list []ClientInfo) int {
	size := 0
	for _, item := range list {
		size += (8 + xgb.Pad((int(item.NumRanges) * 24)))
	}
	return size
}
開發者ID:rjmcguire,項目名稱:xgb,代碼行數:8,代碼來源:record.go

示例12: openConnectionReply

// openConnectionReply reads a byte slice into a OpenConnectionReply value.
func openConnectionReply(buf []byte) *OpenConnectionReply {
	v := new(OpenConnectionReply)
	b := 1 // skip reply determinant

	b += 1 // padding

	v.Sequence = xgb.Get16(buf[b:])
	b += 2

	v.Length = xgb.Get32(buf[b:]) // 4-byte units
	b += 4

	v.SareaHandleLow = xgb.Get32(buf[b:])
	b += 4

	v.SareaHandleHigh = xgb.Get32(buf[b:])
	b += 4

	v.BusIdLen = xgb.Get32(buf[b:])
	b += 4

	b += 12 // padding

	{
		byteString := make([]byte, v.BusIdLen)
		copy(byteString[:v.BusIdLen], buf[b:])
		v.BusId = string(byteString)
		b += xgb.Pad(int(v.BusIdLen))
	}

	return v
}
開發者ID:rjmcguire,項目名稱:xgb,代碼行數:33,代碼來源:xf86dri.go

示例13: getClientDriverNameReply

// getClientDriverNameReply reads a byte slice into a GetClientDriverNameReply value.
func getClientDriverNameReply(buf []byte) *GetClientDriverNameReply {
	v := new(GetClientDriverNameReply)
	b := 1 // skip reply determinant

	b += 1 // padding

	v.Sequence = xgb.Get16(buf[b:])
	b += 2

	v.Length = xgb.Get32(buf[b:]) // 4-byte units
	b += 4

	v.ClientDriverMajorVersion = xgb.Get32(buf[b:])
	b += 4

	v.ClientDriverMinorVersion = xgb.Get32(buf[b:])
	b += 4

	v.ClientDriverPatchVersion = xgb.Get32(buf[b:])
	b += 4

	v.ClientDriverNameLen = xgb.Get32(buf[b:])
	b += 4

	b += 8 // padding

	{
		byteString := make([]byte, v.ClientDriverNameLen)
		copy(byteString[:v.ClientDriverNameLen], buf[b:])
		v.ClientDriverName = string(byteString)
		b += xgb.Pad(int(v.ClientDriverNameLen))
	}

	return v
}
開發者ID:rjmcguire,項目名稱:xgb,代碼行數:36,代碼來源:xf86dri.go

示例14: ResourceIdSpecReadList

// ResourceIdSpecReadList reads a byte slice into a list of ResourceIdSpec values.
func ResourceIdSpecReadList(buf []byte, dest []ResourceIdSpec) int {
	b := 0
	for i := 0; i < len(dest); i++ {
		dest[i] = ResourceIdSpec{}
		b += ResourceIdSpecRead(buf[b:], &dest[i])
	}
	return xgb.Pad(b)
}
開發者ID:BurntSushi,項目名稱:xgb,代碼行數:9,代碼來源:res.go

示例15: RangeReadList

// RangeReadList reads a byte slice into a list of Range values.
func RangeReadList(buf []byte, dest []Range) int {
	b := 0
	for i := 0; i < len(dest); i++ {
		dest[i] = Range{}
		b += RangeRead(buf[b:], &dest[i])
	}
	return xgb.Pad(b)
}
開發者ID:rjmcguire,項目名稱:xgb,代碼行數:9,代碼來源:record.go


注:本文中的github.com/BurntSushi/xgb.Pad函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。