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


Golang C.cfish_incref函數代碼示例

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


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

示例1: goToBoolean

func goToBoolean(value interface{}, nullable bool) unsafe.Pointer {
	switch v := value.(type) {
	case bool:
		if v {
			return unsafe.Pointer(C.cfish_incref(unsafe.Pointer(C.CFISH_TRUE)))
		} else {
			return unsafe.Pointer(C.cfish_incref(unsafe.Pointer(C.CFISH_FALSE)))
		}
	case Obj:
		certifyCF(v, C.CFISH_BOOLEAN, nullable)
		return unsafe.Pointer(C.cfish_incref(unsafe.Pointer(v.TOPTR())))
	}
	mess := fmt.Sprintf("Can't convert %T to clownfish.Boolean", value)
	panic(NewErr(mess))
}
開發者ID:rectang,項目名稱:lucy-clownfish,代碼行數:15,代碼來源:clownfish.go

示例2: Next

func (h *HitsIMP) Next(hit interface{}) bool {
	self := (*C.lucy_Hits)(clownfish.Unwrap(h, "h"))
	ivars := C.lucy_Hits_IVARS(self)
	matchDoc := (*C.lucy_MatchDoc)(unsafe.Pointer(
		C.CFISH_Vec_Fetch(ivars.match_docs, C.size_t(ivars.offset))))
	ivars.offset += 1

	if matchDoc == nil {
		// Bail if there aren't any more *captured* hits.  (There may be
		// more total hits.)
		return false
	} else {
		// Lazily fetch HitDoc, set score.
		searcher := clownfish.WRAPAny(unsafe.Pointer(C.cfish_incref(
			unsafe.Pointer(ivars.searcher)))).(Searcher)
		docID := int32(C.LUCY_MatchDoc_Get_Doc_ID(matchDoc))
		err := searcher.ReadDoc(docID, hit)
		if err != nil {
			h.err = err
			return false
		}
		if ss, ok := hit.(setScorer); ok {
			ss.SetScore(float32(C.LUCY_MatchDoc_Get_Score(matchDoc)))
		}
		return true
	}
}
開發者ID:rlugojr,項目名稱:lucy,代碼行數:27,代碼來源:search.go

示例3: goToHash

func goToHash(value interface{}, nullable bool) unsafe.Pointer {
	switch v := value.(type) {
	case map[string]interface{}:
		if v == nil {
			if nullable {
				return nil
			}
		} else {
			size := len(v)
			hash := C.cfish_Hash_new(C.size_t(size))
			for key, val := range v {
				newVal := GoToClownfish(val, nil, true)
				keySize := len(key)
				keyStr := C.CString(key)
				cfKey := C.cfish_Str_new_steal_utf8(keyStr, C.size_t(keySize))
				defer C.cfish_dec_refcount(unsafe.Pointer(cfKey))
				C.CFISH_Hash_Store(hash, cfKey, (*C.cfish_Obj)(newVal))
			}
			return unsafe.Pointer(hash)
		}
	case Obj:
		certifyCF(v, C.CFISH_HASH, nullable)
		return unsafe.Pointer(C.cfish_incref(unsafe.Pointer(v.TOPTR())))
	}
	mess := fmt.Sprintf("Can't convert %T to clownfish.Hash", value)
	panic(NewErr(mess))
}
開發者ID:rectang,項目名稱:lucy-clownfish,代碼行數:27,代碼來源:clownfish.go

示例4: ToGo

func ToGo(ptr unsafe.Pointer) interface{} {
	if ptr == nil {
		return nil
	}
	class := C.cfish_Obj_get_class((*C.cfish_Obj)(ptr))
	if class == C.CFISH_STRING {
		return CFStringToGo(ptr)
	} else if class == C.CFISH_BLOB {
		return BlobToGo(ptr)
	} else if class == C.CFISH_VECTOR {
		return VectorToGo(ptr)
	} else if class == C.CFISH_HASH {
		return HashToGo(ptr)
	} else if class == C.CFISH_BOOLEAN {
		if ptr == unsafe.Pointer(C.CFISH_TRUE) {
			return true
		} else {
			return false
		}
	} else if class == C.CFISH_INTEGER {
		val := C.CFISH_Int_Get_Value((*C.cfish_Integer)(ptr))
		return int64(val)
	} else if class == C.CFISH_FLOAT {
		val := C.CFISH_Float_Get_Value((*C.cfish_Float)(ptr))
		return float64(val)
	} else {
		// Don't convert to a native Go type, but wrap in a Go struct.
		return WRAPAny(unsafe.Pointer(C.cfish_incref(unsafe.Pointer(ptr))))
	}
}
開發者ID:rectang,項目名稱:lucy-clownfish,代碼行數:30,代碼來源:clownfish.go

示例5: GOLUCY_Doc_Field_Names

//export GOLUCY_Doc_Field_Names
func GOLUCY_Doc_Field_Names(d *C.lucy_Doc) *C.cfish_Vector {
	fields := fetchDocFields(d)
	vec := clownfish.NewVector(len(fields))
	for key, _ := range fields {
		vec.Push(key)
	}
	return (*C.cfish_Vector)(C.cfish_incref(clownfish.Unwrap(vec, "vec")))
}
開發者ID:lazycrazyowl,項目名稱:lucy,代碼行數:9,代碼來源:lucy.go

示例6: GoCfish_TrapErr_internal

//export GoCfish_TrapErr_internal
func GoCfish_TrapErr_internal(routine C.CFISH_Err_Attempt_t,
	context unsafe.Pointer) *C.cfish_Err {
	err := TrapErr(func() { C.GoCfish_RunRoutine(routine, context) })
	if err != nil {
		ptr := (err.(Err)).TOPTR()
		return ((*C.cfish_Err)(unsafe.Pointer(C.cfish_incref(unsafe.Pointer(ptr)))))
	}
	return nil
}
開發者ID:rectang,項目名稱:lucy-clownfish,代碼行數:10,代碼來源:clownfish.go

示例7: Obtain

func (lock *LockIMP) Obtain() error {
	self := (*C.lucy_Lock)(clownfish.Unwrap(lock, "lock"))
	success := C.LUCY_Lock_Obtain(self)
	if !success {
		cfErr := C.cfish_Err_get_error()
		return clownfish.WRAPAny(unsafe.Pointer(C.cfish_incref(unsafe.Pointer(cfErr)))).(error)
	}
	return nil
}
開發者ID:rlugojr,項目名稱:lucy,代碼行數:9,代碼來源:store.go

示例8: ReleaseWindow

func (fh *FileHandleIMP) ReleaseWindow(window FileWindow) error {
	self := (*C.lucy_FileHandle)(clownfish.Unwrap(fh, "fh"))
	windowC := (*C.lucy_FileWindow)(clownfish.Unwrap(window, "window"))
	success := C.LUCY_FH_Release_Window(self, windowC)
	if !success {
		cfErr := C.cfish_Err_get_error()
		return clownfish.WRAPAny(unsafe.Pointer(C.cfish_incref(unsafe.Pointer(cfErr)))).(error)
	}
	return nil
}
開發者ID:rlugojr,項目名稱:lucy,代碼行數:10,代碼來源:store.go

示例9: Window

func (fh *FileHandleIMP) Window(window FileWindow, offset, length int64) error {
	self := (*C.lucy_FileHandle)(clownfish.Unwrap(fh, "fh"))
	windowC := (*C.lucy_FileWindow)(clownfish.Unwrap(window, "window"))
	success := C.LUCY_FH_Window(self, windowC, C.int64_t(offset), C.int64_t(length))
	if !success {
		cfErr := C.cfish_Err_get_error()
		return clownfish.WRAPAny(unsafe.Pointer(C.cfish_incref(unsafe.Pointer(cfErr)))).(error)
	}
	return nil
}
開發者ID:rlugojr,項目名稱:lucy,代碼行數:10,代碼來源:store.go

示例10: Obtain

func (r *IndexReaderIMP) Obtain(api string) (retval DataReader, err error) {
	err = clownfish.TrapErr(func() {
		self := (*C.lucy_IndexReader)(clownfish.Unwrap(r, "r"))
		apiC := (*C.cfish_String)(clownfish.GoToClownfish(api, unsafe.Pointer(C.CFISH_STRING), false))
		defer C.cfish_decref(unsafe.Pointer(apiC))
		retvalCF := C.LUCY_IxReader_Obtain(self, apiC)
		retval = clownfish.WRAPAny(unsafe.Pointer(C.cfish_incref(unsafe.Pointer(retvalCF)))).(DataReader)
	})
	return retval, err
}
開發者ID:rlugojr,項目名稱:lucy,代碼行數:10,代碼來源:index.go

示例11: LocalMkDir

func (f *FolderIMP) LocalMkDir(name string) error {
	self := (*C.lucy_Folder)(clownfish.Unwrap(f, "f"))
	nameC := (*C.cfish_String)(clownfish.GoToClownfish(name, unsafe.Pointer(C.CFISH_STRING), false))
	defer C.cfish_decref(unsafe.Pointer(nameC))
	success := C.LUCY_Folder_Local_MkDir(self, nameC)
	if !success {
		cfErr := C.cfish_Err_get_error()
		return clownfish.WRAPAny(unsafe.Pointer(C.cfish_incref(unsafe.Pointer(cfErr)))).(error)
	}
	return nil
}
開發者ID:rlugojr,項目名稱:lucy,代碼行數:11,代碼來源:store.go

示例12: GetRules

func (spec *SortSpecIMP) GetRules() []SortRule {
	self := (*C.lucy_SortSpec)(clownfish.Unwrap(spec, "spec"))
	vec := C.LUCY_SortSpec_Get_Rules(self)
	length := int(C.CFISH_Vec_Get_Size(vec))
	slice := make([]SortRule, length)
	for i := 0; i < length; i++ {
		elem := C.cfish_incref(unsafe.Pointer(C.CFISH_Vec_Fetch(vec, C.size_t(i))))
		slice[i] = WRAPSortRule(unsafe.Pointer(elem))
	}
	return slice
}
開發者ID:rlugojr,項目名稱:lucy,代碼行數:11,代碼來源:search.go

示例13: GetMatchDocs

func (td *TopDocsIMP) GetMatchDocs() []MatchDoc {
	self := (*C.lucy_TopDocs)(clownfish.Unwrap(td, "td"))
	vec := C.LUCY_TopDocs_Get_Match_Docs(self)
	length := int(C.CFISH_Vec_Get_Size(vec))
	slice := make([]MatchDoc, length)
	for i := 0; i < length; i++ {
		elem := C.cfish_incref(unsafe.Pointer(C.CFISH_Vec_Fetch(vec, C.size_t(i))))
		slice[i] = WRAPMatchDoc(unsafe.Pointer(elem))
	}
	return slice
}
開發者ID:rlugojr,項目名稱:lucy,代碼行數:11,代碼來源:search.go

示例14: GetAnalyzers

func (p *PolyAnalyzerIMP) GetAnalyzers() []Analyzer {
	self := (*C.lucy_PolyAnalyzer)(clownfish.Unwrap(p, "p"))
	retvalCF := C.LUCY_PolyAnalyzer_Get_Analyzers(self)
	size := C.CFISH_Vec_Get_Size(retvalCF)
	retval := make([]Analyzer, int(size))
	for i := 0; i < int(size); i++ {
		child := unsafe.Pointer(C.CFISH_Vec_Fetch(retvalCF, C.size_t(i)))
		retval[i] = clownfish.WRAPAny(unsafe.Pointer(C.cfish_incref(child))).(Analyzer)
	}
	return retval
}
開發者ID:rlugojr,項目名稱:lucy,代碼行數:11,代碼來源:analysis.go

示例15: spanSliceToVec

func spanSliceToVec(slice []Span) *C.cfish_Vector {
	if slice == nil {
		return nil
	}
	length := len(slice)
	vec := C.cfish_Vec_new(C.size_t(length))
	for i := 0; i < length; i++ {
		elem := clownfish.Unwrap(slice[i], "slice[i]")
		C.CFISH_Vec_Push(vec, C.cfish_incref(elem))
	}
	return vec
}
開發者ID:rlugojr,項目名稱:lucy,代碼行數:12,代碼來源:highlight.go


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