本文整理匯總了Golang中C.char函數的典型用法代碼示例。如果您正苦於以下問題:Golang char函數的具體用法?Golang char怎麽用?Golang char使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了char函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: dgemm
// http://www.netlib.org/blas/dgemm.f
func dgemm(transa, transb Transpose, m, n, k int, alpha float64, a []float64, lda int, b []float64, ldb int, beta float64, c []float64, ldc int) {
var (
transa_ = C.char(transa)
transb_ = C.char(transb)
m_ = C.integer(m)
n_ = C.integer(n)
k_ = C.integer(k)
alpha_ = (*C.doublereal)(unsafe.Pointer(&alpha))
a_ *C.doublereal
lda_ = C.integer(lda)
b_ *C.doublereal
ldb_ = C.integer(ldb)
beta_ = (*C.doublereal)(unsafe.Pointer(&beta))
c_ *C.doublereal
ldc_ = C.integer(ldc)
)
if len(a) > 0 {
a_ = (*C.doublereal)(unsafe.Pointer(&a[0]))
}
if len(b) > 0 {
b_ = (*C.doublereal)(unsafe.Pointer(&b[0]))
}
if len(c) > 0 {
c_ = (*C.doublereal)(unsafe.Pointer(&c[0]))
}
C.dgemm_(&transa_, &transb_, &m_, &n_, &k_, alpha_, a_, &lda_, b_, &ldb_, beta_, c_, &ldc_)
}
示例2: convertToken
//TODO: implement TT_BYTES and other tokens
func convertToken(token ast.Token) (ctoken *C.HParsedToken, govalue *interface{}) {
switch v := token.Value.(type) {
case nil:
return nil, nil
case ast.NoneType:
ctoken := &C.HParsedToken{
token_type: C.TT_NONE,
index: C.size_t(token.ByteOffset),
bit_offset: C.char(token.BitOffset),
}
return ctoken, nil
case uint64:
ctoken := &C.HParsedToken{
token_type: C.TT_UINT,
index: C.size_t(token.ByteOffset),
bit_offset: C.char(token.BitOffset),
}
C.assignUintValue(ctoken, C.uint64_t(v))
return ctoken, nil
}
// go token
ctoken = &C.HParsedToken{
token_type: goHParsedToken,
index: C.size_t(token.ByteOffset),
bit_offset: C.char(token.BitOffset),
}
union := (**interface{})(unionPointer(ctoken))
*union = &token.Value
return ctoken, &token.Value
}
示例3: uploChar
func uploChar(tri Triangle) C.char {
switch tri {
case UpperTri:
return C.char('U')
case LowerTri:
return C.char('L')
default:
panic(fmt.Sprintf("invalid uplo value: %v", rune(tri)))
}
}
示例4: diagChar
func diagChar(diag diagType) C.char {
switch diag {
case nonUnitDiag:
return C.char('N')
case unitDiag:
return C.char('U')
default:
panic(fmt.Sprintf("invalid diag value: %v", rune(diag)))
}
}
示例5: jobzChar
func jobzChar(jobz jobzMode) C.char {
switch jobz {
case values:
return C.char('N')
case vectors:
return C.char('V')
default:
panic(fmt.Sprintf("invalid jobz value: %v", rune(jobz)))
}
}
示例6: sideChar
func sideChar(side matSide) C.char {
switch side {
case left:
return C.char('L')
case right:
return C.char('R')
default:
panic(fmt.Sprintf("invalid side value: %v", rune(side)))
}
}
示例7: zhesvHelper
// Needs to be supplied ipiv and work.
func zhesvHelper(n, nrhs int, a []complex128, lda int, ipiv []C.integer, b []complex128, ldb int, work []complex128, lwork int) error {
var (
uplo_ = C.char(DefaultTri)
n_ = C.integer(n)
nrhs_ = C.integer(nrhs)
a_ = ptrComplex128(a)
lda_ = C.integer(lda)
ipiv_ = ptrInt(ipiv)
b_ = ptrComplex128(b)
ldb_ = C.integer(ldb)
work_ = ptrComplex128(work)
lwork_ = C.integer(lwork)
)
var info_ C.integer
C.zhesv_(&uplo_, &n_, &nrhs_, a_, &lda_, ipiv_, b_, &ldb_, work_, &lwork_, &info_)
info := int(info_)
switch {
case info < 0:
return errInvalidArg(-info)
case info > 0:
return errSingular(info)
default:
return nil
}
}
示例8: fatStrReplace
func fatStrReplace(str string, replacement rune) (string, bool) {
cstr := C.CString(str)
ok := C.fat_str_replace(cstr, C.char(replacement)) == 1
newStr := C.GoString(cstr)
C.free(unsafe.Pointer(cstr))
return newStr, ok
}
示例9: byteToBufferAdapter
// Purely exists for the test, as cgo isn't supported inside tests
func byteToBufferAdapter(buffer [128]byte) string {
var tmp [128]C.char
for i, c := range buffer {
tmp[i] = C.char(c)
}
return bufferToString(tmp)
}
示例10: convertWcharToGoRune
// Internal helper function, wrapped by several other functions
func convertWcharToGoRune(w Wchar) (output rune, err error) {
// return if len(input) == 0
if w == 0 {
return '\000', nil
}
// open iconv
iconv, errno := C.iconv_open(iconvCharsetUtf8, iconvCharsetWchar)
if iconv == nil || errno != nil {
return '\000', fmt.Errorf("Could not open iconv instance: %s", errno.Error())
}
defer C.iconv_close(iconv)
// split Wchar into bytes
wcharAsBytes := make([]byte, 4)
binary.LittleEndian.PutUint32(wcharAsBytes, uint32(w))
// place the wcharAsBytes into wcharAsCChars
// TODO: use unsafe.Pointer here to do the conversion?
wcharAsCChars := make([]C.char, 0, 4)
for i := 0; i < 4; i++ {
wcharAsCChars = append(wcharAsCChars, C.char(wcharAsBytes[i]))
}
// pointer to the first wcharAsCChars
wcharAsCCharsPtr := &wcharAsCChars[0]
// calculate buffer size for input
bytesLeftInCSize := C.size_t(4)
// calculate buffer size for output
bytesLeftOutCSize := C.size_t(4)
// create output buffer
outputChars := make([]C.char, 4)
// output buffer pointer for C
outputCharsPtr := &outputChars[0]
// call iconv for conversion of charsets
_, errno = C.iconv(iconv, &wcharAsCCharsPtr, &bytesLeftInCSize, &outputCharsPtr, &bytesLeftOutCSize)
if errno != nil {
return '\000', errno
}
// convert outputChars ([]int8, len 4) to Wchar
// TODO: can this conversion be done easier by using this: ?
// output = *((*rune)(unsafe.Pointer(&outputChars[0])))
runeAsByteAry := make([]byte, 4)
runeAsByteAry[0] = byte(outputChars[0])
runeAsByteAry[1] = byte(outputChars[1])
runeAsByteAry[2] = byte(outputChars[2])
runeAsByteAry[3] = byte(outputChars[3])
// combine 4 position byte slice into uint32 and convert to rune.
runeAsUint32 := binary.LittleEndian.Uint32(runeAsByteAry)
output = rune(runeAsUint32)
return output, nil
}
示例11: New
func New(path string, n ...int) (*Tbx, error) {
if !(xopen.Exists(path) && (xopen.Exists(path+".tbi") || xopen.Exists(path+".csi"))) {
return nil, fmt.Errorf("need gz file and .tbi for %s", path)
}
size := 20
if len(n) > 0 {
size = n[0]
}
t := &Tbx{path: path}
cs, mode := C.CString(t.path), C.char('r')
defer C.free(unsafe.Pointer(cs))
t.htfs = make(chan *C.htsFile, size)
for i := 0; i < cap(t.htfs); i++ {
t.htfs <- C.hts_open(cs, &mode)
}
t.kCache = make(chan C.kstring_t, size*2)
for i := 0; i < cap(t.kCache); i++ {
t.kCache <- C.kstring_t{}
}
t.chromCache = make(map[string]C.int)
if xopen.Exists(path + ".csi") {
csi := C.CString(path + ".csi")
defer C.free(unsafe.Pointer(csi))
t.tbx = C.tbx_index_load2(cs, csi)
} else {
t.tbx = C.tbx_index_load(cs)
}
runtime.SetFinalizer(t, _close)
return t, nil
}
示例12: subvolSnapshot
func subvolSnapshot(src, dest, name string) error {
srcDir, err := openDir(src)
if err != nil {
return err
}
defer closeDir(srcDir)
destDir, err := openDir(dest)
if err != nil {
return err
}
defer closeDir(destDir)
var args C.struct_btrfs_ioctl_vol_args_v2
args.fd = C.__s64(getDirFd(srcDir))
for i, c := range []byte(name) {
args.name[i] = C.char(c)
}
_, _, errno := syscall.Syscall(syscall.SYS_IOCTL, getDirFd(destDir), C.BTRFS_IOC_SNAP_CREATE_V2,
uintptr(unsafe.Pointer(&args)))
if errno != 0 {
return fmt.Errorf("Failed to create btrfs snapshot: %v", errno.Error())
}
return nil
}
示例13: CharacterColor
func CharacterColor(renderer *sdl.Renderer, x, y int, c byte, color sdl.Color) bool {
_x := C.Sint16(x)
_y := C.Sint16(y)
_c := C.char(c)
_color := C.Uint32(gfxColor(color))
return C.characterColor(renderer, _x, _y, _c, _color) == 0
}
示例14: encodeEWkb
func (e *wkbEncoder) encodeEWkb(g *Geometry) ([]byte, error) {
srid, _ := g.SRID()
if srid > 0 {
cGEOSWKBWriter_setIncludeSRID(e.w, C.char(1))
}
return encodeWkb(e, g, cGEOSWKBWriter_write)
}
示例15: zgesddHelper
func zgesddHelper(m, n int, a []complex128, lda int, s []float64, u []complex128, ldu int, vt []complex128, ldvt int, work []complex128, lwork int, rwork []float64, iwork []C.integer) error {
var (
jobz_ = C.char('S')
m_ = C.integer(m)
n_ = C.integer(n)
a_ = ptrComplex128(a)
lda_ = C.integer(lda)
s_ = ptrFloat64(s)
u_ = ptrComplex128(u)
ldu_ = C.integer(ldu)
vt_ = ptrComplex128(vt)
ldvt_ = C.integer(ldvt)
work_ = ptrComplex128(work)
lwork_ = C.integer(lwork)
rwork_ = ptrFloat64(rwork)
iwork_ = ptrInt(iwork)
)
var info_ C.integer
C.zgesdd_(&jobz_, &m_, &n_, a_, &lda_, s_, u_, &ldu_, vt_, &ldvt_, work_, &lwork_, rwork_, iwork_, &info_)
info := int(info_)
switch {
case info < 0:
return errInvalidArg(-info)
case info > 0:
return errFailConverge(info)
default:
return nil
}
}