tioga 1.6 → 1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. data/Tioga_README +35 -10
  2. data/split/Dvector/dvector.c +264 -22
  3. data/split/Dvector/lib/Dvector_extras.rb +30 -2
  4. data/split/Flate/extconf.rb +1 -1
  5. data/split/Function/function.c +112 -2
  6. data/split/Tioga/figures.c +76 -77
  7. data/split/Tioga/figures.h +375 -490
  8. data/split/Tioga/generic.c +254 -0
  9. data/split/Tioga/generic.h +236 -0
  10. data/split/Tioga/init.c +434 -320
  11. data/split/Tioga/lib/Creating_Paths.rb +11 -1
  12. data/split/Tioga/lib/FigMkr.rb +263 -65
  13. data/split/Tioga/lib/Legends.rb +4 -2
  14. data/split/Tioga/lib/Markers.rb +3 -2
  15. data/split/Tioga/lib/Special_Paths.rb +22 -23
  16. data/split/Tioga/lib/TeX_Text.rb +79 -1
  17. data/split/Tioga/lib/TexPreamble.rb +14 -0
  18. data/split/Tioga/lib/Utils.rb +5 -1
  19. data/split/Tioga/pdfs.h +7 -45
  20. data/split/Tioga/{axes.c → shared/axes.c} +210 -197
  21. data/split/Tioga/{makers.c → shared/makers.c} +442 -211
  22. data/split/Tioga/{pdf_font_dicts.c → shared/pdf_font_dicts.c} +0 -0
  23. data/split/Tioga/shared/pdfcolor.c +628 -0
  24. data/split/Tioga/shared/pdfcoords.c +443 -0
  25. data/split/Tioga/{pdffile.c → shared/pdffile.c} +56 -52
  26. data/split/Tioga/{pdfimage.c → shared/pdfimage.c} +103 -211
  27. data/split/Tioga/shared/pdfpath.c +766 -0
  28. data/split/Tioga/{pdftext.c → shared/pdftext.c} +121 -99
  29. data/split/Tioga/shared/texout.c +524 -0
  30. data/split/Tioga/wrappers.c +489 -0
  31. data/split/Tioga/wrappers.h +259 -0
  32. data/split/extconf.rb +4 -0
  33. data/split/mkmf2.rb +12 -1
  34. data/tests/benchmark_dvector_reads.rb +112 -0
  35. data/tests/tc_Dvector.rb +35 -3
  36. data/tests/tc_Function.rb +32 -0
  37. metadata +65 -52
  38. data/split/Tioga/pdfcolor.c +0 -486
  39. data/split/Tioga/pdfcoords.c +0 -523
  40. data/split/Tioga/pdfpath.c +0 -913
  41. data/split/Tioga/texout.c +0 -380
@@ -0,0 +1,254 @@
1
+ /* generic.c */
2
+ /*
3
+ Copyright (C) 2007 Bill Paxton
4
+
5
+ This file is part of Tioga.
6
+
7
+ Tioga is free software; you can redistribute it and/or modify
8
+ it under the terms of the GNU General Library Public License as published
9
+ by the Free Software Foundation; either version 2 of the License, or
10
+ (at your option) any later version.
11
+
12
+ Tioga is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU Library General Public License for more details.
16
+
17
+ You should have received a copy of the GNU Library General Public License
18
+ along with Tioga; if not, write to the Free Software
19
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
+ */
21
+
22
+ #include <ctype.h>
23
+ #include "dvector.h"
24
+ #include "dtable.h"
25
+ #include "ruby.h"
26
+ #include "intern.h"
27
+ #include "generic.h"
28
+ #include "figures.h"
29
+ #include "pdfs.h"
30
+ #include "flate.h"
31
+
32
+
33
+ static OBJ_PTR rb_Integer_class, rb_Numeric_class;
34
+
35
+ void Init_generic(void) {
36
+ rb_Numeric_class = rb_define_class("Numeric", rb_cObject);
37
+ rb_Integer_class = rb_define_class("Integer", rb_Numeric_class);
38
+ }
39
+
40
+ bool Is_Kind_of_Integer(OBJ_PTR obj) { return rb_obj_is_kind_of(obj,rb_Integer_class); }
41
+ bool Is_Kind_of_Number(OBJ_PTR obj) { return rb_obj_is_kind_of(obj,rb_Numeric_class); }
42
+
43
+ void Call_Function(OBJ_PTR fmkr, ID_PTR fn, OBJ_PTR arg, int *ierr) {
44
+ rb_funcall(fmkr, fn, 1, arg);
45
+ }
46
+
47
+ double Number_to_double(OBJ_PTR obj, int *ierr) { return NUM2DBL(obj); }
48
+
49
+ long Number_to_int(OBJ_PTR obj, int *ierr) { return NUM2INT(obj); }
50
+
51
+ OBJ_PTR Integer_New(long val) { return INT2FIX(val); }
52
+
53
+ OBJ_PTR Float_New(double val) { return rb_float_new(val); }
54
+
55
+ OBJ_PTR String_New(char *src, long len) { return rb_str_new(src,len); }
56
+
57
+ OBJ_PTR String_From_Cstring(char *src) { return rb_str_new2(src); }
58
+
59
+ char *String_Ptr(OBJ_PTR obj, int *ierr) {
60
+ VALUE str = rb_String(obj);
61
+ return StringValuePtr(str); }
62
+
63
+ long String_Len(OBJ_PTR obj, int *ierr) {
64
+ VALUE str = rb_String(obj);
65
+ return RSTRING_LEN(str); }
66
+
67
+ char *CString_Ptr(OBJ_PTR obj, int *ierr) {
68
+ VALUE str = rb_String(obj);
69
+ char *cs = StringValuePtr(str);
70
+ long len = RSTRING_LEN(str);
71
+ if (len != strlen(cs)) { RAISE_ERROR("invalid C string; contains NULL character",ierr); return NULL; }
72
+ return cs; }
73
+
74
+ OBJ_PTR Array_New(long len) { return rb_ary_new2(len); }
75
+
76
+ long Array_Len(OBJ_PTR obj, int *ierr) { return (RARRAY(rb_Array(obj))->len); }
77
+
78
+ OBJ_PTR Array_Entry(OBJ_PTR obj, long indx, int *ierr) { return rb_ary_entry(obj,indx); }
79
+
80
+ void Array_Store(OBJ_PTR obj, long indx, OBJ_PTR val, int *ierr) { rb_ary_store(obj,indx,val); }
81
+
82
+ void Array_Push(OBJ_PTR obj, OBJ_PTR val, int *ierr) { rb_ary_push(obj,val); }
83
+
84
+ ID_PTR ID_Get(char *name) { return rb_intern(name); }
85
+
86
+ char *ID_Name(ID_PTR id, int *ierr) { return rb_id2name(id); }
87
+
88
+ OBJ_PTR Obj_Attr_Get(OBJ_PTR obj, ID_PTR attr_ID, int *ierr) { return rb_ivar_get(obj,attr_ID); }
89
+
90
+ void Obj_Attr_Set(OBJ_PTR obj, ID_PTR attr_ID, OBJ_PTR val, int *ierr) { rb_ivar_set(obj,attr_ID,val); }
91
+
92
+
93
+
94
+ OBJ_PTR TEX_PREAMBLE(OBJ_PTR fmkr, int *ierr) { return rb_const_get(CLASS_OF(fmkr),ID_Get("TEX_PREAMBLE")); }
95
+
96
+ OBJ_PTR COLOR_PREAMBLE(OBJ_PTR fmkr, int *ierr) { return rb_const_get(CLASS_OF(fmkr),ID_Get("COLOR_PREAMBLE")); }
97
+
98
+
99
+ //#define Obj_Attr_Get_by_StringName(obj,attr_name_string) rb_iv_get(obj,attr_name_string)
100
+ // returns value of the given attr of the obj (name_string is char *)
101
+ //#define Obj_Attr_Set_by_StringName(obj,attr_name_string,val) rb_iv_set(obj,attr_name_string,val)
102
+ // sets the specified attr of the obj to val (name_string is char *)
103
+
104
+ void GIVE_WARNING(const char *fmt, const char *str) { rb_warn(fmt,str); }
105
+
106
+ void RAISE_ERROR(char *str, int *ierr) { *ierr = -1; rb_raise(rb_eArgError,str); }
107
+
108
+ #define err_buff_len 256
109
+ void RAISE_ERROR_s(char *fmt, char *s, int *ierr) {
110
+ char buff[err_buff_len];
111
+ snprintf(buff,sizeof(buff),fmt,s);
112
+ RAISE_ERROR(buff,ierr);
113
+ }
114
+
115
+ void RAISE_ERROR_ss(char *fmt, char *s1, char *s2, int *ierr) {
116
+ char buff[err_buff_len];
117
+ snprintf(buff,sizeof(buff),fmt,s1,s2);
118
+ RAISE_ERROR(buff,ierr);
119
+ }
120
+
121
+ void RAISE_ERROR_i(char *fmt, int x, int *ierr) {
122
+ char buff[err_buff_len];
123
+ snprintf(buff,sizeof(buff),fmt,x);
124
+ RAISE_ERROR(buff,ierr);
125
+ }
126
+
127
+ void RAISE_ERROR_ii(char *fmt, int x1, int x2, int *ierr) {
128
+ char buff[err_buff_len];
129
+ snprintf(buff,sizeof(buff),fmt,x1,x2);
130
+ RAISE_ERROR(buff,ierr);
131
+ }
132
+
133
+ void RAISE_ERROR_g(char *fmt, double x, int *ierr) {
134
+ char buff[err_buff_len];
135
+ snprintf(buff,sizeof(buff),fmt,x);
136
+ RAISE_ERROR(buff,ierr);
137
+ }
138
+
139
+ void RAISE_ERROR_gg(char *fmt, double x1, double x2, int *ierr) {
140
+ char buff[err_buff_len];
141
+ snprintf(buff,sizeof(buff),fmt,x1,x2);
142
+ RAISE_ERROR(buff,ierr);
143
+ }
144
+
145
+
146
+ /* generic interface for alloc */
147
+
148
+ char *ALLOC_N_char(long len) { return ALLOC_N(char,len); }
149
+ unsigned char *ALLOC_N_unsigned_char(long len) { return ALLOC_N(unsigned char,len); }
150
+
151
+ long *ALLOC_N_long(long len) { return ALLOC_N(long,len); }
152
+ unsigned long *ALLOC_N_unsigned_long(long len) { return ALLOC_N(unsigned long,len); }
153
+
154
+ void **ALLOC_N_pointer(long len) { return ALLOC_N(void *,len); }
155
+ bool *ALLOC_N_bool(long len) { return ALLOC_N(bool,len); }
156
+ double *ALLOC_N_double(long len) { return ALLOC_N(double,len); }
157
+
158
+ void REALLOC_long(long **ptr, long new_len) {
159
+ long *data_ptr = *ptr;
160
+ REALLOC_N(data_ptr,long,new_len);
161
+ *ptr = data_ptr;
162
+ }
163
+
164
+ void REALLOC_double(double **ptr, long new_len) {
165
+ double *data_ptr = *ptr;
166
+ REALLOC_N(data_ptr,double,new_len);
167
+ *ptr = data_ptr;
168
+ }
169
+
170
+
171
+ /* generic interface for vectors and tables */
172
+
173
+ double *Vector_Data_for_Read(OBJ_PTR obj, long *len_ptr, int *ierr) {
174
+ return Dvector_Data_for_Read(obj,len_ptr);
175
+ }
176
+
177
+ double **Table_Data_for_Read(OBJ_PTR tbl, long *num_col_ptr, long *num_row_ptr, int *ierr) {
178
+ return Dtable_Ptr(tbl,num_col_ptr,num_row_ptr);
179
+ }
180
+
181
+ OBJ_PTR Vector_New(long len, double *vals) {
182
+ VALUE dv = Dvector_Create();
183
+ double *data = Dvector_Data_Resize(dv,len);
184
+ long i;
185
+ for (i=0; i<len; i++) data[i] = vals[i];
186
+ return dv;
187
+ }
188
+
189
+ OBJ_PTR Integer_Vector_New(long len, long *vals) {
190
+ VALUE ar = rb_ary_new2(len);
191
+ long i;
192
+ for (i=0; i<len; i++) rb_ary_store(ar,i,LONG2NUM(vals[i]));
193
+ return ar;
194
+ }
195
+
196
+
197
+
198
+ int do_flate_compress(unsigned char *new_ptr, unsigned long *new_len_ptr, unsigned char *ptr, long len) {
199
+ return flate_compress(new_ptr, new_len_ptr, ptr, len); }
200
+
201
+ /* Hash-related functions: */
202
+
203
+ OBJ_PTR Hash_New()
204
+ {
205
+ return rb_hash_new();
206
+ }
207
+
208
+ OBJ_PTR Hash_Get_Obj_Obj(OBJ_PTR hash, OBJ_PTR key)
209
+ {
210
+ return rb_hash_aref(hash, key);
211
+ }
212
+
213
+
214
+ OBJ_PTR Hash_Get_Obj(OBJ_PTR hash, const char * key)
215
+ {
216
+ return rb_hash_aref(hash, rb_str_new2(key));
217
+ }
218
+
219
+ void Hash_Set_Obj(OBJ_PTR hash, const char * key, OBJ_PTR value)
220
+ {
221
+ rb_hash_aset(hash, rb_str_new2(key), value);
222
+ }
223
+
224
+ void Hash_Set_Obj_Obj(OBJ_PTR hash, OBJ_PTR key, OBJ_PTR value)
225
+ {
226
+ rb_hash_aset(hash, key, value);
227
+ }
228
+
229
+ double Hash_Get_Double(OBJ_PTR hash, const char * key)
230
+ {
231
+ int err;
232
+ return Number_to_double(Hash_Get_Obj(hash, key), &err);
233
+ }
234
+ /* Same as Hash_Get_Obj, but returns a double */
235
+ void Hash_Set_Double(OBJ_PTR hash, const char * key, double value)
236
+ {
237
+ Hash_Set_Obj(hash, key, Float_New(value));
238
+ }
239
+ void Hash_Delete(OBJ_PTR hash, const char * key)
240
+ {
241
+ rb_hash_delete(hash, rb_str_new2(key));
242
+ }
243
+
244
+
245
+ bool Hash_Has_Key(OBJ_PTR hash, const char * key)
246
+ {
247
+ return Hash_Has_Key_Obj(hash, rb_str_new2(key));
248
+ }
249
+
250
+ bool Hash_Has_Key_Obj(OBJ_PTR hash, OBJ_PTR key)
251
+ {
252
+ return RTEST(rb_funcall(hash,rb_intern("has_key?"), 1, key));
253
+ }
254
+
@@ -0,0 +1,236 @@
1
+ /* generic.h */
2
+ /*
3
+ Copyright (C) 2007 Bill Paxton
4
+
5
+ This file is part of Tioga.
6
+
7
+ Tioga is free software; you can redistribute it and/or modify
8
+ it under the terms of the GNU General Library Public License as published
9
+ by the Free Software Foundation; either version 2 of the License, or
10
+ (at your option) any later version.
11
+
12
+ Tioga is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU Library General Public License for more details.
16
+
17
+ You should have received a copy of the GNU Library General Public License
18
+ along with Tioga; if not, write to the Free Software
19
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
+ */
21
+
22
+ #ifndef __generic_H__
23
+ #define __generic_H__
24
+
25
+ #include <stdbool.h>
26
+
27
+
28
+ //if ruby
29
+ #include "ruby.h"
30
+ #include "intern.h"
31
+
32
+
33
+ extern void Init_generic(void);
34
+
35
+
36
+ /* most of the c code should use this interface
37
+ rather than directly depending on ruby interfaces */
38
+
39
+
40
+ // if ruby
41
+ #define OBJ_PTR VALUE
42
+ // if python
43
+ //#define OBJ_PTR PyObject*
44
+
45
+ // if ruby
46
+ #define ID_PTR ID
47
+ // if python
48
+ //#define ID_PTR char*
49
+
50
+ //if ruby
51
+ #define OBJ_NIL Qnil
52
+ #define OBJ_TRUE Qtrue
53
+ #define OBJ_FALSE Qfalse
54
+ //if python
55
+ //#define OBJ_NIL Py_None
56
+ //#define OBJ_TRUE Py_True
57
+ //#define OBJ_FALSE Py_False
58
+
59
+ //for python the following will need to increment ref counts
60
+ #define RETURN_NIL return Qnil
61
+ #define RETURN_TRUE return Qtrue
62
+ #define RETURN_FALSE return Qfalse
63
+
64
+
65
+ // all routines set *ierr nonzero in case of error.
66
+
67
+ extern void Call_Function(OBJ_PTR fmkr, ID_PTR fn, OBJ_PTR arg, int *ierr);
68
+ // invokes method given by fn in the object fmkr with the given arg.
69
+
70
+
71
+ /* Interfaces for callbacks */
72
+ /* Not implemented yet, don't use ! */
73
+ extern bool Is_Kind_of_Callback(OBJ_PTR obj); /* True if obj is a callback
74
+ function */
75
+ extern OBJ_PTR Use_Callback(OBJ_PTR callback, int nb, OBJ_PTR * args, int *ierr);
76
+ /*
77
+ Calls the callback callback with an array of nb arguments (args). args
78
+ can be NULL. The return value should be correctly allocated (means the
79
+ reference count should count the return value).
80
+ */
81
+
82
+ /* Hash-related functions */
83
+ /* We deal only with *string* hashes ! That is enough to give us */
84
+
85
+ extern OBJ_PTR Hash_New(); /* Returns a freshly-baked hash */
86
+ extern OBJ_PTR Hash_Get_Obj(OBJ_PTR hash, const char * key);
87
+ /* Returns the value for key */
88
+ extern OBJ_PTR Hash_Get_Obj_Obj(OBJ_PTR hash, OBJ_PTR key);
89
+ /* Same thing as Hash_Get_Obj, but takes an object for a key */
90
+ extern void Hash_Set_Obj(OBJ_PTR hash, const char * key, OBJ_PTR value);
91
+ /* Sets the value for key */
92
+ extern void Hash_Set_Obj_Obj(OBJ_PTR hash, OBJ_PTR key, OBJ_PTR value);
93
+ /* Same thing as Hash_Set_Obj, but takes an object for a key */
94
+ extern double Hash_Get_Double(OBJ_PTR hash, const char * key);
95
+ /* Same as Hash_Get_Obj, but returns a double */
96
+ extern void Hash_Set_Double(OBJ_PTR hash, const char * key, double value);
97
+ /* Same as Hash_Set_Obj, but takes a double */
98
+ extern void Hash_Delete(OBJ_PTR hash, const char * key);
99
+ /* Deletes key */
100
+ extern bool Hash_Has_Key(OBJ_PTR hash, const char * key);
101
+ /* Returns true if the key has been set. */
102
+ extern bool Hash_Has_Key_Obj(OBJ_PTR hash, OBJ_PTR key);
103
+ /* Returns true if the key has been set. */
104
+
105
+
106
+ extern bool Is_Kind_of_Integer(OBJ_PTR obj);
107
+ extern bool Is_Kind_of_Number(OBJ_PTR obj);
108
+
109
+ extern double Number_to_double(OBJ_PTR obj, int *ierr);
110
+ // returns a C double
111
+ // raises error if obj not a kind of number
112
+ extern long Number_to_int(OBJ_PTR obj, int *ierr);
113
+ // returns a C int
114
+ // raises error if obj not a kind of integer
115
+
116
+ extern OBJ_PTR Integer_New(long val);
117
+ // returns a new integer object with given val
118
+ extern OBJ_PTR Float_New(double val);
119
+ // returns a new float object with given val
120
+
121
+ extern OBJ_PTR String_New(char *src, long len);
122
+ // returns a new string object initialized with len chars from src
123
+ extern OBJ_PTR String_From_Cstring(char *src);
124
+ // returns a new string object initialized from null-terminated Cstring src
125
+
126
+
127
+ extern char *String_Ptr(OBJ_PTR obj, int *ierr);
128
+ // returns pointer to storage buffer for string obj
129
+ // tries to convert obj to string if necessary
130
+ // raises error if obj not a kind of string and cannot be converted to one
131
+
132
+ extern char *CString_Ptr(OBJ_PTR obj, int *ierr);
133
+ // like String_Ptr, but checks to make sure that there are no NULL chars in the string
134
+ // i.e., raises an exception if String_Len(obj) is not same as strlen(String_Ptr(obj))
135
+
136
+ extern long String_Len(OBJ_PTR obj, int *ierr);
137
+ // returns int length of contents of string obj
138
+ // tries to convert obj to string if necessary
139
+ // raises error if obj not a kind of string and cannot be converted to one
140
+
141
+ extern OBJ_PTR Array_New(long len);
142
+ // returns a new array object of length len
143
+ extern long Array_Len(OBJ_PTR obj, int *ierr);
144
+ // returns length of the array obj
145
+ // tries to convert obj to array if necessary
146
+ // raises error if obj not a kind of array and cannot be converted to one
147
+ extern OBJ_PTR Array_Entry(OBJ_PTR obj, long indx, int *ierr);
148
+ // returns a BORROWED REFERENCE to array obj entry indx
149
+ // tries to convert obj to array if necessary
150
+ // raises error if obj not a kind of array and cannot be converted to one
151
+ extern void Array_Store(OBJ_PTR obj, long indx, OBJ_PTR val, int *ierr);
152
+ // sets array obj entry indx to val.
153
+ // raises error if obj not a kind of array
154
+ extern void Array_Push(OBJ_PTR obj, OBJ_PTR val, int *ierr);
155
+ // pushes val onto the end of array obj.
156
+ // raises error if obj not a kind of array
157
+
158
+
159
+ extern ID_PTR ID_Get(char *name);
160
+ // returns internal ID for the given name
161
+ extern char *ID_Name(ID_PTR id, int *ierr);
162
+ // return the name of the given id.
163
+ extern OBJ_PTR Obj_Attr_Get(OBJ_PTR obj, ID_PTR attr_ID, int *ierr);
164
+ // returns a BORROWED REFERENCE to value of the given attr of the obj
165
+ extern void Obj_Attr_Set(OBJ_PTR obj, ID_PTR attr_ID, OBJ_PTR val, int *ierr);
166
+ // sets the specified attr of the obj to val.
167
+
168
+
169
+
170
+ extern OBJ_PTR TEX_PREAMBLE(OBJ_PTR fmkr, int *ierr);
171
+ // returns a BORROWED REFERENCE to the class FigureMaker constant named TEX_PREAMBLE
172
+
173
+ extern OBJ_PTR COLOR_PREAMBLE(OBJ_PTR fmkr, int *ierr);
174
+ // returns a BORROWED REFERENCE to the class FigureMaker constant named COLOR_PREAMBLE
175
+
176
+ extern void RAISE_ERROR(char *str, int *ierr); // prints the error message and does *ierr = -1;
177
+ // The following do sprintf to a local string, and then call RAISE_ERROR.
178
+ extern void RAISE_ERROR_s(char *fmt, char *s, int *ierr);
179
+ extern void RAISE_ERROR_ss(char *fmt, char *s1, char *s2, int *ierr);
180
+ extern void RAISE_ERROR_i(char *fmt, int x, int *ierr);
181
+ extern void RAISE_ERROR_ii(char *fmt, int x1, int x2, int *ierr);
182
+ extern void RAISE_ERROR_g(char *fmt, double x, int *ierr);
183
+ extern void RAISE_ERROR_gg(char *fmt, double x1, double x2, int *ierr);
184
+
185
+ extern void GIVE_WARNING(const char *fmt, const char *str);
186
+ // Unconditionally issues a warning message to standard error.
187
+ // The given string fmt and the arg str are interpreted as with printf.
188
+
189
+ /* generic interface for vectors and tables */
190
+
191
+ extern OBJ_PTR Vector_New(long len, double *vals);
192
+ // creates a new 1D vector and initializes it with given values
193
+
194
+ extern OBJ_PTR Integer_Vector_New(long len, long *vals);
195
+ // creates a new 1D vector and initializes it with given values
196
+
197
+ extern double *Vector_Data_for_Read(OBJ_PTR obj, long *len_ptr, int *ierr);
198
+ // returns (double *) pointer to data (read access only)
199
+ // also returns length of vector via len_ptr
200
+
201
+ extern double **Table_Data_for_Read(OBJ_PTR tbl, long *num_col_ptr, long *num_row_ptr, int *ierr);
202
+ // returns (double **) pointer to data (read access only)
203
+ // also returns number of cols and rows via num_col_ptr and num_row_ptr
204
+
205
+
206
+ /* generic interface for alloc */
207
+ // use these instead of directly calling C
208
+ // Ruby versions will trigger a garbage collection if necessary
209
+
210
+ extern char *ALLOC_N_char(long len);
211
+ extern unsigned char *ALLOC_N_unsigned_char(long len);
212
+
213
+ extern long *ALLOC_N_long(long len);
214
+ extern unsigned long *ALLOC_N_unsigned_long(long len);
215
+
216
+ extern void **ALLOC_N_pointer(long len);
217
+ extern bool *ALLOC_N_bool(long len);
218
+ extern double *ALLOC_N_double(long len);
219
+
220
+ extern void REALLOC_long(long **ptr, long new_len);
221
+ extern void REALLOC_double(double **ptr, long new_len);
222
+
223
+
224
+ // zlib compression
225
+
226
+ extern int do_flate_compress(unsigned char *new_ptr, unsigned long *new_len_ptr, unsigned char *ptr, long len);
227
+ // returns FLATE_OK if all okay.
228
+ // source is given by ptr and is len bytes in length.
229
+ // new_ptr is destination buffer of size *new_len_ptr.
230
+ // NOTE: the destination buffer for flate_compress should be LARGER than the source buffer to be safe.
231
+ // The minimal extra is 0.1% larger than the source plus 12 bytes.
232
+ // My rule is to use (len * 11)/10 + 100 just to be sure.
233
+
234
+ #define FLATE_OK 0
235
+
236
+ #endif /* __generic_H__ */