ef7a35ca |
1 | /* -*-c-*- |
2 | * |
3 | * $Id: vec.h,v 1.1 2003/03/07 20:04:21 mdw Exp $ |
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 | |
27 | /*----- Revision history --------------------------------------------------* |
28 | * |
29 | * $Log: vec.h,v $ |
30 | * Revision 1.1 2003/03/07 20:04:21 mdw |
31 | * Version bump. |
32 | * |
33 | */ |
34 | |
35 | #ifndef VEC_H |
36 | #define VEC_H |
37 | |
38 | #ifdef __cplusplus |
39 | extern "C" { |
40 | #endif |
41 | |
42 | /*----- Header files ------------------------------------------------------*/ |
43 | |
44 | #include <stddef.h> |
45 | |
46 | #include <tcl.h> |
47 | |
48 | /*----- Data structures ---------------------------------------------------*/ |
49 | |
50 | typedef struct vec_bound { long lo, hi; } vec_bound; |
51 | typedef struct vec { |
52 | Tcl_Command c; |
53 | size_t ndim; |
54 | vec_bound *dim; |
55 | size_t n; |
56 | Tcl_Obj **v; |
57 | } vec; |
58 | |
59 | /*----- Functions provided ------------------------------------------------*/ |
60 | |
61 | /* --- @vec_find@ --- * |
62 | * |
63 | * Arguments: @Tcl_Interp *ti@ = interpreter vector exists in |
64 | * @Tcl_Obj *o@ = object containing the command name |
65 | * |
66 | * Returns: A pointer to the vector, or null. |
67 | * |
68 | * Use: Finds the vector with a given name. |
69 | */ |
70 | |
71 | extern vec *vec_find(Tcl_Interp */*ti*/, Tcl_Obj */*o*/); |
72 | |
73 | /* --- @vec_index@ --- * |
74 | * |
75 | * Arguments: @Tcl_Interp *ti@ = interpreter to put errors in |
76 | * @vec *v@ = the vector |
77 | * @int objc@ = number of indices provided |
78 | * @Tcl_Obj *const *objv@ = vector of objects |
79 | * |
80 | * Returns: Address of the object pointer, or null. |
81 | * |
82 | * Use: Looks up an index in a vector. |
83 | */ |
84 | |
85 | extern Tcl_Obj **vec_index(Tcl_Interp */*ti*/, vec */*v*/, |
86 | int /*objc*/, Tcl_Obj *const */*objv*/); |
87 | |
88 | /* --- @vec_destroy@ --- * |
89 | * |
90 | * Arguments: @Tcl_Interp *ti@ = owning interpreter |
91 | * @vec *v@ = vector pointer |
92 | * |
93 | * Returns: --- |
94 | * |
95 | * Use: Destroys a vector. |
96 | */ |
97 | |
98 | extern void vec_destroy(Tcl_Interp */*ti*/, vec */*v*/); |
99 | |
100 | /* --- @vec_create@ --- * |
101 | * |
102 | * Arguments: @Tcl_Interp *ti@ = interpreter to create vector in |
103 | * @size_t ndim@ = number of dimensions |
104 | * @const vec_bound *dim@ = the actual dimensions |
105 | * @Tcl_Obj *init@ = initial value |
106 | * |
107 | * Returns: A pointer to the vector, or null if it failed. |
108 | * |
109 | * Use: Creates a new vector object. |
110 | */ |
111 | |
112 | extern vec *vec_create(Tcl_Interp */*ti*/, size_t /*ndim*/, |
113 | const vec_bound */*dim*/, Tcl_Obj */*init*/); |
114 | |
115 | /*----- That's all, folks -------------------------------------------------*/ |
116 | |
117 | #ifdef __cplusplus |
118 | } |
119 | #endif |
120 | |
121 | #endif |