本文整理匯總了Golang中C.long函數的典型用法代碼示例。如果您正苦於以下問題:Golang long函數的具體用法?Golang long怎麽用?Golang long使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了long函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: interfaceToPyObj
func interfaceToPyObj(o interface{}) *C.PyObject {
switch o.(type) {
case int:
return C.PyInt_FromLong(C.long(o.(int)))
case int64:
return C.PyInt_FromLong(C.long(o.(int64)))
case string:
strvalue := C.CString(o.(string))
defer C.free(unsafe.Pointer(strvalue))
return C.PyString_FromStringAndSize(strvalue, C.Py_ssize_t(len(o.(string))))
case map[interface{}]interface{}:
dict := C.PyDict_New()
for key, value := range o.(map[interface{}]interface{}) {
dictAddItem(dict, key, value)
}
return dict
case map[string]string:
dict := C.PyDict_New()
for key, value := range o.(map[string]string) {
dictAddItem(dict, key, value)
}
return dict
case map[string]interface{}:
dict := C.PyDict_New()
for key, value := range o.(map[string]interface{}) {
dictAddItem(dict, key, value)
}
return dict
default:
return C.PyNone()
}
}
示例2: RbString
func RbString(str string) C.VALUE {
if len(str) == 0 {
return C.rb_utf8_str_new(nil, C.long(0))
}
cstr := (*C.char)(unsafe.Pointer(&(*(*[]byte)(unsafe.Pointer(&str)))[0]))
return C.rb_utf8_str_new(cstr, C.long(len(str)))
}
示例3: BeginDatastoreSegment
func BeginDatastoreSegment(
txnID int64,
parentID int64,
table string,
operation string,
sql string,
rollupName string,
) int64 {
ctable := C.CString(table)
defer C.free(unsafe.Pointer(ctable))
coperation := C.CString(operation)
defer C.free(unsafe.Pointer(coperation))
csql := C.CString(sql)
defer C.free(unsafe.Pointer(csql))
crollupName := C.CString(rollupName)
defer C.free(unsafe.Pointer(crollupName))
id := C.newrelic_segment_datastore_begin(
C.long(txnID),
C.long(parentID),
ctable,
coperation,
csql,
crollupName,
(*[0]byte)(C.newrelic_basic_literal_replacement_obfuscator),
)
return int64(id)
}
示例4: SetOpt
func (easy *Easy) SetOpt(opt EasyOption, param interface{}) error {
switch {
case opt >= C.CURLOPTTYPE_OFF_T:
return easy.getError(C.my_esetoptl(easy.cptr, C.CURLoption(opt), C.long(param.(int))))
case opt >= C.CURLOPTTYPE_FUNCTIONPOINT:
return errors.New("function options not supported by SetOpt()")
case opt >= C.CURLOPTTYPE_OBJECTPOINT:
if isStringOption(opt) {
c_param := C.CString(param.(string))
defer C.free(unsafe.Pointer(c_param))
return easy.getError(C.my_esetoptc(easy.cptr, C.CURLoption(opt), c_param))
} else {
return fmt.Errorf("option %d not supported", opt)
}
case opt >= C.CURLOPTTYPE_LONG:
var val C.long
switch t := param.(type) {
case bool:
if t {
val = C.long(1)
}
case int:
val = C.long(t)
case int32:
val = C.long(t)
case int64:
val = C.long(t)
default:
panic("CURLOPTTYPE_LONG param must be of golang type bool, int, int32, or int64")
}
return easy.getError(C.my_esetoptl(easy.cptr, C.CURLoption(opt), val))
}
return nil
}
示例5: Setopt
func (mcurl *CURLM) Setopt(opt int, param interface{}) error {
p := mcurl.handle
if param == nil {
return newCurlMultiError(C.curl_multi_setopt_pointer(p, C.CURLMoption(opt), nil))
}
switch {
// currently cannot support these option
// case MOPT_SOCKETFUNCTION, MOPT_SOCKETDATA, MOPT_TIMERFUNCTION, MOPT_TIMERDATA:
// panic("not supported CURLM.Setopt opt")
case opt >= C.CURLOPTTYPE_LONG:
val := C.long(0)
switch t := param.(type) {
case int:
val := C.long(t)
return newCurlMultiError(C.curl_multi_setopt_long(p, C.CURLMoption(opt), val))
case bool:
val = C.long(0)
if t {
val = C.long(1)
}
return newCurlMultiError(C.curl_multi_setopt_long(p, C.CURLMoption(opt), val))
}
}
panic("not supported CURLM.Setopt opt or param")
return nil
}
示例6: SetSelection
func (t *textEntry) SetSelection(from int, to int) {
p := C.WxTextEntryPtr(pointer(t))
if p == nil {
return
}
C.wxTextEntry_SetSelection(p, C.long(from), C.long(to))
}
示例7: NewNodeConfig
// NewNode returns new Node with a given Logger.
func NewNodeConfig(logfile string, level string, cfg *NodeConfig) (node *Node, err error) {
clevel := C.CString(level)
defer C.free(unsafe.Pointer(clevel))
clogfile := C.CString(logfile)
defer C.free(unsafe.Pointer(clogfile))
var dcfg C.struct_dnet_config
C.memset(unsafe.Pointer(&dcfg), 0, C.sizeof_struct_dnet_config)
dcfg.io_thread_num = C.int(cfg.IOThreadNum)
dcfg.nonblocking_io_thread_num = C.int(cfg.NonBlockingIOThreadNum)
dcfg.net_thread_num = C.int(cfg.NetThreadNum)
dcfg.wait_timeout = C.long(cfg.WaitTimeout)
dcfg.check_timeout = C.long(cfg.CheckTimeout)
dcfg.flags = C.int(cfg.Flags)
dcfg.stall_count = C.long(cfg.StallCount)
cnode := C.new_node_config(clogfile, clevel, &dcfg)
if cnode == nil {
err = fmt.Errorf("could not create node, please check stderr output")
return
}
node = &Node{cnode}
return
}
示例8: Replace
func (t *textEntry) Replace(from int, to int, value string) {
p := C.WxTextEntryPtr(pointer(t))
if p == nil {
return
}
C.wxTextEntry_Replace(p, C.long(from), C.long(to), cString(&value))
}
示例9: Remove
func (t *textEntry) Remove(from int, to int) {
p := C.WxTextEntryPtr(pointer(t))
if p == nil {
return
}
C.wxTextEntry_Remove(p, C.long(from), C.long(to))
}
示例10: Range
func (t *textEntry) Range(from int, to int) string {
p := C.WxTextEntryPtr(pointer(t))
if p == nil {
return ""
}
return goString(C.wxTextEntry_GetRange(p, C.long(from), C.long(to)))
}
示例11: Crop
// Extracts a region from the canvas.
func (cv Canvas) Crop(x int, y int, width uint, height uint) bool {
status := C.MagickCropImage(cv.wand, C.ulong(width), C.ulong(height), C.long(x), C.long(y))
if status == C.MagickFalse {
return false
}
return true
}
示例12: RbBytes
func RbBytes(bytes []byte) C.VALUE {
if len(bytes) == 0 {
return C.rb_str_new(nil, C.long(0))
}
cstr := (*C.char)(unsafe.Pointer(&bytes[0]))
return C.rb_str_new(cstr, C.long(len(bytes)))
}
示例13: BeginExternalSegment
func BeginExternalSegment(txnID int64, parentID int64, host string, name string) int64 {
chost := C.CString(host)
defer C.free(unsafe.Pointer(chost))
cname := C.CString(name)
defer C.free(unsafe.Pointer(cname))
id := C.newrelic_segment_external_begin(C.long(txnID), C.long(parentID), chost, cname)
return int64(id)
}
示例14: transform
func transform(srcpj, dstpj *Proj, x, y, z []float64) ([]float64, []float64, []float64, error) {
if !(srcpj.opened && dstpj.opened) {
return []float64{}, []float64{}, []float64{}, errors.New("projection is closed")
}
var x1, y1, z1 []C.double
ln := len(x)
if len(y) < ln {
ln = len(y)
}
if z != nil && len(z) < ln {
ln = len(z)
}
if ln == 0 {
return []float64{}, []float64{}, []float64{}, nil
}
x1 = make([]C.double, ln)
y1 = make([]C.double, ln)
if z != nil {
z1 = make([]C.double, ln)
}
for i := 0; i < ln; i++ {
x1[i] = C.double(x[i])
y1[i] = C.double(y[i])
if z != nil {
z1[i] = C.double(z[i])
}
}
var e *C.char
if z != nil {
e = C.transform(srcpj.pj, dstpj.pj, C.long(ln), &x1[0], &y1[0], &z1[0])
} else {
e = C.transform(srcpj.pj, dstpj.pj, C.long(ln), &x1[0], &y1[0], nil)
}
if e != nil {
return []float64{}, []float64{}, []float64{}, errors.New(C.GoString(e))
}
var x2, y2, z2 []float64
x2 = make([]float64, ln)
y2 = make([]float64, ln)
if z != nil {
z2 = make([]float64, ln)
}
for i := 0; i < ln; i++ {
x2[i] = float64(x1[i])
y2[i] = float64(y1[i])
if z != nil {
z2[i] = float64(z1[i])
}
}
return x2, y2, z2, nil
}
示例15: SetVideoSettingCameraPct
func (p *VideoInput) SetVideoSettingCameraPct(deviceID int,
Property int32, pctValue float32, Flags int32,
) bool {
rv := C.vi_device_setVideoSettingCameraPct(p.vi,
C.int(deviceID),
C.long(Property), C.float(pctValue), C.long(Flags),
)
return rv != 0
}