chiark / gitweb /
Fix output formatting a little.
[rocl] / vec.h
CommitLineData
ef7a35ca 1/* -*-c-*-
2 *
c53e2dd3 3 * $Id$
ef7a35ca 4 *
5 * Vectors and arrays in Tcl
6 *
7 * (c) 2003 Mark Wooding
8 */
9
10/*----- Licensing notice --------------------------------------------------*
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software Foundation,
24 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 */
26
ef7a35ca 27#ifndef VEC_H
28#define VEC_H
29
30#ifdef __cplusplus
31 extern "C" {
32#endif
33
34/*----- Header files ------------------------------------------------------*/
35
36#include <stddef.h>
37
38#include <tcl.h>
39
40/*----- Data structures ---------------------------------------------------*/
41
42typedef struct vec_bound { long lo, hi; } vec_bound;
43typedef struct vec {
44 Tcl_Command c;
45 size_t ndim;
46 vec_bound *dim;
47 size_t n;
48 Tcl_Obj **v;
49} vec;
50
51/*----- Functions provided ------------------------------------------------*/
52
53/* --- @vec_find@ --- *
54 *
55 * Arguments: @Tcl_Interp *ti@ = interpreter vector exists in
56 * @Tcl_Obj *o@ = object containing the command name
57 *
58 * Returns: A pointer to the vector, or null.
59 *
60 * Use: Finds the vector with a given name.
61 */
62
63extern vec *vec_find(Tcl_Interp */*ti*/, Tcl_Obj */*o*/);
64
65/* --- @vec_index@ --- *
66 *
67 * Arguments: @Tcl_Interp *ti@ = interpreter to put errors in
68 * @vec *v@ = the vector
69 * @int objc@ = number of indices provided
70 * @Tcl_Obj *const *objv@ = vector of objects
71 *
72 * Returns: Address of the object pointer, or null.
73 *
74 * Use: Looks up an index in a vector.
75 */
76
77extern Tcl_Obj **vec_index(Tcl_Interp */*ti*/, vec */*v*/,
78 int /*objc*/, Tcl_Obj *const */*objv*/);
79
80/* --- @vec_destroy@ --- *
81 *
82 * Arguments: @Tcl_Interp *ti@ = owning interpreter
83 * @vec *v@ = vector pointer
84 *
85 * Returns: ---
86 *
87 * Use: Destroys a vector.
88 */
89
90extern void vec_destroy(Tcl_Interp */*ti*/, vec */*v*/);
91
92/* --- @vec_create@ --- *
93 *
94 * Arguments: @Tcl_Interp *ti@ = interpreter to create vector in
95 * @size_t ndim@ = number of dimensions
96 * @const vec_bound *dim@ = the actual dimensions
97 * @Tcl_Obj *init@ = initial value
98 *
99 * Returns: A pointer to the vector, or null if it failed.
100 *
101 * Use: Creates a new vector object.
102 */
103
104extern vec *vec_create(Tcl_Interp */*ti*/, size_t /*ndim*/,
105 const vec_bound */*dim*/, Tcl_Obj */*init*/);
106
107/*----- That's all, folks -------------------------------------------------*/
108
109#ifdef __cplusplus
110 }
111#endif
112
113#endif