cdata

package module
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 16, 2025 License: BSL-1.0 Imports: 4 Imported by: 0

README

cdata

Go Reference Go Report Card

About

cdata is a package for Go to process data in C in specific order. cdata is published on https://github.com/vbsw/golib/cdata.

Copyright 2023 - 2025, Vitali Baumtrok (vbsw@mailbox.org).

cdata is distributed under the Boost Software License, version 1.0. (See accompanying file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt)

cdata is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Boost Software License for more details.

References

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

func Proc(data []CData, params ...int) error

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.)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL