当前位置: 首页>>代码示例>>Golang>>正文


Golang C.int函数代码示例

本文整理汇总了Golang中C.int函数的典型用法代码示例。如果您正苦于以下问题:Golang int函数的具体用法?Golang int怎么用?Golang int使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了int函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: NewField

func NewField(height int, width int, top int, left int, offscreen int, nbuf int) (*Field, error) {
	field := (*Field)(C.new_field(C.int(height), C.int(width), C.int(top), C.int(left), C.int(offscreen), C.int(nbuf)))
	if field == nil {
		return nil, FormsError{"NewField failed"}
	}
	return field, nil
}
开发者ID:mpatraw,项目名称:gocurse,代码行数:7,代码来源:forms.go

示例2: Prepare

// Prepare query string. Return a new statement.
func (c *SQLiteConn) Prepare(query string) (driver.Stmt, error) {
	pquery := C.CString(query)
	defer C.free(unsafe.Pointer(pquery))
	var s *C.sqlite3_stmt
	var tail *C.char
	rv := C.sqlite3_prepare_v2(c.db, pquery, -1, &s, &tail)
	if rv != C.SQLITE_OK {
		return nil, c.lastError()
	}
	var t string
	if tail != nil && *tail != '\000' {
		t = strings.TrimSpace(C.GoString(tail))
	}
	nv := int(C.sqlite3_bind_parameter_count(s))
	var nn []string
	for i := 0; i < nv; i++ {
		pn := C.GoString(C.sqlite3_bind_parameter_name(s, C.int(i+1)))
		if len(pn) > 1 && pn[0] == '$' && 48 <= pn[1] && pn[1] <= 57 {
			nn = append(nn, C.GoString(C.sqlite3_bind_parameter_name(s, C.int(i+1))))
		}
	}
	ss := &SQLiteStmt{c: c, s: s, nv: nv, nn: nn, t: t}
	runtime.SetFinalizer(ss, (*SQLiteStmt).Close)
	return ss, nil
}
开发者ID:Wishing-Wall,项目名称:wishingwall,代码行数:26,代码来源:sqlite3.go

示例3: getDecode

func (c *Code) getDecode(errList []byte, cache bool) (node *decodeNode) {
	if cache {
		node = c.decode.getDecode(errList, 0, byte(c.M))
	} else {
		node = newDecodeNode(errList, byte(c.M))
	}

	node.mutex.Lock()
	defer node.mutex.Unlock()
	if node.galoisTables == nil || node.decodeIndex == nil {
		node.galoisTables = make([]byte, c.K*c.M*32)
		node.decodeIndex = make([]byte, c.K)

		decodeMatrix := make([]byte, c.M*c.K)
		srcInErr := make([]byte, c.M)
		nErrs := len(errList)
		nSrcErrs := 0
		for _, err := range errList {
			srcInErr[err] = 1
			if int(err) < c.K {
				nSrcErrs++
			}
		}

		C.gf_gen_decode_matrix((*C.uchar)(&c.EncodeMatrix[0]), (*C.uchar)(&decodeMatrix[0]), (*C.uchar)(&node.decodeIndex[0]), (*C.uchar)(&errList[0]), (*C.uchar)(&srcInErr[0]), C.int(nErrs), C.int(nSrcErrs), C.int(c.K), C.int(c.M))

		C.ec_init_tables(C.int(c.K), C.int(nErrs), (*C.uchar)(&decodeMatrix[0]), (*C.uchar)(&node.galoisTables[0]))
	}

	return node
}
开发者ID:zoutaiqi,项目名称:go-erasure,代码行数:31,代码来源:erasure.go

示例4: Sethook

// Sets the debugging hook function.
//
// Argument fn is the hook function. mask specifies on which events the hook
// will be called: it is formed by a bitwise OR of the constants Maskcall,
// Maskret, Maskline, and Maskcount. The count argument is only meaningful
// when the mask includes Maskcount. The hook is called for each event type
// present in mask.
//
// A hook is disabled by setting mask to 0.
func (s *State) Sethook(fn Hook, mask, count int) error {
	s.Getglobal(namehooks)
	if mask&Maskcall == Maskcall {
		s.Pushstring(namecall)
		s.Pushlightuserdata(unsafe.Pointer(&fn))
		s.Settable(-3)
	}
	if mask&Maskret == Maskret {
		s.Pushstring(nameret)
		s.Pushlightuserdata(unsafe.Pointer(&fn))
		s.Settable(-3)
	}
	if mask&Maskline == Maskline {
		s.Pushstring(nameline)
		s.Pushlightuserdata(unsafe.Pointer(&fn))
		s.Settable(-3)
	}
	if mask&Maskcount == Maskcount {
		s.Pushstring(namecount)
		s.Pushlightuserdata(unsafe.Pointer(&fn))
		s.Settable(-3)
	}
	s.Pop(1) // pop hook table
	C.sethook(s.l, C.int(mask), C.int(count))
	return nil
}
开发者ID:halturin,项目名称:luajit,代码行数:35,代码来源:debug.go

示例5: RecoverPubkey

//recovers the public key from the signature
//recovery of pubkey means correct signature
func RecoverPubkey(msg []byte, sig []byte) []byte {
	if len(sig) != 65 {
		log.Panic()
	}

	var pubkey []byte = make([]byte, 33)

	var msg_ptr *C.uchar = (*C.uchar)(unsafe.Pointer(&msg[0]))
	var sig_ptr *C.uchar = (*C.uchar)(unsafe.Pointer(&sig[0]))
	var pubkey_ptr *C.uchar = (*C.uchar)(unsafe.Pointer(&pubkey[0]))

	var pubkeylen C.int

	ret := C.secp256k1_ecdsa_recover_compact(
		msg_ptr, C.int(len(msg)),
		sig_ptr,
		pubkey_ptr, &pubkeylen,
		C.int(1), C.int(sig[64]),
	)

	if ret == 0 || int(pubkeylen) != 33 {
		return nil
	}

	return pubkey
}
开发者ID:JmAbuDabi,项目名称:skycoin,代码行数:28,代码来源:secp256.go

示例6: NewMat

func NewMat(r, c int) Mat {
	var m Mat
	m.mat = C.NewGOMat(C.int(r), C.int(c))
	//m.Row() = r
	//m.Colunm() = c
	return m
}
开发者ID:yasukikudan,项目名称:kgocvml,代码行数:7,代码来源:kgocvml.go

示例7: Play

func (t *Sound) Play(loops int) {
	t.channel = int(C.Mix_PlayChannelTimed(C.int(-1), t.chunk, C.int(loops), C.int(-1)))
	if t.channel == -1 {
		panic(fmt.Sprintf("Unable to play Sound file (%v): %v", t.name, util.GetMixError()))
	}
	t.SetVolume(GDefaultVolume)
}
开发者ID:swantescholz,项目名称:coding,代码行数:7,代码来源:sound.go

示例8: Update

// MONGO_EXPORT int mongo_update( mongo *conn, const char *ns, const bson *cond,
//                                const bson *op, int flags, mongo_write_concern *custom_write_concern );
func (m *Mongo) Update(ns string, cond, op *Bson, flags int, writeConcern *MongoWriteConcern) int {
	if writeConcern == nil {
		return int(C.mongo_update(m.conn, C.CString(ns), cond._bson, op._bson, C.int(flags), nil))
	}
	return int(C.mongo_update(m.conn, C.CString(ns), cond._bson,
		op._bson, C.int(flags), writeConcern.writeConcern))
}
开发者ID:QLeelulu,项目名称:libgomongo,代码行数:9,代码来源:mongo.go

示例9: find

func (re *Regexp) find(b []byte, n int, offset int) (match []int) {
	if n == 0 {
		b = []byte{0}
	}
	ptr := unsafe.Pointer(&b[0])
	matchData := re.matchData
	capturesPtr := unsafe.Pointer(&(matchData.indexes[matchData.count][0]))
	numCaptures := int32(0)
	numCapturesPtr := unsafe.Pointer(&numCaptures)
	pos := int(C.SearchOnigRegex((ptr), C.int(n), C.int(offset), C.int(ONIG_OPTION_DEFAULT), re.regex, re.region, re.errorInfo, (*C.char)(nil), (*C.int)(capturesPtr), (*C.int)(numCapturesPtr)))
	if pos >= 0 {
		if numCaptures <= 0 {
			panic("cannot have 0 captures when processing a match")
		}
		match2 := matchData.indexes[matchData.count][:numCaptures*2]
		match = make([]int, len(match2))
		for i := range match2 {
			match[i] = int(match2[i])
		}
		numCapturesInPattern := int32(C.onig_number_of_captures(re.regex)) + 1
		if numCapturesInPattern != numCaptures {
			log.Fatalf("expected %d captures but got %d\n", numCapturesInPattern, numCaptures)
		}
	}
	return
}
开发者ID:charlieegan3,项目名称:sirjest,代码行数:26,代码来源:regex.go

示例10: Parse

func Parse(content, inEncoding, url []byte, options int, outEncoding []byte) (doc *XmlDocument, err error) {
	inEncoding = AppendCStringTerminator(inEncoding)
	outEncoding = AppendCStringTerminator(outEncoding)

	var docPtr *C.xmlDoc
	contentLen := len(content)

	if contentLen > 0 {
		var contentPtr, urlPtr, encodingPtr unsafe.Pointer
		contentPtr = unsafe.Pointer(&content[0])

		if len(url) > 0 {
			url = AppendCStringTerminator(url)
			urlPtr = unsafe.Pointer(&url[0])
		}
		if len(inEncoding) > 0 {
			encodingPtr = unsafe.Pointer(&inEncoding[0])
		}

		docPtr = C.xmlParse(contentPtr, C.int(contentLen), urlPtr, encodingPtr, C.int(options), nil, 0)

		if docPtr == nil {
			err = ERR_FAILED_TO_PARSE_XML
		} else {
			doc = NewDocument(unsafe.Pointer(docPtr), contentLen, inEncoding, outEncoding)
		}

	} else {
		doc = CreateEmptyDocument(inEncoding, outEncoding)
	}
	return
}
开发者ID:weaseldotro,项目名称:gokogiri,代码行数:32,代码来源:document.go

示例11: Emit

// Emit is a wrapper around g_signal_emitv() and emits the signal
// specified by the string s to an Object.  Arguments to callback
// functions connected to this signal must be specified in args.  Emit()
// returns an interface{} which must be type asserted as the Go
// equivalent type to the return value for native C callback.
//
// Note that this code is unsafe in that the types of values in args are
// not checked against whether they are suitable for the callback.
func (v *Object) Emit(s string, args ...interface{}) (interface{}, error) {
	cstr := C.CString(s)
	defer C.free(unsafe.Pointer(cstr))

	// Create array of this instance and arguments
	valv := C.alloc_gvalue_list(C.int(len(args)) + 1)
	defer C.free(unsafe.Pointer(valv))

	// Add args and valv
	val, err := GValue(v)
	if err != nil {
		return nil, errors.New("Error converting Object to GValue: " + err.Error())
	}
	C.val_list_insert(valv, C.int(0), val.native())
	for i := range args {
		val, err := GValue(args[i])
		if err != nil {
			return nil, fmt.Errorf("Error converting arg %d to GValue: %s", i, err.Error())
		}
		C.val_list_insert(valv, C.int(i+1), val.native())
	}

	t := v.TypeFromInstance()
	// TODO: use just the signal name
	id := C.g_signal_lookup((*C.gchar)(cstr), C.GType(t))

	ret, err := ValueAlloc()
	if err != nil {
		return nil, errors.New("Error creating Value for return value")
	}
	C.g_signal_emitv(valv, id, C.GQuark(0), ret.native())

	return ret.GoValue()
}
开发者ID:vvanpo,项目名称:gotk3,代码行数:42,代码来源:glib.go

示例12: Setupvalue

// Sets the value of a closure's upvalue. It assigns the value at the top
// of the stack to the upvalue and returns its name. It also pops the value
// from the stack. Parameters funcindex and n are as in the Getupvalue.
//
// Returns an error (and pops nothing) when the index is greater
// than the number of upvalues.
func (this *State) Setupvalue(funcindex, n int) (string, error) {
	r := C.lua_setupvalue(this.luastate, C.int(funcindex), C.int(n))
	if r == nil {
		return "", errors.New("index exceeds number of upvalues")
	}
	return C.GoString(r), nil
}
开发者ID:rdlaitila,项目名称:leaf,代码行数:13,代码来源:State.go

示例13: Link

func (field *Field) Link(top int, left int) (*Field, error) {
	link := (*Field)(C.link_field((*C.FIELD)(field), C.int(top), C.int(left)))
	if link == nil {
		return nil, FormsError{"Field.Link failed"}
	}
	return link, nil
}
开发者ID:mpatraw,项目名称:gocurse,代码行数:7,代码来源:forms.go

示例14: DupField

func (field *Field) DupField(top int, left int) (*Field, error) {
	dup := (*Field)(C.dup_field((*C.FIELD)(field), C.int(top), C.int(left)))
	if dup == nil {
		return nil, FormsError{"Field.Dup failed"}
	}
	return dup, nil
}
开发者ID:mpatraw,项目名称:gocurse,代码行数:7,代码来源:forms.go

示例15: _CGO

// The C side of things will still need to allocate memory, due to the slices.
// Assumes Configuration is valid.
func (config *Configuration) _CGO() *C.CGO_Configuration {
	INFO.Println("Converting Config: ", config)
	size := C.size_t(unsafe.Sizeof(C.CGO_Configuration{}))
	c := (*C.CGO_Configuration)(C.malloc(size))

	// Need to convert each IceServer struct individually.
	total := len(config.IceServers)
	if total > 0 {
		sizeof := unsafe.Sizeof(C.CGO_IceServer{})
		cServers := unsafe.Pointer(C.malloc(C.size_t(sizeof * uintptr(total))))
		ptr := uintptr(cServers)
		for _, server := range config.IceServers {
			*(*C.CGO_IceServer)(unsafe.Pointer(ptr)) = server._CGO()
			ptr += sizeof
		}
		c.iceServers = (*C.CGO_IceServer)(cServers)
	}
	c.numIceServers = C.int(total)

	// c.iceServers = (*C.CGO_IceServer)(unsafe.Pointer(&config.IceServers))
	c.iceTransportPolicy = C.int(config.IceTransportPolicy)
	c.bundlePolicy = C.int(config.BundlePolicy)
	// [ED] c.RtcpMuxPolicy = C.int(config.RtcpMuxPolicy)
	c.peerIdentity = C.CString(config.PeerIdentity)
	// [ED] c.Certificates = config.Certificates
	// [ED] c.IceCandidatePoolSize = C.int(config.IceCandidatePoolSize)
	return c
}
开发者ID:keroserene,项目名称:go-webrtc,代码行数:30,代码来源:configuration.go


注:本文中的C.int函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。