summaryrefslogtreecommitdiff
path: root/libguile/arrays.c
AgeCommit message (Collapse)AuthorFilesLines
2012-10-23Move array reader from arrays.c to read.cMark H Weaver1-173/+2
* libguile/arrays.c (read_decimal_integer): Move to read.c. (scm_i_read_array): Remove. Incorporate the code into the 'scm_read_array' static function in read.c. * libguile/arrays.h (scm_i_read_array): Remove prototype. * libguile/read.c (read_decimal_integer): Move here from read.c. (scm_read_array): Incorporate the code from 'scm_i_read_array'. Call 'scm_read_vector' and 'scm_read_sexp' instead of 'scm_read'.
2012-02-02Improve the usage of variable names in C docstrings.Bake Timmons1-18/+19
* libguile/alist.c: * libguile/array-map.c: * libguile/arrays.c: * libguile/bitvectors.c: * libguile/filesys.c: * libguile/foreign.c: * libguile/generalized-arrays.c: * libguile/hashtab.c: * libguile/ioext.c: * libguile/load.c: * libguile/numbers.c: * libguile/ports.c: * libguile/posix.c: * libguile/print.c: * libguile/procprop.c: * libguile/promises.c: * libguile/simpos.c: * libguile/socket.c: * libguile/srfi-1.c: * libguile/srfi-13.c: * libguile/srfi-14.c: * libguile/stacks.c: * libguile/stime.c: * libguile/strings.c: * libguile/struct.c: * libguile/symbols.c: * libguile/threads.c: * libguile/weak-table.c: * libguile/weak-vector.c: Make the variable names in the C docstrings more consistent. Replace a few instances of @var with @code when appropriate.
2012-01-09Fix incorrect use of `SCM_UNPACK'.Ludovic Courtès1-4/+4
* libguile/arrays.c (scm_i_make_array): Cast the result of `scm_gc_malloc' directly to `scm_t_bits'.
2012-01-09allocate a tc7 to arraysAndy Wingo1-15/+9
* libguile/tags.h (scm_tc7_array): Allocate a tag for arrays. * libguile/arrays.h (SCM_I_ARRAYP): Change to use scm_tc7_array. The previous definition was not externally usable because scm_i_tc16_array was internal. (scm_i_print_array): Declare, though internally. * libguile/arrays.c (scm_i_make_array): Use scm_cell with the tc7 instead of NEWSMOB. (scm_i_print_array): Make not static. (SCM_ARRAY_IMPLEMENTATION): Adapt. (scm_init_arrays): Remove array smob declaration. * libguile/eq.c (scm_equal_p): Refactor to put the string, pointer, and bytevector cases in the switch. Add a case for arrays. * libguile/goops.c: Add <array> declarations. * libguile/print.c (iprin1): Call scm_i_print_array as needed. * libguile/evalext.c (scm_self_evaluating_p): Add a case for arrays.
2011-07-28fix write beyond array end in arrays.cAndy Wingo1-17/+17
* libguile/arrays.c (scm_i_read_array): Fix write past end of array while reading array type tag. Fix non-ascii type tag elements. Thanks to http://article.gmane.org/gmane.lisp.guile.devel/12685.
2011-03-17fix code that causes warnings on gcc 4.6Andy Wingo1-3/+1
* libguile/arrays.c (scm_i_read_array): * libguile/backtrace.c (display_backtrace_body): * libguile/filesys.c (scm_readdir) * libguile/i18n.c (chr_to_case): * libguile/ports.c (register_finalizer_for_port): * libguile/posix.c (scm_nice): * libguile/stacks.c (scm_make_stack): Clean up a number of set-but-unused vars. Thanks to Douglas Mencken for the report. * libguile/numbers.c (scm_log, scm_exp): Fix a few #if cases that should be #ifdef.
2010-01-11allow compilation of #@2(1 2 3)Andy Wingo1-1/+36
* libguile/arrays.h: * libguile/arrays.c (scm_from_contiguous_array): New public function, like scm_from_contiguous_typed_array but for arrays of generic Scheme values. * libguile/vm-i-scheme.c (make-struct): Sync regs before making the struct, so if we get a GC the regs are on the heap. (make-array): New instruction, makes an generic (untyped) Scheme array. * module/language/glil/compile-assembly.scm (dump-object): Correctly compile arrays.
2010-01-07reimplement srfi-4 vectors on top of bytevectorsAndy Wingo1-144/+0
* libguile/srfi-4.h: * libguile/srfi-4.c (scm_make_srfi_4_vector): New function, exported by (srfi srfi-4 gnu). * libguile/srfi-4.i.c: Removed. * module/srfi/srfi-4.scm: * module/srfi/srfi-4/gnu.scm: Reimplement srfi-4 vectors on top of bytevectors. The implementation is mostly in Scheme now. * test-suite/tests/unif.test: Update to use (srfi srfi-4 gnu). * libguile/bytevectors.c (bytevector_ref_c32, bytevector_ref_c64) (bytevector_set_c32, bytevector_set_c64): Fix some embarrassing bugs. Still need to do an upper bounds check. * libguile/deprecated.h: Remove deprecated array functions: scm_i_arrayp, scm_i_array_ndim, scm_i_array_mem, scm_i_array_v, scm_i_array_base, scm_i_array_dims, and the deprecated macros: SCM_ARRAYP, SCM_ARRAY_NDIM, SCM_ARRAY_CONTP, SCM_ARRAY_MEM, SCM_ARRAY_V, SCM_ARRAY_BASE, SCM_ARRAY_DIMS. * libguile/deprecated.c (scm_uniform_vector_read_x) (scm_uniform_vector_write, scm_uniform_array_read_x) (scm_uniform_array_write): Newly deprecated functions. * libguile/generalized-arrays.c (scm_array_type): Remove the bytevector hack. * libguile/objcodes.c (scm_bytecode_to_objcode, scm_objcode_to_bytecode): Rework to operate on bytevectors, as scm_make_u8vector now causes a module lookup, which can't be done e.g. when loading the VM boot program for psyntax-pp.go on a fresh bootstrap. * libguile/objcodes.h (SCM_F_OBJCODE_IS_BYTEVECTOR): (SCM_OBJCODE_IS_BYTEVECTOR): s/U8VECTOR/BYTEVECTOR/. * module/ice-9/boot-9.scm (the-scm-module): A terrible hack to pull in (srfi srfi-4), as the bindings are primarily there now. We'll worry about this later.
2009-12-15Remove extraneous semicolon after `SCM_ARRAY_IMPLEMENTATION' & co.Ludovic Courtès1-1/+1
* libguile/bitvectors.c, libguile/srfi-4.c, libguile/strings.c, libguile/vectors.c: Remove extraneous semicolon after `SCM_ARRAY_IMPLEMENTATION' and `SCM_VECTOR_IMPLEMENTATION' invocations.
2009-12-08add SCM_SMOB_TYPE_BITS and SCM_SMOB_TYPE_MASKAndy Wingo1-1/+2
* libguile/smob.h (SCM_SMOB_TYPE_BITS, SCM_SMOB_TYPE_MASK): New macros, for when you want to identify a SMOB by type and mask. * libguile/arrays.c: * libguile/bitvectors.c: * libguile/srfi-4.c: Use the new macros.
2009-12-08fix erroneous SCM_CELL_* usage in arrays.[ch]Andy Wingo1-2/+2
* libguile/arrays.h (SCM_I_ARRAY_FLAG_CONTIGUOUS, SCM_I_ARRAY_NDIM): (SCM_I_ARRAY_CONTP, SCM_I_ARRAY_MEM): * libguile/arrays.c (SCM_SET_ARRAY_CONTIGUOUS_FLAG): (SCM_CLR_ARRAY_CONTIGUOUS_FLAG): Fix macros to use SCM_SMOB macros instead of SCM_CELL macros.
2009-10-16bitvector tweaksAndy Wingo1-1/+4
* libguile/arrays.c (scm_from_contiguous_typed_array): * libguile/bytevectors.c (scm_uniform_array_to_bytevector): Error if the uniform element size is more than 8 bits, but not divisible by 8 -- because our math could overflow in that case. * module/ice-9/deprecated.scm (#\y): Indeed, #* is the valid bitvector syntax :)
2009-10-15Fix compilation of literal bitvectors.Ludovic Courtès1-1/+2
* libguile/arrays.c (scm_from_contiguous_typed_array): Fix BYTE_LEN sanity check for bitvectors. * test-suite/tests/unif.test ("syntax")["bitvector is self-evaluating"]: New test. * module/ice-9/deprecated.scm (#\y): Fix deprecation comment: `#*' is not a read syntax.
2009-09-28Remove unneeded SMOB/port mark/free procedures.Ludovic Courtès1-18/+0
* libguile/arrays.c (array_mark, array_free): Remove. (scm_init_arrays): Adjust accordingly. * libguile/bitvectors.c (bitvector_free): Remove. (scm_c_make_bitvector): Use `scm_gc_malloc_pointerless ()'. (scm_init_bitvectors): Adjust accordingly. * libguile/strports.c (scm_make_stptob): Remove `scm_set_port_mark ()' call. * libguile/vports.c (scm_make_sfptob): Likewise.
2009-09-18fix bitvectors after the array handle refactoringAndy Wingo1-8/+16
* libguile/uniform.h (scm_array_handle_uniform_element_bit_size): New public accessor. * libguile/uniform.c (scm_array_handle_uniform_element_size): Better errors in non-byte-aligned arrays. (scm_uniform_vector_element_type, scm_uniform_vector_element_size) (scm_c_uniform_vector_ref, scm_c_uniform_vector_set_x): (scm_uniform_vector_to_list): Don't require byte-aligned access. * libguile/bytevectors.c (scm_uniform_array_to_bytevector): * libguile/arrays.c (scm_from_contiguous_typed_array): Fix for uniform arrays whose element size is not a multiple of the byte size.
2009-07-19make-typed-array builds backing vector via make-generalized-vectorAndy Wingo1-172/+81
* libguile/arrays.c: Rework to use scm_make_generalized_vector instead of our own type table. * libguile/bitvectors.c: Fix some includes.
2009-07-19uniform vector functions to their own fileAndy Wingo1-0/+1
* libguile/uniform.c: * libguile/uniform.h: * libguile/srfi-4.c: * libguile/srfi-4.h: * libguile/Makefile.am: Move uniform vector funcs out of srfi-4 to their own file. * libguile.h: * libguile/arrays.c: * libguile/bytevectors.c: Update includers.
2009-07-19generic vector ops to own fileAndy Wingo1-0/+1
* libguile/Makefile.am: * libguile/vectors.c: * libguile/vectors.h: * libguile/generalized-vectors.c: * libguile/generalized-vectors.h: Move generic vector ops off into their own file too. The implementation is now based on the generic array-handle infrastructure. * libguile.h: * libguile/array-map.c: * libguile/bitvectors.c: * libguile/random.c: * libguile/srfi-4.c: Update includers.
2009-07-19move generic array foo out to its own fileAndy Wingo1-252/+1
* libguile/arrays.h: * libguile/arrays.c: * libguile/generalized-arrays.h: * libguile/generalized-arrays.c: Move some generic functionality out of arrays.c to a new file. * libguile/array-map.c: * libguile/deprecated.c: * libguile/init.c: Update includers.
2009-07-19remove enclosed arraysAndy Wingo1-166/+17
* libguile/arrays.h: * libguile/array-map.c: * libguile/arrays.c: * libguile/deprecated.c: Remove "enclosed arrays". The only user-facing procedures that this affects are scm_enclose_array / enclose-array. If enclosed arrays are added back, it should be through the generic array interface; but really, it sounds like something that would be better implemented in Scheme.
2009-07-19add generic array implementation facilityAndy Wingo1-21/+32
* libguile/array-handle.c (scm_i_register_array_implementation): (scm_i_array_implementation_for_obj): Add generic array facility, which will (in a few commits) detangle the array code. (scm_array_get_handle): Use the generic array facility. Note that scm_t_array_handle no longer has ref and set function pointers; instead it has a pointer to the array implementation. It is unlikely that code out there used these functions, however, as the supported way was through scm_array_handle_ref/set_x. (scm_array_handle_pos): Move this function here from arrays.c. (scm_array_handle_element_type): New function, returns a Scheme value representing the type of element stored in this array. * libguile/array-handle.h (scm_t_array_element_type): New enum, for generically determining the type of an array. (scm_array_handle_rank): (scm_array_handle_dims): These are now just #defines. * libguile/arrays.c: * libguile/bitvectors.c: * libguile/bytevectors.c: * libguile/srfi-4.c: * libguile/strings.c: * libguile/vectors.c: Register array implementations for all of these. * libguile/inline.h: Update for array_handle_ref/set change. * libguile/deprecated.h: Need to include arrays.h now.
2009-07-19rename unif.[ch] to arrays.[ch]Andy Wingo1-0/+1634
* libguile/Makefile.am: * libguile/unif.c: * libguile/unif.h: * libguile/arrays.c: * libguile/arrays.h: Rename unif.[ch] to arrays.[ch]. * libguile.h: * libguile/array-handle.c: * libguile/array-map.c: * libguile/bitvectors.c: * libguile/bytevectors.c: * libguile/eq.c: * libguile/gc-card.c: * libguile/gc-malloc.c: * libguile/gc-mark.c: * libguile/gc.c: * libguile/init.c: * libguile/inline.h: * libguile/print.c: * libguile/random.c: * libguile/read.c: * libguile/socket.c: * libguile/sort.c: * libguile/srfi-4.c: * libguile/srfi-4.h: * libguile/strports.c: * libguile/vectors.c: * libguile/vectors.h: Update includers.