[ Main Table Of Contents | Table Of Contents | Keyword Index ]

c::slice(n) 1 doc "Tcl Data Structures"

Name

c::slice - Create and manipulate C-level array slices

Table Of Contents

Synopsis

Description

Welcome to Struct, a set of packages providing various data structures to Tcl, and additional operations for existing Tcl structures.

This package provides a basic C API for the creation and use of continous array slices. It does provide neither Tcl commands nor other items visible at script level.

The package is meant to be used by other C level data structure packages, as a means to provide access to parts of their internal data, assuming that they are (conceptually) an array.

To support this the package provides its C API by means of a stubs table which can be imported.

API

CSLICE cslice_create ( long int cc, void** cv )

This function creates and initializes a slice object with the specified slice of an array of cells. The return value of the function is the handle of the new slice object.

void cslice_destroy ( CSLICE s )

This function destroys the specified slice object, releasing all allocated memory.

void cslice_get ( CSLICE s, long int* cc, void*** cv )

This function provides access to the slice of cells contained in the specified slice object.

void cslice_revers ( CSLICE s )

This function creates a new slice which is the reverse of the input. The input slice is destroyed.

void cslice_concat ( CSLICE a CSLICE b )

This function creates a new slice which is the concatenation of the two inputs. The input slices are destroyed.

CSLICE cslice_from_list ( Tcl_Interp* interp Tcl_Obj* l )

This function creates a new slice containing the elements of the Tcl list object l.

If l was not a list object 0 is returned, and an error message left in the interpreter interp. Note that interp can be 0, in that case no error message is left.

Tcl_Obj* cslice_to_list ( CSLICE s )

This function creates a new Tcl list object containing the elements of the slice. This makes sense if and only if the elements of the slice are of type Tcl_Obj*. Any other type and the resulting Tcl object is broken, causing a crash at some point in the future.

long int cslice_size ( CSLICE s )

This function returns the size of the slice s.

void* cslice_at ( CSLICE s long int at )

This function returns the element at index at in slice s.

License

This package, written by Andreas Kupries, is BSD licensed.

Bugs, Ideas, Feedback

This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such at the Struct Tracker. Please also report any ideas for enhancements you may have for either package and/or documentation.

Keywords

array slice, data structures, slice

Category

Data structures