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

2198 commits

Author SHA1 Message Date
Andy Wingo
b071ce2147 redo the SCM tagging strategy
Currently failing some guardian tests.

* libguile/tags.h: Refactor tagging so that tc3 bits for a pair live in
  the SCM value, not in the heap words.  Do the same for structs.  This
  more rational tagging strategy will make native code generation
  easier.  Note that this means that to check a heap pointer for its
  type, you first have to ensure that it has the expected tc3, as not
  all the type bits are on the heap.
  (SCM_TYP3): Check the SCM tag type, not the bits in the cell.
  (SCM_HAS_TYP3): New helper.
  (SCM_I_CONSP): Redefine to just check the typ3.
  (scm_tcs_cons_imcar, scm_tcs_cons_nimcar, scm_tcs_struct): Remove, as
  they are no longer necessary.

* libguile/array-handle.c (scm_i_array_implementation_for_obj): Check
  for heap objects before checking type bits, so we don't check pairs.

* libguile/evalext.c (scm_self_evaluating_p):
* libguile/gc.c (scm_i_tag_name):
* libguile/goops.c (scm_class_of)
* libguile/hash.c (scm_hasher):
* libguile/print.c (iprin1): Adapt to tagging changes.

* libguile/gc.c (scm_storage_prehistory): Register all displacements
  here.  There are the same displacements as before, unfortunately.

* libguile/list.c (SCM_I_CONS):
* libguile/pairs.c (scm_cons):
* libguile/pairs.h (scm_is_pair):
* libguile/vm-engine.h (CONS): Tag pairs with scm_tc3_pair.

* libguile/modules.c (scm_post_boot_init_modules):
* libguile/modules.h (SCM_MODULEP):
* libguile/struct.c (struct_finalizer_trampoline, scm_i_alloc_struct):
  (scm_make_vtable_vtable):
* libguile/struct.h (SCM_STRUCTP, SCM_STRUCT_VTABLE_DATA):
  (SCM_STRUCT_VTABLE_SLOTS):
* libguile/vm-i-scheme.c (make-struct): Adapt to struct tagging
  changes.

* libguile/numbers.h (SCM_I_INUMP):
* module/rnrs/arithmetic/fixnums.scm (fixnum?, inline-fixnum?): Adapt
  to the new fixnum tag.

* libguile/numbers.h (SCM_INEXACTP): Make sure of the tc3 before looking
  at the cell type.
2013-01-15 19:13:03 +01:00
Andy Wingo
e5cef86e9c fix string->bytevector for utf-8 and non-error conversion strategies
* module/ice-9/iconv.scm (call-with-encoded-output-string):
  (string->bytevector, bytevector->string): Only call string->utf8 and
  utf8->string if the conversion strategy is `error'.
2013-01-15 16:37:01 +01:00
Andy Wingo
e2551947dd All r6rs ports are both textual and binary
* module/rnrs/io/ports.scm (binary-port?): All ports are binary _and_
  textual.  Bytevectors and strings may be written to or read from
  either.
  (port-transcoder): All textual ports (all ports) have transcoders of
  some sort.

* test-suite/tests/r6rs-ports.test ("8.2.6  Input and output ports"):
  Remove test that binary ports don't have transcoders, because binary
  ports are also textual.
2013-01-15 16:32:52 +01:00
Andy Wingo
b4fa6cc909 Merge remote-tracking branch 'origin/stable-2.0'
There is a failing test due to a scm_from_utf8_stringn bug brought out
by the iconv test that will be fixed in the next commit.

Conflicts:
	libguile/deprecated.h
	module/ice-9/deprecated.scm
2013-01-15 10:45:39 +01:00
Andy Wingo
18c5bffe96 Docstrings in (ice-9 iconv)
* module/ice-9/iconv.scm: Add docstrings.
2013-01-11 21:28:51 +01:00
Andy Wingo
5ed4ea90a9 Change iconv procedures to take optional instead of keyword arg
* module/ice-9/iconv.scm (call-with-encoded-output-string):
  (string->bytevector, bytevector->string): Take an optional instead of
  a keyword argument.

* doc/ref/api-data.texi (Representing Strings as Bytes): Adapt docs to
  change, and fix a number of errors.  Thanks to Ludovic Courtès for the
  pointers.

* test-suite/tests/iconv.test ("wide non-ascii string"): Add a test for
  the 'substitute path.
2013-01-11 21:15:28 +01:00
Andy Wingo
990b11c53f Add http-post, http-put, et cetera
* module/web/client.scm (ensure-uri): New helper.
  (open-socket-for-uri): Accept a URI as a string or as a URI object.
  (extend-request, sanitize-request): New helpers, like the
  corresponding functions in (web server).
  (decode-response-body): Add a reference to the HTTP/1.1 spec, and
  use (ice-9 iconv).
  (request): New helper, factoring all aspects of sending an HTTP
  request and getting a response.
  (http-get): Redefine in terms of http-get.  Deprecate the
  #:extra-headers argument in favor of #:headers.  Allow a body.  Add a
  #:streaming? argument, subsuming the functionality of http-get*.
  (http-get*): Deprecate.
  (http-head, http-post, http-put, http-delete, http-trace)
  (http-options): Define interfaces for all HTTP verbs.

* test-suite/tests/web-client.test: Add tests.

* doc/ref/web.texi: Update documentation.

Thanks to Gregory Benison for the initial patch.
2013-01-11 15:40:00 +01:00
Andy Wingo
2ac3c0a590 read-response-body always returns bytevector or #f
* module/web/response.scm (read-response-body): Fix to always return
  either a bytevector or #f.  Previously, reading a 0-length body could
  return the EOF object.
2013-01-11 15:15:43 +01:00
Andy Wingo
67e5ab8ac6 remove (web http) TODO list
* module/web/http.scm: Remove outdated TODO list.
2013-01-11 15:15:42 +01:00
Andy Wingo
8cb9a30c17 (web server) uses (ice-9 iconv)
* module/web/server.scm (sanitize-response): Use the procedures
  from (ice-9 iconv) to encode the response.
2013-01-11 15:15:42 +01:00
Andy Wingo
f05bb8494c add bytevector->string and string->bytevector in new (ice-9 iconv) module
* module/Makefile.am:
* module/ice-9/iconv.scm: New module implementing procedures to encode
  and decode representations of strings as bytes.

* test-suite/Makefile.am:
* test-suite/tests/iconv.test: Add tests.

* doc/ref/api-data.texi: Add docs.
2013-01-11 15:15:37 +01:00
Andy Wingo
b194b59fa1 fix ice-9/slib
* module/ice-9/slib.scm: Change to just load up slib.init directly.  The
  recently submitted patch to slib-discuss and guile-user should make
  this work correctly.
2013-01-10 17:30:38 +01:00
Andy Wingo
921cd222b9 deprecate SCM_CHAR_CODE_LIMIT and char-code-limit
* libguile/__scm.h:
* libguile/deprecated.h (SCM_CHAR_CODE_LIMIT): Move declaration here
  from __scm.h.

* libguile/feature.c:
* module/ice-9/deprecated.scm (char-code-limit): Move definition here.

* test-suite/tests/regexp.test: Update to not use char-code-limit.
2013-01-10 16:01:06 +01:00
Andy Wingo
03a2f59851 slight open-pipe* / open-process refactor
* libguile/posix.c (scm_open_process): Return the ports as values
  instead of calling out to Scheme again to make-rw-port.  This
  function is private to (ice-9 popen).

* module/ice-9/popen.scm (open-pipe*): Adapt to change.
2013-01-08 12:58:05 +01:00
Mark H Weaver
e0c211bb2e Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	GUILE-VERSION
	libguile/posix.c
	module/ice-9/eval.scm
	test-suite/tests/cse.test
2013-01-07 17:23:26 -05:00
Andy Wingo
ed3e8b8e06 http-get: don't shutdown write end of socket
* module/web/http.scm ("Connection"): Write the "close" token in
  lower-case.

* module/web/client.scm (http-get): Don't shutdown the writing side of
  the pipe if we are not doing a keepalive, as this may prevent the
  request from being sent at all.  Prevented http://friendfeed.com/ from
  being correctly fetched.
2013-01-07 23:21:16 +01:00
Andy Wingo
9f17d967c9 More procedure-arguments-alist documentation and a bugfix
* doc/ref/api-procedures.texi (Compiled Procedures): Expand
  program-arguments-alist and program-lambda-list documentation.

* module/system/vm/program.scm (arity->arguments-alist): Fix the rest
  arg if there are also keyword args, a bug found while documenting!

* test-suite/tests/session.test ("procedure-arguments"): Update.
2013-01-07 22:02:26 +01:00
Cedric Cellier
6fca8730f7 document program-arguments-alist and program-lambda-list 2013-01-07 20:37:07 +01:00
Ludovic Courtès
b9d724982d web: Correctly detect "No route to host" conditions.
* module/web/client.scm (open-socket-for-uri): Delete addrinfos
  with the same address.  Always open SOCK_STREAM/IPPROTO_IP sockets.
  Fix the error handler's condition to determine what to do.
  Reported by Nikita Karetnikov <nikita.karetnikov@gmail.com> at
  <http://lists.gnu.org/archive/html/bug-guix/2012-12/msg00150.html>.
2012-12-17 00:27:00 +01:00
Daniel Hartwig
afdf5467e5 repl: add repl-option for customized print
Closes <http://bugs.gnu.org/13077>.

* module/system/repl/common.scm (repl-default-options)
  (repl-print): Add option to use customized print procedure.
* doc/ref/scheme-using.texi (REPL Commands): Update.
2012-12-10 23:41:06 +01:00
Ludovic Courtès
4d599c2441 futures: Remove circular dependency with (ice-9 threads).
* module/ice-9/futures.scm: Remove now-useless import of (ice-9 threads)
  introduced in commit be05b336.
2012-11-29 22:44:12 +01:00
Ludovic Courtès
91e693a8e8 web: Add `http-get*'.
* module/web/client.scm (http-get*): New procedure.
* doc/ref/web.texi (Web Client): Document it.
2012-11-28 22:50:26 +01:00
Ludovic Courtès
75d6c59fc2 web: Add `response-body-port'.
* module/web/response.scm (make-delimited-input-port,
  response-body-port): New procedures.
  (read-response-body): Use `response-body-port'.

* test-suite/tests/web-response.test ("example-1")["response-body-port"]:
  New test.
  ("example-2")["response-body-port"]: New test.
2012-11-28 22:41:25 +01:00
Ludovic Courtès
ee2d874119 web: Export `text-content-type?'.
* module/web/client.scm (text-type?): Remove.
  (decode-response-body): Use `text-content-type?'.
* module/web/response.scm (text-content-type?): New procedure.
* doc/ref/web.texi (Responses): Document it.
2012-11-28 22:12:59 +01:00
Ludovic Courtès
c438cd7175 eval: Store docstrings for lambdas.
Fixes <http://bugs.gnu.org/12173>.
Reported by Ian Price <ianprice90@googlemail.com>.

* libguile/memoize.c (MAKMEMO_LAMBDA): New `docstring' parameter.  Add
  it as the second argument of `SCM_M_LAMBDA'.  Update caller.
  (memoize)[SCM_M_LAMBDA]: Extract docstring from EXP; when `memoize'
  returns, add the docstring to the lambda's arguments.
  (unmemoize)[SCM_M_LAMBDA]: Adjust to new argument layout of
  `SCM_M_LAMBDA'.
* libguile/eval.c (BOOT_CLOSURE_NUM_REQUIRED_ARGS,
  BOOT_CLOSURE_HAS_REST_ARGS, BOOT_CLOSURE_IS_REST,
  BOOT_CLOSURE_PARSE_FULL): Adjust to new argument layout of
  `SCM_M_LAMBDA'.
* module/ice-9/eval.scm (primitive-eval)[make-general-closure]:
  Likewise.
  [eval]: When EXP is a lambda, match its docstring; when the docstring
  is not #f, add it to the closures procedure properties.
* test-suite/tests/eval.test ("docstrings"): New test prefix.

* libguile/procs.c (sym_documentation): Rename to...
  (scm_sym_documentation): ... this.  Make it global.
* libguile/procs.h (scm_sym_documentation): New declaration.
2012-11-28 16:43:59 +01:00
Ludovic Courtès
c04c118461 vlist: Remove Texinfo markup from docstrings.
* module/ice-9/vlist.scm: Remove Texinfo markup from docstrings with
  sed -e"s/@var{\([a-z0-9?!-]\+\)}/\U\1/g ; s/@code{\([^}]\+\)}/‘\1’/g".
2012-11-27 23:02:15 +01:00
Daniel Hartwig
4e81e9d9a3 web client: correctly handle uri-query, etc. in relative URI headers
* module/web/uri.scm (uri-pat): Make scheme part optional.
  (string->uri*): New private procedure to also parse relative URIs.
* module/web/http.scm (declare-relative-uri-header!): Use that.
2012-11-27 22:41:33 +01:00
Ludovic Courtès
261af76005 web client: Support relative URIs in some headers.
Fixes <http://bugs.gnu.org/12827>.

* module/web/http.scm (declare-relative-uri-header!): New procedure.
  ("Content-Location", "Referer"): Use it.
  Based on discussions with Daniel Hartwig <mandyke@gmail.com>.
2012-11-27 00:10:24 +01:00
Ludovic Courtès
ca8be3f5b3 Have load-in-vicinity' look for .go' files in %LOAD-COMPILED-PATH.
Fixes <http://bugs.gnu.org/12519>.

* module/ice-9/boot-9.scm (load-in-vicinity)[fresh-compiled-file-name]:
  New `scmstat' parameter; use it.
  [sans-extension]: New procedure.
  [load-absolute]: Call (stat ABS-PATH) from here.  Search a `.go' file
  from %LOAD-COMPILED-PATH before searching %COMPILE-FALLBACK-PATH.
2012-11-27 00:10:24 +01:00
Ludovic Courtès
9fbca4b32e Split `load-in-vicinity' into small procedures.
* module/ice-9/boot-9.scm (load-in-vicinity)[compiled-extension]: New
  variable.
  [compiled-file-name]: Rename to...
  [fallback-file-name]: ... this; update caller.  Use COMPILED-EXTENSION.
  [more-recent?, compile, warn-about-exception]: New procedures.
  [fresh-compiled-file-name]: Use them.
2012-11-27 00:10:24 +01:00
Ian Price
5d7c55bdcf R6RS srfi library names should ignore first identifier after the :n
* module/ice-9/r6rs-libraries.scm (resolve-r6rs-interface):
  (srfi :n name ids ...) -> (srfi srfi-n ids ...)
* test-suite/tests/rnrs-libraries.test ("srfi"): Add test.
2012-11-25 12:28:41 +00:00
Daniel Hartwig
890647559d (web uri): document that uri-port is an integer
* doc/ref/web.texi (URIs):
* module/web/uri.scm (build-uri): Document that uri-port is an integer.
2012-11-24 15:54:07 +01:00
Daniel Hartwig
06883ae000 syncronize web module docstrings with manual
* doc/ref/web.texi: Fix spacing.  Update with a few missing function
  descriptions.

* module/web/client.scm:
* module/web/http.scm:
* module/web/request.scm:
* module/web/server.scm:
* module/web/uri.scm: Update docstrings from manual (reworked by Ludovic
  Courtès).
2012-11-24 15:40:14 +01:00
Ludovic Courtès
9ee0455738 Turn on the `case' warnings in auto-compilation.
* module/ice-9/boot-9.scm (%auto-compilation-options): Add
  `duplicate-case-datum' and `bad-case-datum'.
2012-11-24 00:16:14 +01:00
Ludovic Courtès
712ca51ffe Remove reference to scm_init_popen' when fork' is unavailable.
Fixes <http://bugs.gnu.org/12477>.
Reported by lin ray <lin.wei.ray@gmail.com>.

* configure.ac: Define the `HAVE_FORK' Automake conditional.
* module/Makefile.am (ICE_9_SOURCES): Add `ice-9/popen.scm' only when
  HAVE_FORK.
* libguile/posix.c (scm_init_posix): Register `scm_init_popen' only when
  HAVE_FORK.
2012-11-23 23:37:29 +01:00
Ian Price
06906f370f R6RS `string-for-each' should accept multiple string arguments
* module/rnrs/base.scm (string-for-each): Rewrite.
* test-suite/tests/r6rs-base.test ("string-for-each"): Add tests.
2012-11-22 22:26:16 +01:00
Ludovic Courtès
2c7b7e0f21 cse: Fix out-of-bounds access to the database.
Fixes <http://bugs.gnu.org/12883>.

* module/language/tree-il/cse.scm (cse)[find-dominating-lexical]: Fix
  computation of the last argument passed to `unroll'.
  Patch by Stefan Israelsson Tampe <stefan.itampe@gmail.com>.
* test-suite/tests/cse.test ("cse")["http://bugs.gnu.org/12883"]: New
  test.
2012-11-21 23:51:16 +01:00
Ludovic Courtès
2d37a93494 Update `par-map' to use nested futures.
This allows it to actually use all CPU cores, instead of having the main
thread stuck on a `wait-condition-variable'.

* module/ice-9/threads.scm (par-mapper): Add a `cons' argument; update
  callers accordingly.  Rewrite using nested futures.
2012-11-21 23:33:30 +01:00
Ludovic Courtès
3e529bf02a futures: Allow nested futures; put the main thread to work.
* module/ice-9/futures.scm (%futures-waiting, %within-future?,
  %future-prompt): New variables.
  (let/ec): New macro.
  (process-future!): Run FUTURE's thunk in a prompt; capture FUTURE's
  continuation when it aborts, and add it to %FUTURES-WAITING.  Set
  %WITHIN-FUTURE? in the dynamic extent of the call FUTURE's thunk.
  (process-futures): Move loop body to...
  (process-one-future): ... here.  New procedure.
  (notify-completion): New procedure.
  (touch)[work, loop]: New procedures.
  When %WITHIN-FUTURE? and FUTURE is started, abort; if not
  %WITHIN-FUTURE, call `work' while waiting.
  When FUTURE is queued, call `work' too.

* test-suite/tests/future.test ("nested futures"): New tests.
2012-11-21 23:33:30 +01:00
Ludovic Courtès
ab975cf592 futures: Add a record printer.
* module/ice-9/futures.scm: Add a record printer for <future>.
2012-11-21 23:33:30 +01:00
Ludovic Courtès
f2fb5e5328 futures: Keep futures unlocked while they are processing.
* module/ice-9/futures.scm (<future>)[completion]: New field.
  [done?]: Rename to...
  [state]: ... this.  Change `set-future-done?!' to
  `set-future-state!', and `future-done?' to `future-state'.
  (make-future): Initialize the `completion' field to 'queued.
  (with-mutex): New macro.
  (process-future!): Remove `set-future-done?!' call.
  (process-futures): Check `future-state'.  Unlock FUTURE's mutex before
  processing it.  Broadcast FUTURE's `completion' cond. var. when done.
  (touch): Likewise.
2012-11-21 23:33:30 +01:00
Ludovic Courtès
67768115d7 doc: Fix typo in `set-record-type-printer!' doc.
* module/srfi/srfi-9/gnu.scm (set-record-type-printer!): Change the
  parameter name to `proc'.
* doc/ref/api-compound.texi (SRFI-9 Records): Update accordingly.
2012-11-17 15:34:49 +01:00
Mark H Weaver
110ef00ba1 Merge remote-tracking branch 'origin/stable-2.0' 2012-11-15 05:31:18 -05:00
Andreas Rottmann
3ae5a02f1d Add missing R6RS `open-file-input/output-port' procedure
* module/rnrs/io/port.scm (r6rs-open): New internal helper procedure for
  opening files.
  (open-file-input-port, open-file-output-port): Make use of
  `r6rs-open'.
  (open-file-input/output-port): Implement in terms of `r6rs-open',
  add to exported identifiers list.

* module/rnrs.scm (open-file-input/output-port): Add to exported
  identifiers.

* test-suite/tests/r6rs-ports.test (test-input-file-opener): New
  procedure, collects several tests for opening file input ports.
  ("7.2.7 Input Ports"): Use `test-input-file-opener' for checking
  `open-file-input-port'.
  (test-output-file-opener): New procedure, collects several tests for
  opening file output ports.
  ("8.2.10 Output ports"): Use `test-output-file-opener' for checking
  `open-file-output-port'.
  ("8.2.13 Input/output ports"): New test prefix, making use of both
  `test-input-file-opener' and `test-output-file-opener' to check
  `open-file-input/output-port'.
2012-11-12 20:47:57 +01:00
Mark H Weaver
db18a252fb Merge remote-tracking branch 'origin/stable-2.0' 2012-11-10 19:17:30 -05:00
Mark H Weaver
3d01c19a78 Change the argument order of 'set-fields' to match that of 'set-fields'.
* module/srfi/srfi-9/gnu.scm (set-fields): Swap order of first two
  arguments.

* test-suite/tests/srfi-9.test: Update tests.
2012-11-10 16:05:24 -05:00
Mark H Weaver
4695483901 Add system/base/ck.scm to SYSTEM_BASE_SOURCES in module/Makefile.am.
* module/Makefile.am (SYSTEM_BASE_SOURCES): Add system/base/ck.scm.
2012-11-10 14:35:49 -05:00
Mark H Weaver
be05b33609 Futures: Avoid creating the worker pool more than once.
* module/ice-9/futures.scm (%create-workers!): Use 'with-mutex' in case
  an exception is thrown.  Within the critical section, check to make
  sure the worker pool hasn't already been created by another thread.
2012-11-10 10:08:19 -05:00
Mark H Weaver
92fac8c056 Improve error for set-fields paths leading to different types.
* module/system/base/ck.scm: New module.

* module/srfi/srfi-9.scm: Import (system base ck).

  (getter-type, getter-index, getter-copier): Convert incoming argument
  convention to CK form.

  (define-tagged-inlinable): Convert return value convention for key
  lookup to CK form.

* module/srfi/srfi-9/gnu.scm: Import (system base ck).
  Rename '%set-fields-unknown-getter' to 'unknown-getter'.

  (c-list, c-same-type-check): New macros.

  (%set-fields): Using the CK abstract machine, arrange to check (at
  macro expansion time) that all of the getters in head position
  correspond to the same record type.

* test-suite/tests/srfi-9.test: Add test.
2012-11-10 01:37:20 -05:00
Mark H Weaver
ad84cc8b84 Merge remote-tracking branch 'origin/stable-2.0' 2012-11-09 23:09:38 -05:00