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