split/Tioga/generic.c in tioga-1.8 vs split/Tioga/generic.c in tioga-1.9

- old
+ new

@@ -18,20 +18,22 @@ along with Tioga; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <ctype.h> + #include "dvector.h" #include "dtable.h" #include "ruby.h" #include "intern.h" #include "generic.h" #include "figures.h" #include "pdfs.h" #include "flate.h" + static OBJ_PTR rb_Integer_class, rb_Numeric_class; void Init_generic(void) { rb_Numeric_class = rb_define_class("Numeric", rb_cObject); rb_Integer_class = rb_define_class("Integer", rb_Numeric_class); @@ -71,16 +73,27 @@ if (len != strlen(cs)) { RAISE_ERROR("invalid C string; contains NULL character",ierr); return NULL; } return cs; } OBJ_PTR Array_New(long len) { return rb_ary_new2(len); } -long Array_Len(OBJ_PTR obj, int *ierr) { return (RARRAY(rb_Array(obj))->len); } +long Array_Len(OBJ_PTR obj, int *ierr) { + return isa_Dvector(obj)? len_Dvector(obj) : (RARRAY(rb_Array(obj))->len); } OBJ_PTR Array_Entry(OBJ_PTR obj, long indx, int *ierr) { return rb_ary_entry(obj,indx); } void Array_Store(OBJ_PTR obj, long indx, OBJ_PTR val, int *ierr) { rb_ary_store(obj,indx,val); } void Array_Push(OBJ_PTR obj, OBJ_PTR val, int *ierr) { rb_ary_push(obj,val); } + +double Array_Entry_double(OBJ_PTR obj, long indx, int *ierr) { + return isa_Dvector(obj)? access_Dvector(obj,indx) : Number_to_double(rb_ary_entry(obj,indx),ierr); +} + +long Array_Entry_int(OBJ_PTR obj, long indx, int *ierr) { + return isa_Dvector(obj)? round(access_Dvector(obj,indx)) : Number_to_int(rb_ary_entry(obj,indx),ierr); +} + + ID_PTR ID_Get(char *name) { return rb_intern(name); } char *ID_Name(ID_PTR id, int *ierr) { return rb_id2name(id); }