1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 11:50:28 +02:00
Commit graph

50 commits

Author SHA1 Message Date
Daniel Llorens
e0bcda4ad9 Fix bitvectors and non-zero lower bound arrays in truncated-print
* module/ice-9/arrays.scm (array-print-prefix): New private function.
* libguile/arrays.c (scm_i_print_array): Reuse (array-print-prefix) from
  (ice-9 arrays). Make sure to release the array handle.
* module/ice-9/pretty-print.scm (truncated-print): Support
  bitvectors.
  Don't try to guess the array prefix but call array-print-prefix from
  (ice-9 arrays) instead.
  Fix call to print-sequence to support non-zero lower bound arrays.
* test-suite/tests/arrays.test: Test that arrays print properly.
* test-suite/tests/print.test: Test truncated-print with bitvectors,
  non-zero lower bound arrays.
2017-10-31 13:23:44 +01:00
Daniel Llorens
7e93950552 Final names for new array functions
Globally rename (array-from* -> array-slice), (array-from ->
array-cell-ref), (array-amend! -> array-cell-set!), (array-for-each-cell
-> array-slice-for-each).
2017-01-09 09:02:04 +01:00
Daniel Llorens
fa4a22971a Deprecate scm_from_contiguous_array
scm_from_contiguous_array() was undocumented, unused within Guile, and
can be replaced by make-array + array-copy! without requiring contiguity
and without loss of performance.

* libguile/arrays.c (scm_array_contents): Do not rely on
  SCM_I_ARRAY_CONTP.
* test-suite/tests/arrays.test: Test array-contents with 0-rank array.
* libguile/arrays.h: Declare scm_i_shap2ra(),
  SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG so that
  scm_from_contiguous_array() can keep using them.
* libguile/deprecated.c (scm_from_contiguous_array): Move here from
  arrays.c.
* libguile/deprecated.h (scm_from_contiguous_array): Deprecate.
* NEWS: Add deprecation notice.
2016-11-23 13:05:49 +01:00
Daniel Llorens
d1435ea6bd New functions array-from, array-from*, array-amend!
* libguile/arrays.h (scm_array_from, scm_array_from_s,
  scm_array_amend_x): New declarations.

* libguile/arrays.c (scm_array_from, scm_array_from_s,
  scm_array_amend_x): New functions, export as array-from, array-from*,
  array-amend!.

* test-suite/tests/arrays.test: Tests for array-from, array-from*,
  array-amend!. Replace with-test-prefix/c&e with with-test-prefix where
  the array read syntax isn't used.
2016-11-23 13:04:26 +01:00
Daniel Llorens
4e766795b2 Avoid unneeded internal use of array handles
* libguile/arrays.c (scm_shared_array_root): Adopt uniform check order.

  (scm_shared_array_offset, scm_shared_array_increments): Use the array
  fields directly just as scm_shared_array_root does.

  (scm_c_array_rank): Moved from libguile/generalized-arrays.c. Don't
  use array handles, but follow the same type check sequence as the
  other array functions (shared-array-root, etc).

  (scm_array_rank): Moved from libguile/generalized-arrays.h.

* libguile/arrays.h: Move prototypes here.

* test-suite/tests/arrays.test: Tests for shared-array-offset,
  shared-array-increments.
2016-11-23 11:49:35 +01:00
Andy Wingo
dc2a560264 Deprecate dynamic roots
* libguile/root.h:
* libguile/root.c: Remove these files.
* libguile/deprecated.h:
* libguile/deprecated.c (scm_internal_cwdr, scm_call_with_dynamic_root)
  (scm_dynamic_root, scm_apply_with_dynamic_root): Deprecate.

Remove all root.h usage, which was vestigial.

* module/ice-9/serialize.scm: Use (current-thread) instead
  of (dynamic-root).
2016-11-21 23:09:21 +01:00
Andy Wingo
206b3f6e03 Remove scm_putc_unlocked.
* libguile/ports.h (scm_putc_unlocked): Remove.
* libguile/ports.c (scm_putc): Replace implementation with
  scm_putc_unlocked's implementation.
  (scm_port_print): Use scm_putc.
* libguile/arbiters.c:
* libguile/arrays.c:
* libguile/bitvectors.c:
* libguile/bytevectors.c:
* libguile/continuations.c:
* libguile/dynl.c:
* libguile/eval.c:
* libguile/filesys.c:
* libguile/fluids.c:
* libguile/foreign.c:
* libguile/fports.c:
* libguile/frames.c:
* libguile/hashtab.c:
* libguile/hooks.c:
* libguile/macros.c:
* libguile/mallocs.c:
* libguile/print.c:
* libguile/programs.c:
* libguile/promises.c:
* libguile/r6rs-ports.c:
* libguile/smob.c:
* libguile/srcprop.c:
* libguile/struct.c:
* libguile/variable.c:
* libguile/weak-set.c:
* libguile/weak-table.c: Use scm_putc instead of scm_putc_unlocked.
2016-04-26 23:01:14 +02:00
Daniel Llorens
eb3d623da5 Non-vector 1D arrays print as #1()
* libguile/arrays.c (scm_i_print_array): Print the dimension whenever
  the array is a true scm_tc7_array.

* test-suite/tests/arrays.test: Check that non-vector 1D arrays print as
  expected.
2015-02-18 09:32:30 +01:00
Daniel Llorens
65704b982d Pack array dimensions in array object
* libguile/arrays.c (scm_i_make_array): redo object layout.

* libguile/arrays.h (SCM_I_ARRAY_V, SCM_ARRAY_BASE, SCM_I_ARRAY_DIMS):
  to match new layout.

  (SCM_I_ARRAY_SET_V, SCM_ARRAY_SET_BASE): new setters.

  (SCM_I_ARRAY_MEM, scm_i_t_array): unused, remove.

  (scm_i_shap2ra, scm_make_typed_array, scm_from_contiguous_typed_array,
  scm_from_contiguous_array, scm_make_shared_array, scm_transpose_array,
  scm_array_contents): fix uses of SCM_I_ARRAY_V, SCM_ARRAY_BASE as
  lvalues.

* libguile/array-map.c (make1array, scm_ramapc): fix uses of
  SCM_I_ARRAY_V, SCM_ARRAY_BASE as lvalues.
2014-09-30 11:35:08 +02:00
Daniel Llorens
2c1ccb02c5 array-contents returns root for empty arrays with empty root
This fixes a compiler issue where (uniform-array->bytevector #2f64())
failed because of the stricter definition of uniform-vector? on this branch.

Perhaps it would be better if uniform-array->bytevector didn't require
a contiguous argument.

* libguile/arrays.c: (scm_array_contents): return the root regardless of
  the value of SCM_I_ARRAY_DIMS (ra)->inc.
* test-suite/tests/arrays.test: check.
2014-02-10 21:58:28 +01:00
Daniel Llorens
1e2a55e42a Match types used in arrays.c to struct field types
* libguile/arrays.c
  - scm_shared_array_root: check for SCM_I_ARRAYP first.
  - scm_i_shap2ra:
    * check valid bounds in the '(lbnd ubnd) case. This makes
      (make-array 0 '(4 -3)) fail with a 'bad dimension' instead of
      with a 'wrong index' error.
    * use ssize_t for lbnd/ubnd/inc, not long.
  - scm_make_shared_array: use ssize_t for indices, not long.
  - scm_transpose_array: use size_t for ndim, not ulong.
  - scm_i_print_array: idem.
2014-02-10 21:58:28 +01:00
Daniel Llorens
35f45ed6d0 Check more cases of array-contents
* libguile/arrays.c: (scm_array_contents): fix comment.
* test-suite/tests/arrays.test: add cases that depend on correct
  setting of CONTIGUOUS_FLAG.
2014-02-10 21:25:42 +01:00
Daniel Llorens
c545f7164a Refactor array-contents
* libguile/arrays.c (scm_array_contents): Branch cases not on
  scm_is_generalized_vector but on SCM_I_ARRAYP. Thus lbnd!=0, which
  could happen with scm_is_generalized_vector, never appears in the
  output.
* test-suite/tests/arrays.test: Test array-contents.
2014-02-10 21:18:48 +01:00
Andy Wingo
cf64dca65c Remove array impl. registry; instead, hard-code array handle creation
* libguile/array-handle.h (scm_t_vector_ref, scm_t_vector_set): Rename
  from scm_t_array_ref, scm_t_array_set.  These were named
  scm_i_t_array_ref and scm_i_t_array_set in 1.8 and 2.0.  Change to
  take the vector directly, instead of the array handle.  In this way,
  generic array handles are layered on top of specific implementations
  of backing stores.

  Remove scm_t_array_implementation, introduced in 2.0 but never
  documented.  It was a failed attempt to layer the array implementation
  that actually introduced too many layers, as it prevented the "vref"
  and "vset" members of scm_t_array_handle (called "ref" and "set" in
  1.8, not present in 2.0) from specializing on array backing stores.

  (scm_i_register_array_implementation) (scm_i_array_implementation_for_obj):
  Remove these internal interfaces.

  (scm_t_array_handle): Adapt to scm_t_vector_ref / scm_t_vector_set
  change.

  (scm_array_handle_ref, scm_array_handle_set): Adapt to change in
  vref/vset prototype.

* libguile/array-handle.c (scm_array_get_handle): Inline all the
  necessary initializations here for all specific array types.

* libguile/array-map.c (rafill, racp, ramap, rafe, array_index_map_1):

* libguile/arrays.c: Remove array implementation code.

* libguile/bitvectors.h:
* libguile/bitvectors.c: Remove array implementation code.
  (scm_i_bitvector_bits): New internal interface.

* libguile/bytevectors.c: Remove array implementation code.

* libguile/srfi-4.h: Remove declarations for internal procedures that
  don't exist (!).

* libguile/strings.c: Remove array implementation code.

* libguile/vectors.c: Remove array implementation code.
2014-02-09 12:48:21 +01:00
Daniel Llorens
13af75bfe0 Fix bad uses of base and lbnd on rank 1 arrays
* libguile/array-map.c
   - rafill, ramap, rafe, racp: object from SCM_I_ARRAY_V always
     has base 0, lbnd 0 and inc 1; make use of this.
 * libguile/arrays.c
   - array_handle_ref, array_handle_set: idem.
   - array_get_handle: sanity check.
 * libguile/generalized-vectors.c
   - scm_c_generalized_vector_ref, scm_c_generalized_vector_set_x:
     pos should be base when idx is lbnd. Furthermore, pos should be signed and
     have its overflow checked; do this by handling the job to
     scm_c_array_ref_1, scm_c_array_set_1_x.
 * libguile/generalized-vectors.h
   - fix prototypes.
2014-02-07 10:36:55 +01:00
Daniel Llorens
a6f8d3ddd8 Don't use scm_is_generalized_vector in transpose-array
* libguile/arrays.c (scm_transpose_array)
  - Use scm_c_array_rank(), which contains an implicit is_array test.
  - Handle the rank 0 case.
* test-suite/tests/arrays.test
  - Add test for rank 0 case.
  - Add failure test for non array argument.
2014-02-06 21:40:38 +01:00
Daniel Llorens
c2cb82f85a Don't use scm_is_generalized_vector in shared-array-root
* libguile/arrays.c: (scm_shared_array_root): replace check for
  scm_is_generalized_vector.
2014-02-06 21:40:38 +01:00
Daniel Llorens
2bee653acb Remove unnecessary conditions in array constructors
* libguile/arrays.c: (scm_make_type_array, scm_from_contigous_typed_array,
  scm_from_contigous_array): Remove conditions known to be true.
2014-02-06 21:37:34 +01:00
Andy Wingo
1fadf369b8 Replace generalized-vector calls in array_handle_ref/set
* libguile/arrays.c: (array-handle-ref, array-handle-set): Use the
  rank-1 array accessors.
2014-02-06 11:02:20 +01:00
Daniel Llorens
9da9c22f84 Replace scm_c_generalized_vector_length in arrays.c
* libguile/arrays.c: (scm_array_contents, scm_make_shared_array):
  arrays are known of rank 1 so replace by scm_c_array_length.
2014-02-06 10:51:56 +01:00
Andy Wingo
d65514a2de RTL compiler supports static bitvectors
* libguile/arrays.c (scm_from_contiguous_typed_array):
* libguile/bytevectors.c (scm_uniform_array_to_bytevector): For
  bitvectors, round up the length to 32-bit units, as they are stored
  internally.  Otherwise I think this probably does the wrong thing for
  the last word on big-endian systems.
* libguile/bitvectors.c (BITVECTOR_LENGTH, BITVECTOR_BITS):
  (scm_c_make_bitvector): Reorder the length and pointer words to match
  the layout of bytevectors.

* module/language/cps/primitives.scm (*branching-primcall-arities*):
* module/system/vm/assembler.scm (br-if-bitvector):
* module/system/vm/disassembler.scm (code-annotation): Add bitvector
  test support.

* module/system/vm/assembler.scm (<uniform-vector-backing-store>): Add
  an element-size field.
  (intern-constant): Adapt make-uniform-vector-backing-store call.  Use
  uniform-array->bytevector, as the old compiler did.
  (link-data): Add bitvector cases.
2013-11-03 21:48:48 +01:00
Mark H Weaver
fa980bcc0f Merge remote-tracking branch 'origin/stable-2.0'
Moved scm_i_struct_hash from struct.c to hash.c and made it static.

The port's alist is now a field of 'scm_t_port'.

Conflicts:
	libguile/arrays.c
	libguile/hash.c
	libguile/ports.c
	libguile/print.h
	libguile/read.c
2012-10-30 23:46:31 -04:00
Mark H Weaver
493ceb99e5 Move array reader from arrays.c to read.c
* 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-10-23 22:42:30 -04:00
Andy Wingo
0858753e82 Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	GUILE-VERSION
	libguile/gc-malloc.c
	libguile/ports.c
2012-02-08 11:48:08 +01:00
Bake Timmons
b7e64f8b26 Improve the usage of variable names in C docstrings.
* 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-02-02 12:22:10 +01:00
Andy Wingo
91ee7515da Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	libguile/__scm.h
	libguile/array-map.c
	libguile/procprop.c
	libguile/tags.h
	module/ice-9/deprecated.scm
	module/ice-9/psyntax-pp.scm
	module/ice-9/psyntax.scm
	test-suite/standalone/test-num2integral.c
	test-suite/tests/regexp.test
2012-01-10 00:41:42 +01:00
Ludovic Courtès
67543d0761 Fix incorrect use of `SCM_UNPACK'.
* libguile/arrays.c (scm_i_make_array): Cast the result of
  `scm_gc_malloc' directly to `scm_t_bits'.
2012-01-09 22:16:49 +01:00
Andy Wingo
b2637c985c allocate a tc7 to arrays
* 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.
2012-01-09 17:50:56 +01:00
Andy Wingo
0607ebbfcf locking for putc, puts
* libguile/ports.c (scm_putc, scm_puts):
* libguile/ports.h (scm_putc_unlocked, scm_puts_unlocked): Separate into
  _unlocked and locked variants.  Change all callers to use the
  _unlocked versions.
2011-11-08 00:55:05 +01:00
Andy Wingo
c932ce0b55 locking on unget_byte, ungetc, ungets
* libguile/ports.h:
* libguile/ports.c (scm_unget_byte_unlocked, scm_unget_byte)
  (scm_ungetc_unlocked, scm_ungetc, scm_ungets_unlocked, scm_ungets):
  Add locking and _unlocked variants.

* libguile/arrays.c:
* libguile/rdelim.c:
* libguile/read.c:
* libguile/vports.c: Adapt callers to use the _unlocked variants.
2011-11-08 00:54:58 +01:00
Andy Wingo
be632904ca locking on scm_c_read, scm_getc
* libguile/ports.c (scm_c_read_unlocked, scm_c_read, scm_getc_unlocked)
  (scm_getc): Split getc and read operations into locked and unlocked
  variants.  Change most uses to use the _unlocked version.
2011-11-08 00:54:58 +01:00
Andy Wingo
8c5bb72920 add SCM_HEAP_OBJECT_P
* libguile/tags.h (SCM_HEAP_OBJECT_P): New macro, an alias for
  SCM_NIMP.

* libguile/arrays.c:
* libguile/debug.c:
* libguile/foreign.c:
* libguile/gdbint.c:
* libguile/guardians.c:
* libguile/list.c:
* libguile/modules.c:
* libguile/options.c:
* libguile/smob.c:
* libguile/validate.h:
* libguile/weak-set.c:
* libguile/weak-table.c:
* libguile/weak-vector.c: Use it instead of SCM_NIMP or !SCM_IMP.
2011-10-24 18:55:43 +02:00
Andy Wingo
eff3dd99f7 fix write beyond array end in arrays.c
* 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-07-28 19:04:38 +02:00
Andy Wingo
03976fee3b fix code that causes warnings on gcc 4.6
* 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.
2011-03-17 12:39:53 +01:00
Andy Wingo
73788ca8be allow compilation of #@2(1 2 3)
* 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-11 21:47:10 +01:00
Andy Wingo
a268973767 reimplement srfi-4 vectors on top of bytevectors
* 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.
2010-01-07 22:06:56 +01:00
Ludovic Courtès
f65e0168d5 Remove extraneous semicolon after `SCM_ARRAY_IMPLEMENTATION' & co.
* 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-15 01:01:17 +01:00
Andy Wingo
735bcfe579 add SCM_SMOB_TYPE_BITS and SCM_SMOB_TYPE_MASK
* 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-08 23:13:21 +01:00
Andy Wingo
c395cb7813 fix erroneous SCM_CELL_* usage in arrays.[ch]
* 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-12-08 23:13:07 +01:00
Andy Wingo
b0fae4ecaa bitvector tweaks
* 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-16 11:59:30 +02:00
Ludovic Courtès
cd48c32cf4 Fix compilation of literal bitvectors.
* 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-10-15 23:29:50 +02:00
Ludovic Courtès
8cf0dd6104 Remove unneeded SMOB/port mark/free procedures.
* 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-28 23:32:34 +02:00
Andy Wingo
f5a51caec1 fix bitvectors after the array handle refactoring
* 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-09-18 16:27:32 +02:00
Andy Wingo
943a0a8759 make-typed-array builds backing vector via make-generalized-vector
* libguile/arrays.c: Rework to use scm_make_generalized_vector instead
  of our own type table.

* libguile/bitvectors.c: Fix some includes.
2009-07-19 15:15:44 +02:00
Andy Wingo
476b894c71 uniform vector functions to their own file
* 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-19 15:15:44 +02:00
Andy Wingo
f332e95717 generic vector ops to own file
* 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-19 15:15:44 +02:00
Andy Wingo
1030b45049 move generic array foo out to its own file
* 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-19 15:15:44 +02:00
Andy Wingo
66b9d7d304 remove enclosed arrays
* 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-19 15:15:44 +02:00
Andy Wingo
2a610be594 add generic array implementation facility
* 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-19 15:15:40 +02:00
Andy Wingo
2fa901a51f rename unif.[ch] to arrays.[ch]
* 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.
2009-07-19 14:53:03 +02:00
Renamed from libguile/unif.c (Browse further)