Documentation
¶
Overview ¶
Package cdata processes C data.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Proc ¶ added in v0.5.0
Proc processes CData in sequence.
The second parameter is the number of passes. The third parameter is the number of IDs in ID list. The fourth parameter is the minumum IDs word capacity in bytes.
If second or third parameter is set to 0, then no memory is allocated to manage IDs and data. (Calling cdata_set or cdata_get will cause an error.)
CProcFunc are called from index 0 to len(data)-1 and backwards from len(cdata)-1 to 0. Processing forward is one pass. Processing backwards is another pass. Only in first pass data (that will be passed to SetCData) can be set via cdata_set. If not set, it is initialized to NULL.
If error occurs, SetCData isn't called and CProcFunc are called from index len(cdata)-1 to 0 (once). It is expected, that CProcFunc performes cleanup.
Types ¶
type CData ¶
type CData interface {
CProcFunc() unsafe.Pointer
SetCData(unsafe.Pointer)
ToError(int64, int64, string) error
}
CData is an interface to call C functions. CData are processed as list in sequence. First, all CProcFunc's are called. Then, the returned data are passed in sequence to SetCData.
If an error occurs, CProcFunc's are called in reversed sequence with a negative pass number. (It is expected, that CProcFunc performes cleanup.) In this case SetCData is not called. The error is passed to all ToError in a reversed sequence until any returns not nil. (First parameter of ToError should be unique.)