本文整理汇总了Golang中C.uint32_t函数的典型用法代码示例。如果您正苦于以下问题:Golang uint32_t函数的具体用法?Golang uint32_t怎么用?Golang uint32_t使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了uint32_t函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: FilesAndFolders
func (d *Device) FilesAndFolders(storageId uint32, parentId uint32) (files []*File, err error) {
file := C.LIBMTP_Get_Files_And_Folders(d.me(), C.uint32_t(storageId), C.uint32_t(parentId))
for f := (*File)(file); f != nil; f = (*File)(f.next) {
files = append(files, f)
}
return files, d.ErrorStack()
}
示例2: SetVolume
// Set the volume of all channels of this sink to a factor of the maximum
// volume (0.0 <= v <= 1.0). Factors greater than 1.0 will be accepted, but
// clipping or distortion may occur beyond that value.
//
func (self *Sink) SetVolume(factor float64) error {
if self.Channels > 0 {
operation := NewOperation(self.Client)
newVolume := &C.pa_cvolume{}
// new volume is the (maximum number of normal volume steps * factor)
newVolume = C.pa_cvolume_init(newVolume)
newVolumeT := C.pa_volume_t(C.uint32_t(uint(float64(self.NumVolumeSteps) * factor)))
// prepare newVolume for its journey into PulseAudio
C.pa_cvolume_set(newVolume, C.uint(self.Channels), newVolumeT)
// make the call
operation.paOper = C.pa_context_set_sink_volume_by_index(C.pulse_get_context(), C.uint32_t(self.Index), newVolume, (C.pa_context_success_cb_t)(unsafe.Pointer(C.pulse_generic_success_callback)), unsafe.Pointer(operation))
// wait for the result, refresh, return any errors
return operation.WaitSuccess(func(op *Operation) error {
return self.Refresh()
})
} else {
return fmt.Errorf("Cannot set volume on sink %d, no channels defined", self.Index)
}
return nil
}
示例3: Write
func Write(m message.Message) ([]byte, error) {
var b C.buf_t
m2 := C.messageNew()
switch m1 := m.(type) {
case *message.Setup:
m2.mtype = C.Setup
s := (*C.struct_Setup)(unsafe.Pointer(ptr(m2.u[:])))
s.ver_min = C.uint32_t(m1.Versions.Min)
s.ver_max = C.uint32_t(m1.Versions.Max)
for i, x := range m1.PeerNaClPublicKey {
s.PeerNaClPublicKey[i] = C.uchar(x)
}
s.mtu = C.uint64_t(m1.Mtu)
s.sharedTokens = C.uint64_t(m1.SharedTokens)
default:
panic("not impl yet")
}
err := C.messageAppend(m2, &b)
if err != C.ERR_OK {
return nil, GoError(err)
}
out := C.GoBytes(unsafe.Pointer(b.buf), C.int(b.len))
C.bufDealloc(&b)
return out, nil
}
示例4: Wi_crop
func Wi_crop(im *Image, x int, y int, cols int, rows int) (int, error) {
ret := int(C.wi_crop(im.im, C.uint32_t(x), C.uint32_t(y), C.uint32_t(cols), C.uint32_t(rows)))
if ret == WI_FAILED {
return ret, errors.New("C.wi_crop() failed!")
}
return ret, nil
}
示例5: diffOptionsToC
func diffOptionsToC(opts *DiffOptions) (copts *C.git_diff_options, notifyData *diffNotifyData) {
cpathspec := C.git_strarray{}
if opts != nil {
notifyData = &diffNotifyData{
Callback: opts.NotifyCallback,
}
if opts.Pathspec != nil {
cpathspec.count = C.size_t(len(opts.Pathspec))
cpathspec.strings = makeCStringsFromStrings(opts.Pathspec)
}
copts = &C.git_diff_options{
version: C.GIT_DIFF_OPTIONS_VERSION,
flags: C.uint32_t(opts.Flags),
ignore_submodules: C.git_submodule_ignore_t(opts.IgnoreSubmodules),
pathspec: cpathspec,
context_lines: C.uint32_t(opts.ContextLines),
interhunk_lines: C.uint32_t(opts.InterhunkLines),
id_abbrev: C.uint16_t(opts.IdAbbrev),
max_size: C.git_off_t(opts.MaxSize),
old_prefix: C.CString(opts.OldPrefix),
new_prefix: C.CString(opts.NewPrefix),
}
if opts.NotifyCallback != nil {
C._go_git_setup_diff_notify_callbacks(copts)
copts.notify_payload = unsafe.Pointer(notifyData)
}
}
return
}
示例6: GetSearcher
// This will need to be a bit more generic,
// but for testing this will work fine.
func (search *Search) GetSearcher() IndexReader {
idxLocation := cb_newf(search.Location)
search.lucySearcher = C.LucyIxSearcherNew(idxLocation)
C.DECREF(idxLocation)
return func(q string, field string, offset, limit uint) (uint, []string) {
query := cb_new_from_utf8(q)
getField := cb_newf(field)
hits := C.LucyIxSearcherHits(search.lucySearcher, query, C.uint32_t(offset), C.uint32_t(limit), nil)
totalNumHits := uint(C.LucyHitsTotal(hits))
requestedNumHits := minUInt(limit, totalNumHits)
results := make([]string, requestedNumHits)
var hit *C.LucyHitDoc
for i := uint(0); i < requestedNumHits; i++ {
hit = C.LucyHitsNext(hits)
if hit == nil {
break
}
value_cb := C.LucyHitDocExtract(hit, getField, nil) // do i need to free this
value := cb_ptr2char(value_cb) // do i need to free this
results[i] = C.GoString(value)
C.DECREF(hit)
}
C.DECREF(query)
C.DECREF(getField)
C.DECREF(hits)
return totalNumHits, results
}
}
示例7: BlameFile
func (v *Repository) BlameFile(path string, opts *BlameOptions) (*Blame, error) {
var blamePtr *C.git_blame
var copts *C.git_blame_options
if opts != nil {
copts = &C.git_blame_options{
version: C.GIT_BLAME_OPTIONS_VERSION,
flags: C.uint32_t(opts.Flags),
min_match_characters: C.uint16_t(opts.MinMatchCharacters),
min_line: C.uint32_t(opts.MinLine),
max_line: C.uint32_t(opts.MaxLine),
}
if opts.NewestCommit != nil {
copts.newest_commit = *opts.NewestCommit.toC()
}
if opts.OldestCommit != nil {
copts.oldest_commit = *opts.OldestCommit.toC()
}
}
cpath := C.CString(path)
defer C.free(unsafe.Pointer(cpath))
runtime.LockOSThread()
defer runtime.UnlockOSThread()
ecode := C.git_blame_file(&blamePtr, v.ptr, cpath, copts)
if ecode < 0 {
return nil, MakeGitError(ecode)
}
return newBlameFromC(blamePtr), nil
}
示例8: SetInstrument
// Return true if the file header contains instrument information for the file. false otherwise.
func (f *File) SetInstrument(i *Instrument) bool {
c := new(C.SF_INSTRUMENT)
c.gain = C.int(i.Gain)
c.basenote = C.char(i.Basenote)
c.detune = C.char(i.Detune)
c.velocity_lo = C.char(i.Velocity[0])
c.velocity_hi = C.char(i.Velocity[1])
c.key_lo = C.char(i.Key[0])
c.key_hi = C.char(i.Key[1])
c.loop_count = C.int(i.LoopCount)
var index int
for ; index < i.LoopCount; index++ {
c.loops[index].mode = C.int(i.Loops[index].Mode)
c.loops[index].start = C.uint32_t(i.Loops[index].Start)
c.loops[index].end = C.uint32_t(i.Loops[index].End)
c.loops[index].count = C.uint32_t(i.Loops[index].Count)
}
for ; index < 16; index++ {
c.loops[index].mode = C.int(None)
// why is this necessary? libsndfile doesn't check loopcount for AIFF
}
r := C.sf_command(f.s, C.SFC_SET_INSTRUMENT, unsafe.Pointer(c), C.int(unsafe.Sizeof(*c)))
return (r == C.SF_TRUE)
}
示例9: SetVolume
// Set the volume of all channels of this source to a factor of the maximum
// volume (0.0 <= v <= 1.0). Factors greater than 1.0 will be accepted, but
// clipping or distortion may occur beyond that value.
//
func (self *Source) SetVolume(factor float64) error {
if self.Channels > 0 {
operation := NewOperation(self.Client)
defer operation.Destroy()
newVolume := &C.pa_cvolume{}
// new volume is the (maximum number of normal volume steps * factor)
newVolume = C.pa_cvolume_init(newVolume)
newVolumeT := C.pa_volume_t(C.uint32_t(uint(float64(self.NumVolumeSteps) * factor)))
// prepare newVolume for its journey into PulseAudio
C.pa_cvolume_set(newVolume, C.uint(self.Channels), newVolumeT)
// make the call
operation.paOper = C.pa_context_set_source_volume_by_index(self.Client.context, C.uint32_t(self.Index), newVolume, (C.pa_context_success_cb_t)(C.pulse_generic_success_callback), operation.ToUserdata())
// wait for the result, refresh, return any errors
if err := operation.Wait(); err == nil {
return self.Refresh()
} else {
return err
}
} else {
return fmt.Errorf("Cannot set volume on source %d, no channels defined", self.Index)
}
return nil
}
示例10: newUser
func newUser(ptr *C.AB_USER) User {
user := User{}
user.ID = int(C.AB_User_GetUniqueId(ptr))
user.UserID = C.GoString(C.AB_User_GetUserId(ptr))
user.CustomerID = C.GoString(C.AB_User_GetCustomerId(ptr))
user.Name = C.GoString(C.AB_User_GetUserName(ptr))
user.BankCode = C.GoString(C.AB_User_GetBankCode(ptr))
url := C.AH_User_GetServerUrl(ptr)
if url != nil {
tbuf := C.GWEN_Buffer_new(
nil,
C.uint32_t(256),
C.uint32_t(0),
C.int(1),
)
C.GWEN_Url_toString(url, tbuf)
user.ServerURI = C.GoString(C.GWEN_Buffer_GetStart(tbuf))
C.GWEN_Buffer_free(tbuf)
}
user.HbciVersion = int(C.AH_User_GetHbciVersion(ptr))
user.ptr = ptr
return user
}
示例11: Read
func (usm *USM) Read(user *C.snmp_user_t) SnmpError {
usm.auth_proto = AuthType(user.auth_proto)
usm.priv_proto = PrivType(user.priv_proto)
usm.name = readGoString(&user.sec_name[0], SNMP_ADM_STR32_LEN)
usm.localization_auth_key = readGoBytes(&user.auth_key[0], C.uint32_t(user.auth_len))
usm.localization_priv_key = readGoBytes(&user.priv_key[0], C.uint32_t(user.priv_len))
return nil
}
示例12: c
func (g *Geometry) c() *C.struct_wlc_geometry {
return C.init_geometry(
C.int32_t(g.Origin.X),
C.int32_t(g.Origin.Y),
C.uint32_t(g.Size.W),
C.uint32_t(g.Size.H),
)
}
示例13: SetTimeout
func (this ModbusRTUConnection) SetTimeout(timeout time.Duration) error {
var sec C.uint32_t = C.uint32_t(timeout / time.Second)
var usec C.uint32_t = C.uint32_t((timeout - time.Duration(sec)) / time.Microsecond)
if C.modbus_set_response_timeout(this.ctx, sec, usec) == -1 {
return errors.New("Invalid timeout value")
}
return nil
}
示例14: New
/*
New to create a memcached client:
servers: is a list of memcached server addresses. Each address can be
in format of hostname[:port] [alias]. port and alias are optional.
If port is not given, default port 11211 will be used. alias will be
used to compute server hash if given, otherwise server hash will be
computed based on host and port (i.e.: If port is not given or it is
equal to 11211, host will be used to compute server hash.
If port is not equal to 11211, host:port will be used).
noreply: whether to enable memcached's noreply behaviour.
default: False
prefix: The key prefix. default: ''
hashFunc: hashing function for keys. possible values:
HashMD5, HashFNV1_32, HashFNV1a32, HashCRC32
NOTE: fnv1_32, fnv1a_32, crc_32 implementations
in libmc are per each spec, but they're not compatible
with corresponding implementions in libmemcached.
NOTE: The hashing algorithm for host mapping on continuum is always md5.
failover: Whether to failover to next server when current server is
not available. default: False
disableLock: Whether to disable a lock of type sync.Mutex which will be
use in every retrieval/storage command. default False.
*/
func New(servers []string, noreply bool, prefix string, hashFunc int, failover bool, disableLock bool) (client *Client) {
client = new(Client)
client._imp = C.client_create()
runtime.SetFinalizer(client, finalizer)
n := len(servers)
cHosts := make([]*C.char, n)
cPorts := make([]C.uint32_t, n)
cAliases := make([]*C.char, n)
for i, srv := range servers {
addrAndAlias := strings.Split(srv, " ")
addr := addrAndAlias[0]
if len(addrAndAlias) == 2 {
cAlias := C.CString(addrAndAlias[1])
defer C.free(unsafe.Pointer(cAlias))
cAliases[i] = cAlias
}
hostAndPort := strings.Split(addr, ":")
host := hostAndPort[0]
cHost := C.CString(host)
defer C.free(unsafe.Pointer(cHost))
cHosts[i] = cHost
if len(hostAndPort) == 2 {
port, err := strconv.Atoi(hostAndPort[1])
if err != nil {
return nil
}
cPorts[i] = C.uint32_t(port)
} else {
cPorts[i] = C.uint32_t(DefaultPort)
}
}
failoverInt := 0
if failover {
failoverInt = 1
}
C.client_init(
client._imp,
(**C.char)(unsafe.Pointer(&cHosts[0])),
(*C.uint32_t)(unsafe.Pointer(&cPorts[0])),
C.size_t(n),
(**C.char)(unsafe.Pointer(&cAliases[0])),
C.int(failoverInt),
)
client.configHashFunction(int(hashFunctionMapping[hashFunc]))
client.servers = servers
client.prefix = prefix
client.noreply = noreply
client.disableLock = disableLock
return
}
示例15: DebugTextPrintf
func DebugTextPrintf(x, y int, attr uint8, format string, args ...interface{}) {
text := []byte(fmt.Sprintf(format+"\x00", args...))
C.bgfx_dbg_text_print(
C.uint32_t(x),
C.uint32_t(y),
C.uint8_t(attr),
(*C.char)(unsafe.Pointer(&text[0])),
)
}